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.ThirdPartyAuthApi = exports.ThirdPartyAuthApiApiKeys = 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 ThirdPartyAuthApiApiKeys;
30
47
  ThirdPartyAuthApiApiKeys[ThirdPartyAuthApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(ThirdPartyAuthApiApiKeys = exports.ThirdPartyAuthApiApiKeys || (exports.ThirdPartyAuthApiApiKeys = {}));
32
49
  class ThirdPartyAuthApi {
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 ThirdPartyAuthApi {
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,10 +124,12 @@ class ThirdPartyAuthApi {
90
124
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
91
125
  .replace('{' + 'authId' + '}', encodeURIComponent(String(authId)));
92
126
  let localVarQueryParameters = {};
93
- let localVarHeaderParams = Object.assign({
94
- 'User-Agent': 'edgeimpulse-api nodejs'
95
- }, this.defaultHeaders);
96
- let localVarFormParams = {};
127
+ let localVarHeaderParams = {
128
+ 'User-Agent': 'edgeimpulse-api nodejs',
129
+ 'Content-Type': 'application/json',
130
+ ...this.defaultHeaders,
131
+ };
132
+ let localVarFormParams;
97
133
  // verify required parameter 'projectId' is not null or undefined
98
134
  if (projectId === null || projectId === undefined) {
99
135
  throw new Error('Required parameter projectId was null or undefined when calling authorizeThirdParty.');
@@ -106,57 +142,67 @@ class ThirdPartyAuthApi {
106
142
  if (params.nextUrl === null || params.nextUrl === undefined) {
107
143
  throw new Error('Required parameter params.nextUrl was null or undefined when calling authorizeThirdParty.');
108
144
  }
109
- Object.assign(localVarHeaderParams, options.headers);
110
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
111
- let localVarUseFormData = false;
145
+ localVarHeaderParams = {
146
+ ...localVarHeaderParams,
147
+ ...options.headers,
148
+ ...this.opts.extraHeaders,
149
+ };
112
150
  if (params.nextUrl !== undefined) {
113
- localVarFormParams['nextUrl'] = models_1.ObjectSerializer.serializeFormData(params.nextUrl, "string");
151
+ const isParametersField = "nextUrl" === "parameters";
152
+ const serializableParams = isParametersField && params && ("parameters" in params);
153
+ const nextUrlSerialized = serializableParams
154
+ ? JSON.stringify(params.parameters)
155
+ : models_1.ObjectSerializer.serializeFormData(params.nextUrl, "string");
156
+ if (localVarFormParams instanceof FormData) {
157
+ localVarFormParams.append('nextUrl', nextUrlSerialized);
158
+ }
159
+ else {
160
+ if (!localVarFormParams) {
161
+ localVarFormParams = {};
162
+ }
163
+ localVarFormParams['nextUrl'] = nextUrlSerialized;
164
+ }
114
165
  }
166
+ const queryString = Object.entries(localVarQueryParameters)
167
+ .filter(([, value]) => value !== undefined)
168
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
169
+ .join('&');
170
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
115
171
  let localVarRequestOptions = {
116
172
  method: 'POST',
117
- qs: localVarQueryParameters,
118
- headers: localVarHeaderParams,
119
- uri: localVarPath,
120
- useQuerystring: this._useQuerystring,
121
- agentOptions: { keepAlive: false },
122
- json: true,
173
+ headers: { ...localVarHeaderParams },
123
174
  };
124
- let authenticationPromise = Promise.resolve();
125
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
126
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
127
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
128
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
129
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
130
- return authenticationPromise.then(() => {
131
- if (Object.keys(localVarFormParams).length) {
132
- if (localVarUseFormData) {
133
- localVarRequestOptions.formData = localVarFormParams;
134
- }
135
- else {
136
- localVarRequestOptions.form = localVarFormParams;
137
- }
175
+ let requestOptions = localVarRequestOptions;
176
+ let url = localVarUrl;
177
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
178
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
179
+ url = auth_ApiKeyAuthentication.url;
180
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
181
+ requestOptions = auth_JWTAuthentication.requestOptions;
182
+ url = auth_JWTAuthentication.url;
183
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
184
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
185
+ url = auth_JWTHttpHeaderAuthentication.url;
186
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
187
+ requestOptions = auth_OAuth2.requestOptions;
188
+ url = auth_OAuth2.url;
189
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
190
+ requestOptions = authDefault.requestOptions;
191
+ url = authDefault.url;
192
+ if (localVarFormParams) {
193
+ delete requestOptions.headers['Content-Type'];
194
+ if (localVarFormParams instanceof FormData) {
195
+ // FormData: fetch will handle Content-Type automatically.
196
+ requestOptions.body = localVarFormParams;
138
197
  }
139
- return new Promise((resolve, reject) => {
140
- localVarRequest(localVarRequestOptions, (error, response, body) => {
141
- if (error) {
142
- reject(error);
143
- }
144
- else {
145
- if (typeof body.success === 'boolean' && !body.success) {
146
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
147
- reject(new Error(body.error || errString));
148
- }
149
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
150
- resolve(body);
151
- }
152
- else {
153
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
154
- reject(errString);
155
- }
156
- }
157
- });
158
- });
159
- });
198
+ else if (Object.keys(localVarFormParams).length > 0) {
199
+ // URL-encoded form
200
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
201
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
202
+ }
203
+ }
204
+ const response = await fetch(url, requestOptions);
205
+ return this.handleResponse(response, undefined);
160
206
  }
161
207
  /**
162
208
  * Create a new third party authentication partner
@@ -166,9 +212,11 @@ class ThirdPartyAuthApi {
166
212
  async createThirdPartyAuth(createThirdPartyAuthRequest, options = { headers: {} }) {
167
213
  const localVarPath = this.basePath + '/api/third-party-auth';
168
214
  let localVarQueryParameters = {};
169
- let localVarHeaderParams = Object.assign({
170
- 'User-Agent': 'edgeimpulse-api nodejs'
171
- }, this.defaultHeaders);
215
+ let localVarHeaderParams = {
216
+ 'User-Agent': 'edgeimpulse-api nodejs',
217
+ 'Content-Type': 'application/json',
218
+ ...this.defaultHeaders,
219
+ };
172
220
  const produces = ['application/json'];
173
221
  // give precedence to 'application/json'
174
222
  if (produces.indexOf('application/json') >= 0) {
@@ -177,61 +225,57 @@ class ThirdPartyAuthApi {
177
225
  else {
178
226
  localVarHeaderParams.Accept = produces.join(',');
179
227
  }
180
- let localVarFormParams = {};
228
+ let localVarFormParams;
181
229
  // verify required parameter 'createThirdPartyAuthRequest' is not null or undefined
182
230
  if (createThirdPartyAuthRequest === null || createThirdPartyAuthRequest === undefined) {
183
231
  throw new Error('Required parameter createThirdPartyAuthRequest was null or undefined when calling createThirdPartyAuth.');
184
232
  }
185
- Object.assign(localVarHeaderParams, options.headers);
186
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
187
- let localVarUseFormData = false;
233
+ localVarHeaderParams = {
234
+ ...localVarHeaderParams,
235
+ ...options.headers,
236
+ ...this.opts.extraHeaders,
237
+ };
238
+ const queryString = Object.entries(localVarQueryParameters)
239
+ .filter(([, value]) => value !== undefined)
240
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
241
+ .join('&');
242
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
188
243
  let localVarRequestOptions = {
189
244
  method: 'POST',
190
- qs: localVarQueryParameters,
191
- headers: localVarHeaderParams,
192
- uri: localVarPath,
193
- useQuerystring: this._useQuerystring,
194
- agentOptions: { keepAlive: false },
195
- json: true,
196
- body: models_1.ObjectSerializer.serialize(createThirdPartyAuthRequest, "CreateThirdPartyAuthRequest")
245
+ headers: { ...localVarHeaderParams },
197
246
  };
198
- let authenticationPromise = Promise.resolve();
199
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
200
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
201
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
202
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
203
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
204
- return authenticationPromise.then(() => {
205
- if (Object.keys(localVarFormParams).length) {
206
- if (localVarUseFormData) {
207
- localVarRequestOptions.formData = localVarFormParams;
208
- }
209
- else {
210
- localVarRequestOptions.form = localVarFormParams;
211
- }
247
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(createThirdPartyAuthRequest, "CreateThirdPartyAuthRequest"));
248
+ let requestOptions = localVarRequestOptions;
249
+ let url = localVarUrl;
250
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
251
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
252
+ url = auth_ApiKeyAuthentication.url;
253
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
254
+ requestOptions = auth_JWTAuthentication.requestOptions;
255
+ url = auth_JWTAuthentication.url;
256
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
257
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
258
+ url = auth_JWTHttpHeaderAuthentication.url;
259
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
260
+ requestOptions = auth_OAuth2.requestOptions;
261
+ url = auth_OAuth2.url;
262
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
263
+ requestOptions = authDefault.requestOptions;
264
+ url = authDefault.url;
265
+ if (localVarFormParams) {
266
+ delete requestOptions.headers['Content-Type'];
267
+ if (localVarFormParams instanceof FormData) {
268
+ // FormData: fetch will handle Content-Type automatically.
269
+ requestOptions.body = localVarFormParams;
270
+ }
271
+ else if (Object.keys(localVarFormParams).length > 0) {
272
+ // URL-encoded form
273
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
274
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
212
275
  }
213
- return new Promise((resolve, reject) => {
214
- localVarRequest(localVarRequestOptions, (error, response, body) => {
215
- if (error) {
216
- reject(error);
217
- }
218
- else {
219
- body = models_1.ObjectSerializer.deserialize(body, "CreateThirdPartyAuthResponse");
220
- if (typeof body.success === 'boolean' && !body.success) {
221
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
222
- reject(new Error(body.error || errString));
223
- }
224
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
225
- resolve(body);
226
- }
227
- else {
228
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
229
- reject(errString);
230
- }
231
- }
232
- });
233
- });
234
- });
276
+ }
277
+ const response = await fetch(url, requestOptions);
278
+ return this.handleResponse(response, 'CreateThirdPartyAuthResponse');
235
279
  }
236
280
  /**
237
281
  * Login as a user as a third-party authentication provider. If the user does not exists, it\'s automatically created. You can only log in as users that were previously created by you.
@@ -243,9 +287,11 @@ class ThirdPartyAuthApi {
243
287
  const localVarPath = this.basePath + '/api/third-party-auth/{authId}/login'
244
288
  .replace('{' + 'authId' + '}', encodeURIComponent(String(authId)));
245
289
  let localVarQueryParameters = {};
246
- let localVarHeaderParams = Object.assign({
247
- 'User-Agent': 'edgeimpulse-api nodejs'
248
- }, this.defaultHeaders);
290
+ let localVarHeaderParams = {
291
+ 'User-Agent': 'edgeimpulse-api nodejs',
292
+ 'Content-Type': 'application/json',
293
+ ...this.defaultHeaders,
294
+ };
249
295
  const produces = ['application/json'];
250
296
  // give precedence to 'application/json'
251
297
  if (produces.indexOf('application/json') >= 0) {
@@ -254,7 +300,7 @@ class ThirdPartyAuthApi {
254
300
  else {
255
301
  localVarHeaderParams.Accept = produces.join(',');
256
302
  }
257
- let localVarFormParams = {};
303
+ let localVarFormParams;
258
304
  // verify required parameter 'authId' is not null or undefined
259
305
  if (authId === null || authId === undefined) {
260
306
  throw new Error('Required parameter authId was null or undefined when calling createUserThirdParty.');
@@ -263,56 +309,52 @@ class ThirdPartyAuthApi {
263
309
  if (createUserThirdPartyRequest === null || createUserThirdPartyRequest === undefined) {
264
310
  throw new Error('Required parameter createUserThirdPartyRequest was null or undefined when calling createUserThirdParty.');
265
311
  }
266
- Object.assign(localVarHeaderParams, options.headers);
267
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
268
- let localVarUseFormData = false;
312
+ localVarHeaderParams = {
313
+ ...localVarHeaderParams,
314
+ ...options.headers,
315
+ ...this.opts.extraHeaders,
316
+ };
317
+ const queryString = Object.entries(localVarQueryParameters)
318
+ .filter(([, value]) => value !== undefined)
319
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
320
+ .join('&');
321
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
269
322
  let localVarRequestOptions = {
270
323
  method: 'POST',
271
- qs: localVarQueryParameters,
272
- headers: localVarHeaderParams,
273
- uri: localVarPath,
274
- useQuerystring: this._useQuerystring,
275
- agentOptions: { keepAlive: false },
276
- json: true,
277
- body: models_1.ObjectSerializer.serialize(createUserThirdPartyRequest, "CreateUserThirdPartyRequest")
324
+ headers: { ...localVarHeaderParams },
278
325
  };
279
- let authenticationPromise = Promise.resolve();
280
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
281
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
282
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
283
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
284
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
285
- return authenticationPromise.then(() => {
286
- if (Object.keys(localVarFormParams).length) {
287
- if (localVarUseFormData) {
288
- localVarRequestOptions.formData = localVarFormParams;
289
- }
290
- else {
291
- localVarRequestOptions.form = localVarFormParams;
292
- }
326
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(createUserThirdPartyRequest, "CreateUserThirdPartyRequest"));
327
+ let requestOptions = localVarRequestOptions;
328
+ let url = localVarUrl;
329
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
330
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
331
+ url = auth_ApiKeyAuthentication.url;
332
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
333
+ requestOptions = auth_JWTAuthentication.requestOptions;
334
+ url = auth_JWTAuthentication.url;
335
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
336
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
337
+ url = auth_JWTHttpHeaderAuthentication.url;
338
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
339
+ requestOptions = auth_OAuth2.requestOptions;
340
+ url = auth_OAuth2.url;
341
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
342
+ requestOptions = authDefault.requestOptions;
343
+ url = authDefault.url;
344
+ if (localVarFormParams) {
345
+ delete requestOptions.headers['Content-Type'];
346
+ if (localVarFormParams instanceof FormData) {
347
+ // FormData: fetch will handle Content-Type automatically.
348
+ requestOptions.body = localVarFormParams;
293
349
  }
294
- return new Promise((resolve, reject) => {
295
- localVarRequest(localVarRequestOptions, (error, response, body) => {
296
- if (error) {
297
- reject(error);
298
- }
299
- else {
300
- body = models_1.ObjectSerializer.deserialize(body, "CreateUserThirdPartyResponse");
301
- if (typeof body.success === 'boolean' && !body.success) {
302
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
303
- reject(new Error(body.error || errString));
304
- }
305
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
306
- resolve(body);
307
- }
308
- else {
309
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
310
- reject(errString);
311
- }
312
- }
313
- });
314
- });
315
- });
350
+ else if (Object.keys(localVarFormParams).length > 0) {
351
+ // URL-encoded form
352
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
353
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
354
+ }
355
+ }
356
+ const response = await fetch(url, requestOptions);
357
+ return this.handleResponse(response, 'CreateUserThirdPartyResponse');
316
358
  }
317
359
  /**
318
360
  * Delete a third party authentication partner
@@ -323,9 +365,11 @@ class ThirdPartyAuthApi {
323
365
  const localVarPath = this.basePath + '/api/third-party-auth/{authId}'
324
366
  .replace('{' + 'authId' + '}', encodeURIComponent(String(authId)));
325
367
  let localVarQueryParameters = {};
326
- let localVarHeaderParams = Object.assign({
327
- 'User-Agent': 'edgeimpulse-api nodejs'
328
- }, this.defaultHeaders);
368
+ let localVarHeaderParams = {
369
+ 'User-Agent': 'edgeimpulse-api nodejs',
370
+ 'Content-Type': 'application/json',
371
+ ...this.defaultHeaders,
372
+ };
329
373
  const produces = ['application/json'];
330
374
  // give precedence to 'application/json'
331
375
  if (produces.indexOf('application/json') >= 0) {
@@ -334,60 +378,56 @@ class ThirdPartyAuthApi {
334
378
  else {
335
379
  localVarHeaderParams.Accept = produces.join(',');
336
380
  }
337
- let localVarFormParams = {};
381
+ let localVarFormParams;
338
382
  // verify required parameter 'authId' is not null or undefined
339
383
  if (authId === null || authId === undefined) {
340
384
  throw new Error('Required parameter authId was null or undefined when calling deleteThirdPartyAuth.');
341
385
  }
342
- Object.assign(localVarHeaderParams, options.headers);
343
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
344
- let localVarUseFormData = false;
386
+ localVarHeaderParams = {
387
+ ...localVarHeaderParams,
388
+ ...options.headers,
389
+ ...this.opts.extraHeaders,
390
+ };
391
+ const queryString = Object.entries(localVarQueryParameters)
392
+ .filter(([, value]) => value !== undefined)
393
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
394
+ .join('&');
395
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
345
396
  let localVarRequestOptions = {
346
397
  method: 'DELETE',
347
- qs: localVarQueryParameters,
348
- headers: localVarHeaderParams,
349
- uri: localVarPath,
350
- useQuerystring: this._useQuerystring,
351
- agentOptions: { keepAlive: false },
352
- json: true,
398
+ headers: { ...localVarHeaderParams },
353
399
  };
354
- let authenticationPromise = Promise.resolve();
355
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
356
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
357
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
358
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
359
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
360
- return authenticationPromise.then(() => {
361
- if (Object.keys(localVarFormParams).length) {
362
- if (localVarUseFormData) {
363
- localVarRequestOptions.formData = localVarFormParams;
364
- }
365
- else {
366
- localVarRequestOptions.form = localVarFormParams;
367
- }
400
+ let requestOptions = localVarRequestOptions;
401
+ let url = localVarUrl;
402
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
403
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
404
+ url = auth_ApiKeyAuthentication.url;
405
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
406
+ requestOptions = auth_JWTAuthentication.requestOptions;
407
+ url = auth_JWTAuthentication.url;
408
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
409
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
410
+ url = auth_JWTHttpHeaderAuthentication.url;
411
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
412
+ requestOptions = auth_OAuth2.requestOptions;
413
+ url = auth_OAuth2.url;
414
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
415
+ requestOptions = authDefault.requestOptions;
416
+ url = authDefault.url;
417
+ if (localVarFormParams) {
418
+ delete requestOptions.headers['Content-Type'];
419
+ if (localVarFormParams instanceof FormData) {
420
+ // FormData: fetch will handle Content-Type automatically.
421
+ requestOptions.body = localVarFormParams;
422
+ }
423
+ else if (Object.keys(localVarFormParams).length > 0) {
424
+ // URL-encoded form
425
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
426
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
368
427
  }
369
- return new Promise((resolve, reject) => {
370
- localVarRequest(localVarRequestOptions, (error, response, body) => {
371
- if (error) {
372
- reject(error);
373
- }
374
- else {
375
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
376
- if (typeof body.success === 'boolean' && !body.success) {
377
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
378
- reject(new Error(body.error || errString));
379
- }
380
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
381
- resolve(body);
382
- }
383
- else {
384
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
385
- reject(errString);
386
- }
387
- }
388
- });
389
- });
390
- });
428
+ }
429
+ const response = await fetch(url, requestOptions);
430
+ return this.handleResponse(response, 'GenericApiResponse');
391
431
  }
392
432
  /**
393
433
  * Get information about all third party authentication partners
@@ -396,9 +436,11 @@ class ThirdPartyAuthApi {
396
436
  async getAllThirdPartyAuth(options = { headers: {} }) {
397
437
  const localVarPath = this.basePath + '/api/third-party-auth';
398
438
  let localVarQueryParameters = {};
399
- let localVarHeaderParams = Object.assign({
400
- 'User-Agent': 'edgeimpulse-api nodejs'
401
- }, this.defaultHeaders);
439
+ let localVarHeaderParams = {
440
+ 'User-Agent': 'edgeimpulse-api nodejs',
441
+ 'Content-Type': 'application/json',
442
+ ...this.defaultHeaders,
443
+ };
402
444
  const produces = ['application/json'];
403
445
  // give precedence to 'application/json'
404
446
  if (produces.indexOf('application/json') >= 0) {
@@ -407,56 +449,52 @@ class ThirdPartyAuthApi {
407
449
  else {
408
450
  localVarHeaderParams.Accept = produces.join(',');
409
451
  }
410
- let localVarFormParams = {};
411
- Object.assign(localVarHeaderParams, options.headers);
412
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
413
- let localVarUseFormData = false;
452
+ let localVarFormParams;
453
+ localVarHeaderParams = {
454
+ ...localVarHeaderParams,
455
+ ...options.headers,
456
+ ...this.opts.extraHeaders,
457
+ };
458
+ const queryString = Object.entries(localVarQueryParameters)
459
+ .filter(([, value]) => value !== undefined)
460
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
461
+ .join('&');
462
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
414
463
  let localVarRequestOptions = {
415
464
  method: 'GET',
416
- qs: localVarQueryParameters,
417
- headers: localVarHeaderParams,
418
- uri: localVarPath,
419
- useQuerystring: this._useQuerystring,
420
- agentOptions: { keepAlive: false },
421
- json: true,
465
+ headers: { ...localVarHeaderParams },
422
466
  };
423
- let authenticationPromise = Promise.resolve();
424
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
425
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
426
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
427
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
428
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
429
- return authenticationPromise.then(() => {
430
- if (Object.keys(localVarFormParams).length) {
431
- if (localVarUseFormData) {
432
- localVarRequestOptions.formData = localVarFormParams;
433
- }
434
- else {
435
- localVarRequestOptions.form = localVarFormParams;
436
- }
467
+ let requestOptions = localVarRequestOptions;
468
+ let url = localVarUrl;
469
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
470
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
471
+ url = auth_ApiKeyAuthentication.url;
472
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
473
+ requestOptions = auth_JWTAuthentication.requestOptions;
474
+ url = auth_JWTAuthentication.url;
475
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
476
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
477
+ url = auth_JWTHttpHeaderAuthentication.url;
478
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
479
+ requestOptions = auth_OAuth2.requestOptions;
480
+ url = auth_OAuth2.url;
481
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
482
+ requestOptions = authDefault.requestOptions;
483
+ url = authDefault.url;
484
+ if (localVarFormParams) {
485
+ delete requestOptions.headers['Content-Type'];
486
+ if (localVarFormParams instanceof FormData) {
487
+ // FormData: fetch will handle Content-Type automatically.
488
+ requestOptions.body = localVarFormParams;
437
489
  }
438
- return new Promise((resolve, reject) => {
439
- localVarRequest(localVarRequestOptions, (error, response, body) => {
440
- if (error) {
441
- reject(error);
442
- }
443
- else {
444
- body = models_1.ObjectSerializer.deserialize(body, "GetAllThirdPartyAuthResponse");
445
- if (typeof body.success === 'boolean' && !body.success) {
446
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
447
- reject(new Error(body.error || errString));
448
- }
449
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
450
- resolve(body);
451
- }
452
- else {
453
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
454
- reject(errString);
455
- }
456
- }
457
- });
458
- });
459
- });
490
+ else if (Object.keys(localVarFormParams).length > 0) {
491
+ // URL-encoded form
492
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
493
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
494
+ }
495
+ }
496
+ const response = await fetch(url, requestOptions);
497
+ return this.handleResponse(response, 'GetAllThirdPartyAuthResponse');
460
498
  }
461
499
  /**
462
500
  * Get information about a third party authentication partner
@@ -467,9 +505,11 @@ class ThirdPartyAuthApi {
467
505
  const localVarPath = this.basePath + '/api/third-party-auth/{authId}'
468
506
  .replace('{' + 'authId' + '}', encodeURIComponent(String(authId)));
469
507
  let localVarQueryParameters = {};
470
- let localVarHeaderParams = Object.assign({
471
- 'User-Agent': 'edgeimpulse-api nodejs'
472
- }, this.defaultHeaders);
508
+ let localVarHeaderParams = {
509
+ 'User-Agent': 'edgeimpulse-api nodejs',
510
+ 'Content-Type': 'application/json',
511
+ ...this.defaultHeaders,
512
+ };
473
513
  const produces = ['application/json'];
474
514
  // give precedence to 'application/json'
475
515
  if (produces.indexOf('application/json') >= 0) {
@@ -478,60 +518,56 @@ class ThirdPartyAuthApi {
478
518
  else {
479
519
  localVarHeaderParams.Accept = produces.join(',');
480
520
  }
481
- let localVarFormParams = {};
521
+ let localVarFormParams;
482
522
  // verify required parameter 'authId' is not null or undefined
483
523
  if (authId === null || authId === undefined) {
484
524
  throw new Error('Required parameter authId was null or undefined when calling getThirdPartyAuth.');
485
525
  }
486
- Object.assign(localVarHeaderParams, options.headers);
487
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
488
- let localVarUseFormData = false;
526
+ localVarHeaderParams = {
527
+ ...localVarHeaderParams,
528
+ ...options.headers,
529
+ ...this.opts.extraHeaders,
530
+ };
531
+ const queryString = Object.entries(localVarQueryParameters)
532
+ .filter(([, value]) => value !== undefined)
533
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
534
+ .join('&');
535
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
489
536
  let localVarRequestOptions = {
490
537
  method: 'GET',
491
- qs: localVarQueryParameters,
492
- headers: localVarHeaderParams,
493
- uri: localVarPath,
494
- useQuerystring: this._useQuerystring,
495
- agentOptions: { keepAlive: false },
496
- json: true,
538
+ headers: { ...localVarHeaderParams },
497
539
  };
498
- let authenticationPromise = Promise.resolve();
499
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
500
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
501
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
502
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
503
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
504
- return authenticationPromise.then(() => {
505
- if (Object.keys(localVarFormParams).length) {
506
- if (localVarUseFormData) {
507
- localVarRequestOptions.formData = localVarFormParams;
508
- }
509
- else {
510
- localVarRequestOptions.form = localVarFormParams;
511
- }
540
+ let requestOptions = localVarRequestOptions;
541
+ let url = localVarUrl;
542
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
543
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
544
+ url = auth_ApiKeyAuthentication.url;
545
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
546
+ requestOptions = auth_JWTAuthentication.requestOptions;
547
+ url = auth_JWTAuthentication.url;
548
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
549
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
550
+ url = auth_JWTHttpHeaderAuthentication.url;
551
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
552
+ requestOptions = auth_OAuth2.requestOptions;
553
+ url = auth_OAuth2.url;
554
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
555
+ requestOptions = authDefault.requestOptions;
556
+ url = authDefault.url;
557
+ if (localVarFormParams) {
558
+ delete requestOptions.headers['Content-Type'];
559
+ if (localVarFormParams instanceof FormData) {
560
+ // FormData: fetch will handle Content-Type automatically.
561
+ requestOptions.body = localVarFormParams;
562
+ }
563
+ else if (Object.keys(localVarFormParams).length > 0) {
564
+ // URL-encoded form
565
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
566
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
512
567
  }
513
- return new Promise((resolve, reject) => {
514
- localVarRequest(localVarRequestOptions, (error, response, body) => {
515
- if (error) {
516
- reject(error);
517
- }
518
- else {
519
- body = models_1.ObjectSerializer.deserialize(body, "GetThirdPartyAuthResponse");
520
- if (typeof body.success === 'boolean' && !body.success) {
521
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
522
- reject(new Error(body.error || errString));
523
- }
524
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
525
- resolve(body);
526
- }
527
- else {
528
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
529
- reject(errString);
530
- }
531
- }
532
- });
533
- });
534
- });
568
+ }
569
+ const response = await fetch(url, requestOptions);
570
+ return this.handleResponse(response, 'GetThirdPartyAuthResponse');
535
571
  }
536
572
  /**
537
573
  * Update a third party authentication partner
@@ -543,9 +579,11 @@ class ThirdPartyAuthApi {
543
579
  const localVarPath = this.basePath + '/api/third-party-auth/{authId}'
544
580
  .replace('{' + 'authId' + '}', encodeURIComponent(String(authId)));
545
581
  let localVarQueryParameters = {};
546
- let localVarHeaderParams = Object.assign({
547
- 'User-Agent': 'edgeimpulse-api nodejs'
548
- }, this.defaultHeaders);
582
+ let localVarHeaderParams = {
583
+ 'User-Agent': 'edgeimpulse-api nodejs',
584
+ 'Content-Type': 'application/json',
585
+ ...this.defaultHeaders,
586
+ };
549
587
  const produces = ['application/json'];
550
588
  // give precedence to 'application/json'
551
589
  if (produces.indexOf('application/json') >= 0) {
@@ -554,7 +592,7 @@ class ThirdPartyAuthApi {
554
592
  else {
555
593
  localVarHeaderParams.Accept = produces.join(',');
556
594
  }
557
- let localVarFormParams = {};
595
+ let localVarFormParams;
558
596
  // verify required parameter 'authId' is not null or undefined
559
597
  if (authId === null || authId === undefined) {
560
598
  throw new Error('Required parameter authId was null or undefined when calling updateThirdPartyAuth.');
@@ -563,56 +601,52 @@ class ThirdPartyAuthApi {
563
601
  if (updateThirdPartyAuthRequest === null || updateThirdPartyAuthRequest === undefined) {
564
602
  throw new Error('Required parameter updateThirdPartyAuthRequest was null or undefined when calling updateThirdPartyAuth.');
565
603
  }
566
- Object.assign(localVarHeaderParams, options.headers);
567
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
568
- let localVarUseFormData = false;
604
+ localVarHeaderParams = {
605
+ ...localVarHeaderParams,
606
+ ...options.headers,
607
+ ...this.opts.extraHeaders,
608
+ };
609
+ const queryString = Object.entries(localVarQueryParameters)
610
+ .filter(([, value]) => value !== undefined)
611
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
612
+ .join('&');
613
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
569
614
  let localVarRequestOptions = {
570
615
  method: 'POST',
571
- qs: localVarQueryParameters,
572
- headers: localVarHeaderParams,
573
- uri: localVarPath,
574
- useQuerystring: this._useQuerystring,
575
- agentOptions: { keepAlive: false },
576
- json: true,
577
- body: models_1.ObjectSerializer.serialize(updateThirdPartyAuthRequest, "UpdateThirdPartyAuthRequest")
616
+ headers: { ...localVarHeaderParams },
578
617
  };
579
- let authenticationPromise = Promise.resolve();
580
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
581
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
582
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
583
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
584
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
585
- return authenticationPromise.then(() => {
586
- if (Object.keys(localVarFormParams).length) {
587
- if (localVarUseFormData) {
588
- localVarRequestOptions.formData = localVarFormParams;
589
- }
590
- else {
591
- localVarRequestOptions.form = localVarFormParams;
592
- }
618
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(updateThirdPartyAuthRequest, "UpdateThirdPartyAuthRequest"));
619
+ let requestOptions = localVarRequestOptions;
620
+ let url = localVarUrl;
621
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
622
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
623
+ url = auth_ApiKeyAuthentication.url;
624
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
625
+ requestOptions = auth_JWTAuthentication.requestOptions;
626
+ url = auth_JWTAuthentication.url;
627
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
628
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
629
+ url = auth_JWTHttpHeaderAuthentication.url;
630
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
631
+ requestOptions = auth_OAuth2.requestOptions;
632
+ url = auth_OAuth2.url;
633
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
634
+ requestOptions = authDefault.requestOptions;
635
+ url = authDefault.url;
636
+ if (localVarFormParams) {
637
+ delete requestOptions.headers['Content-Type'];
638
+ if (localVarFormParams instanceof FormData) {
639
+ // FormData: fetch will handle Content-Type automatically.
640
+ requestOptions.body = localVarFormParams;
641
+ }
642
+ else if (Object.keys(localVarFormParams).length > 0) {
643
+ // URL-encoded form
644
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
645
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
593
646
  }
594
- return new Promise((resolve, reject) => {
595
- localVarRequest(localVarRequestOptions, (error, response, body) => {
596
- if (error) {
597
- reject(error);
598
- }
599
- else {
600
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
601
- if (typeof body.success === 'boolean' && !body.success) {
602
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
603
- reject(new Error(body.error || errString));
604
- }
605
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
606
- resolve(body);
607
- }
608
- else {
609
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
610
- reject(errString);
611
- }
612
- }
613
- });
614
- });
615
- });
647
+ }
648
+ const response = await fetch(url, requestOptions);
649
+ return this.handleResponse(response, 'GenericApiResponse');
616
650
  }
617
651
  }
618
652
  exports.ThirdPartyAuthApi = ThirdPartyAuthApi;