edge-impulse-api 1.82.6 → 1.82.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/build/library/sdk/api/adminApi.d.ts +4 -6
  2. package/build/library/sdk/api/adminApi.js +4782 -4928
  3. package/build/library/sdk/api/adminApi.js.map +1 -1
  4. package/build/library/sdk/api/authApi.d.ts +4 -6
  5. package/build/library/sdk/api/authApi.js +88 -56
  6. package/build/library/sdk/api/authApi.js.map +1 -1
  7. package/build/library/sdk/api/cDNApi.d.ts +4 -6
  8. package/build/library/sdk/api/cDNApi.js +76 -53
  9. package/build/library/sdk/api/cDNApi.js.map +1 -1
  10. package/build/library/sdk/api/canaryApi.d.ts +4 -6
  11. package/build/library/sdk/api/canaryApi.js +79 -53
  12. package/build/library/sdk/api/canaryApi.js.map +1 -1
  13. package/build/library/sdk/api/classifyApi.d.ts +4 -6
  14. package/build/library/sdk/api/classifyApi.js +527 -499
  15. package/build/library/sdk/api/classifyApi.js.map +1 -1
  16. package/build/library/sdk/api/dSPApi.d.ts +4 -6
  17. package/build/library/sdk/api/dSPApi.js +938 -942
  18. package/build/library/sdk/api/dSPApi.js.map +1 -1
  19. package/build/library/sdk/api/deploymentApi.d.ts +4 -6
  20. package/build/library/sdk/api/deploymentApi.js +680 -603
  21. package/build/library/sdk/api/deploymentApi.js.map +1 -1
  22. package/build/library/sdk/api/devicesApi.d.ts +4 -6
  23. package/build/library/sdk/api/devicesApi.js +802 -800
  24. package/build/library/sdk/api/devicesApi.js.map +1 -1
  25. package/build/library/sdk/api/emailVerificationApi.d.ts +4 -6
  26. package/build/library/sdk/api/emailVerificationApi.js +184 -190
  27. package/build/library/sdk/api/emailVerificationApi.js.map +1 -1
  28. package/build/library/sdk/api/exportApi.d.ts +4 -6
  29. package/build/library/sdk/api/exportApi.js +88 -56
  30. package/build/library/sdk/api/exportApi.js.map +1 -1
  31. package/build/library/sdk/api/featureFlagsApi.d.ts +4 -6
  32. package/build/library/sdk/api/featureFlagsApi.js +76 -52
  33. package/build/library/sdk/api/featureFlagsApi.js.map +1 -1
  34. package/build/library/sdk/api/healthApi.d.ts +4 -6
  35. package/build/library/sdk/api/healthApi.js +111 -97
  36. package/build/library/sdk/api/healthApi.js.map +1 -1
  37. package/build/library/sdk/api/impulseApi.d.ts +4 -6
  38. package/build/library/sdk/api/impulseApi.js +942 -902
  39. package/build/library/sdk/api/impulseApi.js.map +1 -1
  40. package/build/library/sdk/api/integrationsApi.d.ts +4 -6
  41. package/build/library/sdk/api/integrationsApi.js +136 -106
  42. package/build/library/sdk/api/integrationsApi.js.map +1 -1
  43. package/build/library/sdk/api/jobsApi.d.ts +4 -6
  44. package/build/library/sdk/api/jobsApi.js +2270 -2326
  45. package/build/library/sdk/api/jobsApi.js.map +1 -1
  46. package/build/library/sdk/api/learnApi.d.ts +22 -6
  47. package/build/library/sdk/api/learnApi.js +1597 -1424
  48. package/build/library/sdk/api/learnApi.js.map +1 -1
  49. package/build/library/sdk/api/loginApi.d.ts +4 -6
  50. package/build/library/sdk/api/loginApi.js +112 -98
  51. package/build/library/sdk/api/loginApi.js.map +1 -1
  52. package/build/library/sdk/api/metricsApi.d.ts +4 -6
  53. package/build/library/sdk/api/metricsApi.js +148 -144
  54. package/build/library/sdk/api/metricsApi.js.map +1 -1
  55. package/build/library/sdk/api/optimizationApi.d.ts +4 -6
  56. package/build/library/sdk/api/optimizationApi.js +844 -844
  57. package/build/library/sdk/api/optimizationApi.js.map +1 -1
  58. package/build/library/sdk/api/organizationBlocksApi.d.ts +4 -6
  59. package/build/library/sdk/api/organizationBlocksApi.js +1968 -1550
  60. package/build/library/sdk/api/organizationBlocksApi.js.map +1 -1
  61. package/build/library/sdk/api/organizationCreateProjectApi.d.ts +4 -6
  62. package/build/library/sdk/api/organizationCreateProjectApi.js +700 -652
  63. package/build/library/sdk/api/organizationCreateProjectApi.js.map +1 -1
  64. package/build/library/sdk/api/organizationDataApi.d.ts +4 -6
  65. package/build/library/sdk/api/organizationDataApi.js +2074 -1985
  66. package/build/library/sdk/api/organizationDataApi.js.map +1 -1
  67. package/build/library/sdk/api/organizationDataCampaignsApi.d.ts +4 -6
  68. package/build/library/sdk/api/organizationDataCampaignsApi.js +626 -602
  69. package/build/library/sdk/api/organizationDataCampaignsApi.js.map +1 -1
  70. package/build/library/sdk/api/organizationJobsApi.d.ts +4 -6
  71. package/build/library/sdk/api/organizationJobsApi.js +417 -399
  72. package/build/library/sdk/api/organizationJobsApi.js.map +1 -1
  73. package/build/library/sdk/api/organizationPipelinesApi.d.ts +4 -6
  74. package/build/library/sdk/api/organizationPipelinesApi.js +419 -401
  75. package/build/library/sdk/api/organizationPipelinesApi.js.map +1 -1
  76. package/build/library/sdk/api/organizationPortalsApi.d.ts +4 -6
  77. package/build/library/sdk/api/organizationPortalsApi.js +372 -352
  78. package/build/library/sdk/api/organizationPortalsApi.js.map +1 -1
  79. package/build/library/sdk/api/organizationsApi.d.ts +4 -6
  80. package/build/library/sdk/api/organizationsApi.js +4024 -4050
  81. package/build/library/sdk/api/organizationsApi.js.map +1 -1
  82. package/build/library/sdk/api/performanceCalibrationApi.d.ts +4 -6
  83. package/build/library/sdk/api/performanceCalibrationApi.js +586 -560
  84. package/build/library/sdk/api/performanceCalibrationApi.js.map +1 -1
  85. package/build/library/sdk/api/postProcessingApi.d.ts +4 -6
  86. package/build/library/sdk/api/postProcessingApi.js +279 -255
  87. package/build/library/sdk/api/postProcessingApi.js.map +1 -1
  88. package/build/library/sdk/api/projectsApi.d.ts +4 -6
  89. package/build/library/sdk/api/projectsApi.js +2758 -2818
  90. package/build/library/sdk/api/projectsApi.js.map +1 -1
  91. package/build/library/sdk/api/rawDataApi.d.ts +4 -6
  92. package/build/library/sdk/api/rawDataApi.js +3055 -3131
  93. package/build/library/sdk/api/rawDataApi.js.map +1 -1
  94. package/build/library/sdk/api/testApi.d.ts +4 -6
  95. package/build/library/sdk/api/testApi.js +152 -108
  96. package/build/library/sdk/api/testApi.js.map +1 -1
  97. package/build/library/sdk/api/themesApi.d.ts +4 -6
  98. package/build/library/sdk/api/themesApi.js +341 -305
  99. package/build/library/sdk/api/themesApi.js.map +1 -1
  100. package/build/library/sdk/api/thirdPartyAuthApi.d.ts +4 -6
  101. package/build/library/sdk/api/thirdPartyAuthApi.js +387 -353
  102. package/build/library/sdk/api/thirdPartyAuthApi.js.map +1 -1
  103. package/build/library/sdk/api/uploadPortalApi.d.ts +4 -6
  104. package/build/library/sdk/api/uploadPortalApi.js +375 -355
  105. package/build/library/sdk/api/uploadPortalApi.js.map +1 -1
  106. package/build/library/sdk/api/userApi.d.ts +4 -6
  107. package/build/library/sdk/api/userApi.js +2345 -2452
  108. package/build/library/sdk/api/userApi.js.map +1 -1
  109. package/build/library/sdk/api/vlmApi.d.ts +4 -6
  110. package/build/library/sdk/api/vlmApi.js +277 -253
  111. package/build/library/sdk/api/vlmApi.js.map +1 -1
  112. package/build/library/sdk/api/whitelabelsApi.d.ts +4 -6
  113. package/build/library/sdk/api/whitelabelsApi.js +408 -398
  114. package/build/library/sdk/api/whitelabelsApi.js.map +1 -1
  115. package/build/library/sdk/model/deployPretrainedModelRequest.d.ts +4 -0
  116. package/build/library/sdk/model/deployPretrainedModelRequest.js +5 -0
  117. package/build/library/sdk/model/deployPretrainedModelRequest.js.map +1 -1
  118. package/build/library/sdk/model/models.d.ts +47 -7
  119. package/build/library/sdk/model/models.js +33 -22
  120. package/build/library/sdk/model/models.js.map +1 -1
  121. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.d.ts +47 -0
  122. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js +55 -0
  123. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js.map +1 -0
  124. package/build/library/sdk/model/uploadPretrainedModelRequest.d.ts +4 -0
  125. package/build/library/sdk/model/uploadPretrainedModelRequest.js +5 -0
  126. package/build/library/sdk/model/uploadPretrainedModelRequest.js.map +1 -1
  127. package/package.json +3 -2
