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.OrganizationJobsApi = exports.OrganizationJobsApiApiKeys = 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 OrganizationJobsApiApiKeys;
30
47
  OrganizationJobsApiApiKeys[OrganizationJobsApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(OrganizationJobsApiApiKeys = exports.OrganizationJobsApiApiKeys || (exports.OrganizationJobsApiApiKeys = {}));
32
49
  class OrganizationJobsApi {
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 OrganizationJobsApi {
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 OrganizationJobsApi {
90
124
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
91
125
  .replace('{' + 'jobId' + '}', encodeURIComponent(String(jobId)));
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 OrganizationJobsApi {
101
137
  else {
102
138
  localVarHeaderParams.Accept = produces.join(',');
103
139
  }
104
- let localVarFormParams = {};
140
+ let localVarFormParams;
105
141
  // verify required parameter 'organizationId' is not null or undefined
106
142
  if (organizationId === null || organizationId === undefined) {
107
143
  throw new Error('Required parameter organizationId was null or undefined when calling cancelOrganizationJob.');
@@ -113,55 +149,51 @@ class OrganizationJobsApi {
113
149
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.forceCancel) !== undefined) {
114
150
  localVarQueryParameters['forceCancel'] = models_1.ObjectSerializer.serialize(queryParams.forceCancel, "string");
115
151
  }
116
- Object.assign(localVarHeaderParams, options.headers);
117
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
118
- let localVarUseFormData = false;
152
+ localVarHeaderParams = {
153
+ ...localVarHeaderParams,
154
+ ...options.headers,
155
+ ...this.opts.extraHeaders,
156
+ };
157
+ const queryString = Object.entries(localVarQueryParameters)
158
+ .filter(([, value]) => value !== undefined)
159
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
160
+ .join('&');
161
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
119
162
  let localVarRequestOptions = {
120
163
  method: 'POST',
121
- qs: localVarQueryParameters,
122
- headers: localVarHeaderParams,
123
- uri: localVarPath,
124
- useQuerystring: this._useQuerystring,
125
- agentOptions: { keepAlive: false },
126
- json: true,
164
+ headers: { ...localVarHeaderParams },
127
165
  };
128
- let authenticationPromise = Promise.resolve();
129
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
130
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
131
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
132
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
133
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
134
- return authenticationPromise.then(() => {
135
- if (Object.keys(localVarFormParams).length) {
136
- if (localVarUseFormData) {
137
- localVarRequestOptions.formData = localVarFormParams;
138
- }
139
- else {
140
- localVarRequestOptions.form = localVarFormParams;
141
- }
166
+ let requestOptions = localVarRequestOptions;
167
+ let url = localVarUrl;
168
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
169
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
170
+ url = auth_ApiKeyAuthentication.url;
171
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
172
+ requestOptions = auth_JWTAuthentication.requestOptions;
173
+ url = auth_JWTAuthentication.url;
174
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
175
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
176
+ url = auth_JWTHttpHeaderAuthentication.url;
177
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
178
+ requestOptions = auth_OAuth2.requestOptions;
179
+ url = auth_OAuth2.url;
180
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
181
+ requestOptions = authDefault.requestOptions;
182
+ url = authDefault.url;
183
+ if (localVarFormParams) {
184
+ delete requestOptions.headers['Content-Type'];
185
+ if (localVarFormParams instanceof FormData) {
186
+ // FormData: fetch will handle Content-Type automatically.
187
+ requestOptions.body = localVarFormParams;
188
+ }
189
+ else if (Object.keys(localVarFormParams).length > 0) {
190
+ // URL-encoded form
191
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
192
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
142
193
  }
143
- return new Promise((resolve, reject) => {
144
- localVarRequest(localVarRequestOptions, (error, response, body) => {
145
- if (error) {
146
- reject(error);
147
- }
148
- else {
149
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
150
- if (typeof body.success === 'boolean' && !body.success) {
151
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
152
- reject(new Error(body.error || errString));
153
- }
154
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
155
- resolve(body);
156
- }
157
- else {
158
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
159
- reject(errString);
160
- }
161
- }
162
- });
163
- });
164
- });
194
+ }
195
+ const response = await fetch(url, requestOptions);
196
+ return this.handleResponse(response, 'GenericApiResponse');
165
197
  }
166
198
  /**
167
199
  * Download the logs for a job (as a text file).
@@ -176,9 +208,11 @@ class OrganizationJobsApi {
176
208
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
177
209
  .replace('{' + 'jobId' + '}', encodeURIComponent(String(jobId)));
178
210
  let localVarQueryParameters = {};
179
- let localVarHeaderParams = Object.assign({
180
- 'User-Agent': 'edgeimpulse-api nodejs'
181
- }, this.defaultHeaders);
211
+ let localVarHeaderParams = {
212
+ 'User-Agent': 'edgeimpulse-api nodejs',
213
+ 'Content-Type': 'application/json',
214
+ ...this.defaultHeaders,
215
+ };
182
216
  const produces = ['text/plain'];
183
217
  // give precedence to 'application/json'
184
218
  if (produces.indexOf('application/json') >= 0) {
@@ -187,7 +221,7 @@ class OrganizationJobsApi {
187
221
  else {
188
222
  localVarHeaderParams.Accept = produces.join(',');
189
223
  }
190
- let localVarFormParams = {};
224
+ let localVarFormParams;
191
225
  // verify required parameter 'organizationId' is not null or undefined
192
226
  if (organizationId === null || organizationId === undefined) {
193
227
  throw new Error('Required parameter organizationId was null or undefined when calling downloadOrganizationJobsLogs.');
@@ -202,55 +236,51 @@ class OrganizationJobsApi {
202
236
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.logLevel) !== undefined) {
203
237
  localVarQueryParameters['logLevel'] = models_1.ObjectSerializer.serialize(queryParams.logLevel, "'error' | 'warn' | 'info' | 'debug'");
204
238
  }
205
- Object.assign(localVarHeaderParams, options.headers);
206
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
207
- let localVarUseFormData = false;
239
+ localVarHeaderParams = {
240
+ ...localVarHeaderParams,
241
+ ...options.headers,
242
+ ...this.opts.extraHeaders,
243
+ };
244
+ const queryString = Object.entries(localVarQueryParameters)
245
+ .filter(([, value]) => value !== undefined)
246
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
247
+ .join('&');
248
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
208
249
  let localVarRequestOptions = {
209
250
  method: 'GET',
210
- qs: localVarQueryParameters,
211
- headers: localVarHeaderParams,
212
- uri: localVarPath,
213
- useQuerystring: this._useQuerystring,
214
- agentOptions: { keepAlive: false },
215
- json: true,
251
+ headers: { ...localVarHeaderParams },
216
252
  };
217
- let authenticationPromise = Promise.resolve();
218
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
219
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
220
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
221
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
222
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
223
- return authenticationPromise.then(() => {
224
- if (Object.keys(localVarFormParams).length) {
225
- if (localVarUseFormData) {
226
- localVarRequestOptions.formData = localVarFormParams;
227
- }
228
- else {
229
- localVarRequestOptions.form = localVarFormParams;
230
- }
253
+ let requestOptions = localVarRequestOptions;
254
+ let url = localVarUrl;
255
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
256
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
257
+ url = auth_ApiKeyAuthentication.url;
258
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
259
+ requestOptions = auth_JWTAuthentication.requestOptions;
260
+ url = auth_JWTAuthentication.url;
261
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
262
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
263
+ url = auth_JWTHttpHeaderAuthentication.url;
264
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
265
+ requestOptions = auth_OAuth2.requestOptions;
266
+ url = auth_OAuth2.url;
267
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
268
+ requestOptions = authDefault.requestOptions;
269
+ url = authDefault.url;
270
+ if (localVarFormParams) {
271
+ delete requestOptions.headers['Content-Type'];
272
+ if (localVarFormParams instanceof FormData) {
273
+ // FormData: fetch will handle Content-Type automatically.
274
+ requestOptions.body = localVarFormParams;
231
275
  }
232
- return new Promise((resolve, reject) => {
233
- localVarRequest(localVarRequestOptions, (error, response, body) => {
234
- if (error) {
235
- reject(error);
236
- }
237
- else {
238
- body = models_1.ObjectSerializer.deserialize(body, "string");
239
- if (typeof body.success === 'boolean' && !body.success) {
240
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
241
- reject(new Error(body.error || errString));
242
- }
243
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
244
- resolve(body);
245
- }
246
- else {
247
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
248
- reject(errString);
249
- }
250
- }
251
- });
252
- });
253
- });
276
+ else if (Object.keys(localVarFormParams).length > 0) {
277
+ // URL-encoded form
278
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
279
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
280
+ }
281
+ }
282
+ const response = await fetch(url, requestOptions);
283
+ return this.handleResponse(response, 'string');
254
284
  }
255
285
  /**
256
286
  * Get the status for a job.
@@ -263,9 +293,11 @@ class OrganizationJobsApi {
263
293
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
264
294
  .replace('{' + 'jobId' + '}', encodeURIComponent(String(jobId)));
265
295
  let localVarQueryParameters = {};
266
- let localVarHeaderParams = Object.assign({
267
- 'User-Agent': 'edgeimpulse-api nodejs'
268
- }, this.defaultHeaders);
296
+ let localVarHeaderParams = {
297
+ 'User-Agent': 'edgeimpulse-api nodejs',
298
+ 'Content-Type': 'application/json',
299
+ ...this.defaultHeaders,
300
+ };
269
301
  const produces = ['application/json'];
270
302
  // give precedence to 'application/json'
271
303
  if (produces.indexOf('application/json') >= 0) {
@@ -274,7 +306,7 @@ class OrganizationJobsApi {
274
306
  else {
275
307
  localVarHeaderParams.Accept = produces.join(',');
276
308
  }
277
- let localVarFormParams = {};
309
+ let localVarFormParams;
278
310
  // verify required parameter 'organizationId' is not null or undefined
279
311
  if (organizationId === null || organizationId === undefined) {
280
312
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationJobStatus.');
@@ -283,55 +315,51 @@ class OrganizationJobsApi {
283
315
  if (jobId === null || jobId === undefined) {
284
316
  throw new Error('Required parameter jobId was null or undefined when calling getOrganizationJobStatus.');
285
317
  }
286
- Object.assign(localVarHeaderParams, options.headers);
287
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
288
- let localVarUseFormData = false;
318
+ localVarHeaderParams = {
319
+ ...localVarHeaderParams,
320
+ ...options.headers,
321
+ ...this.opts.extraHeaders,
322
+ };
323
+ const queryString = Object.entries(localVarQueryParameters)
324
+ .filter(([, value]) => value !== undefined)
325
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
326
+ .join('&');
327
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
289
328
  let localVarRequestOptions = {
290
329
  method: 'GET',
291
- qs: localVarQueryParameters,
292
- headers: localVarHeaderParams,
293
- uri: localVarPath,
294
- useQuerystring: this._useQuerystring,
295
- agentOptions: { keepAlive: false },
296
- json: true,
330
+ headers: { ...localVarHeaderParams },
297
331
  };
298
- let authenticationPromise = Promise.resolve();
299
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
300
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
301
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
302
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
303
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
304
- return authenticationPromise.then(() => {
305
- if (Object.keys(localVarFormParams).length) {
306
- if (localVarUseFormData) {
307
- localVarRequestOptions.formData = localVarFormParams;
308
- }
309
- else {
310
- localVarRequestOptions.form = localVarFormParams;
311
- }
332
+ let requestOptions = localVarRequestOptions;
333
+ let url = localVarUrl;
334
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
335
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
336
+ url = auth_ApiKeyAuthentication.url;
337
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
338
+ requestOptions = auth_JWTAuthentication.requestOptions;
339
+ url = auth_JWTAuthentication.url;
340
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
341
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
342
+ url = auth_JWTHttpHeaderAuthentication.url;
343
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
344
+ requestOptions = auth_OAuth2.requestOptions;
345
+ url = auth_OAuth2.url;
346
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
347
+ requestOptions = authDefault.requestOptions;
348
+ url = authDefault.url;
349
+ if (localVarFormParams) {
350
+ delete requestOptions.headers['Content-Type'];
351
+ if (localVarFormParams instanceof FormData) {
352
+ // FormData: fetch will handle Content-Type automatically.
353
+ requestOptions.body = localVarFormParams;
354
+ }
355
+ else if (Object.keys(localVarFormParams).length > 0) {
356
+ // URL-encoded form
357
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
358
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
312
359
  }
313
- return new Promise((resolve, reject) => {
314
- localVarRequest(localVarRequestOptions, (error, response, body) => {
315
- if (error) {
316
- reject(error);
317
- }
318
- else {
319
- body = models_1.ObjectSerializer.deserialize(body, "GetJobResponse");
320
- if (typeof body.success === 'boolean' && !body.success) {
321
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
322
- reject(new Error(body.error || errString));
323
- }
324
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
325
- resolve(body);
326
- }
327
- else {
328
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
329
- reject(errString);
330
- }
331
- }
332
- });
333
- });
334
- });
360
+ }
361
+ const response = await fetch(url, requestOptions);
362
+ return this.handleResponse(response, 'GetJobResponse');
335
363
  }
336
364
  /**
337
365
  * Get the logs for a job.
@@ -346,9 +374,11 @@ class OrganizationJobsApi {
346
374
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
347
375
  .replace('{' + 'jobId' + '}', encodeURIComponent(String(jobId)));
348
376
  let localVarQueryParameters = {};
349
- let localVarHeaderParams = Object.assign({
350
- 'User-Agent': 'edgeimpulse-api nodejs'
351
- }, this.defaultHeaders);
377
+ let localVarHeaderParams = {
378
+ 'User-Agent': 'edgeimpulse-api nodejs',
379
+ 'Content-Type': 'application/json',
380
+ ...this.defaultHeaders,
381
+ };
352
382
  const produces = ['application/json'];
353
383
  // give precedence to 'application/json'
354
384
  if (produces.indexOf('application/json') >= 0) {
@@ -357,7 +387,7 @@ class OrganizationJobsApi {
357
387
  else {
358
388
  localVarHeaderParams.Accept = produces.join(',');
359
389
  }
360
- let localVarFormParams = {};
390
+ let localVarFormParams;
361
391
  // verify required parameter 'organizationId' is not null or undefined
362
392
  if (organizationId === null || organizationId === undefined) {
363
393
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationJobsLogs.');
@@ -372,55 +402,51 @@ class OrganizationJobsApi {
372
402
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.logLevel) !== undefined) {
373
403
  localVarQueryParameters['logLevel'] = models_1.ObjectSerializer.serialize(queryParams.logLevel, "'error' | 'warn' | 'info' | 'debug'");
374
404
  }
375
- Object.assign(localVarHeaderParams, options.headers);
376
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
377
- let localVarUseFormData = false;
405
+ localVarHeaderParams = {
406
+ ...localVarHeaderParams,
407
+ ...options.headers,
408
+ ...this.opts.extraHeaders,
409
+ };
410
+ const queryString = Object.entries(localVarQueryParameters)
411
+ .filter(([, value]) => value !== undefined)
412
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
413
+ .join('&');
414
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
378
415
  let localVarRequestOptions = {
379
416
  method: 'GET',
380
- qs: localVarQueryParameters,
381
- headers: localVarHeaderParams,
382
- uri: localVarPath,
383
- useQuerystring: this._useQuerystring,
384
- agentOptions: { keepAlive: false },
385
- json: true,
417
+ headers: { ...localVarHeaderParams },
386
418
  };
387
- let authenticationPromise = Promise.resolve();
388
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
389
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
390
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
391
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
392
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
393
- return authenticationPromise.then(() => {
394
- if (Object.keys(localVarFormParams).length) {
395
- if (localVarUseFormData) {
396
- localVarRequestOptions.formData = localVarFormParams;
397
- }
398
- else {
399
- localVarRequestOptions.form = localVarFormParams;
400
- }
419
+ let requestOptions = localVarRequestOptions;
420
+ let url = localVarUrl;
421
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
422
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
423
+ url = auth_ApiKeyAuthentication.url;
424
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
425
+ requestOptions = auth_JWTAuthentication.requestOptions;
426
+ url = auth_JWTAuthentication.url;
427
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
428
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
429
+ url = auth_JWTHttpHeaderAuthentication.url;
430
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
431
+ requestOptions = auth_OAuth2.requestOptions;
432
+ url = auth_OAuth2.url;
433
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
434
+ requestOptions = authDefault.requestOptions;
435
+ url = authDefault.url;
436
+ if (localVarFormParams) {
437
+ delete requestOptions.headers['Content-Type'];
438
+ if (localVarFormParams instanceof FormData) {
439
+ // FormData: fetch will handle Content-Type automatically.
440
+ requestOptions.body = localVarFormParams;
401
441
  }
402
- return new Promise((resolve, reject) => {
403
- localVarRequest(localVarRequestOptions, (error, response, body) => {
404
- if (error) {
405
- reject(error);
406
- }
407
- else {
408
- body = models_1.ObjectSerializer.deserialize(body, "LogStdoutResponse");
409
- if (typeof body.success === 'boolean' && !body.success) {
410
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
411
- reject(new Error(body.error || errString));
412
- }
413
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
414
- resolve(body);
415
- }
416
- else {
417
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
418
- reject(errString);
419
- }
420
- }
421
- });
422
- });
423
- });
442
+ else if (Object.keys(localVarFormParams).length > 0) {
443
+ // URL-encoded form
444
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
445
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
446
+ }
447
+ }
448
+ const response = await fetch(url, requestOptions);
449
+ return this.handleResponse(response, 'LogStdoutResponse');
424
450
  }
425
451
  /**
426
452
  * Get a token to authenticate with the web socket interface.
@@ -431,9 +457,11 @@ class OrganizationJobsApi {
431
457
  const localVarPath = this.basePath + '/api/organizations/{organizationId}/socket-token'
432
458
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)));
433
459
  let localVarQueryParameters = {};
434
- let localVarHeaderParams = Object.assign({
435
- 'User-Agent': 'edgeimpulse-api nodejs'
436
- }, this.defaultHeaders);
460
+ let localVarHeaderParams = {
461
+ 'User-Agent': 'edgeimpulse-api nodejs',
462
+ 'Content-Type': 'application/json',
463
+ ...this.defaultHeaders,
464
+ };
437
465
  const produces = ['application/json'];
438
466
  // give precedence to 'application/json'
439
467
  if (produces.indexOf('application/json') >= 0) {
@@ -442,60 +470,56 @@ class OrganizationJobsApi {
442
470
  else {
443
471
  localVarHeaderParams.Accept = produces.join(',');
444
472
  }
445
- let localVarFormParams = {};
473
+ let localVarFormParams;
446
474
  // verify required parameter 'organizationId' is not null or undefined
447
475
  if (organizationId === null || organizationId === undefined) {
448
476
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationSocketToken.');
449
477
  }
450
- Object.assign(localVarHeaderParams, options.headers);
451
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
452
- let localVarUseFormData = false;
478
+ localVarHeaderParams = {
479
+ ...localVarHeaderParams,
480
+ ...options.headers,
481
+ ...this.opts.extraHeaders,
482
+ };
483
+ const queryString = Object.entries(localVarQueryParameters)
484
+ .filter(([, value]) => value !== undefined)
485
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
486
+ .join('&');
487
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
453
488
  let localVarRequestOptions = {
454
489
  method: 'GET',
455
- qs: localVarQueryParameters,
456
- headers: localVarHeaderParams,
457
- uri: localVarPath,
458
- useQuerystring: this._useQuerystring,
459
- agentOptions: { keepAlive: false },
460
- json: true,
490
+ headers: { ...localVarHeaderParams },
461
491
  };
462
- let authenticationPromise = Promise.resolve();
463
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
464
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
465
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
466
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
467
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
468
- return authenticationPromise.then(() => {
469
- if (Object.keys(localVarFormParams).length) {
470
- if (localVarUseFormData) {
471
- localVarRequestOptions.formData = localVarFormParams;
472
- }
473
- else {
474
- localVarRequestOptions.form = localVarFormParams;
475
- }
492
+ let requestOptions = localVarRequestOptions;
493
+ let url = localVarUrl;
494
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
495
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
496
+ url = auth_ApiKeyAuthentication.url;
497
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
498
+ requestOptions = auth_JWTAuthentication.requestOptions;
499
+ url = auth_JWTAuthentication.url;
500
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
501
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
502
+ url = auth_JWTHttpHeaderAuthentication.url;
503
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
504
+ requestOptions = auth_OAuth2.requestOptions;
505
+ url = auth_OAuth2.url;
506
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
507
+ requestOptions = authDefault.requestOptions;
508
+ url = authDefault.url;
509
+ if (localVarFormParams) {
510
+ delete requestOptions.headers['Content-Type'];
511
+ if (localVarFormParams instanceof FormData) {
512
+ // FormData: fetch will handle Content-Type automatically.
513
+ requestOptions.body = localVarFormParams;
514
+ }
515
+ else if (Object.keys(localVarFormParams).length > 0) {
516
+ // URL-encoded form
517
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
518
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
476
519
  }
477
- return new Promise((resolve, reject) => {
478
- localVarRequest(localVarRequestOptions, (error, response, body) => {
479
- if (error) {
480
- reject(error);
481
- }
482
- else {
483
- body = models_1.ObjectSerializer.deserialize(body, "SocketTokenResponse");
484
- if (typeof body.success === 'boolean' && !body.success) {
485
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
486
- reject(new Error(body.error || errString));
487
- }
488
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
489
- resolve(body);
490
- }
491
- else {
492
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
493
- reject(errString);
494
- }
495
- }
496
- });
497
- });
498
- });
520
+ }
521
+ const response = await fetch(url, requestOptions);
522
+ return this.handleResponse(response, 'SocketTokenResponse');
499
523
  }
500
524
  /**
501
525
  * Get all active jobs for this organization
@@ -507,9 +531,11 @@ class OrganizationJobsApi {
507
531
  const localVarPath = this.basePath + '/api/organizations/{organizationId}/jobs'
508
532
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)));
509
533
  let localVarQueryParameters = {};
510
- let localVarHeaderParams = Object.assign({
511
- 'User-Agent': 'edgeimpulse-api nodejs'
512
- }, this.defaultHeaders);
534
+ let localVarHeaderParams = {
535
+ 'User-Agent': 'edgeimpulse-api nodejs',
536
+ 'Content-Type': 'application/json',
537
+ ...this.defaultHeaders,
538
+ };
513
539
  const produces = ['application/json'];
514
540
  // give precedence to 'application/json'
515
541
  if (produces.indexOf('application/json') >= 0) {
@@ -518,7 +544,7 @@ class OrganizationJobsApi {
518
544
  else {
519
545
  localVarHeaderParams.Accept = produces.join(',');
520
546
  }
521
- let localVarFormParams = {};
547
+ let localVarFormParams;
522
548
  // verify required parameter 'organizationId' is not null or undefined
523
549
  if (organizationId === null || organizationId === undefined) {
524
550
  throw new Error('Required parameter organizationId was null or undefined when calling listActiveOrganizationJobs.');
@@ -526,55 +552,51 @@ class OrganizationJobsApi {
526
552
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.rootOnly) !== undefined) {
527
553
  localVarQueryParameters['rootOnly'] = models_1.ObjectSerializer.serialize(queryParams.rootOnly, "boolean");
528
554
  }
529
- Object.assign(localVarHeaderParams, options.headers);
530
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
531
- let localVarUseFormData = false;
555
+ localVarHeaderParams = {
556
+ ...localVarHeaderParams,
557
+ ...options.headers,
558
+ ...this.opts.extraHeaders,
559
+ };
560
+ const queryString = Object.entries(localVarQueryParameters)
561
+ .filter(([, value]) => value !== undefined)
562
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
563
+ .join('&');
564
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
532
565
  let localVarRequestOptions = {
533
566
  method: 'GET',
534
- qs: localVarQueryParameters,
535
- headers: localVarHeaderParams,
536
- uri: localVarPath,
537
- useQuerystring: this._useQuerystring,
538
- agentOptions: { keepAlive: false },
539
- json: true,
567
+ headers: { ...localVarHeaderParams },
540
568
  };
541
- let authenticationPromise = Promise.resolve();
542
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
543
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
544
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
545
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
546
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
547
- return authenticationPromise.then(() => {
548
- if (Object.keys(localVarFormParams).length) {
549
- if (localVarUseFormData) {
550
- localVarRequestOptions.formData = localVarFormParams;
551
- }
552
- else {
553
- localVarRequestOptions.form = localVarFormParams;
554
- }
569
+ let requestOptions = localVarRequestOptions;
570
+ let url = localVarUrl;
571
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
572
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
573
+ url = auth_ApiKeyAuthentication.url;
574
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
575
+ requestOptions = auth_JWTAuthentication.requestOptions;
576
+ url = auth_JWTAuthentication.url;
577
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
578
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
579
+ url = auth_JWTHttpHeaderAuthentication.url;
580
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
581
+ requestOptions = auth_OAuth2.requestOptions;
582
+ url = auth_OAuth2.url;
583
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
584
+ requestOptions = authDefault.requestOptions;
585
+ url = authDefault.url;
586
+ if (localVarFormParams) {
587
+ delete requestOptions.headers['Content-Type'];
588
+ if (localVarFormParams instanceof FormData) {
589
+ // FormData: fetch will handle Content-Type automatically.
590
+ requestOptions.body = localVarFormParams;
555
591
  }
556
- return new Promise((resolve, reject) => {
557
- localVarRequest(localVarRequestOptions, (error, response, body) => {
558
- if (error) {
559
- reject(error);
560
- }
561
- else {
562
- body = models_1.ObjectSerializer.deserialize(body, "ListJobsResponse");
563
- if (typeof body.success === 'boolean' && !body.success) {
564
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
565
- reject(new Error(body.error || errString));
566
- }
567
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
568
- resolve(body);
569
- }
570
- else {
571
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
572
- reject(errString);
573
- }
574
- }
575
- });
576
- });
577
- });
592
+ else if (Object.keys(localVarFormParams).length > 0) {
593
+ // URL-encoded form
594
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
595
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
596
+ }
597
+ }
598
+ const response = await fetch(url, requestOptions);
599
+ return this.handleResponse(response, 'ListJobsResponse');
578
600
  }
579
601
  /**
580
602
  * Get all jobs for this organization
@@ -594,9 +616,11 @@ class OrganizationJobsApi {
594
616
  const localVarPath = this.basePath + '/api/organizations/{organizationId}/jobs/all'
595
617
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)));
596
618
  let localVarQueryParameters = {};
597
- let localVarHeaderParams = Object.assign({
598
- 'User-Agent': 'edgeimpulse-api nodejs'
599
- }, this.defaultHeaders);
619
+ let localVarHeaderParams = {
620
+ 'User-Agent': 'edgeimpulse-api nodejs',
621
+ 'Content-Type': 'application/json',
622
+ ...this.defaultHeaders,
623
+ };
600
624
  const produces = ['application/json'];
601
625
  // give precedence to 'application/json'
602
626
  if (produces.indexOf('application/json') >= 0) {
@@ -605,7 +629,7 @@ class OrganizationJobsApi {
605
629
  else {
606
630
  localVarHeaderParams.Accept = produces.join(',');
607
631
  }
608
- let localVarFormParams = {};
632
+ let localVarFormParams;
609
633
  // verify required parameter 'organizationId' is not null or undefined
610
634
  if (organizationId === null || organizationId === undefined) {
611
635
  throw new Error('Required parameter organizationId was null or undefined when calling listAllOrganizationJobs.');
@@ -637,55 +661,51 @@ class OrganizationJobsApi {
637
661
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.finished) !== undefined) {
638
662
  localVarQueryParameters['finished'] = models_1.ObjectSerializer.serialize(queryParams.finished, "'successful' | 'failed' | 'all'");
639
663
  }
640
- Object.assign(localVarHeaderParams, options.headers);
641
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
642
- let localVarUseFormData = false;
664
+ localVarHeaderParams = {
665
+ ...localVarHeaderParams,
666
+ ...options.headers,
667
+ ...this.opts.extraHeaders,
668
+ };
669
+ const queryString = Object.entries(localVarQueryParameters)
670
+ .filter(([, value]) => value !== undefined)
671
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
672
+ .join('&');
673
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
643
674
  let localVarRequestOptions = {
644
675
  method: 'GET',
645
- qs: localVarQueryParameters,
646
- headers: localVarHeaderParams,
647
- uri: localVarPath,
648
- useQuerystring: this._useQuerystring,
649
- agentOptions: { keepAlive: false },
650
- json: true,
676
+ headers: { ...localVarHeaderParams },
651
677
  };
652
- let authenticationPromise = Promise.resolve();
653
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
654
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
655
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
656
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
657
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
658
- return authenticationPromise.then(() => {
659
- if (Object.keys(localVarFormParams).length) {
660
- if (localVarUseFormData) {
661
- localVarRequestOptions.formData = localVarFormParams;
662
- }
663
- else {
664
- localVarRequestOptions.form = localVarFormParams;
665
- }
678
+ let requestOptions = localVarRequestOptions;
679
+ let url = localVarUrl;
680
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
681
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
682
+ url = auth_ApiKeyAuthentication.url;
683
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
684
+ requestOptions = auth_JWTAuthentication.requestOptions;
685
+ url = auth_JWTAuthentication.url;
686
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
687
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
688
+ url = auth_JWTHttpHeaderAuthentication.url;
689
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
690
+ requestOptions = auth_OAuth2.requestOptions;
691
+ url = auth_OAuth2.url;
692
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
693
+ requestOptions = authDefault.requestOptions;
694
+ url = authDefault.url;
695
+ if (localVarFormParams) {
696
+ delete requestOptions.headers['Content-Type'];
697
+ if (localVarFormParams instanceof FormData) {
698
+ // FormData: fetch will handle Content-Type automatically.
699
+ requestOptions.body = localVarFormParams;
700
+ }
701
+ else if (Object.keys(localVarFormParams).length > 0) {
702
+ // URL-encoded form
703
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
704
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
666
705
  }
667
- return new Promise((resolve, reject) => {
668
- localVarRequest(localVarRequestOptions, (error, response, body) => {
669
- if (error) {
670
- reject(error);
671
- }
672
- else {
673
- body = models_1.ObjectSerializer.deserialize(body, "ListJobsResponse");
674
- if (typeof body.success === 'boolean' && !body.success) {
675
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
676
- reject(new Error(body.error || errString));
677
- }
678
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
679
- resolve(body);
680
- }
681
- else {
682
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
683
- reject(errString);
684
- }
685
- }
686
- });
687
- });
688
- });
706
+ }
707
+ const response = await fetch(url, requestOptions);
708
+ return this.handleResponse(response, 'ListJobsResponse');
689
709
  }
690
710
  /**
691
711
  * Get all finished jobs for this organization
@@ -701,9 +721,11 @@ class OrganizationJobsApi {
701
721
  const localVarPath = this.basePath + '/api/organizations/{organizationId}/jobs/history'
702
722
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)));
703
723
  let localVarQueryParameters = {};
704
- let localVarHeaderParams = Object.assign({
705
- 'User-Agent': 'edgeimpulse-api nodejs'
706
- }, this.defaultHeaders);
724
+ let localVarHeaderParams = {
725
+ 'User-Agent': 'edgeimpulse-api nodejs',
726
+ 'Content-Type': 'application/json',
727
+ ...this.defaultHeaders,
728
+ };
707
729
  const produces = ['application/json'];
708
730
  // give precedence to 'application/json'
709
731
  if (produces.indexOf('application/json') >= 0) {
@@ -712,7 +734,7 @@ class OrganizationJobsApi {
712
734
  else {
713
735
  localVarHeaderParams.Accept = produces.join(',');
714
736
  }
715
- let localVarFormParams = {};
737
+ let localVarFormParams;
716
738
  // verify required parameter 'organizationId' is not null or undefined
717
739
  if (organizationId === null || organizationId === undefined) {
718
740
  throw new Error('Required parameter organizationId was null or undefined when calling listFinishedOrganizationJobs.');
@@ -732,55 +754,51 @@ class OrganizationJobsApi {
732
754
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.rootOnly) !== undefined) {
733
755
  localVarQueryParameters['rootOnly'] = models_1.ObjectSerializer.serialize(queryParams.rootOnly, "boolean");
734
756
  }
735
- Object.assign(localVarHeaderParams, options.headers);
736
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
737
- let localVarUseFormData = false;
757
+ localVarHeaderParams = {
758
+ ...localVarHeaderParams,
759
+ ...options.headers,
760
+ ...this.opts.extraHeaders,
761
+ };
762
+ const queryString = Object.entries(localVarQueryParameters)
763
+ .filter(([, value]) => value !== undefined)
764
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
765
+ .join('&');
766
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
738
767
  let localVarRequestOptions = {
739
768
  method: 'GET',
740
- qs: localVarQueryParameters,
741
- headers: localVarHeaderParams,
742
- uri: localVarPath,
743
- useQuerystring: this._useQuerystring,
744
- agentOptions: { keepAlive: false },
745
- json: true,
769
+ headers: { ...localVarHeaderParams },
746
770
  };
747
- let authenticationPromise = Promise.resolve();
748
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
749
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
750
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
751
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
752
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
753
- return authenticationPromise.then(() => {
754
- if (Object.keys(localVarFormParams).length) {
755
- if (localVarUseFormData) {
756
- localVarRequestOptions.formData = localVarFormParams;
757
- }
758
- else {
759
- localVarRequestOptions.form = localVarFormParams;
760
- }
771
+ let requestOptions = localVarRequestOptions;
772
+ let url = localVarUrl;
773
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
774
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
775
+ url = auth_ApiKeyAuthentication.url;
776
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
777
+ requestOptions = auth_JWTAuthentication.requestOptions;
778
+ url = auth_JWTAuthentication.url;
779
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
780
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
781
+ url = auth_JWTHttpHeaderAuthentication.url;
782
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
783
+ requestOptions = auth_OAuth2.requestOptions;
784
+ url = auth_OAuth2.url;
785
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
786
+ requestOptions = authDefault.requestOptions;
787
+ url = authDefault.url;
788
+ if (localVarFormParams) {
789
+ delete requestOptions.headers['Content-Type'];
790
+ if (localVarFormParams instanceof FormData) {
791
+ // FormData: fetch will handle Content-Type automatically.
792
+ requestOptions.body = localVarFormParams;
761
793
  }
762
- return new Promise((resolve, reject) => {
763
- localVarRequest(localVarRequestOptions, (error, response, body) => {
764
- if (error) {
765
- reject(error);
766
- }
767
- else {
768
- body = models_1.ObjectSerializer.deserialize(body, "ListJobsResponse");
769
- if (typeof body.success === 'boolean' && !body.success) {
770
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
771
- reject(new Error(body.error || errString));
772
- }
773
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
774
- resolve(body);
775
- }
776
- else {
777
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
778
- reject(errString);
779
- }
780
- }
781
- });
782
- });
783
- });
794
+ else if (Object.keys(localVarFormParams).length > 0) {
795
+ // URL-encoded form
796
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
797
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
798
+ }
799
+ }
800
+ const response = await fetch(url, requestOptions);
801
+ return this.handleResponse(response, 'ListJobsResponse');
784
802
  }
785
803
  }
786
804
  exports.OrganizationJobsApi = OrganizationJobsApi;