@@ -12,14 +12,31 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.LearnApi = exports.LearnApiApiKeys = 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 LearnApiApiKeys;
30
47
  LearnApiApiKeys[LearnApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(LearnApiApiKeys = exports.LearnApiApiKeys || (exports.LearnApiApiKeys = {}));
32
49
  class LearnApi {
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 LearnApi {
54
91
  }
55
92
  this.opts = opts !== null && opts !== void 0 ? opts : {};
56
93
  }
57
- set useQuerystring(value) {
58
- this._useQuerystring = value;
59
- }
60
94
  set basePath(basePath) {
61
95
  this._basePath = basePath;
62
96
  }
@@ -90,9 +124,11 @@ class LearnApi {
90
124
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
91
125
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
92
126
  let localVarQueryParameters = {};
93
- let localVarHeaderParams = Object.assign({
94
- 'User-Agent': 'edgeimpulse-api nodejs'
95
- }, this.defaultHeaders);
127
+ let localVarHeaderParams = {
128
+ 'User-Agent': 'edgeimpulse-api nodejs',
129
+ 'Content-Type': 'application/json',
130
+ ...this.defaultHeaders,
131
+ };
96
132
  const produces = ['application/json'];
97
133
  // give precedence to 'application/json'
98
134
  if (produces.indexOf('application/json') >= 0) {
@@ -101,7 +137,7 @@ class LearnApi {
101
137
  else {
102
138
  localVarHeaderParams.Accept = produces.join(',');
103
139
  }
104
- let localVarFormParams = {};
140
+ let localVarFormParams;
105
141
  // verify required parameter 'projectId' is not null or undefined
106
142
  if (projectId === null || projectId === undefined) {
107
143
  throw new Error('Required parameter projectId was null or undefined when calling addKerasFiles.');
@@ -114,59 +150,69 @@ class LearnApi {
114
150
  if (params.zip === null || params.zip === undefined) {
115
151
  throw new Error('Required parameter params.zip was null or undefined when calling addKerasFiles.');
116
152
  }
117
- Object.assign(localVarHeaderParams, options.headers);
118
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
119
- let localVarUseFormData = false;
153
+ localVarHeaderParams = {
154
+ ...localVarHeaderParams,
155
+ ...options.headers,
156
+ ...this.opts.extraHeaders,
157
+ };
120
158
  if (params.zip !== undefined) {
121
- localVarFormParams['zip'] = params.zip;
159
+ if (!(localVarFormParams instanceof FormData)) {
160
+ const existingParams = localVarFormParams;
161
+ localVarFormParams = new FormData();
162
+ if (existingParams && typeof existingParams === 'object') {
163
+ Object.keys(existingParams).forEach(key => {
164
+ localVarFormParams.append(key, existingParams[key]);
165
+ });
166
+ }
167
+ }
168
+ const zipFiles = Array.isArray(params.zip) ? params.zip : [params.zip];
169
+ const Blob = globalThis.Blob || require('buffer').Blob;
170
+ zipFiles.forEach((f) => {
171
+ localVarFormParams.append('zip', new Blob([f.value], {
172
+ type: f.options.contentType
173
+ }), f.options.filename);
174
+ });
122
175
  }
123
- localVarUseFormData = true;
176
+ const queryString = Object.entries(localVarQueryParameters)
177
+ .filter(([, value]) => value !== undefined)
178
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
179
+ .join('&');
180
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
124
181
  let localVarRequestOptions = {
125
182
  method: 'POST',
126
- qs: localVarQueryParameters,
127
- headers: localVarHeaderParams,
128
- uri: localVarPath,
129
- useQuerystring: this._useQuerystring,
130
- agentOptions: { keepAlive: false },
131
- json: true,
132
- };
133
- let authenticationPromise = Promise.resolve();
134
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
135
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
136
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
137
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
138
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
139
- return authenticationPromise.then(() => {
140
- if (Object.keys(localVarFormParams).length) {
141
- if (localVarUseFormData) {
142
- localVarRequestOptions.formData = localVarFormParams;
143
- }
144
- else {
145
- localVarRequestOptions.form = localVarFormParams;
146
- }
183
+ headers: { ...localVarHeaderParams },
184
+ };
185
+ let requestOptions = localVarRequestOptions;
186
+ let url = localVarUrl;
187
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
188
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
189
+ url = auth_ApiKeyAuthentication.url;
190
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
191
+ requestOptions = auth_JWTAuthentication.requestOptions;
192
+ url = auth_JWTAuthentication.url;
193
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
194
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
195
+ url = auth_JWTHttpHeaderAuthentication.url;
196
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
197
+ requestOptions = auth_OAuth2.requestOptions;
198
+ url = auth_OAuth2.url;
199
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
200
+ requestOptions = authDefault.requestOptions;
201
+ url = authDefault.url;
202
+ if (localVarFormParams) {
203
+ delete requestOptions.headers['Content-Type'];
204
+ if (localVarFormParams instanceof FormData) {
205
+ // FormData: fetch will handle Content-Type automatically.
206
+ requestOptions.body = localVarFormParams;
147
207
  }
148
- return new Promise((resolve, reject) => {
149
- localVarRequest(localVarRequestOptions, (error, response, body) => {
150
- if (error) {
151
- reject(error);
152
- }
153
- else {
154
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
155
- if (typeof body.success === 'boolean' && !body.success) {
156
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
157
- reject(new Error(body.error || errString));
158
- }
159
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
160
- resolve(body);
161
- }
162
- else {
163
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
164
- reject(errString);
165
- }
166
- }
167
- });
168
- });
169
- });
208
+ else if (Object.keys(localVarFormParams).length > 0) {
209
+ // URL-encoded form
210
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
211
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
212
+ }
213
+ }
214
+ const response = await fetch(url, requestOptions);
215
+ return this.handleResponse(response, 'GenericApiResponse');
170
216
  }
171
217
  /**
172
218
  * Get a sample of trained features, this extracts a number of samples and their features.
@@ -181,9 +227,11 @@ class LearnApi {
181
227
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
182
228
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
183
229
  let localVarQueryParameters = {};
184
- let localVarHeaderParams = Object.assign({
185
- 'User-Agent': 'edgeimpulse-api nodejs'
186
- }, this.defaultHeaders);
230
+ let localVarHeaderParams = {
231
+ 'User-Agent': 'edgeimpulse-api nodejs',
232
+ 'Content-Type': 'application/json',
233
+ ...this.defaultHeaders,
234
+ };
187
235
  const produces = ['application/json'];
188
236
  // give precedence to 'application/json'
189
237
  if (produces.indexOf('application/json') >= 0) {
@@ -192,7 +240,7 @@ class LearnApi {
192
240
  else {
193
241
  localVarHeaderParams.Accept = produces.join(',');
194
242
  }
195
- let localVarFormParams = {};
243
+ let localVarFormParams;
196
244
  // verify required parameter 'projectId' is not null or undefined
197
245
  if (projectId === null || projectId === undefined) {
198
246
  throw new Error('Required parameter projectId was null or undefined when calling anomalyTrainedFeatures.');
@@ -215,55 +263,51 @@ class LearnApi {
215
263
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.featureAx2) !== undefined) {
216
264
  localVarQueryParameters['featureAx2'] = models_1.ObjectSerializer.serialize(queryParams.featureAx2, "number");
217
265
  }
218
- Object.assign(localVarHeaderParams, options.headers);
219
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
220
- let localVarUseFormData = false;
266
+ localVarHeaderParams = {
267
+ ...localVarHeaderParams,
268
+ ...options.headers,
269
+ ...this.opts.extraHeaders,
270
+ };
271
+ const queryString = Object.entries(localVarQueryParameters)
272
+ .filter(([, value]) => value !== undefined)
273
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
274
+ .join('&');
275
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
221
276
  let localVarRequestOptions = {
222
277
  method: 'GET',
223
- qs: localVarQueryParameters,
224
- headers: localVarHeaderParams,
225
- uri: localVarPath,
226
- useQuerystring: this._useQuerystring,
227
- agentOptions: { keepAlive: false },
228
- json: true,
229
- };
230
- let authenticationPromise = Promise.resolve();
231
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
232
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
233
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
234
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
235
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
236
- return authenticationPromise.then(() => {
237
- if (Object.keys(localVarFormParams).length) {
238
- if (localVarUseFormData) {
239
- localVarRequestOptions.formData = localVarFormParams;
240
- }
241
- else {
242
- localVarRequestOptions.form = localVarFormParams;
243
- }
278
+ headers: { ...localVarHeaderParams },
279
+ };
280
+ let requestOptions = localVarRequestOptions;
281
+ let url = localVarUrl;
282
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
283
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
284
+ url = auth_ApiKeyAuthentication.url;
285
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
286
+ requestOptions = auth_JWTAuthentication.requestOptions;
287
+ url = auth_JWTAuthentication.url;
288
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
289
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
290
+ url = auth_JWTHttpHeaderAuthentication.url;
291
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
292
+ requestOptions = auth_OAuth2.requestOptions;
293
+ url = auth_OAuth2.url;
294
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
295
+ requestOptions = authDefault.requestOptions;
296
+ url = authDefault.url;
297
+ if (localVarFormParams) {
298
+ delete requestOptions.headers['Content-Type'];
299
+ if (localVarFormParams instanceof FormData) {
300
+ // FormData: fetch will handle Content-Type automatically.
301
+ requestOptions.body = localVarFormParams;
244
302
  }
245
- return new Promise((resolve, reject) => {
246
- localVarRequest(localVarRequestOptions, (error, response, body) => {
247
- if (error) {
248
- reject(error);
249
- }
250
- else {
251
- body = models_1.ObjectSerializer.deserialize(body, "AnomalyTrainedFeaturesResponse");
252
- if (typeof body.success === 'boolean' && !body.success) {
253
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
254
- reject(new Error(body.error || errString));
255
- }
256
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
257
- resolve(body);
258
- }
259
- else {
260
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
261
- reject(errString);
262
- }
263
- }
264
- });
265
- });
266
- });
303
+ else if (Object.keys(localVarFormParams).length > 0) {
304
+ // URL-encoded form
305
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
306
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
307
+ }
308
+ }
309
+ const response = await fetch(url, requestOptions);
310
+ return this.handleResponse(response, 'AnomalyTrainedFeaturesResponse');
267
311
  }
268
312
  /**
269
313
  * Get trained features for a single sample. This runs both the DSP prerequisites and the anomaly classifier.
@@ -278,9 +322,11 @@ class LearnApi {
278
322
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)))
279
323
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
280
324
  let localVarQueryParameters = {};
281
- let localVarHeaderParams = Object.assign({
282
- 'User-Agent': 'edgeimpulse-api nodejs'
283
- }, this.defaultHeaders);
325
+ let localVarHeaderParams = {
326
+ 'User-Agent': 'edgeimpulse-api nodejs',
327
+ 'Content-Type': 'application/json',
328
+ ...this.defaultHeaders,
329
+ };
284
330
  const produces = ['application/json'];
285
331
  // give precedence to 'application/json'
286
332
  if (produces.indexOf('application/json') >= 0) {
@@ -289,7 +335,7 @@ class LearnApi {
289
335
  else {
290
336
  localVarHeaderParams.Accept = produces.join(',');
291
337
  }
292
- let localVarFormParams = {};
338
+ let localVarFormParams;
293
339
  // verify required parameter 'projectId' is not null or undefined
294
340
  if (projectId === null || projectId === undefined) {
295
341
  throw new Error('Required parameter projectId was null or undefined when calling anomalyTrainedFeaturesPerSample.');
@@ -302,55 +348,51 @@ class LearnApi {
302
348
  if (sampleId === null || sampleId === undefined) {
303
349
  throw new Error('Required parameter sampleId was null or undefined when calling anomalyTrainedFeaturesPerSample.');
304
350
  }
305
- Object.assign(localVarHeaderParams, options.headers);
306
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
307
- let localVarUseFormData = false;
351
+ localVarHeaderParams = {
352
+ ...localVarHeaderParams,
353
+ ...options.headers,
354
+ ...this.opts.extraHeaders,
355
+ };
356
+ const queryString = Object.entries(localVarQueryParameters)
357
+ .filter(([, value]) => value !== undefined)
358
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
359
+ .join('&');
360
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
308
361
  let localVarRequestOptions = {
309
362
  method: 'GET',
310
- qs: localVarQueryParameters,
311
- headers: localVarHeaderParams,
312
- uri: localVarPath,
313
- useQuerystring: this._useQuerystring,
314
- agentOptions: { keepAlive: false },
315
- json: true,
316
- };
317
- let authenticationPromise = Promise.resolve();
318
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
319
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
320
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
321
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
322
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
323
- return authenticationPromise.then(() => {
324
- if (Object.keys(localVarFormParams).length) {
325
- if (localVarUseFormData) {
326
- localVarRequestOptions.formData = localVarFormParams;
327
- }
328
- else {
329
- localVarRequestOptions.form = localVarFormParams;
330
- }
363
+ headers: { ...localVarHeaderParams },
364
+ };
365
+ let requestOptions = localVarRequestOptions;
366
+ let url = localVarUrl;
367
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
368
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
369
+ url = auth_ApiKeyAuthentication.url;
370
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
371
+ requestOptions = auth_JWTAuthentication.requestOptions;
372
+ url = auth_JWTAuthentication.url;
373
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
374
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
375
+ url = auth_JWTHttpHeaderAuthentication.url;
376
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
377
+ requestOptions = auth_OAuth2.requestOptions;
378
+ url = auth_OAuth2.url;
379
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
380
+ requestOptions = authDefault.requestOptions;
381
+ url = authDefault.url;
382
+ if (localVarFormParams) {
383
+ delete requestOptions.headers['Content-Type'];
384
+ if (localVarFormParams instanceof FormData) {
385
+ // FormData: fetch will handle Content-Type automatically.
386
+ requestOptions.body = localVarFormParams;
331
387
  }
332
- return new Promise((resolve, reject) => {
333
- localVarRequest(localVarRequestOptions, (error, response, body) => {
334
- if (error) {
335
- reject(error);
336
- }
337
- else {
338
- body = models_1.ObjectSerializer.deserialize(body, "AnomalyTrainedFeaturesResponse");
339
- if (typeof body.success === 'boolean' && !body.success) {
340
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
341
- reject(new Error(body.error || errString));
342
- }
343
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
344
- resolve(body);
345
- }
346
- else {
347
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
348
- reject(errString);
349
- }
350
- }
351
- });
352
- });
353
- });
388
+ else if (Object.keys(localVarFormParams).length > 0) {
389
+ // URL-encoded form
390
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
391
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
392
+ }
393
+ }
394
+ const response = await fetch(url, requestOptions);
395
+ return this.handleResponse(response, 'AnomalyTrainedFeaturesResponse');
354
396
  }
355
397
  /**
356
398
  * Download the data of an exported Keras block - needs to be exported via \'exportKerasBlockData\' first
@@ -363,9 +405,11 @@ class LearnApi {
363
405
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
364
406
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
365
407
  let localVarQueryParameters = {};
366
- let localVarHeaderParams = Object.assign({
367
- 'User-Agent': 'edgeimpulse-api nodejs'
368
- }, this.defaultHeaders);
408
+ let localVarHeaderParams = {
409
+ 'User-Agent': 'edgeimpulse-api nodejs',
410
+ 'Content-Type': 'application/json',
411
+ ...this.defaultHeaders,
412
+ };
369
413
  const produces = ['application/zip'];
370
414
  // give precedence to 'application/json'
371
415
  if (produces.indexOf('application/json') >= 0) {
@@ -374,7 +418,7 @@ class LearnApi {
374
418
  else {
375
419
  localVarHeaderParams.Accept = produces.join(',');
376
420
  }
377
- let localVarFormParams = {};
421
+ let localVarFormParams;
378
422
  // verify required parameter 'projectId' is not null or undefined
379
423
  if (projectId === null || projectId === undefined) {
380
424
  throw new Error('Required parameter projectId was null or undefined when calling downloadKerasData.');
@@ -383,55 +427,51 @@ class LearnApi {
383
427
  if (learnId === null || learnId === undefined) {
384
428
  throw new Error('Required parameter learnId was null or undefined when calling downloadKerasData.');
385
429
  }
386
- Object.assign(localVarHeaderParams, options.headers);
387
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
388
- let localVarUseFormData = false;
430
+ localVarHeaderParams = {
431
+ ...localVarHeaderParams,
432
+ ...options.headers,
433
+ ...this.opts.extraHeaders,
434
+ };
435
+ const queryString = Object.entries(localVarQueryParameters)
436
+ .filter(([, value]) => value !== undefined)
437
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
438
+ .join('&');
439
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
389
440
  let localVarRequestOptions = {
390
441
  method: 'GET',
391
- qs: localVarQueryParameters,
392
- headers: localVarHeaderParams,
393
- uri: localVarPath,
394
- useQuerystring: this._useQuerystring,
395
- agentOptions: { keepAlive: false },
396
- encoding: null,
397
- };
398
- let authenticationPromise = Promise.resolve();
399
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
400
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
401
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
402
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
403
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
404
- return authenticationPromise.then(() => {
405
- if (Object.keys(localVarFormParams).length) {
406
- if (localVarUseFormData) {
407
- localVarRequestOptions.formData = localVarFormParams;
408
- }
409
- else {
410
- localVarRequestOptions.form = localVarFormParams;
411
- }
442
+ headers: { ...localVarHeaderParams },
443
+ };
444
+ let requestOptions = localVarRequestOptions;
445
+ let url = localVarUrl;
446
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
447
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
448
+ url = auth_ApiKeyAuthentication.url;
449
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
450
+ requestOptions = auth_JWTAuthentication.requestOptions;
451
+ url = auth_JWTAuthentication.url;
452
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
453
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
454
+ url = auth_JWTHttpHeaderAuthentication.url;
455
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
456
+ requestOptions = auth_OAuth2.requestOptions;
457
+ url = auth_OAuth2.url;
458
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
459
+ requestOptions = authDefault.requestOptions;
460
+ url = authDefault.url;
461
+ if (localVarFormParams) {
462
+ delete requestOptions.headers['Content-Type'];
463
+ if (localVarFormParams instanceof FormData) {
464
+ // FormData: fetch will handle Content-Type automatically.
465
+ requestOptions.body = localVarFormParams;
412
466
  }
413
- return new Promise((resolve, reject) => {
414
- localVarRequest(localVarRequestOptions, (error, response, body) => {
415
- if (error) {
416
- reject(error);
417
- }
418
- else {
419
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
420
- if (typeof body.success === 'boolean' && !body.success) {
421
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
422
- reject(new Error(body.error || errString));
423
- }
424
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
425
- resolve(body);
426
- }
427
- else {
428
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
429
- reject(errString);
430
- }
431
- }
432
- });
433
- });
434
- });
467
+ else if (Object.keys(localVarFormParams).length > 0) {
468
+ // URL-encoded form
469
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
470
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
471
+ }
472
+ }
473
+ const response = await fetch(url, requestOptions);
474
+ return this.handleResponse(response, 'Buffer');
435
475
  }
436
476
  /**
437
477
  * Download an exported Keras block - needs to be exported via \'exportKerasBlock\' first
@@ -444,9 +484,11 @@ class LearnApi {
444
484
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
445
485
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
446
486
  let localVarQueryParameters = {};
447
- let localVarHeaderParams = Object.assign({
448
- 'User-Agent': 'edgeimpulse-api nodejs'
449
- }, this.defaultHeaders);
487
+ let localVarHeaderParams = {
488
+ 'User-Agent': 'edgeimpulse-api nodejs',
489
+ 'Content-Type': 'application/json',
490
+ ...this.defaultHeaders,
491
+ };
450
492
  const produces = ['application/zip'];
451
493
  // give precedence to 'application/json'
452
494
  if (produces.indexOf('application/json') >= 0) {
@@ -455,7 +497,7 @@ class LearnApi {
455
497
  else {
456
498
  localVarHeaderParams.Accept = produces.join(',');
457
499
  }
458
- let localVarFormParams = {};
500
+ let localVarFormParams;
459
501
  // verify required parameter 'projectId' is not null or undefined
460
502
  if (projectId === null || projectId === undefined) {
461
503
  throw new Error('Required parameter projectId was null or undefined when calling downloadKerasExport.');
@@ -464,55 +506,51 @@ class LearnApi {
464
506
  if (learnId === null || learnId === undefined) {
465
507
  throw new Error('Required parameter learnId was null or undefined when calling downloadKerasExport.');
466
508
  }
467
- Object.assign(localVarHeaderParams, options.headers);
468
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
469
- let localVarUseFormData = false;
509
+ localVarHeaderParams = {
510
+ ...localVarHeaderParams,
511
+ ...options.headers,
512
+ ...this.opts.extraHeaders,
513
+ };
514
+ const queryString = Object.entries(localVarQueryParameters)
515
+ .filter(([, value]) => value !== undefined)
516
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
517
+ .join('&');
518
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
470
519
  let localVarRequestOptions = {
471
520
  method: 'GET',
472
- qs: localVarQueryParameters,
473
- headers: localVarHeaderParams,
474
- uri: localVarPath,
475
- useQuerystring: this._useQuerystring,
476
- agentOptions: { keepAlive: false },
477
- encoding: null,
478
- };
479
- let authenticationPromise = Promise.resolve();
480
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
481
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
482
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
483
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
484
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
485
- return authenticationPromise.then(() => {
486
- if (Object.keys(localVarFormParams).length) {
487
- if (localVarUseFormData) {
488
- localVarRequestOptions.formData = localVarFormParams;
489
- }
490
- else {
491
- localVarRequestOptions.form = localVarFormParams;
492
- }
521
+ headers: { ...localVarHeaderParams },
522
+ };
523
+ let requestOptions = localVarRequestOptions;
524
+ let url = localVarUrl;
525
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
526
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
527
+ url = auth_ApiKeyAuthentication.url;
528
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
529
+ requestOptions = auth_JWTAuthentication.requestOptions;
530
+ url = auth_JWTAuthentication.url;
531
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
532
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
533
+ url = auth_JWTHttpHeaderAuthentication.url;
534
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
535
+ requestOptions = auth_OAuth2.requestOptions;
536
+ url = auth_OAuth2.url;
537
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
538
+ requestOptions = authDefault.requestOptions;
539
+ url = authDefault.url;
540
+ if (localVarFormParams) {
541
+ delete requestOptions.headers['Content-Type'];
542
+ if (localVarFormParams instanceof FormData) {
543
+ // FormData: fetch will handle Content-Type automatically.
544
+ requestOptions.body = localVarFormParams;
493
545
  }
494
- return new Promise((resolve, reject) => {
495
- localVarRequest(localVarRequestOptions, (error, response, body) => {
496
- if (error) {
497
- reject(error);
498
- }
499
- else {
500
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
501
- if (typeof body.success === 'boolean' && !body.success) {
502
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
503
- reject(new Error(body.error || errString));
504
- }
505
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
506
- resolve(body);
507
- }
508
- else {
509
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
510
- reject(errString);
511
- }
512
- }
513
- });
514
- });
515
- });
546
+ else if (Object.keys(localVarFormParams).length > 0) {
547
+ // URL-encoded form
548
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
549
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
550
+ }
551
+ }
552
+ const response = await fetch(url, requestOptions);
553
+ return this.handleResponse(response, 'Buffer');
516
554
  }
517
555
  /**
518
556
  * Download a trained model for a learning block. Depending on the block this can be a TensorFlow model, or the cluster centroids.
@@ -527,9 +565,11 @@ class LearnApi {
527
565
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)))
528
566
  .replace('{' + 'modelDownloadId' + '}', encodeURIComponent(String(modelDownloadId)));
529
567
  let localVarQueryParameters = {};
530
- let localVarHeaderParams = Object.assign({
531
- 'User-Agent': 'edgeimpulse-api nodejs'
532
- }, this.defaultHeaders);
568
+ let localVarHeaderParams = {
569
+ 'User-Agent': 'edgeimpulse-api nodejs',
570
+ 'Content-Type': 'application/json',
571
+ ...this.defaultHeaders,
572
+ };
533
573
  const produces = ['application/octet-stream'];
534
574
  // give precedence to 'application/json'
535
575
  if (produces.indexOf('application/json') >= 0) {
@@ -538,7 +578,7 @@ class LearnApi {
538
578
  else {
539
579
  localVarHeaderParams.Accept = produces.join(',');
540
580
  }
541
- let localVarFormParams = {};
581
+ let localVarFormParams;
542
582
  // verify required parameter 'projectId' is not null or undefined
543
583
  if (projectId === null || projectId === undefined) {
544
584
  throw new Error('Required parameter projectId was null or undefined when calling downloadLearnModel.');
@@ -551,55 +591,51 @@ class LearnApi {
551
591
  if (modelDownloadId === null || modelDownloadId === undefined) {
552
592
  throw new Error('Required parameter modelDownloadId was null or undefined when calling downloadLearnModel.');
553
593
  }
554
- Object.assign(localVarHeaderParams, options.headers);
555
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
556
- let localVarUseFormData = false;
594
+ localVarHeaderParams = {
595
+ ...localVarHeaderParams,
596
+ ...options.headers,
597
+ ...this.opts.extraHeaders,
598
+ };
599
+ const queryString = Object.entries(localVarQueryParameters)
600
+ .filter(([, value]) => value !== undefined)
601
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
602
+ .join('&');
603
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
557
604
  let localVarRequestOptions = {
558
605
  method: 'GET',
559
- qs: localVarQueryParameters,
560
- headers: localVarHeaderParams,
561
- uri: localVarPath,
562
- useQuerystring: this._useQuerystring,
563
- agentOptions: { keepAlive: false },
564
- encoding: null,
565
- };
566
- let authenticationPromise = Promise.resolve();
567
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
568
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
569
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
570
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
571
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
572
- return authenticationPromise.then(() => {
573
- if (Object.keys(localVarFormParams).length) {
574
- if (localVarUseFormData) {
575
- localVarRequestOptions.formData = localVarFormParams;
576
- }
577
- else {
578
- localVarRequestOptions.form = localVarFormParams;
579
- }
606
+ headers: { ...localVarHeaderParams },
607
+ };
608
+ let requestOptions = localVarRequestOptions;
609
+ let url = localVarUrl;
610
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
611
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
612
+ url = auth_ApiKeyAuthentication.url;
613
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
614
+ requestOptions = auth_JWTAuthentication.requestOptions;
615
+ url = auth_JWTAuthentication.url;
616
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
617
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
618
+ url = auth_JWTHttpHeaderAuthentication.url;
619
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
620
+ requestOptions = auth_OAuth2.requestOptions;
621
+ url = auth_OAuth2.url;
622
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
623
+ requestOptions = authDefault.requestOptions;
624
+ url = authDefault.url;
625
+ if (localVarFormParams) {
626
+ delete requestOptions.headers['Content-Type'];
627
+ if (localVarFormParams instanceof FormData) {
628
+ // FormData: fetch will handle Content-Type automatically.
629
+ requestOptions.body = localVarFormParams;
580
630
  }
581
- return new Promise((resolve, reject) => {
582
- localVarRequest(localVarRequestOptions, (error, response, body) => {
583
- if (error) {
584
- reject(error);
585
- }
586
- else {
587
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
588
- if (typeof body.success === 'boolean' && !body.success) {
589
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
590
- reject(new Error(body.error || errString));
591
- }
592
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
593
- resolve(body);
594
- }
595
- else {
596
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
597
- reject(errString);
598
- }
599
- }
600
- });
601
- });
602
- });
631
+ else if (Object.keys(localVarFormParams).length > 0) {
632
+ // URL-encoded form
633
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
634
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
635
+ }
636
+ }
637
+ const response = await fetch(url, requestOptions);
638
+ return this.handleResponse(response, 'Buffer');
603
639
  }
604
640
  /**
605
641
  * Download a pretrained model file
@@ -613,9 +649,11 @@ class LearnApi {
613
649
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
614
650
  .replace('{' + 'pretrainedModelDownloadType' + '}', encodeURIComponent(String(pretrainedModelDownloadType)));
615
651
  let localVarQueryParameters = {};
616
- let localVarHeaderParams = Object.assign({
617
- 'User-Agent': 'edgeimpulse-api nodejs'
618
- }, this.defaultHeaders);
652
+ let localVarHeaderParams = {
653
+ 'User-Agent': 'edgeimpulse-api nodejs',
654
+ 'Content-Type': 'application/json',
655
+ ...this.defaultHeaders,
656
+ };
619
657
  const produces = ['application/octet-stream'];
620
658
  // give precedence to 'application/json'
621
659
  if (produces.indexOf('application/json') >= 0) {
@@ -624,7 +662,7 @@ class LearnApi {
624
662
  else {
625
663
  localVarHeaderParams.Accept = produces.join(',');
626
664
  }
627
- let localVarFormParams = {};
665
+ let localVarFormParams;
628
666
  // verify required parameter 'projectId' is not null or undefined
629
667
  if (projectId === null || projectId === undefined) {
630
668
  throw new Error('Required parameter projectId was null or undefined when calling downloadPretrainedModel.');
@@ -636,55 +674,51 @@ class LearnApi {
636
674
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
637
675
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
638
676
  }
639
- Object.assign(localVarHeaderParams, options.headers);
640
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
641
- let localVarUseFormData = false;
677
+ localVarHeaderParams = {
678
+ ...localVarHeaderParams,
679
+ ...options.headers,
680
+ ...this.opts.extraHeaders,
681
+ };
682
+ const queryString = Object.entries(localVarQueryParameters)
683
+ .filter(([, value]) => value !== undefined)
684
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
685
+ .join('&');
686
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
642
687
  let localVarRequestOptions = {
643
688
  method: 'GET',
644
- qs: localVarQueryParameters,
645
- headers: localVarHeaderParams,
646
- uri: localVarPath,
647
- useQuerystring: this._useQuerystring,
648
- agentOptions: { keepAlive: false },
649
- encoding: null,
650
- };
651
- let authenticationPromise = Promise.resolve();
652
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
653
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
654
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
655
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
656
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
657
- return authenticationPromise.then(() => {
658
- if (Object.keys(localVarFormParams).length) {
659
- if (localVarUseFormData) {
660
- localVarRequestOptions.formData = localVarFormParams;
661
- }
662
- else {
663
- localVarRequestOptions.form = localVarFormParams;
664
- }
689
+ headers: { ...localVarHeaderParams },
690
+ };
691
+ let requestOptions = localVarRequestOptions;
692
+ let url = localVarUrl;
693
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
694
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
695
+ url = auth_ApiKeyAuthentication.url;
696
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
697
+ requestOptions = auth_JWTAuthentication.requestOptions;
698
+ url = auth_JWTAuthentication.url;
699
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
700
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
701
+ url = auth_JWTHttpHeaderAuthentication.url;
702
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
703
+ requestOptions = auth_OAuth2.requestOptions;
704
+ url = auth_OAuth2.url;
705
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
706
+ requestOptions = authDefault.requestOptions;
707
+ url = authDefault.url;
708
+ if (localVarFormParams) {
709
+ delete requestOptions.headers['Content-Type'];
710
+ if (localVarFormParams instanceof FormData) {
711
+ // FormData: fetch will handle Content-Type automatically.
712
+ requestOptions.body = localVarFormParams;
665
713
  }
666
- return new Promise((resolve, reject) => {
667
- localVarRequest(localVarRequestOptions, (error, response, body) => {
668
- if (error) {
669
- reject(error);
670
- }
671
- else {
672
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
673
- if (typeof body.success === 'boolean' && !body.success) {
674
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
675
- reject(new Error(body.error || errString));
676
- }
677
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
678
- resolve(body);
679
- }
680
- else {
681
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
682
- reject(errString);
683
- }
684
- }
685
- });
686
- });
687
- });
714
+ else if (Object.keys(localVarFormParams).length > 0) {
715
+ // URL-encoded form
716
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
717
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
718
+ }
719
+ }
720
+ const response = await fetch(url, requestOptions);
721
+ return this.handleResponse(response, 'Buffer');
688
722
  }
689
723
  /**
690
724
  * Get information about an anomaly block, such as its dependencies. Use the impulse blocks to find the learnId.
@@ -697,9 +731,11 @@ class LearnApi {
697
731
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
698
732
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
699
733
  let localVarQueryParameters = {};
700
- let localVarHeaderParams = Object.assign({
701
- 'User-Agent': 'edgeimpulse-api nodejs'
702
- }, this.defaultHeaders);
734
+ let localVarHeaderParams = {
735
+ 'User-Agent': 'edgeimpulse-api nodejs',
736
+ 'Content-Type': 'application/json',
737
+ ...this.defaultHeaders,
738
+ };
703
739
  const produces = ['application/json'];
704
740
  // give precedence to 'application/json'
705
741
  if (produces.indexOf('application/json') >= 0) {
@@ -708,7 +744,7 @@ class LearnApi {
708
744
  else {
709
745
  localVarHeaderParams.Accept = produces.join(',');
710
746
  }
711
- let localVarFormParams = {};
747
+ let localVarFormParams;
712
748
  // verify required parameter 'projectId' is not null or undefined
713
749
  if (projectId === null || projectId === undefined) {
714
750
  throw new Error('Required parameter projectId was null or undefined when calling getAnomaly.');
@@ -717,55 +753,51 @@ class LearnApi {
717
753
  if (learnId === null || learnId === undefined) {
718
754
  throw new Error('Required parameter learnId was null or undefined when calling getAnomaly.');
719
755
  }
720
- Object.assign(localVarHeaderParams, options.headers);
721
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
722
- let localVarUseFormData = false;
756
+ localVarHeaderParams = {
757
+ ...localVarHeaderParams,
758
+ ...options.headers,
759
+ ...this.opts.extraHeaders,
760
+ };
761
+ const queryString = Object.entries(localVarQueryParameters)
762
+ .filter(([, value]) => value !== undefined)
763
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
764
+ .join('&');
765
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
723
766
  let localVarRequestOptions = {
724
767
  method: 'GET',
725
- qs: localVarQueryParameters,
726
- headers: localVarHeaderParams,
727
- uri: localVarPath,
728
- useQuerystring: this._useQuerystring,
729
- agentOptions: { keepAlive: false },
730
- json: true,
731
- };
732
- let authenticationPromise = Promise.resolve();
733
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
734
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
735
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
736
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
737
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
738
- return authenticationPromise.then(() => {
739
- if (Object.keys(localVarFormParams).length) {
740
- if (localVarUseFormData) {
741
- localVarRequestOptions.formData = localVarFormParams;
742
- }
743
- else {
744
- localVarRequestOptions.form = localVarFormParams;
745
- }
768
+ headers: { ...localVarHeaderParams },
769
+ };
770
+ let requestOptions = localVarRequestOptions;
771
+ let url = localVarUrl;
772
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
773
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
774
+ url = auth_ApiKeyAuthentication.url;
775
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
776
+ requestOptions = auth_JWTAuthentication.requestOptions;
777
+ url = auth_JWTAuthentication.url;
778
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
779
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
780
+ url = auth_JWTHttpHeaderAuthentication.url;
781
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
782
+ requestOptions = auth_OAuth2.requestOptions;
783
+ url = auth_OAuth2.url;
784
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
785
+ requestOptions = authDefault.requestOptions;
786
+ url = authDefault.url;
787
+ if (localVarFormParams) {
788
+ delete requestOptions.headers['Content-Type'];
789
+ if (localVarFormParams instanceof FormData) {
790
+ // FormData: fetch will handle Content-Type automatically.
791
+ requestOptions.body = localVarFormParams;
746
792
  }
747
- return new Promise((resolve, reject) => {
748
- localVarRequest(localVarRequestOptions, (error, response, body) => {
749
- if (error) {
750
- reject(error);
751
- }
752
- else {
753
- body = models_1.ObjectSerializer.deserialize(body, "AnomalyConfigResponse");
754
- if (typeof body.success === 'boolean' && !body.success) {
755
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
756
- reject(new Error(body.error || errString));
757
- }
758
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
759
- resolve(body);
760
- }
761
- else {
762
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
763
- reject(errString);
764
- }
765
- }
766
- });
767
- });
768
- });
793
+ else if (Object.keys(localVarFormParams).length > 0) {
794
+ // URL-encoded form
795
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
796
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
797
+ }
798
+ }
799
+ const response = await fetch(url, requestOptions);
800
+ return this.handleResponse(response, 'AnomalyConfigResponse');
769
801
  }
770
802
  /**
771
803
  * Get metadata about a trained anomaly block. Use the impulse blocks to find the learnId.
@@ -778,9 +810,11 @@ class LearnApi {
778
810
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
779
811
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
780
812
  let localVarQueryParameters = {};
781
- let localVarHeaderParams = Object.assign({
782
- 'User-Agent': 'edgeimpulse-api nodejs'
783
- }, this.defaultHeaders);
813
+ let localVarHeaderParams = {
814
+ 'User-Agent': 'edgeimpulse-api nodejs',
815
+ 'Content-Type': 'application/json',
816
+ ...this.defaultHeaders,
817
+ };
784
818
  const produces = ['application/json'];
785
819
  // give precedence to 'application/json'
786
820
  if (produces.indexOf('application/json') >= 0) {
@@ -789,7 +823,7 @@ class LearnApi {
789
823
  else {
790
824
  localVarHeaderParams.Accept = produces.join(',');
791
825
  }
792
- let localVarFormParams = {};
826
+ let localVarFormParams;
793
827
  // verify required parameter 'projectId' is not null or undefined
794
828
  if (projectId === null || projectId === undefined) {
795
829
  throw new Error('Required parameter projectId was null or undefined when calling getAnomalyMetadata.');
@@ -798,55 +832,51 @@ class LearnApi {
798
832
  if (learnId === null || learnId === undefined) {
799
833
  throw new Error('Required parameter learnId was null or undefined when calling getAnomalyMetadata.');
800
834
  }
801
- Object.assign(localVarHeaderParams, options.headers);
802
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
803
- let localVarUseFormData = false;
835
+ localVarHeaderParams = {
836
+ ...localVarHeaderParams,
837
+ ...options.headers,
838
+ ...this.opts.extraHeaders,
839
+ };
840
+ const queryString = Object.entries(localVarQueryParameters)
841
+ .filter(([, value]) => value !== undefined)
842
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
843
+ .join('&');
844
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
804
845
  let localVarRequestOptions = {
805
846
  method: 'GET',
806
- qs: localVarQueryParameters,
807
- headers: localVarHeaderParams,
808
- uri: localVarPath,
809
- useQuerystring: this._useQuerystring,
810
- agentOptions: { keepAlive: false },
811
- json: true,
812
- };
813
- let authenticationPromise = Promise.resolve();
814
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
815
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
816
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
817
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
818
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
819
- return authenticationPromise.then(() => {
820
- if (Object.keys(localVarFormParams).length) {
821
- if (localVarUseFormData) {
822
- localVarRequestOptions.formData = localVarFormParams;
823
- }
824
- else {
825
- localVarRequestOptions.form = localVarFormParams;
826
- }
847
+ headers: { ...localVarHeaderParams },
848
+ };
849
+ let requestOptions = localVarRequestOptions;
850
+ let url = localVarUrl;
851
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
852
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
853
+ url = auth_ApiKeyAuthentication.url;
854
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
855
+ requestOptions = auth_JWTAuthentication.requestOptions;
856
+ url = auth_JWTAuthentication.url;
857
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
858
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
859
+ url = auth_JWTHttpHeaderAuthentication.url;
860
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
861
+ requestOptions = auth_OAuth2.requestOptions;
862
+ url = auth_OAuth2.url;
863
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
864
+ requestOptions = authDefault.requestOptions;
865
+ url = authDefault.url;
866
+ if (localVarFormParams) {
867
+ delete requestOptions.headers['Content-Type'];
868
+ if (localVarFormParams instanceof FormData) {
869
+ // FormData: fetch will handle Content-Type automatically.
870
+ requestOptions.body = localVarFormParams;
827
871
  }
828
- return new Promise((resolve, reject) => {
829
- localVarRequest(localVarRequestOptions, (error, response, body) => {
830
- if (error) {
831
- reject(error);
832
- }
833
- else {
834
- body = models_1.ObjectSerializer.deserialize(body, "AnomalyModelMetadataResponse");
835
- if (typeof body.success === 'boolean' && !body.success) {
836
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
837
- reject(new Error(body.error || errString));
838
- }
839
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
840
- resolve(body);
841
- }
842
- else {
843
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
844
- reject(errString);
845
- }
846
- }
847
- });
848
- });
849
- });
872
+ else if (Object.keys(localVarFormParams).length > 0) {
873
+ // URL-encoded form
874
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
875
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
876
+ }
877
+ }
878
+ const response = await fetch(url, requestOptions);
879
+ return this.handleResponse(response, 'AnomalyModelMetadataResponse');
850
880
  }
851
881
  /**
852
882
  * Get raw model metadata of the Gaussian mixture model (GMM) for a trained anomaly block. Use the impulse blocks to find the learnId.
@@ -859,9 +889,11 @@ class LearnApi {
859
889
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
860
890
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
861
891
  let localVarQueryParameters = {};
862
- let localVarHeaderParams = Object.assign({
863
- 'User-Agent': 'edgeimpulse-api nodejs'
864
- }, this.defaultHeaders);
892
+ let localVarHeaderParams = {
893
+ 'User-Agent': 'edgeimpulse-api nodejs',
894
+ 'Content-Type': 'application/json',
895
+ ...this.defaultHeaders,
896
+ };
865
897
  const produces = ['application/json'];
866
898
  // give precedence to 'application/json'
867
899
  if (produces.indexOf('application/json') >= 0) {
@@ -870,7 +902,7 @@ class LearnApi {
870
902
  else {
871
903
  localVarHeaderParams.Accept = produces.join(',');
872
904
  }
873
- let localVarFormParams = {};
905
+ let localVarFormParams;
874
906
  // verify required parameter 'projectId' is not null or undefined
875
907
  if (projectId === null || projectId === undefined) {
876
908
  throw new Error('Required parameter projectId was null or undefined when calling getGmmMetadata.');
@@ -879,55 +911,51 @@ class LearnApi {
879
911
  if (learnId === null || learnId === undefined) {
880
912
  throw new Error('Required parameter learnId was null or undefined when calling getGmmMetadata.');
881
913
  }
882
- Object.assign(localVarHeaderParams, options.headers);
883
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
884
- let localVarUseFormData = false;
914
+ localVarHeaderParams = {
915
+ ...localVarHeaderParams,
916
+ ...options.headers,
917
+ ...this.opts.extraHeaders,
918
+ };
919
+ const queryString = Object.entries(localVarQueryParameters)
920
+ .filter(([, value]) => value !== undefined)
921
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
922
+ .join('&');
923
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
885
924
  let localVarRequestOptions = {
886
925
  method: 'GET',
887
- qs: localVarQueryParameters,
888
- headers: localVarHeaderParams,
889
- uri: localVarPath,
890
- useQuerystring: this._useQuerystring,
891
- agentOptions: { keepAlive: false },
892
- json: true,
893
- };
894
- let authenticationPromise = Promise.resolve();
895
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
896
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
897
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
898
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
899
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
900
- return authenticationPromise.then(() => {
901
- if (Object.keys(localVarFormParams).length) {
902
- if (localVarUseFormData) {
903
- localVarRequestOptions.formData = localVarFormParams;
904
- }
905
- else {
906
- localVarRequestOptions.form = localVarFormParams;
907
- }
926
+ headers: { ...localVarHeaderParams },
927
+ };
928
+ let requestOptions = localVarRequestOptions;
929
+ let url = localVarUrl;
930
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
931
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
932
+ url = auth_ApiKeyAuthentication.url;
933
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
934
+ requestOptions = auth_JWTAuthentication.requestOptions;
935
+ url = auth_JWTAuthentication.url;
936
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
937
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
938
+ url = auth_JWTHttpHeaderAuthentication.url;
939
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
940
+ requestOptions = auth_OAuth2.requestOptions;
941
+ url = auth_OAuth2.url;
942
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
943
+ requestOptions = authDefault.requestOptions;
944
+ url = authDefault.url;
945
+ if (localVarFormParams) {
946
+ delete requestOptions.headers['Content-Type'];
947
+ if (localVarFormParams instanceof FormData) {
948
+ // FormData: fetch will handle Content-Type automatically.
949
+ requestOptions.body = localVarFormParams;
908
950
  }
909
- return new Promise((resolve, reject) => {
910
- localVarRequest(localVarRequestOptions, (error, response, body) => {
911
- if (error) {
912
- reject(error);
913
- }
914
- else {
915
- body = models_1.ObjectSerializer.deserialize(body, "AnomalyGmmMetadataResponse");
916
- if (typeof body.success === 'boolean' && !body.success) {
917
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
918
- reject(new Error(body.error || errString));
919
- }
920
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
921
- resolve(body);
922
- }
923
- else {
924
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
925
- reject(errString);
926
- }
927
- }
928
- });
929
- });
930
- });
951
+ else if (Object.keys(localVarFormParams).length > 0) {
952
+ // URL-encoded form
953
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
954
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
955
+ }
956
+ }
957
+ const response = await fetch(url, requestOptions);
958
+ return this.handleResponse(response, 'AnomalyGmmMetadataResponse');
931
959
  }
932
960
  /**
933
961
  * Get information about a Keras block, such as its dependencies. Use the impulse blocks to find the learnId.
@@ -940,9 +968,11 @@ class LearnApi {
940
968
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
941
969
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
942
970
  let localVarQueryParameters = {};
943
- let localVarHeaderParams = Object.assign({
944
- 'User-Agent': 'edgeimpulse-api nodejs'
945
- }, this.defaultHeaders);
971
+ let localVarHeaderParams = {
972
+ 'User-Agent': 'edgeimpulse-api nodejs',
973
+ 'Content-Type': 'application/json',
974
+ ...this.defaultHeaders,
975
+ };
946
976
  const produces = ['application/json'];
947
977
  // give precedence to 'application/json'
948
978
  if (produces.indexOf('application/json') >= 0) {
@@ -951,7 +981,7 @@ class LearnApi {
951
981
  else {
952
982
  localVarHeaderParams.Accept = produces.join(',');
953
983
  }
954
- let localVarFormParams = {};
984
+ let localVarFormParams;
955
985
  // verify required parameter 'projectId' is not null or undefined
956
986
  if (projectId === null || projectId === undefined) {
957
987
  throw new Error('Required parameter projectId was null or undefined when calling getKeras.');
@@ -960,55 +990,51 @@ class LearnApi {
960
990
  if (learnId === null || learnId === undefined) {
961
991
  throw new Error('Required parameter learnId was null or undefined when calling getKeras.');
962
992
  }
963
- Object.assign(localVarHeaderParams, options.headers);
964
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
965
- let localVarUseFormData = false;
993
+ localVarHeaderParams = {
994
+ ...localVarHeaderParams,
995
+ ...options.headers,
996
+ ...this.opts.extraHeaders,
997
+ };
998
+ const queryString = Object.entries(localVarQueryParameters)
999
+ .filter(([, value]) => value !== undefined)
1000
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1001
+ .join('&');
1002
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
966
1003
  let localVarRequestOptions = {
967
1004
  method: 'GET',
968
- qs: localVarQueryParameters,
969
- headers: localVarHeaderParams,
970
- uri: localVarPath,
971
- useQuerystring: this._useQuerystring,
972
- agentOptions: { keepAlive: false },
973
- json: true,
974
- };
975
- let authenticationPromise = Promise.resolve();
976
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
977
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
978
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
979
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
980
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
981
- return authenticationPromise.then(() => {
982
- if (Object.keys(localVarFormParams).length) {
983
- if (localVarUseFormData) {
984
- localVarRequestOptions.formData = localVarFormParams;
985
- }
986
- else {
987
- localVarRequestOptions.form = localVarFormParams;
988
- }
1005
+ headers: { ...localVarHeaderParams },
1006
+ };
1007
+ let requestOptions = localVarRequestOptions;
1008
+ let url = localVarUrl;
1009
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1010
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1011
+ url = auth_ApiKeyAuthentication.url;
1012
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1013
+ requestOptions = auth_JWTAuthentication.requestOptions;
1014
+ url = auth_JWTAuthentication.url;
1015
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1016
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1017
+ url = auth_JWTHttpHeaderAuthentication.url;
1018
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1019
+ requestOptions = auth_OAuth2.requestOptions;
1020
+ url = auth_OAuth2.url;
1021
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1022
+ requestOptions = authDefault.requestOptions;
1023
+ url = authDefault.url;
1024
+ if (localVarFormParams) {
1025
+ delete requestOptions.headers['Content-Type'];
1026
+ if (localVarFormParams instanceof FormData) {
1027
+ // FormData: fetch will handle Content-Type automatically.
1028
+ requestOptions.body = localVarFormParams;
989
1029
  }
990
- return new Promise((resolve, reject) => {
991
- localVarRequest(localVarRequestOptions, (error, response, body) => {
992
- if (error) {
993
- reject(error);
994
- }
995
- else {
996
- body = models_1.ObjectSerializer.deserialize(body, "KerasResponse");
997
- if (typeof body.success === 'boolean' && !body.success) {
998
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
999
- reject(new Error(body.error || errString));
1000
- }
1001
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1002
- resolve(body);
1003
- }
1004
- else {
1005
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1006
- reject(errString);
1007
- }
1008
- }
1009
- });
1010
- });
1011
- });
1030
+ else if (Object.keys(localVarFormParams).length > 0) {
1031
+ // URL-encoded form
1032
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1033
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1034
+ }
1035
+ }
1036
+ const response = await fetch(url, requestOptions);
1037
+ return this.handleResponse(response, 'KerasResponse');
1012
1038
  }
1013
1039
  /**
1014
1040
  * t-SNE2 output of the raw dataset using embeddings from this Keras block
@@ -1021,9 +1047,11 @@ class LearnApi {
1021
1047
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1022
1048
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1023
1049
  let localVarQueryParameters = {};
1024
- let localVarHeaderParams = Object.assign({
1025
- 'User-Agent': 'edgeimpulse-api nodejs'
1026
- }, this.defaultHeaders);
1050
+ let localVarHeaderParams = {
1051
+ 'User-Agent': 'edgeimpulse-api nodejs',
1052
+ 'Content-Type': 'application/json',
1053
+ ...this.defaultHeaders,
1054
+ };
1027
1055
  const produces = ['application/json'];
1028
1056
  // give precedence to 'application/json'
1029
1057
  if (produces.indexOf('application/json') >= 0) {
@@ -1032,7 +1060,7 @@ class LearnApi {
1032
1060
  else {
1033
1061
  localVarHeaderParams.Accept = produces.join(',');
1034
1062
  }
1035
- let localVarFormParams = {};
1063
+ let localVarFormParams;
1036
1064
  // verify required parameter 'projectId' is not null or undefined
1037
1065
  if (projectId === null || projectId === undefined) {
1038
1066
  throw new Error('Required parameter projectId was null or undefined when calling getKerasDataExplorerFeatures.');
@@ -1041,55 +1069,51 @@ class LearnApi {
1041
1069
  if (learnId === null || learnId === undefined) {
1042
1070
  throw new Error('Required parameter learnId was null or undefined when calling getKerasDataExplorerFeatures.');
1043
1071
  }
1044
- Object.assign(localVarHeaderParams, options.headers);
1045
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1046
- let localVarUseFormData = false;
1072
+ localVarHeaderParams = {
1073
+ ...localVarHeaderParams,
1074
+ ...options.headers,
1075
+ ...this.opts.extraHeaders,
1076
+ };
1077
+ const queryString = Object.entries(localVarQueryParameters)
1078
+ .filter(([, value]) => value !== undefined)
1079
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1080
+ .join('&');
1081
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1047
1082
  let localVarRequestOptions = {
1048
1083
  method: 'GET',
1049
- qs: localVarQueryParameters,
1050
- headers: localVarHeaderParams,
1051
- uri: localVarPath,
1052
- useQuerystring: this._useQuerystring,
1053
- agentOptions: { keepAlive: false },
1054
- json: true,
1055
- };
1056
- let authenticationPromise = Promise.resolve();
1057
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1058
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1059
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1060
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1061
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1062
- return authenticationPromise.then(() => {
1063
- if (Object.keys(localVarFormParams).length) {
1064
- if (localVarUseFormData) {
1065
- localVarRequestOptions.formData = localVarFormParams;
1066
- }
1067
- else {
1068
- localVarRequestOptions.form = localVarFormParams;
1069
- }
1084
+ headers: { ...localVarHeaderParams },
1085
+ };
1086
+ let requestOptions = localVarRequestOptions;
1087
+ let url = localVarUrl;
1088
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1089
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1090
+ url = auth_ApiKeyAuthentication.url;
1091
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1092
+ requestOptions = auth_JWTAuthentication.requestOptions;
1093
+ url = auth_JWTAuthentication.url;
1094
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1095
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1096
+ url = auth_JWTHttpHeaderAuthentication.url;
1097
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1098
+ requestOptions = auth_OAuth2.requestOptions;
1099
+ url = auth_OAuth2.url;
1100
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1101
+ requestOptions = authDefault.requestOptions;
1102
+ url = authDefault.url;
1103
+ if (localVarFormParams) {
1104
+ delete requestOptions.headers['Content-Type'];
1105
+ if (localVarFormParams instanceof FormData) {
1106
+ // FormData: fetch will handle Content-Type automatically.
1107
+ requestOptions.body = localVarFormParams;
1070
1108
  }
1071
- return new Promise((resolve, reject) => {
1072
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1073
- if (error) {
1074
- reject(error);
1075
- }
1076
- else {
1077
- body = models_1.ObjectSerializer.deserialize(body, "GetDataExplorerFeaturesResponse");
1078
- if (typeof body.success === 'boolean' && !body.success) {
1079
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1080
- reject(new Error(body.error || errString));
1081
- }
1082
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1083
- resolve(body);
1084
- }
1085
- else {
1086
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1087
- reject(errString);
1088
- }
1089
- }
1090
- });
1091
- });
1092
- });
1109
+ else if (Object.keys(localVarFormParams).length > 0) {
1110
+ // URL-encoded form
1111
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1112
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1113
+ }
1114
+ }
1115
+ const response = await fetch(url, requestOptions);
1116
+ return this.handleResponse(response, 'GetDataExplorerFeaturesResponse');
1093
1117
  }
1094
1118
  /**
1095
1119
  * Get metadata about a trained Keras block. Use the impulse blocks to find the learnId.
@@ -1103,9 +1127,11 @@ class LearnApi {
1103
1127
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1104
1128
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1105
1129
  let localVarQueryParameters = {};
1106
- let localVarHeaderParams = Object.assign({
1107
- 'User-Agent': 'edgeimpulse-api nodejs'
1108
- }, this.defaultHeaders);
1130
+ let localVarHeaderParams = {
1131
+ 'User-Agent': 'edgeimpulse-api nodejs',
1132
+ 'Content-Type': 'application/json',
1133
+ ...this.defaultHeaders,
1134
+ };
1109
1135
  const produces = ['application/json'];
1110
1136
  // give precedence to 'application/json'
1111
1137
  if (produces.indexOf('application/json') >= 0) {
@@ -1114,7 +1140,7 @@ class LearnApi {
1114
1140
  else {
1115
1141
  localVarHeaderParams.Accept = produces.join(',');
1116
1142
  }
1117
- let localVarFormParams = {};
1143
+ let localVarFormParams;
1118
1144
  // verify required parameter 'projectId' is not null or undefined
1119
1145
  if (projectId === null || projectId === undefined) {
1120
1146
  throw new Error('Required parameter projectId was null or undefined when calling getKerasMetadata.');
@@ -1126,55 +1152,51 @@ class LearnApi {
1126
1152
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.excludeLabels) !== undefined) {
1127
1153
  localVarQueryParameters['excludeLabels'] = models_1.ObjectSerializer.serialize(queryParams.excludeLabels, "boolean");
1128
1154
  }
1129
- Object.assign(localVarHeaderParams, options.headers);
1130
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1131
- let localVarUseFormData = false;
1155
+ localVarHeaderParams = {
1156
+ ...localVarHeaderParams,
1157
+ ...options.headers,
1158
+ ...this.opts.extraHeaders,
1159
+ };
1160
+ const queryString = Object.entries(localVarQueryParameters)
1161
+ .filter(([, value]) => value !== undefined)
1162
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1163
+ .join('&');
1164
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1132
1165
  let localVarRequestOptions = {
1133
1166
  method: 'GET',
1134
- qs: localVarQueryParameters,
1135
- headers: localVarHeaderParams,
1136
- uri: localVarPath,
1137
- useQuerystring: this._useQuerystring,
1138
- agentOptions: { keepAlive: false },
1139
- json: true,
1140
- };
1141
- let authenticationPromise = Promise.resolve();
1142
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1143
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1144
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1145
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1146
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1147
- return authenticationPromise.then(() => {
1148
- if (Object.keys(localVarFormParams).length) {
1149
- if (localVarUseFormData) {
1150
- localVarRequestOptions.formData = localVarFormParams;
1151
- }
1152
- else {
1153
- localVarRequestOptions.form = localVarFormParams;
1154
- }
1167
+ headers: { ...localVarHeaderParams },
1168
+ };
1169
+ let requestOptions = localVarRequestOptions;
1170
+ let url = localVarUrl;
1171
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1172
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1173
+ url = auth_ApiKeyAuthentication.url;
1174
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1175
+ requestOptions = auth_JWTAuthentication.requestOptions;
1176
+ url = auth_JWTAuthentication.url;
1177
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1178
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1179
+ url = auth_JWTHttpHeaderAuthentication.url;
1180
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1181
+ requestOptions = auth_OAuth2.requestOptions;
1182
+ url = auth_OAuth2.url;
1183
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1184
+ requestOptions = authDefault.requestOptions;
1185
+ url = authDefault.url;
1186
+ if (localVarFormParams) {
1187
+ delete requestOptions.headers['Content-Type'];
1188
+ if (localVarFormParams instanceof FormData) {
1189
+ // FormData: fetch will handle Content-Type automatically.
1190
+ requestOptions.body = localVarFormParams;
1155
1191
  }
1156
- return new Promise((resolve, reject) => {
1157
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1158
- if (error) {
1159
- reject(error);
1160
- }
1161
- else {
1162
- body = models_1.ObjectSerializer.deserialize(body, "KerasModelMetadataResponse");
1163
- if (typeof body.success === 'boolean' && !body.success) {
1164
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1165
- reject(new Error(body.error || errString));
1166
- }
1167
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1168
- resolve(body);
1169
- }
1170
- else {
1171
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1172
- reject(errString);
1173
- }
1174
- }
1175
- });
1176
- });
1177
- });
1192
+ else if (Object.keys(localVarFormParams).length > 0) {
1193
+ // URL-encoded form
1194
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1195
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1196
+ }
1197
+ }
1198
+ const response = await fetch(url, requestOptions);
1199
+ return this.handleResponse(response, 'KerasModelMetadataResponse');
1178
1200
  }
1179
1201
  /**
1180
1202
  * Download the processed data for this learning block. This is data already processed by the signal processing blocks.
@@ -1187,9 +1209,11 @@ class LearnApi {
1187
1209
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1188
1210
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1189
1211
  let localVarQueryParameters = {};
1190
- let localVarHeaderParams = Object.assign({
1191
- 'User-Agent': 'edgeimpulse-api nodejs'
1192
- }, this.defaultHeaders);
1212
+ let localVarHeaderParams = {
1213
+ 'User-Agent': 'edgeimpulse-api nodejs',
1214
+ 'Content-Type': 'application/json',
1215
+ ...this.defaultHeaders,
1216
+ };
1193
1217
  const produces = ['application/octet-stream'];
1194
1218
  // give precedence to 'application/json'
1195
1219
  if (produces.indexOf('application/json') >= 0) {
@@ -1198,7 +1222,7 @@ class LearnApi {
1198
1222
  else {
1199
1223
  localVarHeaderParams.Accept = produces.join(',');
1200
1224
  }
1201
- let localVarFormParams = {};
1225
+ let localVarFormParams;
1202
1226
  // verify required parameter 'projectId' is not null or undefined
1203
1227
  if (projectId === null || projectId === undefined) {
1204
1228
  throw new Error('Required parameter projectId was null or undefined when calling getLearnXData.');
@@ -1207,55 +1231,51 @@ class LearnApi {
1207
1231
  if (learnId === null || learnId === undefined) {
1208
1232
  throw new Error('Required parameter learnId was null or undefined when calling getLearnXData.');
1209
1233
  }
1210
- Object.assign(localVarHeaderParams, options.headers);
1211
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1212
- let localVarUseFormData = false;
1234
+ localVarHeaderParams = {
1235
+ ...localVarHeaderParams,
1236
+ ...options.headers,
1237
+ ...this.opts.extraHeaders,
1238
+ };
1239
+ const queryString = Object.entries(localVarQueryParameters)
1240
+ .filter(([, value]) => value !== undefined)
1241
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1242
+ .join('&');
1243
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1213
1244
  let localVarRequestOptions = {
1214
1245
  method: 'GET',
1215
- qs: localVarQueryParameters,
1216
- headers: localVarHeaderParams,
1217
- uri: localVarPath,
1218
- useQuerystring: this._useQuerystring,
1219
- agentOptions: { keepAlive: false },
1220
- encoding: null,
1221
- };
1222
- let authenticationPromise = Promise.resolve();
1223
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1224
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1225
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1226
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1227
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1228
- return authenticationPromise.then(() => {
1229
- if (Object.keys(localVarFormParams).length) {
1230
- if (localVarUseFormData) {
1231
- localVarRequestOptions.formData = localVarFormParams;
1232
- }
1233
- else {
1234
- localVarRequestOptions.form = localVarFormParams;
1235
- }
1246
+ headers: { ...localVarHeaderParams },
1247
+ };
1248
+ let requestOptions = localVarRequestOptions;
1249
+ let url = localVarUrl;
1250
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1251
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1252
+ url = auth_ApiKeyAuthentication.url;
1253
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1254
+ requestOptions = auth_JWTAuthentication.requestOptions;
1255
+ url = auth_JWTAuthentication.url;
1256
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1257
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1258
+ url = auth_JWTHttpHeaderAuthentication.url;
1259
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1260
+ requestOptions = auth_OAuth2.requestOptions;
1261
+ url = auth_OAuth2.url;
1262
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1263
+ requestOptions = authDefault.requestOptions;
1264
+ url = authDefault.url;
1265
+ if (localVarFormParams) {
1266
+ delete requestOptions.headers['Content-Type'];
1267
+ if (localVarFormParams instanceof FormData) {
1268
+ // FormData: fetch will handle Content-Type automatically.
1269
+ requestOptions.body = localVarFormParams;
1236
1270
  }
1237
- return new Promise((resolve, reject) => {
1238
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1239
- if (error) {
1240
- reject(error);
1241
- }
1242
- else {
1243
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
1244
- if (typeof body.success === 'boolean' && !body.success) {
1245
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1246
- reject(new Error(body.error || errString));
1247
- }
1248
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1249
- resolve(body);
1250
- }
1251
- else {
1252
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1253
- reject(errString);
1254
- }
1255
- }
1256
- });
1257
- });
1258
- });
1271
+ else if (Object.keys(localVarFormParams).length > 0) {
1272
+ // URL-encoded form
1273
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1274
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1275
+ }
1276
+ }
1277
+ const response = await fetch(url, requestOptions);
1278
+ return this.handleResponse(response, 'Buffer');
1259
1279
  }
1260
1280
  /**
1261
1281
  * Download the labels for this learning block. This is data already processed by the signal processing blocks. Not all blocks support this function. If so, a GenericApiResponse is returned with an error message.
@@ -1268,9 +1288,11 @@ class LearnApi {
1268
1288
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1269
1289
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1270
1290
  let localVarQueryParameters = {};
1271
- let localVarHeaderParams = Object.assign({
1272
- 'User-Agent': 'edgeimpulse-api nodejs'
1273
- }, this.defaultHeaders);
1291
+ let localVarHeaderParams = {
1292
+ 'User-Agent': 'edgeimpulse-api nodejs',
1293
+ 'Content-Type': 'application/json',
1294
+ ...this.defaultHeaders,
1295
+ };
1274
1296
  const produces = ['application/octet-stream'];
1275
1297
  // give precedence to 'application/json'
1276
1298
  if (produces.indexOf('application/json') >= 0) {
@@ -1279,7 +1301,7 @@ class LearnApi {
1279
1301
  else {
1280
1302
  localVarHeaderParams.Accept = produces.join(',');
1281
1303
  }
1282
- let localVarFormParams = {};
1304
+ let localVarFormParams;
1283
1305
  // verify required parameter 'projectId' is not null or undefined
1284
1306
  if (projectId === null || projectId === undefined) {
1285
1307
  throw new Error('Required parameter projectId was null or undefined when calling getLearnYData.');
@@ -1288,55 +1310,51 @@ class LearnApi {
1288
1310
  if (learnId === null || learnId === undefined) {
1289
1311
  throw new Error('Required parameter learnId was null or undefined when calling getLearnYData.');
1290
1312
  }
1291
- Object.assign(localVarHeaderParams, options.headers);
1292
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1293
- let localVarUseFormData = false;
1313
+ localVarHeaderParams = {
1314
+ ...localVarHeaderParams,
1315
+ ...options.headers,
1316
+ ...this.opts.extraHeaders,
1317
+ };
1318
+ const queryString = Object.entries(localVarQueryParameters)
1319
+ .filter(([, value]) => value !== undefined)
1320
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1321
+ .join('&');
1322
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1294
1323
  let localVarRequestOptions = {
1295
1324
  method: 'GET',
1296
- qs: localVarQueryParameters,
1297
- headers: localVarHeaderParams,
1298
- uri: localVarPath,
1299
- useQuerystring: this._useQuerystring,
1300
- agentOptions: { keepAlive: false },
1301
- encoding: null,
1302
- };
1303
- let authenticationPromise = Promise.resolve();
1304
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1305
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1306
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1307
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1308
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1309
- return authenticationPromise.then(() => {
1310
- if (Object.keys(localVarFormParams).length) {
1311
- if (localVarUseFormData) {
1312
- localVarRequestOptions.formData = localVarFormParams;
1313
- }
1314
- else {
1315
- localVarRequestOptions.form = localVarFormParams;
1316
- }
1325
+ headers: { ...localVarHeaderParams },
1326
+ };
1327
+ let requestOptions = localVarRequestOptions;
1328
+ let url = localVarUrl;
1329
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1330
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1331
+ url = auth_ApiKeyAuthentication.url;
1332
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1333
+ requestOptions = auth_JWTAuthentication.requestOptions;
1334
+ url = auth_JWTAuthentication.url;
1335
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1336
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1337
+ url = auth_JWTHttpHeaderAuthentication.url;
1338
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1339
+ requestOptions = auth_OAuth2.requestOptions;
1340
+ url = auth_OAuth2.url;
1341
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1342
+ requestOptions = authDefault.requestOptions;
1343
+ url = authDefault.url;
1344
+ if (localVarFormParams) {
1345
+ delete requestOptions.headers['Content-Type'];
1346
+ if (localVarFormParams instanceof FormData) {
1347
+ // FormData: fetch will handle Content-Type automatically.
1348
+ requestOptions.body = localVarFormParams;
1317
1349
  }
1318
- return new Promise((resolve, reject) => {
1319
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1320
- if (error) {
1321
- reject(error);
1322
- }
1323
- else {
1324
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
1325
- if (typeof body.success === 'boolean' && !body.success) {
1326
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1327
- reject(new Error(body.error || errString));
1328
- }
1329
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1330
- resolve(body);
1331
- }
1332
- else {
1333
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1334
- reject(errString);
1335
- }
1336
- }
1337
- });
1338
- });
1339
- });
1350
+ else if (Object.keys(localVarFormParams).length > 0) {
1351
+ // URL-encoded form
1352
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1353
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1354
+ }
1355
+ }
1356
+ const response = await fetch(url, requestOptions);
1357
+ return this.handleResponse(response, 'Buffer');
1340
1358
  }
1341
1359
  /**
1342
1360
  * Receive info back about the earlier uploaded pretrained model (via `uploadPretrainedModel`) input/output tensors. If you want to deploy a pretrained model from the API, see `startDeployPretrainedModelJob`.
@@ -1348,9 +1366,11 @@ class LearnApi {
1348
1366
  const localVarPath = this.basePath + '/api/{projectId}/pretrained-model'
1349
1367
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1350
1368
  let localVarQueryParameters = {};
1351
- let localVarHeaderParams = Object.assign({
1352
- 'User-Agent': 'edgeimpulse-api nodejs'
1353
- }, this.defaultHeaders);
1369
+ let localVarHeaderParams = {
1370
+ 'User-Agent': 'edgeimpulse-api nodejs',
1371
+ 'Content-Type': 'application/json',
1372
+ ...this.defaultHeaders,
1373
+ };
1354
1374
  const produces = ['application/json'];
1355
1375
  // give precedence to 'application/json'
1356
1376
  if (produces.indexOf('application/json') >= 0) {
@@ -1359,7 +1379,7 @@ class LearnApi {
1359
1379
  else {
1360
1380
  localVarHeaderParams.Accept = produces.join(',');
1361
1381
  }
1362
- let localVarFormParams = {};
1382
+ let localVarFormParams;
1363
1383
  // verify required parameter 'projectId' is not null or undefined
1364
1384
  if (projectId === null || projectId === undefined) {
1365
1385
  throw new Error('Required parameter projectId was null or undefined when calling getPretrainedModelInfo.');
@@ -1367,55 +1387,51 @@ class LearnApi {
1367
1387
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
1368
1388
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
1369
1389
  }
1370
- Object.assign(localVarHeaderParams, options.headers);
1371
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1372
- let localVarUseFormData = false;
1390
+ localVarHeaderParams = {
1391
+ ...localVarHeaderParams,
1392
+ ...options.headers,
1393
+ ...this.opts.extraHeaders,
1394
+ };
1395
+ const queryString = Object.entries(localVarQueryParameters)
1396
+ .filter(([, value]) => value !== undefined)
1397
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1398
+ .join('&');
1399
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1373
1400
  let localVarRequestOptions = {
1374
1401
  method: 'GET',
1375
- qs: localVarQueryParameters,
1376
- headers: localVarHeaderParams,
1377
- uri: localVarPath,
1378
- useQuerystring: this._useQuerystring,
1379
- agentOptions: { keepAlive: false },
1380
- json: true,
1381
- };
1382
- let authenticationPromise = Promise.resolve();
1383
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1384
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1385
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1386
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1387
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1388
- return authenticationPromise.then(() => {
1389
- if (Object.keys(localVarFormParams).length) {
1390
- if (localVarUseFormData) {
1391
- localVarRequestOptions.formData = localVarFormParams;
1392
- }
1393
- else {
1394
- localVarRequestOptions.form = localVarFormParams;
1395
- }
1402
+ headers: { ...localVarHeaderParams },
1403
+ };
1404
+ let requestOptions = localVarRequestOptions;
1405
+ let url = localVarUrl;
1406
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1407
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1408
+ url = auth_ApiKeyAuthentication.url;
1409
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1410
+ requestOptions = auth_JWTAuthentication.requestOptions;
1411
+ url = auth_JWTAuthentication.url;
1412
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1413
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1414
+ url = auth_JWTHttpHeaderAuthentication.url;
1415
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1416
+ requestOptions = auth_OAuth2.requestOptions;
1417
+ url = auth_OAuth2.url;
1418
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1419
+ requestOptions = authDefault.requestOptions;
1420
+ url = authDefault.url;
1421
+ if (localVarFormParams) {
1422
+ delete requestOptions.headers['Content-Type'];
1423
+ if (localVarFormParams instanceof FormData) {
1424
+ // FormData: fetch will handle Content-Type automatically.
1425
+ requestOptions.body = localVarFormParams;
1396
1426
  }
1397
- return new Promise((resolve, reject) => {
1398
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1399
- if (error) {
1400
- reject(error);
1401
- }
1402
- else {
1403
- body = models_1.ObjectSerializer.deserialize(body, "GetPretrainedModelResponse");
1404
- if (typeof body.success === 'boolean' && !body.success) {
1405
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1406
- reject(new Error(body.error || errString));
1407
- }
1408
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1409
- resolve(body);
1410
- }
1411
- else {
1412
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1413
- reject(errString);
1414
- }
1415
- }
1416
- });
1417
- });
1418
- });
1427
+ else if (Object.keys(localVarFormParams).length > 0) {
1428
+ // URL-encoded form
1429
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1430
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1431
+ }
1432
+ }
1433
+ const response = await fetch(url, requestOptions);
1434
+ return this.handleResponse(response, 'GetPretrainedModelResponse');
1419
1435
  }
1420
1436
  /**
1421
1437
  * Get config for a VLM learn block, including prompt and other model parameters
@@ -1428,9 +1444,11 @@ class LearnApi {
1428
1444
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1429
1445
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1430
1446
  let localVarQueryParameters = {};
1431
- let localVarHeaderParams = Object.assign({
1432
- 'User-Agent': 'edgeimpulse-api nodejs'
1433
- }, this.defaultHeaders);
1447
+ let localVarHeaderParams = {
1448
+ 'User-Agent': 'edgeimpulse-api nodejs',
1449
+ 'Content-Type': 'application/json',
1450
+ ...this.defaultHeaders,
1451
+ };
1434
1452
  const produces = ['application/json'];
1435
1453
  // give precedence to 'application/json'
1436
1454
  if (produces.indexOf('application/json') >= 0) {
@@ -1439,7 +1457,7 @@ class LearnApi {
1439
1457
  else {
1440
1458
  localVarHeaderParams.Accept = produces.join(',');
1441
1459
  }
1442
- let localVarFormParams = {};
1460
+ let localVarFormParams;
1443
1461
  // verify required parameter 'projectId' is not null or undefined
1444
1462
  if (projectId === null || projectId === undefined) {
1445
1463
  throw new Error('Required parameter projectId was null or undefined when calling getVlmConfig.');
@@ -1448,55 +1466,51 @@ class LearnApi {
1448
1466
  if (learnId === null || learnId === undefined) {
1449
1467
  throw new Error('Required parameter learnId was null or undefined when calling getVlmConfig.');
1450
1468
  }
1451
- Object.assign(localVarHeaderParams, options.headers);
1452
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1453
- let localVarUseFormData = false;
1469
+ localVarHeaderParams = {
1470
+ ...localVarHeaderParams,
1471
+ ...options.headers,
1472
+ ...this.opts.extraHeaders,
1473
+ };
1474
+ const queryString = Object.entries(localVarQueryParameters)
1475
+ .filter(([, value]) => value !== undefined)
1476
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1477
+ .join('&');
1478
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1454
1479
  let localVarRequestOptions = {
1455
1480
  method: 'GET',
1456
- qs: localVarQueryParameters,
1457
- headers: localVarHeaderParams,
1458
- uri: localVarPath,
1459
- useQuerystring: this._useQuerystring,
1460
- agentOptions: { keepAlive: false },
1461
- json: true,
1462
- };
1463
- let authenticationPromise = Promise.resolve();
1464
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1465
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1466
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1467
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1468
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1469
- return authenticationPromise.then(() => {
1470
- if (Object.keys(localVarFormParams).length) {
1471
- if (localVarUseFormData) {
1472
- localVarRequestOptions.formData = localVarFormParams;
1473
- }
1474
- else {
1475
- localVarRequestOptions.form = localVarFormParams;
1476
- }
1481
+ headers: { ...localVarHeaderParams },
1482
+ };
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;
1477
1505
  }
1478
- return new Promise((resolve, reject) => {
1479
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1480
- if (error) {
1481
- reject(error);
1482
- }
1483
- else {
1484
- body = models_1.ObjectSerializer.deserialize(body, "VlmConfigResponse");
1485
- if (typeof body.success === 'boolean' && !body.success) {
1486
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1487
- reject(new Error(body.error || errString));
1488
- }
1489
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1490
- resolve(body);
1491
- }
1492
- else {
1493
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1494
- reject(errString);
1495
- }
1496
- }
1497
- });
1498
- });
1499
- });
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';
1510
+ }
1511
+ }
1512
+ const response = await fetch(url, requestOptions);
1513
+ return this.handleResponse(response, 'VlmConfigResponse');
1500
1514
  }
1501
1515
  /**
1502
1516
  * Returns the latency, RAM and ROM used for the pretrained model - upload first via `uploadPretrainedModel`. This is using the project\'s selected latency device. 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.
@@ -1508,9 +1522,11 @@ class LearnApi {
1508
1522
  const localVarPath = this.basePath + '/api/{projectId}/pretrained-model/profile'
1509
1523
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1510
1524
  let localVarQueryParameters = {};
1511
- let localVarHeaderParams = Object.assign({
1512
- 'User-Agent': 'edgeimpulse-api nodejs'
1513
- }, this.defaultHeaders);
1525
+ let localVarHeaderParams = {
1526
+ 'User-Agent': 'edgeimpulse-api nodejs',
1527
+ 'Content-Type': 'application/json',
1528
+ ...this.defaultHeaders,
1529
+ };
1514
1530
  const produces = ['application/json'];
1515
1531
  // give precedence to 'application/json'
1516
1532
  if (produces.indexOf('application/json') >= 0) {
@@ -1519,7 +1535,7 @@ class LearnApi {
1519
1535
  else {
1520
1536
  localVarHeaderParams.Accept = produces.join(',');
1521
1537
  }
1522
- let localVarFormParams = {};
1538
+ let localVarFormParams;
1523
1539
  // verify required parameter 'projectId' is not null or undefined
1524
1540
  if (projectId === null || projectId === undefined) {
1525
1541
  throw new Error('Required parameter projectId was null or undefined when calling profilePretrainedModel.');
@@ -1527,55 +1543,51 @@ class LearnApi {
1527
1543
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
1528
1544
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
1529
1545
  }
1530
- Object.assign(localVarHeaderParams, options.headers);
1531
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1532
- let localVarUseFormData = false;
1546
+ localVarHeaderParams = {
1547
+ ...localVarHeaderParams,
1548
+ ...options.headers,
1549
+ ...this.opts.extraHeaders,
1550
+ };
1551
+ const queryString = Object.entries(localVarQueryParameters)
1552
+ .filter(([, value]) => value !== undefined)
1553
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1554
+ .join('&');
1555
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1533
1556
  let localVarRequestOptions = {
1534
1557
  method: 'POST',
1535
- qs: localVarQueryParameters,
1536
- headers: localVarHeaderParams,
1537
- uri: localVarPath,
1538
- useQuerystring: this._useQuerystring,
1539
- agentOptions: { keepAlive: false },
1540
- json: true,
1541
- };
1542
- let authenticationPromise = Promise.resolve();
1543
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1544
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1545
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1546
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1547
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1548
- return authenticationPromise.then(() => {
1549
- if (Object.keys(localVarFormParams).length) {
1550
- if (localVarUseFormData) {
1551
- localVarRequestOptions.formData = localVarFormParams;
1552
- }
1553
- else {
1554
- localVarRequestOptions.form = localVarFormParams;
1555
- }
1558
+ headers: { ...localVarHeaderParams },
1559
+ };
1560
+ let requestOptions = localVarRequestOptions;
1561
+ let url = localVarUrl;
1562
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1563
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1564
+ url = auth_ApiKeyAuthentication.url;
1565
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1566
+ requestOptions = auth_JWTAuthentication.requestOptions;
1567
+ url = auth_JWTAuthentication.url;
1568
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1569
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1570
+ url = auth_JWTHttpHeaderAuthentication.url;
1571
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1572
+ requestOptions = auth_OAuth2.requestOptions;
1573
+ url = auth_OAuth2.url;
1574
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1575
+ requestOptions = authDefault.requestOptions;
1576
+ url = authDefault.url;
1577
+ if (localVarFormParams) {
1578
+ delete requestOptions.headers['Content-Type'];
1579
+ if (localVarFormParams instanceof FormData) {
1580
+ // FormData: fetch will handle Content-Type automatically.
1581
+ requestOptions.body = localVarFormParams;
1556
1582
  }
1557
- return new Promise((resolve, reject) => {
1558
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1559
- if (error) {
1560
- reject(error);
1561
- }
1562
- else {
1563
- body = models_1.ObjectSerializer.deserialize(body, "StartJobResponse");
1564
- if (typeof body.success === 'boolean' && !body.success) {
1565
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1566
- reject(new Error(body.error || errString));
1567
- }
1568
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1569
- resolve(body);
1570
- }
1571
- else {
1572
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1573
- reject(errString);
1574
- }
1575
- }
1576
- });
1577
- });
1578
- });
1583
+ else if (Object.keys(localVarFormParams).length > 0) {
1584
+ // URL-encoded form
1585
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1586
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1587
+ }
1588
+ }
1589
+ const response = await fetch(url, requestOptions);
1590
+ return this.handleResponse(response, 'StartJobResponse');
1579
1591
  }
1580
1592
  /**
1581
1593
  * Save input / model configuration for a pretrained model. This overrides the current impulse. If you want to deploy a pretrained model from the API, see `startDeployPretrainedModelJob`.
@@ -1588,9 +1600,11 @@ class LearnApi {
1588
1600
  const localVarPath = this.basePath + '/api/{projectId}/pretrained-model/save'
1589
1601
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1590
1602
  let localVarQueryParameters = {};
1591
- let localVarHeaderParams = Object.assign({
1592
- 'User-Agent': 'edgeimpulse-api nodejs'
1593
- }, this.defaultHeaders);
1603
+ let localVarHeaderParams = {
1604
+ 'User-Agent': 'edgeimpulse-api nodejs',
1605
+ 'Content-Type': 'application/json',
1606
+ ...this.defaultHeaders,
1607
+ };
1594
1608
  const produces = ['application/json'];
1595
1609
  // give precedence to 'application/json'
1596
1610
  if (produces.indexOf('application/json') >= 0) {
@@ -1599,7 +1613,7 @@ class LearnApi {
1599
1613
  else {
1600
1614
  localVarHeaderParams.Accept = produces.join(',');
1601
1615
  }
1602
- let localVarFormParams = {};
1616
+ let localVarFormParams;
1603
1617
  // verify required parameter 'projectId' is not null or undefined
1604
1618
  if (projectId === null || projectId === undefined) {
1605
1619
  throw new Error('Required parameter projectId was null or undefined when calling savePretrainedModelParameters.');
@@ -1611,56 +1625,52 @@ class LearnApi {
1611
1625
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
1612
1626
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
1613
1627
  }
1614
- Object.assign(localVarHeaderParams, options.headers);
1615
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1616
- let localVarUseFormData = false;
1628
+ localVarHeaderParams = {
1629
+ ...localVarHeaderParams,
1630
+ ...options.headers,
1631
+ ...this.opts.extraHeaders,
1632
+ };
1633
+ const queryString = Object.entries(localVarQueryParameters)
1634
+ .filter(([, value]) => value !== undefined)
1635
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1636
+ .join('&');
1637
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1617
1638
  let localVarRequestOptions = {
1618
1639
  method: 'POST',
1619
- qs: localVarQueryParameters,
1620
- headers: localVarHeaderParams,
1621
- uri: localVarPath,
1622
- useQuerystring: this._useQuerystring,
1623
- agentOptions: { keepAlive: false },
1624
- json: true,
1625
- body: models_1.ObjectSerializer.serialize(savePretrainedModelRequest, "SavePretrainedModelRequest")
1626
- };
1627
- let authenticationPromise = Promise.resolve();
1628
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1629
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1630
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1631
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1632
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1633
- return authenticationPromise.then(() => {
1634
- if (Object.keys(localVarFormParams).length) {
1635
- if (localVarUseFormData) {
1636
- localVarRequestOptions.formData = localVarFormParams;
1637
- }
1638
- else {
1639
- localVarRequestOptions.form = localVarFormParams;
1640
- }
1640
+ headers: { ...localVarHeaderParams },
1641
+ };
1642
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(savePretrainedModelRequest, "SavePretrainedModelRequest"));
1643
+ let requestOptions = localVarRequestOptions;
1644
+ let url = localVarUrl;
1645
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1646
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1647
+ url = auth_ApiKeyAuthentication.url;
1648
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1649
+ requestOptions = auth_JWTAuthentication.requestOptions;
1650
+ url = auth_JWTAuthentication.url;
1651
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1652
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1653
+ url = auth_JWTHttpHeaderAuthentication.url;
1654
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1655
+ requestOptions = auth_OAuth2.requestOptions;
1656
+ url = auth_OAuth2.url;
1657
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1658
+ requestOptions = authDefault.requestOptions;
1659
+ url = authDefault.url;
1660
+ if (localVarFormParams) {
1661
+ delete requestOptions.headers['Content-Type'];
1662
+ if (localVarFormParams instanceof FormData) {
1663
+ // FormData: fetch will handle Content-Type automatically.
1664
+ requestOptions.body = localVarFormParams;
1641
1665
  }
1642
- return new Promise((resolve, reject) => {
1643
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1644
- if (error) {
1645
- reject(error);
1646
- }
1647
- else {
1648
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1649
- if (typeof body.success === 'boolean' && !body.success) {
1650
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1651
- reject(new Error(body.error || errString));
1652
- }
1653
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1654
- resolve(body);
1655
- }
1656
- else {
1657
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1658
- reject(errString);
1659
- }
1660
- }
1661
- });
1662
- });
1663
- });
1666
+ else if (Object.keys(localVarFormParams).length > 0) {
1667
+ // URL-encoded form
1668
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1669
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1670
+ }
1671
+ }
1672
+ const response = await fetch(url, requestOptions);
1673
+ return this.handleResponse(response, 'GenericApiResponse');
1664
1674
  }
1665
1675
  /**
1666
1676
  * Configure the anomaly block, such as its minimum confidence score. Use the impulse blocks to find the learnId.
@@ -1674,9 +1684,11 @@ class LearnApi {
1674
1684
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1675
1685
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1676
1686
  let localVarQueryParameters = {};
1677
- let localVarHeaderParams = Object.assign({
1678
- 'User-Agent': 'edgeimpulse-api nodejs'
1679
- }, this.defaultHeaders);
1687
+ let localVarHeaderParams = {
1688
+ 'User-Agent': 'edgeimpulse-api nodejs',
1689
+ 'Content-Type': 'application/json',
1690
+ ...this.defaultHeaders,
1691
+ };
1680
1692
  const produces = ['application/json'];
1681
1693
  // give precedence to 'application/json'
1682
1694
  if (produces.indexOf('application/json') >= 0) {
@@ -1685,7 +1697,7 @@ class LearnApi {
1685
1697
  else {
1686
1698
  localVarHeaderParams.Accept = produces.join(',');
1687
1699
  }
1688
- let localVarFormParams = {};
1700
+ let localVarFormParams;
1689
1701
  // verify required parameter 'projectId' is not null or undefined
1690
1702
  if (projectId === null || projectId === undefined) {
1691
1703
  throw new Error('Required parameter projectId was null or undefined when calling setAnomaly.');
@@ -1698,56 +1710,52 @@ class LearnApi {
1698
1710
  if (setAnomalyParameterRequest === null || setAnomalyParameterRequest === undefined) {
1699
1711
  throw new Error('Required parameter setAnomalyParameterRequest was null or undefined when calling setAnomaly.');
1700
1712
  }
1701
- Object.assign(localVarHeaderParams, options.headers);
1702
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1703
- let localVarUseFormData = false;
1713
+ localVarHeaderParams = {
1714
+ ...localVarHeaderParams,
1715
+ ...options.headers,
1716
+ ...this.opts.extraHeaders,
1717
+ };
1718
+ const queryString = Object.entries(localVarQueryParameters)
1719
+ .filter(([, value]) => value !== undefined)
1720
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1721
+ .join('&');
1722
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1704
1723
  let localVarRequestOptions = {
1705
1724
  method: 'POST',
1706
- qs: localVarQueryParameters,
1707
- headers: localVarHeaderParams,
1708
- uri: localVarPath,
1709
- useQuerystring: this._useQuerystring,
1710
- agentOptions: { keepAlive: false },
1711
- json: true,
1712
- body: models_1.ObjectSerializer.serialize(setAnomalyParameterRequest, "SetAnomalyParameterRequest")
1713
- };
1714
- let authenticationPromise = Promise.resolve();
1715
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1716
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1717
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1718
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1719
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1720
- return authenticationPromise.then(() => {
1721
- if (Object.keys(localVarFormParams).length) {
1722
- if (localVarUseFormData) {
1723
- localVarRequestOptions.formData = localVarFormParams;
1724
- }
1725
- else {
1726
- localVarRequestOptions.form = localVarFormParams;
1727
- }
1725
+ headers: { ...localVarHeaderParams },
1726
+ };
1727
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(setAnomalyParameterRequest, "SetAnomalyParameterRequest"));
1728
+ let requestOptions = localVarRequestOptions;
1729
+ let url = localVarUrl;
1730
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1731
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1732
+ url = auth_ApiKeyAuthentication.url;
1733
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1734
+ requestOptions = auth_JWTAuthentication.requestOptions;
1735
+ url = auth_JWTAuthentication.url;
1736
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1737
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1738
+ url = auth_JWTHttpHeaderAuthentication.url;
1739
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1740
+ requestOptions = auth_OAuth2.requestOptions;
1741
+ url = auth_OAuth2.url;
1742
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1743
+ requestOptions = authDefault.requestOptions;
1744
+ url = authDefault.url;
1745
+ if (localVarFormParams) {
1746
+ delete requestOptions.headers['Content-Type'];
1747
+ if (localVarFormParams instanceof FormData) {
1748
+ // FormData: fetch will handle Content-Type automatically.
1749
+ requestOptions.body = localVarFormParams;
1728
1750
  }
1729
- return new Promise((resolve, reject) => {
1730
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1731
- if (error) {
1732
- reject(error);
1733
- }
1734
- else {
1735
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1736
- if (typeof body.success === 'boolean' && !body.success) {
1737
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1738
- reject(new Error(body.error || errString));
1739
- }
1740
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1741
- resolve(body);
1742
- }
1743
- else {
1744
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1745
- reject(errString);
1746
- }
1747
- }
1748
- });
1749
- });
1750
- });
1751
+ else if (Object.keys(localVarFormParams).length > 0) {
1752
+ // URL-encoded form
1753
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1754
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1755
+ }
1756
+ }
1757
+ const response = await fetch(url, requestOptions);
1758
+ return this.handleResponse(response, 'GenericApiResponse');
1751
1759
  }
1752
1760
  /**
1753
1761
  * Configure the Keras block, such as its minimum confidence score. Use the impulse blocks to find the learnId.
@@ -1761,9 +1769,11 @@ class LearnApi {
1761
1769
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1762
1770
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1763
1771
  let localVarQueryParameters = {};
1764
- let localVarHeaderParams = Object.assign({
1765
- 'User-Agent': 'edgeimpulse-api nodejs'
1766
- }, this.defaultHeaders);
1772
+ let localVarHeaderParams = {
1773
+ 'User-Agent': 'edgeimpulse-api nodejs',
1774
+ 'Content-Type': 'application/json',
1775
+ ...this.defaultHeaders,
1776
+ };
1767
1777
  const produces = ['application/json'];
1768
1778
  // give precedence to 'application/json'
1769
1779
  if (produces.indexOf('application/json') >= 0) {
@@ -1772,7 +1782,7 @@ class LearnApi {
1772
1782
  else {
1773
1783
  localVarHeaderParams.Accept = produces.join(',');
1774
1784
  }
1775
- let localVarFormParams = {};
1785
+ let localVarFormParams;
1776
1786
  // verify required parameter 'projectId' is not null or undefined
1777
1787
  if (projectId === null || projectId === undefined) {
1778
1788
  throw new Error('Required parameter projectId was null or undefined when calling setKeras.');
@@ -1785,56 +1795,52 @@ class LearnApi {
1785
1795
  if (setKerasParameterRequest === null || setKerasParameterRequest === undefined) {
1786
1796
  throw new Error('Required parameter setKerasParameterRequest was null or undefined when calling setKeras.');
1787
1797
  }
1788
- Object.assign(localVarHeaderParams, options.headers);
1789
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1790
- let localVarUseFormData = false;
1798
+ localVarHeaderParams = {
1799
+ ...localVarHeaderParams,
1800
+ ...options.headers,
1801
+ ...this.opts.extraHeaders,
1802
+ };
1803
+ const queryString = Object.entries(localVarQueryParameters)
1804
+ .filter(([, value]) => value !== undefined)
1805
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1806
+ .join('&');
1807
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1791
1808
  let localVarRequestOptions = {
1792
1809
  method: 'POST',
1793
- qs: localVarQueryParameters,
1794
- headers: localVarHeaderParams,
1795
- uri: localVarPath,
1796
- useQuerystring: this._useQuerystring,
1797
- agentOptions: { keepAlive: false },
1798
- json: true,
1799
- body: models_1.ObjectSerializer.serialize(setKerasParameterRequest, "SetKerasParameterRequest")
1800
- };
1801
- let authenticationPromise = Promise.resolve();
1802
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1803
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1804
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1805
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1806
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1807
- return authenticationPromise.then(() => {
1808
- if (Object.keys(localVarFormParams).length) {
1809
- if (localVarUseFormData) {
1810
- localVarRequestOptions.formData = localVarFormParams;
1811
- }
1812
- else {
1813
- localVarRequestOptions.form = localVarFormParams;
1814
- }
1810
+ headers: { ...localVarHeaderParams },
1811
+ };
1812
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(setKerasParameterRequest, "SetKerasParameterRequest"));
1813
+ let requestOptions = localVarRequestOptions;
1814
+ let url = localVarUrl;
1815
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1816
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1817
+ url = auth_ApiKeyAuthentication.url;
1818
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1819
+ requestOptions = auth_JWTAuthentication.requestOptions;
1820
+ url = auth_JWTAuthentication.url;
1821
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1822
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1823
+ url = auth_JWTHttpHeaderAuthentication.url;
1824
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1825
+ requestOptions = auth_OAuth2.requestOptions;
1826
+ url = auth_OAuth2.url;
1827
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1828
+ requestOptions = authDefault.requestOptions;
1829
+ url = authDefault.url;
1830
+ if (localVarFormParams) {
1831
+ delete requestOptions.headers['Content-Type'];
1832
+ if (localVarFormParams instanceof FormData) {
1833
+ // FormData: fetch will handle Content-Type automatically.
1834
+ requestOptions.body = localVarFormParams;
1815
1835
  }
1816
- return new Promise((resolve, reject) => {
1817
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1818
- if (error) {
1819
- reject(error);
1820
- }
1821
- else {
1822
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1823
- if (typeof body.success === 'boolean' && !body.success) {
1824
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1825
- reject(new Error(body.error || errString));
1826
- }
1827
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1828
- resolve(body);
1829
- }
1830
- else {
1831
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1832
- reject(errString);
1833
- }
1834
- }
1835
- });
1836
- });
1837
- });
1836
+ else if (Object.keys(localVarFormParams).length > 0) {
1837
+ // URL-encoded form
1838
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1839
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1840
+ }
1841
+ }
1842
+ const response = await fetch(url, requestOptions);
1843
+ return this.handleResponse(response, 'GenericApiResponse');
1838
1844
  }
1839
1845
  /**
1840
1846
  * Update config for a VLM learn block, including prompt and other model parameters.
@@ -1848,9 +1854,11 @@ class LearnApi {
1848
1854
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1849
1855
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1850
1856
  let localVarQueryParameters = {};
1851
- let localVarHeaderParams = Object.assign({
1852
- 'User-Agent': 'edgeimpulse-api nodejs'
1853
- }, this.defaultHeaders);
1857
+ let localVarHeaderParams = {
1858
+ 'User-Agent': 'edgeimpulse-api nodejs',
1859
+ 'Content-Type': 'application/json',
1860
+ ...this.defaultHeaders,
1861
+ };
1854
1862
  const produces = ['application/json'];
1855
1863
  // give precedence to 'application/json'
1856
1864
  if (produces.indexOf('application/json') >= 0) {
@@ -1859,7 +1867,7 @@ class LearnApi {
1859
1867
  else {
1860
1868
  localVarHeaderParams.Accept = produces.join(',');
1861
1869
  }
1862
- let localVarFormParams = {};
1870
+ let localVarFormParams;
1863
1871
  // verify required parameter 'projectId' is not null or undefined
1864
1872
  if (projectId === null || projectId === undefined) {
1865
1873
  throw new Error('Required parameter projectId was null or undefined when calling setVlmConfig.');
@@ -1872,56 +1880,52 @@ class LearnApi {
1872
1880
  if (vlmConfigurationBase === null || vlmConfigurationBase === undefined) {
1873
1881
  throw new Error('Required parameter vlmConfigurationBase was null or undefined when calling setVlmConfig.');
1874
1882
  }
1875
- Object.assign(localVarHeaderParams, options.headers);
1876
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1877
- let localVarUseFormData = false;
1883
+ localVarHeaderParams = {
1884
+ ...localVarHeaderParams,
1885
+ ...options.headers,
1886
+ ...this.opts.extraHeaders,
1887
+ };
1888
+ const queryString = Object.entries(localVarQueryParameters)
1889
+ .filter(([, value]) => value !== undefined)
1890
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1891
+ .join('&');
1892
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1878
1893
  let localVarRequestOptions = {
1879
1894
  method: 'POST',
1880
- qs: localVarQueryParameters,
1881
- headers: localVarHeaderParams,
1882
- uri: localVarPath,
1883
- useQuerystring: this._useQuerystring,
1884
- agentOptions: { keepAlive: false },
1885
- json: true,
1886
- body: models_1.ObjectSerializer.serialize(vlmConfigurationBase, "VlmConfigurationBase")
1887
- };
1888
- let authenticationPromise = Promise.resolve();
1889
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1890
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1891
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1892
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1893
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1894
- return authenticationPromise.then(() => {
1895
- if (Object.keys(localVarFormParams).length) {
1896
- if (localVarUseFormData) {
1897
- localVarRequestOptions.formData = localVarFormParams;
1898
- }
1899
- else {
1900
- localVarRequestOptions.form = localVarFormParams;
1901
- }
1895
+ headers: { ...localVarHeaderParams },
1896
+ };
1897
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(vlmConfigurationBase, "VlmConfigurationBase"));
1898
+ let requestOptions = localVarRequestOptions;
1899
+ let url = localVarUrl;
1900
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1901
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1902
+ url = auth_ApiKeyAuthentication.url;
1903
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1904
+ requestOptions = auth_JWTAuthentication.requestOptions;
1905
+ url = auth_JWTAuthentication.url;
1906
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1907
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1908
+ url = auth_JWTHttpHeaderAuthentication.url;
1909
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1910
+ requestOptions = auth_OAuth2.requestOptions;
1911
+ url = auth_OAuth2.url;
1912
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1913
+ requestOptions = authDefault.requestOptions;
1914
+ url = authDefault.url;
1915
+ if (localVarFormParams) {
1916
+ delete requestOptions.headers['Content-Type'];
1917
+ if (localVarFormParams instanceof FormData) {
1918
+ // FormData: fetch will handle Content-Type automatically.
1919
+ requestOptions.body = localVarFormParams;
1902
1920
  }
1903
- return new Promise((resolve, reject) => {
1904
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1905
- if (error) {
1906
- reject(error);
1907
- }
1908
- else {
1909
- body = models_1.ObjectSerializer.deserialize(body, "VlmSetConfigResponse");
1910
- if (typeof body.success === 'boolean' && !body.success) {
1911
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1912
- reject(new Error(body.error || errString));
1913
- }
1914
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1915
- resolve(body);
1916
- }
1917
- else {
1918
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1919
- reject(errString);
1920
- }
1921
- }
1922
- });
1923
- });
1924
- });
1921
+ else if (Object.keys(localVarFormParams).length > 0) {
1922
+ // URL-encoded form
1923
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1924
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1925
+ }
1926
+ }
1927
+ const response = await fetch(url, requestOptions);
1928
+ return this.handleResponse(response, 'VlmSetConfigResponse');
1925
1929
  }
1926
1930
  /**
1927
1931
  * Starts an asynchronous profiling job, if there\'s no profiling information for the currently selected latency device. Afterwards, re-fetch model metadata to get the profiling job IDs.
@@ -1934,9 +1938,11 @@ class LearnApi {
1934
1938
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1935
1939
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
1936
1940
  let localVarQueryParameters = {};
1937
- let localVarHeaderParams = Object.assign({
1938
- 'User-Agent': 'edgeimpulse-api nodejs'
1939
- }, this.defaultHeaders);
1941
+ let localVarHeaderParams = {
1942
+ 'User-Agent': 'edgeimpulse-api nodejs',
1943
+ 'Content-Type': 'application/json',
1944
+ ...this.defaultHeaders,
1945
+ };
1940
1946
  const produces = ['application/json'];
1941
1947
  // give precedence to 'application/json'
1942
1948
  if (produces.indexOf('application/json') >= 0) {
@@ -1945,7 +1951,7 @@ class LearnApi {
1945
1951
  else {
1946
1952
  localVarHeaderParams.Accept = produces.join(',');
1947
1953
  }
1948
- let localVarFormParams = {};
1954
+ let localVarFormParams;
1949
1955
  // verify required parameter 'projectId' is not null or undefined
1950
1956
  if (projectId === null || projectId === undefined) {
1951
1957
  throw new Error('Required parameter projectId was null or undefined when calling startAnomalyProfileJob.');
@@ -1954,55 +1960,51 @@ class LearnApi {
1954
1960
  if (learnId === null || learnId === undefined) {
1955
1961
  throw new Error('Required parameter learnId was null or undefined when calling startAnomalyProfileJob.');
1956
1962
  }
1957
- Object.assign(localVarHeaderParams, options.headers);
1958
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1959
- let localVarUseFormData = false;
1963
+ localVarHeaderParams = {
1964
+ ...localVarHeaderParams,
1965
+ ...options.headers,
1966
+ ...this.opts.extraHeaders,
1967
+ };
1968
+ const queryString = Object.entries(localVarQueryParameters)
1969
+ .filter(([, value]) => value !== undefined)
1970
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1971
+ .join('&');
1972
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1960
1973
  let localVarRequestOptions = {
1961
1974
  method: 'POST',
1962
- qs: localVarQueryParameters,
1963
- headers: localVarHeaderParams,
1964
- uri: localVarPath,
1965
- useQuerystring: this._useQuerystring,
1966
- agentOptions: { keepAlive: false },
1967
- json: true,
1968
- };
1969
- let authenticationPromise = Promise.resolve();
1970
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1971
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1972
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1973
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1974
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1975
- return authenticationPromise.then(() => {
1976
- if (Object.keys(localVarFormParams).length) {
1977
- if (localVarUseFormData) {
1978
- localVarRequestOptions.formData = localVarFormParams;
1979
- }
1980
- else {
1981
- localVarRequestOptions.form = localVarFormParams;
1982
- }
1975
+ headers: { ...localVarHeaderParams },
1976
+ };
1977
+ let requestOptions = localVarRequestOptions;
1978
+ let url = localVarUrl;
1979
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1980
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1981
+ url = auth_ApiKeyAuthentication.url;
1982
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1983
+ requestOptions = auth_JWTAuthentication.requestOptions;
1984
+ url = auth_JWTAuthentication.url;
1985
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1986
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1987
+ url = auth_JWTHttpHeaderAuthentication.url;
1988
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1989
+ requestOptions = auth_OAuth2.requestOptions;
1990
+ url = auth_OAuth2.url;
1991
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1992
+ requestOptions = authDefault.requestOptions;
1993
+ url = authDefault.url;
1994
+ if (localVarFormParams) {
1995
+ delete requestOptions.headers['Content-Type'];
1996
+ if (localVarFormParams instanceof FormData) {
1997
+ // FormData: fetch will handle Content-Type automatically.
1998
+ requestOptions.body = localVarFormParams;
1983
1999
  }
1984
- return new Promise((resolve, reject) => {
1985
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1986
- if (error) {
1987
- reject(error);
1988
- }
1989
- else {
1990
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1991
- if (typeof body.success === 'boolean' && !body.success) {
1992
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1993
- reject(new Error(body.error || errString));
1994
- }
1995
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1996
- resolve(body);
1997
- }
1998
- else {
1999
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2000
- reject(errString);
2001
- }
2002
- }
2003
- });
2004
- });
2005
- });
2000
+ else if (Object.keys(localVarFormParams).length > 0) {
2001
+ // URL-encoded form
2002
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
2003
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2004
+ }
2005
+ }
2006
+ const response = await fetch(url, requestOptions);
2007
+ return this.handleResponse(response, 'GenericApiResponse');
2006
2008
  }
2007
2009
  /**
2008
2010
  * Starts an asynchronous profiling job, if there\'s no profiling information for the currently selected latency device. Afterwards, re-fetch model metadata to get the profiling job IDs.
@@ -2015,9 +2017,11 @@ class LearnApi {
2015
2017
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
2016
2018
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
2017
2019
  let localVarQueryParameters = {};
2018
- let localVarHeaderParams = Object.assign({
2019
- 'User-Agent': 'edgeimpulse-api nodejs'
2020
- }, this.defaultHeaders);
2020
+ let localVarHeaderParams = {
2021
+ 'User-Agent': 'edgeimpulse-api nodejs',
2022
+ 'Content-Type': 'application/json',
2023
+ ...this.defaultHeaders,
2024
+ };
2021
2025
  const produces = ['application/json'];
2022
2026
  // give precedence to 'application/json'
2023
2027
  if (produces.indexOf('application/json') >= 0) {
@@ -2026,7 +2030,7 @@ class LearnApi {
2026
2030
  else {
2027
2031
  localVarHeaderParams.Accept = produces.join(',');
2028
2032
  }
2029
- let localVarFormParams = {};
2033
+ let localVarFormParams;
2030
2034
  // verify required parameter 'projectId' is not null or undefined
2031
2035
  if (projectId === null || projectId === undefined) {
2032
2036
  throw new Error('Required parameter projectId was null or undefined when calling startKerasProfileJob.');
@@ -2035,55 +2039,51 @@ class LearnApi {
2035
2039
  if (learnId === null || learnId === undefined) {
2036
2040
  throw new Error('Required parameter learnId was null or undefined when calling startKerasProfileJob.');
2037
2041
  }
2038
- Object.assign(localVarHeaderParams, options.headers);
2039
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
2040
- let localVarUseFormData = false;
2042
+ localVarHeaderParams = {
2043
+ ...localVarHeaderParams,
2044
+ ...options.headers,
2045
+ ...this.opts.extraHeaders,
2046
+ };
2047
+ const queryString = Object.entries(localVarQueryParameters)
2048
+ .filter(([, value]) => value !== undefined)
2049
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
2050
+ .join('&');
2051
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
2041
2052
  let localVarRequestOptions = {
2042
2053
  method: 'POST',
2043
- qs: localVarQueryParameters,
2044
- headers: localVarHeaderParams,
2045
- uri: localVarPath,
2046
- useQuerystring: this._useQuerystring,
2047
- agentOptions: { keepAlive: false },
2048
- json: true,
2049
- };
2050
- let authenticationPromise = Promise.resolve();
2051
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
2052
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
2053
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
2054
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
2055
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
2056
- return authenticationPromise.then(() => {
2057
- if (Object.keys(localVarFormParams).length) {
2058
- if (localVarUseFormData) {
2059
- localVarRequestOptions.formData = localVarFormParams;
2060
- }
2061
- else {
2062
- localVarRequestOptions.form = localVarFormParams;
2063
- }
2054
+ headers: { ...localVarHeaderParams },
2055
+ };
2056
+ let requestOptions = localVarRequestOptions;
2057
+ let url = localVarUrl;
2058
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
2059
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
2060
+ url = auth_ApiKeyAuthentication.url;
2061
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
2062
+ requestOptions = auth_JWTAuthentication.requestOptions;
2063
+ url = auth_JWTAuthentication.url;
2064
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
2065
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
2066
+ url = auth_JWTHttpHeaderAuthentication.url;
2067
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
2068
+ requestOptions = auth_OAuth2.requestOptions;
2069
+ url = auth_OAuth2.url;
2070
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
2071
+ requestOptions = authDefault.requestOptions;
2072
+ url = authDefault.url;
2073
+ if (localVarFormParams) {
2074
+ delete requestOptions.headers['Content-Type'];
2075
+ if (localVarFormParams instanceof FormData) {
2076
+ // FormData: fetch will handle Content-Type automatically.
2077
+ requestOptions.body = localVarFormParams;
2064
2078
  }
2065
- return new Promise((resolve, reject) => {
2066
- localVarRequest(localVarRequestOptions, (error, response, body) => {
2067
- if (error) {
2068
- reject(error);
2069
- }
2070
- else {
2071
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
2072
- if (typeof body.success === 'boolean' && !body.success) {
2073
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2074
- reject(new Error(body.error || errString));
2075
- }
2076
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2077
- resolve(body);
2078
- }
2079
- else {
2080
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2081
- reject(errString);
2082
- }
2083
- }
2084
- });
2085
- });
2086
- });
2079
+ else if (Object.keys(localVarFormParams).length > 0) {
2080
+ // URL-encoded form
2081
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
2082
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2083
+ }
2084
+ }
2085
+ const response = await fetch(url, requestOptions);
2086
+ return this.handleResponse(response, 'GenericApiResponse');
2087
2087
  }
2088
2088
  /**
2089
2089
  * Test out a pretrained model (using raw features) - upload first via `uploadPretrainedModel`. If you want to deploy a pretrained model from the API, see `startDeployPretrainedModelJob`.
@@ -2096,9 +2096,11 @@ class LearnApi {
2096
2096
  const localVarPath = this.basePath + '/api/{projectId}/pretrained-model/test'
2097
2097
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
2098
2098
  let localVarQueryParameters = {};
2099
- let localVarHeaderParams = Object.assign({
2100
- 'User-Agent': 'edgeimpulse-api nodejs'
2101
- }, this.defaultHeaders);
2099
+ let localVarHeaderParams = {
2100
+ 'User-Agent': 'edgeimpulse-api nodejs',
2101
+ 'Content-Type': 'application/json',
2102
+ ...this.defaultHeaders,
2103
+ };
2102
2104
  const produces = ['application/json'];
2103
2105
  // give precedence to 'application/json'
2104
2106
  if (produces.indexOf('application/json') >= 0) {
@@ -2107,7 +2109,7 @@ class LearnApi {
2107
2109
  else {
2108
2110
  localVarHeaderParams.Accept = produces.join(',');
2109
2111
  }
2110
- let localVarFormParams = {};
2112
+ let localVarFormParams;
2111
2113
  // verify required parameter 'projectId' is not null or undefined
2112
2114
  if (projectId === null || projectId === undefined) {
2113
2115
  throw new Error('Required parameter projectId was null or undefined when calling testPretrainedModel.');
@@ -2119,56 +2121,52 @@ class LearnApi {
2119
2121
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
2120
2122
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
2121
2123
  }
2122
- Object.assign(localVarHeaderParams, options.headers);
2123
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
2124
- let localVarUseFormData = false;
2124
+ localVarHeaderParams = {
2125
+ ...localVarHeaderParams,
2126
+ ...options.headers,
2127
+ ...this.opts.extraHeaders,
2128
+ };
2129
+ const queryString = Object.entries(localVarQueryParameters)
2130
+ .filter(([, value]) => value !== undefined)
2131
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
2132
+ .join('&');
2133
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
2125
2134
  let localVarRequestOptions = {
2126
2135
  method: 'POST',
2127
- qs: localVarQueryParameters,
2128
- headers: localVarHeaderParams,
2129
- uri: localVarPath,
2130
- useQuerystring: this._useQuerystring,
2131
- agentOptions: { keepAlive: false },
2132
- json: true,
2133
- body: models_1.ObjectSerializer.serialize(testPretrainedModelRequest, "TestPretrainedModelRequest")
2134
- };
2135
- let authenticationPromise = Promise.resolve();
2136
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
2137
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
2138
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
2139
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
2140
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
2141
- return authenticationPromise.then(() => {
2142
- if (Object.keys(localVarFormParams).length) {
2143
- if (localVarUseFormData) {
2144
- localVarRequestOptions.formData = localVarFormParams;
2145
- }
2146
- else {
2147
- localVarRequestOptions.form = localVarFormParams;
2148
- }
2136
+ headers: { ...localVarHeaderParams },
2137
+ };
2138
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(testPretrainedModelRequest, "TestPretrainedModelRequest"));
2139
+ let requestOptions = localVarRequestOptions;
2140
+ let url = localVarUrl;
2141
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
2142
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
2143
+ url = auth_ApiKeyAuthentication.url;
2144
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
2145
+ requestOptions = auth_JWTAuthentication.requestOptions;
2146
+ url = auth_JWTAuthentication.url;
2147
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
2148
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
2149
+ url = auth_JWTHttpHeaderAuthentication.url;
2150
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
2151
+ requestOptions = auth_OAuth2.requestOptions;
2152
+ url = auth_OAuth2.url;
2153
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
2154
+ requestOptions = authDefault.requestOptions;
2155
+ url = authDefault.url;
2156
+ if (localVarFormParams) {
2157
+ delete requestOptions.headers['Content-Type'];
2158
+ if (localVarFormParams instanceof FormData) {
2159
+ // FormData: fetch will handle Content-Type automatically.
2160
+ requestOptions.body = localVarFormParams;
2149
2161
  }
2150
- return new Promise((resolve, reject) => {
2151
- localVarRequest(localVarRequestOptions, (error, response, body) => {
2152
- if (error) {
2153
- reject(error);
2154
- }
2155
- else {
2156
- body = models_1.ObjectSerializer.deserialize(body, "TestPretrainedModelResponse");
2157
- if (typeof body.success === 'boolean' && !body.success) {
2158
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2159
- reject(new Error(body.error || errString));
2160
- }
2161
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2162
- resolve(body);
2163
- }
2164
- else {
2165
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2166
- reject(errString);
2167
- }
2168
- }
2169
- });
2170
- });
2171
- });
2162
+ else if (Object.keys(localVarFormParams).length > 0) {
2163
+ // URL-encoded form
2164
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
2165
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2166
+ }
2167
+ }
2168
+ const response = await fetch(url, requestOptions);
2169
+ return this.handleResponse(response, 'TestPretrainedModelResponse');
2172
2170
  }
2173
2171
  /**
2174
2172
  * Test out a pretrained model (using image data) - upload first via `uploadPretrainedModel`. If you want to deploy a pretrained model from the API, see `startDeployPretrainedModelJob`. This will transform raw image data (e.g. RGB to grayscale, resize) before classifying. To classify raw features, see `testPretrainedModel`.
@@ -2181,9 +2179,11 @@ class LearnApi {
2181
2179
  const localVarPath = this.basePath + '/api/{projectId}/pretrained-model/test-image'
2182
2180
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
2183
2181
  let localVarQueryParameters = {};
2184
- let localVarHeaderParams = Object.assign({
2185
- 'User-Agent': 'edgeimpulse-api nodejs'
2186
- }, this.defaultHeaders);
2182
+ let localVarHeaderParams = {
2183
+ 'User-Agent': 'edgeimpulse-api nodejs',
2184
+ 'Content-Type': 'application/json',
2185
+ ...this.defaultHeaders,
2186
+ };
2187
2187
  const produces = ['application/json'];
2188
2188
  // give precedence to 'application/json'
2189
2189
  if (produces.indexOf('application/json') >= 0) {
@@ -2192,7 +2192,7 @@ class LearnApi {
2192
2192
  else {
2193
2193
  localVarHeaderParams.Accept = produces.join(',');
2194
2194
  }
2195
- let localVarFormParams = {};
2195
+ let localVarFormParams;
2196
2196
  // verify required parameter 'projectId' is not null or undefined
2197
2197
  if (projectId === null || projectId === undefined) {
2198
2198
  throw new Error('Required parameter projectId was null or undefined when calling testPretrainedModelImages.');
@@ -2204,56 +2204,52 @@ class LearnApi {
2204
2204
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
2205
2205
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
2206
2206
  }
2207
- Object.assign(localVarHeaderParams, options.headers);
2208
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
2209
- let localVarUseFormData = false;
2207
+ localVarHeaderParams = {
2208
+ ...localVarHeaderParams,
2209
+ ...options.headers,
2210
+ ...this.opts.extraHeaders,
2211
+ };
2212
+ const queryString = Object.entries(localVarQueryParameters)
2213
+ .filter(([, value]) => value !== undefined)
2214
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
2215
+ .join('&');
2216
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
2210
2217
  let localVarRequestOptions = {
2211
2218
  method: 'POST',
2212
- qs: localVarQueryParameters,
2213
- headers: localVarHeaderParams,
2214
- uri: localVarPath,
2215
- useQuerystring: this._useQuerystring,
2216
- agentOptions: { keepAlive: false },
2217
- json: true,
2218
- body: models_1.ObjectSerializer.serialize(testPretrainedModelImagesRequest, "TestPretrainedModelImagesRequest")
2219
- };
2220
- let authenticationPromise = Promise.resolve();
2221
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
2222
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
2223
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
2224
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
2225
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
2226
- return authenticationPromise.then(() => {
2227
- if (Object.keys(localVarFormParams).length) {
2228
- if (localVarUseFormData) {
2229
- localVarRequestOptions.formData = localVarFormParams;
2230
- }
2231
- else {
2232
- localVarRequestOptions.form = localVarFormParams;
2233
- }
2219
+ headers: { ...localVarHeaderParams },
2220
+ };
2221
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(testPretrainedModelImagesRequest, "TestPretrainedModelImagesRequest"));
2222
+ let requestOptions = localVarRequestOptions;
2223
+ let url = localVarUrl;
2224
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
2225
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
2226
+ url = auth_ApiKeyAuthentication.url;
2227
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
2228
+ requestOptions = auth_JWTAuthentication.requestOptions;
2229
+ url = auth_JWTAuthentication.url;
2230
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
2231
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
2232
+ url = auth_JWTHttpHeaderAuthentication.url;
2233
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
2234
+ requestOptions = auth_OAuth2.requestOptions;
2235
+ url = auth_OAuth2.url;
2236
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
2237
+ requestOptions = authDefault.requestOptions;
2238
+ url = authDefault.url;
2239
+ if (localVarFormParams) {
2240
+ delete requestOptions.headers['Content-Type'];
2241
+ if (localVarFormParams instanceof FormData) {
2242
+ // FormData: fetch will handle Content-Type automatically.
2243
+ requestOptions.body = localVarFormParams;
2234
2244
  }
2235
- return new Promise((resolve, reject) => {
2236
- localVarRequest(localVarRequestOptions, (error, response, body) => {
2237
- if (error) {
2238
- reject(error);
2239
- }
2240
- else {
2241
- body = models_1.ObjectSerializer.deserialize(body, "TestPretrainedModelResponse");
2242
- if (typeof body.success === 'boolean' && !body.success) {
2243
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2244
- reject(new Error(body.error || errString));
2245
- }
2246
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2247
- resolve(body);
2248
- }
2249
- else {
2250
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2251
- reject(errString);
2252
- }
2253
- }
2254
- });
2255
- });
2256
- });
2245
+ else if (Object.keys(localVarFormParams).length > 0) {
2246
+ // URL-encoded form
2247
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
2248
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2249
+ }
2250
+ }
2251
+ const response = await fetch(url, requestOptions);
2252
+ return this.handleResponse(response, 'TestPretrainedModelResponse');
2257
2253
  }
2258
2254
  /**
2259
2255
  * Replace Keras block files with the contents of a zip. This is an internal API.
@@ -2267,9 +2263,11 @@ class LearnApi {
2267
2263
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
2268
2264
  .replace('{' + 'learnId' + '}', encodeURIComponent(String(learnId)));
2269
2265
  let localVarQueryParameters = {};
2270
- let localVarHeaderParams = Object.assign({
2271
- 'User-Agent': 'edgeimpulse-api nodejs'
2272
- }, this.defaultHeaders);
2266
+ let localVarHeaderParams = {
2267
+ 'User-Agent': 'edgeimpulse-api nodejs',
2268
+ 'Content-Type': 'application/json',
2269
+ ...this.defaultHeaders,
2270
+ };
2273
2271
  const produces = ['application/json'];
2274
2272
  // give precedence to 'application/json'
2275
2273
  if (produces.indexOf('application/json') >= 0) {
@@ -2278,7 +2276,7 @@ class LearnApi {
2278
2276
  else {
2279
2277
  localVarHeaderParams.Accept = produces.join(',');
2280
2278
  }
2281
- let localVarFormParams = {};
2279
+ let localVarFormParams;
2282
2280
  // verify required parameter 'projectId' is not null or undefined
2283
2281
  if (projectId === null || projectId === undefined) {
2284
2282
  throw new Error('Required parameter projectId was null or undefined when calling uploadKerasFiles.');
@@ -2291,59 +2289,69 @@ class LearnApi {
2291
2289
  if (params.zip === null || params.zip === undefined) {
2292
2290
  throw new Error('Required parameter params.zip was null or undefined when calling uploadKerasFiles.');
2293
2291
  }
2294
- Object.assign(localVarHeaderParams, options.headers);
2295
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
2296
- let localVarUseFormData = false;
2292
+ localVarHeaderParams = {
2293
+ ...localVarHeaderParams,
2294
+ ...options.headers,
2295
+ ...this.opts.extraHeaders,
2296
+ };
2297
2297
  if (params.zip !== undefined) {
2298
- localVarFormParams['zip'] = params.zip;
2298
+ if (!(localVarFormParams instanceof FormData)) {
2299
+ const existingParams = localVarFormParams;
2300
+ localVarFormParams = new FormData();
2301
+ if (existingParams && typeof existingParams === 'object') {
2302
+ Object.keys(existingParams).forEach(key => {
2303
+ localVarFormParams.append(key, existingParams[key]);
2304
+ });
2305
+ }
2306
+ }
2307
+ const zipFiles = Array.isArray(params.zip) ? params.zip : [params.zip];
2308
+ const Blob = globalThis.Blob || require('buffer').Blob;
2309
+ zipFiles.forEach((f) => {
2310
+ localVarFormParams.append('zip', new Blob([f.value], {
2311
+ type: f.options.contentType
2312
+ }), f.options.filename);
2313
+ });
2299
2314
  }
2300
- localVarUseFormData = true;
2315
+ const queryString = Object.entries(localVarQueryParameters)
2316
+ .filter(([, value]) => value !== undefined)
2317
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
2318
+ .join('&');
2319
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
2301
2320
  let localVarRequestOptions = {
2302
2321
  method: 'POST',
2303
- qs: localVarQueryParameters,
2304
- headers: localVarHeaderParams,
2305
- uri: localVarPath,
2306
- useQuerystring: this._useQuerystring,
2307
- agentOptions: { keepAlive: false },
2308
- json: true,
2309
- };
2310
- let authenticationPromise = Promise.resolve();
2311
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
2312
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
2313
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
2314
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
2315
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
2316
- return authenticationPromise.then(() => {
2317
- if (Object.keys(localVarFormParams).length) {
2318
- if (localVarUseFormData) {
2319
- localVarRequestOptions.formData = localVarFormParams;
2320
- }
2321
- else {
2322
- localVarRequestOptions.form = localVarFormParams;
2323
- }
2322
+ headers: { ...localVarHeaderParams },
2323
+ };
2324
+ let requestOptions = localVarRequestOptions;
2325
+ let url = localVarUrl;
2326
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
2327
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
2328
+ url = auth_ApiKeyAuthentication.url;
2329
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
2330
+ requestOptions = auth_JWTAuthentication.requestOptions;
2331
+ url = auth_JWTAuthentication.url;
2332
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
2333
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
2334
+ url = auth_JWTHttpHeaderAuthentication.url;
2335
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
2336
+ requestOptions = auth_OAuth2.requestOptions;
2337
+ url = auth_OAuth2.url;
2338
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
2339
+ requestOptions = authDefault.requestOptions;
2340
+ url = authDefault.url;
2341
+ if (localVarFormParams) {
2342
+ delete requestOptions.headers['Content-Type'];
2343
+ if (localVarFormParams instanceof FormData) {
2344
+ // FormData: fetch will handle Content-Type automatically.
2345
+ requestOptions.body = localVarFormParams;
2324
2346
  }
2325
- return new Promise((resolve, reject) => {
2326
- localVarRequest(localVarRequestOptions, (error, response, body) => {
2327
- if (error) {
2328
- reject(error);
2329
- }
2330
- else {
2331
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
2332
- if (typeof body.success === 'boolean' && !body.success) {
2333
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2334
- reject(new Error(body.error || errString));
2335
- }
2336
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2337
- resolve(body);
2338
- }
2339
- else {
2340
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2341
- reject(errString);
2342
- }
2343
- }
2344
- });
2345
- });
2346
- });
2347
+ else if (Object.keys(localVarFormParams).length > 0) {
2348
+ // URL-encoded form
2349
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
2350
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2351
+ }
2352
+ }
2353
+ const response = await fetch(url, requestOptions);
2354
+ return this.handleResponse(response, 'GenericApiResponse');
2347
2355
  }
2348
2356
  /**
2349
2357
  * Upload a pretrained model and receive info back about the input/output tensors. If you want to deploy a pretrained model from the API, see `startDeployPretrainedModelJob`.
@@ -2355,14 +2363,17 @@ class LearnApi {
2355
2363
  * @param impulseId Impulse ID. If this is unset then the default impulse is used.
2356
2364
  * @param representativeFeatures
2357
2365
  * @param device MCU used for calculating latency, query &#x60;latencyDevices&#x60; in &#x60;listProject&#x60; for a list of supported devices (and use the \\\&quot;mcu\\\&quot; property here). If this is kept empty then we\\\&#39;ll show an overview of multiple devices.
2366
+ * @param overrideInputShape Optional for ONNX files: overrides the input shape of the model. This is highly suggested if the model has dynamic dimensions. If this field is not set, then all dynamic dimensions will be set to \&#39;1\&#39;.
2358
2367
  */
2359
2368
  async uploadPretrainedModel(projectId, params, queryParams, options = { headers: {} }) {
2360
2369
  const localVarPath = this.basePath + '/api/{projectId}/pretrained-model/upload'
2361
2370
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
2362
2371
  let localVarQueryParameters = {};
2363
- let localVarHeaderParams = Object.assign({
2364
- 'User-Agent': 'edgeimpulse-api nodejs'
2365
- }, this.defaultHeaders);
2372
+ let localVarHeaderParams = {
2373
+ 'User-Agent': 'edgeimpulse-api nodejs',
2374
+ 'Content-Type': 'application/json',
2375
+ ...this.defaultHeaders,
2376
+ };
2366
2377
  const produces = ['application/json'];
2367
2378
  // give precedence to 'application/json'
2368
2379
  if (produces.indexOf('application/json') >= 0) {
@@ -2371,7 +2382,7 @@ class LearnApi {
2371
2382
  else {
2372
2383
  localVarHeaderParams.Accept = produces.join(',');
2373
2384
  }
2374
- let localVarFormParams = {};
2385
+ let localVarFormParams;
2375
2386
  // verify required parameter 'projectId' is not null or undefined
2376
2387
  if (projectId === null || projectId === undefined) {
2377
2388
  throw new Error('Required parameter projectId was null or undefined when calling uploadPretrainedModel.');
@@ -2391,72 +2402,234 @@ class LearnApi {
2391
2402
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
2392
2403
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
2393
2404
  }
2394
- Object.assign(localVarHeaderParams, options.headers);
2395
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
2396
- let localVarUseFormData = false;
2405
+ localVarHeaderParams = {
2406
+ ...localVarHeaderParams,
2407
+ ...options.headers,
2408
+ ...this.opts.extraHeaders,
2409
+ };
2397
2410
  if (params.modelFile !== undefined) {
2398
- localVarFormParams['modelFile'] = params.modelFile;
2411
+ if (!(localVarFormParams instanceof FormData)) {
2412
+ const existingParams = localVarFormParams;
2413
+ localVarFormParams = new FormData();
2414
+ if (existingParams && typeof existingParams === 'object') {
2415
+ Object.keys(existingParams).forEach(key => {
2416
+ localVarFormParams.append(key, existingParams[key]);
2417
+ });
2418
+ }
2419
+ }
2420
+ const modelFileFiles = Array.isArray(params.modelFile) ? params.modelFile : [params.modelFile];
2421
+ const Blob = globalThis.Blob || require('buffer').Blob;
2422
+ modelFileFiles.forEach((f) => {
2423
+ localVarFormParams.append('modelFile', new Blob([f.value], {
2424
+ type: f.options.contentType
2425
+ }), f.options.filename);
2426
+ });
2399
2427
  }
2400
- localVarUseFormData = true;
2401
2428
  if (params.modelFileName !== undefined) {
2402
- localVarFormParams['modelFileName'] = models_1.ObjectSerializer.serializeFormData(params.modelFileName, "string");
2429
+ const isParametersField = "modelFileName" === "parameters";
2430
+ const serializableParams = isParametersField && params && ("parameters" in params);
2431
+ const modelFileNameSerialized = serializableParams
2432
+ ? JSON.stringify(params.parameters)
2433
+ : models_1.ObjectSerializer.serializeFormData(params.modelFileName, "string");
2434
+ if (localVarFormParams instanceof FormData) {
2435
+ localVarFormParams.append('modelFileName', modelFileNameSerialized);
2436
+ }
2437
+ else {
2438
+ if (!localVarFormParams) {
2439
+ localVarFormParams = {};
2440
+ }
2441
+ localVarFormParams['modelFileName'] = modelFileNameSerialized;
2442
+ }
2403
2443
  }
2404
2444
  if (params.modelFileType !== undefined) {
2405
- localVarFormParams['modelFileType'] = models_1.ObjectSerializer.serializeFormData(params.modelFileType, "string");
2445
+ const isParametersField = "modelFileType" === "parameters";
2446
+ const serializableParams = isParametersField && params && ("parameters" in params);
2447
+ const modelFileTypeSerialized = serializableParams
2448
+ ? JSON.stringify(params.parameters)
2449
+ : models_1.ObjectSerializer.serializeFormData(params.modelFileType, "string");
2450
+ if (localVarFormParams instanceof FormData) {
2451
+ localVarFormParams.append('modelFileType', modelFileTypeSerialized);
2452
+ }
2453
+ else {
2454
+ if (!localVarFormParams) {
2455
+ localVarFormParams = {};
2456
+ }
2457
+ localVarFormParams['modelFileType'] = modelFileTypeSerialized;
2458
+ }
2406
2459
  }
2407
2460
  if (params.representativeFeatures !== undefined) {
2408
- localVarFormParams['representativeFeatures'] = params.representativeFeatures;
2461
+ if (!(localVarFormParams instanceof FormData)) {
2462
+ const existingParams = localVarFormParams;
2463
+ localVarFormParams = new FormData();
2464
+ if (existingParams && typeof existingParams === 'object') {
2465
+ Object.keys(existingParams).forEach(key => {
2466
+ localVarFormParams.append(key, existingParams[key]);
2467
+ });
2468
+ }
2469
+ }
2470
+ const representativeFeaturesFiles = Array.isArray(params.representativeFeatures) ? params.representativeFeatures : [params.representativeFeatures];
2471
+ const Blob = globalThis.Blob || require('buffer').Blob;
2472
+ representativeFeaturesFiles.forEach((f) => {
2473
+ localVarFormParams.append('representativeFeatures', new Blob([f.value], {
2474
+ type: f.options.contentType
2475
+ }), f.options.filename);
2476
+ });
2409
2477
  }
2410
- localVarUseFormData = true;
2411
2478
  if (params.device !== undefined) {
2412
- localVarFormParams['device'] = models_1.ObjectSerializer.serializeFormData(params.device, "string");
2479
+ const isParametersField = "device" === "parameters";
2480
+ const serializableParams = isParametersField && params && ("parameters" in params);
2481
+ const deviceSerialized = serializableParams
2482
+ ? JSON.stringify(params.parameters)
2483
+ : models_1.ObjectSerializer.serializeFormData(params.device, "string");
2484
+ if (localVarFormParams instanceof FormData) {
2485
+ localVarFormParams.append('device', deviceSerialized);
2486
+ }
2487
+ else {
2488
+ if (!localVarFormParams) {
2489
+ localVarFormParams = {};
2490
+ }
2491
+ localVarFormParams['device'] = deviceSerialized;
2492
+ }
2413
2493
  }
2494
+ if (params.overrideInputShape !== undefined) {
2495
+ const isParametersField = "overrideInputShape" === "parameters";
2496
+ const serializableParams = isParametersField && params && ("parameters" in params);
2497
+ const overrideInputShapeSerialized = serializableParams
2498
+ ? JSON.stringify(params.parameters)
2499
+ : models_1.ObjectSerializer.serializeFormData(params.overrideInputShape, "Array<number>");
2500
+ if (localVarFormParams instanceof FormData) {
2501
+ localVarFormParams.append('overrideInputShape', overrideInputShapeSerialized);
2502
+ }
2503
+ else {
2504
+ if (!localVarFormParams) {
2505
+ localVarFormParams = {};
2506
+ }
2507
+ localVarFormParams['overrideInputShape'] = overrideInputShapeSerialized;
2508
+ }
2509
+ }
2510
+ const queryString = Object.entries(localVarQueryParameters)
2511
+ .filter(([, value]) => value !== undefined)
2512
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
2513
+ .join('&');
2514
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
2414
2515
  let localVarRequestOptions = {
2415
2516
  method: 'POST',
2416
- qs: localVarQueryParameters,
2417
- headers: localVarHeaderParams,
2418
- uri: localVarPath,
2419
- useQuerystring: this._useQuerystring,
2420
- agentOptions: { keepAlive: false },
2421
- json: true,
2422
- };
2423
- let authenticationPromise = Promise.resolve();
2424
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
2425
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
2426
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
2427
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
2428
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
2429
- return authenticationPromise.then(() => {
2430
- if (Object.keys(localVarFormParams).length) {
2431
- if (localVarUseFormData) {
2432
- localVarRequestOptions.formData = localVarFormParams;
2433
- }
2434
- else {
2435
- localVarRequestOptions.form = localVarFormParams;
2436
- }
2517
+ headers: { ...localVarHeaderParams },
2518
+ };
2519
+ let requestOptions = localVarRequestOptions;
2520
+ let url = localVarUrl;
2521
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
2522
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
2523
+ url = auth_ApiKeyAuthentication.url;
2524
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
2525
+ requestOptions = auth_JWTAuthentication.requestOptions;
2526
+ url = auth_JWTAuthentication.url;
2527
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
2528
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
2529
+ url = auth_JWTHttpHeaderAuthentication.url;
2530
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
2531
+ requestOptions = auth_OAuth2.requestOptions;
2532
+ url = auth_OAuth2.url;
2533
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
2534
+ requestOptions = authDefault.requestOptions;
2535
+ url = authDefault.url;
2536
+ if (localVarFormParams) {
2537
+ delete requestOptions.headers['Content-Type'];
2538
+ if (localVarFormParams instanceof FormData) {
2539
+ // FormData: fetch will handle Content-Type automatically.
2540
+ requestOptions.body = localVarFormParams;
2437
2541
  }
2438
- return new Promise((resolve, reject) => {
2439
- localVarRequest(localVarRequestOptions, (error, response, body) => {
2440
- if (error) {
2441
- reject(error);
2442
- }
2443
- else {
2444
- body = models_1.ObjectSerializer.deserialize(body, "StartJobResponse");
2445
- if (typeof body.success === 'boolean' && !body.success) {
2446
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2447
- reject(new Error(body.error || errString));
2448
- }
2449
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
2450
- resolve(body);
2451
- }
2452
- else {
2453
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
2454
- reject(errString);
2455
- }
2456
- }
2457
- });
2458
- });
2459
- });
2542
+ else if (Object.keys(localVarFormParams).length > 0) {
2543
+ // URL-encoded form
2544
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
2545
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2546
+ }
2547
+ }
2548
+ const response = await fetch(url, requestOptions);
2549
+ return this.handleResponse(response, 'StartJobResponse');
2550
+ }
2551
+ /**
2552
+ * Internal API, used in tests (only available on *.test.edgeimpulse.com). Upload a pretrained model by providing a URL - rather than uploading the file itself (as we have a request size limit on test).
2553
+ * @summary Upload a pretrained model
2554
+ * @param projectId Project ID
2555
+ * @param uploadPretrainedModelByUrlRequest
2556
+ * @param impulseId Impulse ID. If this is unset then the default impulse is used.
2557
+ */
2558
+ async uploadPretrainedModelByUrl(projectId, uploadPretrainedModelByUrlRequest, queryParams, options = { headers: {} }) {
2559
+ const localVarPath = this.basePath + '/api/{projectId}/pretrained-model/upload-by-url'
2560
+ .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
2561
+ let localVarQueryParameters = {};
2562
+ let localVarHeaderParams = {
2563
+ 'User-Agent': 'edgeimpulse-api nodejs',
2564
+ 'Content-Type': 'application/json',
2565
+ ...this.defaultHeaders,
2566
+ };
2567
+ const produces = ['application/json'];
2568
+ // give precedence to 'application/json'
2569
+ if (produces.indexOf('application/json') >= 0) {
2570
+ localVarHeaderParams.Accept = 'application/json';
2571
+ }
2572
+ else {
2573
+ localVarHeaderParams.Accept = produces.join(',');
2574
+ }
2575
+ let localVarFormParams;
2576
+ // verify required parameter 'projectId' is not null or undefined
2577
+ if (projectId === null || projectId === undefined) {
2578
+ throw new Error('Required parameter projectId was null or undefined when calling uploadPretrainedModelByUrl.');
2579
+ }
2580
+ // verify required parameter 'uploadPretrainedModelByUrlRequest' is not null or undefined
2581
+ if (uploadPretrainedModelByUrlRequest === null || uploadPretrainedModelByUrlRequest === undefined) {
2582
+ throw new Error('Required parameter uploadPretrainedModelByUrlRequest was null or undefined when calling uploadPretrainedModelByUrl.');
2583
+ }
2584
+ if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
2585
+ localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
2586
+ }
2587
+ localVarHeaderParams = {
2588
+ ...localVarHeaderParams,
2589
+ ...options.headers,
2590
+ ...this.opts.extraHeaders,
2591
+ };
2592
+ const queryString = Object.entries(localVarQueryParameters)
2593
+ .filter(([, value]) => value !== undefined)
2594
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
2595
+ .join('&');
2596
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
2597
+ let localVarRequestOptions = {
2598
+ method: 'POST',
2599
+ headers: { ...localVarHeaderParams },
2600
+ };
2601
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(uploadPretrainedModelByUrlRequest, "UploadPretrainedModelByUrlRequest"));
2602
+ let requestOptions = localVarRequestOptions;
2603
+ let url = localVarUrl;
2604
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
2605
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
2606
+ url = auth_ApiKeyAuthentication.url;
2607
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
2608
+ requestOptions = auth_JWTAuthentication.requestOptions;
2609
+ url = auth_JWTAuthentication.url;
2610
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
2611
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
2612
+ url = auth_JWTHttpHeaderAuthentication.url;
2613
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
2614
+ requestOptions = auth_OAuth2.requestOptions;
2615
+ url = auth_OAuth2.url;
2616
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
2617
+ requestOptions = authDefault.requestOptions;
2618
+ url = authDefault.url;
2619
+ if (localVarFormParams) {
2620
+ delete requestOptions.headers['Content-Type'];
2621
+ if (localVarFormParams instanceof FormData) {
2622
+ // FormData: fetch will handle Content-Type automatically.
2623
+ requestOptions.body = localVarFormParams;
2624
+ }
2625
+ else if (Object.keys(localVarFormParams).length > 0) {
2626
+ // URL-encoded form
2627
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
2628
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
2629
+ }
2630
+ }
2631
+ const response = await fetch(url, requestOptions);
2632
+ return this.handleResponse(response, 'StartJobResponse');
2460
2633
  }
2461
2634
  }
2462
2635
  exports.LearnApi = LearnApi;