edge-impulse-api 1.82.6 → 1.82.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/build/library/sdk/api/adminApi.d.ts +4 -6
  2. package/build/library/sdk/api/adminApi.js +4782 -4928
  3. package/build/library/sdk/api/adminApi.js.map +1 -1
  4. package/build/library/sdk/api/authApi.d.ts +4 -6
  5. package/build/library/sdk/api/authApi.js +88 -56
  6. package/build/library/sdk/api/authApi.js.map +1 -1
  7. package/build/library/sdk/api/cDNApi.d.ts +4 -6
  8. package/build/library/sdk/api/cDNApi.js +76 -53
  9. package/build/library/sdk/api/cDNApi.js.map +1 -1
  10. package/build/library/sdk/api/canaryApi.d.ts +4 -6
  11. package/build/library/sdk/api/canaryApi.js +79 -53
  12. package/build/library/sdk/api/canaryApi.js.map +1 -1
  13. package/build/library/sdk/api/classifyApi.d.ts +4 -6
  14. package/build/library/sdk/api/classifyApi.js +527 -499
  15. package/build/library/sdk/api/classifyApi.js.map +1 -1
  16. package/build/library/sdk/api/dSPApi.d.ts +4 -6
  17. package/build/library/sdk/api/dSPApi.js +938 -942
  18. package/build/library/sdk/api/dSPApi.js.map +1 -1
  19. package/build/library/sdk/api/deploymentApi.d.ts +4 -6
  20. package/build/library/sdk/api/deploymentApi.js +680 -603
  21. package/build/library/sdk/api/deploymentApi.js.map +1 -1
  22. package/build/library/sdk/api/devicesApi.d.ts +4 -6
  23. package/build/library/sdk/api/devicesApi.js +802 -800
  24. package/build/library/sdk/api/devicesApi.js.map +1 -1
  25. package/build/library/sdk/api/emailVerificationApi.d.ts +4 -6
  26. package/build/library/sdk/api/emailVerificationApi.js +184 -190
  27. package/build/library/sdk/api/emailVerificationApi.js.map +1 -1
  28. package/build/library/sdk/api/exportApi.d.ts +4 -6
  29. package/build/library/sdk/api/exportApi.js +88 -56
  30. package/build/library/sdk/api/exportApi.js.map +1 -1
  31. package/build/library/sdk/api/featureFlagsApi.d.ts +4 -6
  32. package/build/library/sdk/api/featureFlagsApi.js +76 -52
  33. package/build/library/sdk/api/featureFlagsApi.js.map +1 -1
  34. package/build/library/sdk/api/healthApi.d.ts +4 -6
  35. package/build/library/sdk/api/healthApi.js +111 -97
  36. package/build/library/sdk/api/healthApi.js.map +1 -1
  37. package/build/library/sdk/api/impulseApi.d.ts +4 -6
  38. package/build/library/sdk/api/impulseApi.js +942 -902
  39. package/build/library/sdk/api/impulseApi.js.map +1 -1
  40. package/build/library/sdk/api/integrationsApi.d.ts +4 -6
  41. package/build/library/sdk/api/integrationsApi.js +136 -106
  42. package/build/library/sdk/api/integrationsApi.js.map +1 -1
  43. package/build/library/sdk/api/jobsApi.d.ts +4 -6
  44. package/build/library/sdk/api/jobsApi.js +2270 -2326
  45. package/build/library/sdk/api/jobsApi.js.map +1 -1
  46. package/build/library/sdk/api/learnApi.d.ts +22 -6
  47. package/build/library/sdk/api/learnApi.js +1597 -1424
  48. package/build/library/sdk/api/learnApi.js.map +1 -1
  49. package/build/library/sdk/api/loginApi.d.ts +4 -6
  50. package/build/library/sdk/api/loginApi.js +112 -98
  51. package/build/library/sdk/api/loginApi.js.map +1 -1
  52. package/build/library/sdk/api/metricsApi.d.ts +4 -6
  53. package/build/library/sdk/api/metricsApi.js +148 -144
  54. package/build/library/sdk/api/metricsApi.js.map +1 -1
  55. package/build/library/sdk/api/optimizationApi.d.ts +4 -6
  56. package/build/library/sdk/api/optimizationApi.js +844 -844
  57. package/build/library/sdk/api/optimizationApi.js.map +1 -1
  58. package/build/library/sdk/api/organizationBlocksApi.d.ts +4 -6
  59. package/build/library/sdk/api/organizationBlocksApi.js +1968 -1550
  60. package/build/library/sdk/api/organizationBlocksApi.js.map +1 -1
  61. package/build/library/sdk/api/organizationCreateProjectApi.d.ts +4 -6
  62. package/build/library/sdk/api/organizationCreateProjectApi.js +700 -652
  63. package/build/library/sdk/api/organizationCreateProjectApi.js.map +1 -1
  64. package/build/library/sdk/api/organizationDataApi.d.ts +4 -6
  65. package/build/library/sdk/api/organizationDataApi.js +2074 -1985
  66. package/build/library/sdk/api/organizationDataApi.js.map +1 -1
  67. package/build/library/sdk/api/organizationDataCampaignsApi.d.ts +4 -6
  68. package/build/library/sdk/api/organizationDataCampaignsApi.js +626 -602
  69. package/build/library/sdk/api/organizationDataCampaignsApi.js.map +1 -1
  70. package/build/library/sdk/api/organizationJobsApi.d.ts +4 -6
  71. package/build/library/sdk/api/organizationJobsApi.js +417 -399
  72. package/build/library/sdk/api/organizationJobsApi.js.map +1 -1
  73. package/build/library/sdk/api/organizationPipelinesApi.d.ts +4 -6
  74. package/build/library/sdk/api/organizationPipelinesApi.js +419 -401
  75. package/build/library/sdk/api/organizationPipelinesApi.js.map +1 -1
  76. package/build/library/sdk/api/organizationPortalsApi.d.ts +4 -6
  77. package/build/library/sdk/api/organizationPortalsApi.js +372 -352
  78. package/build/library/sdk/api/organizationPortalsApi.js.map +1 -1
  79. package/build/library/sdk/api/organizationsApi.d.ts +4 -6
  80. package/build/library/sdk/api/organizationsApi.js +4024 -4050
  81. package/build/library/sdk/api/organizationsApi.js.map +1 -1
  82. package/build/library/sdk/api/performanceCalibrationApi.d.ts +4 -6
  83. package/build/library/sdk/api/performanceCalibrationApi.js +586 -560
  84. package/build/library/sdk/api/performanceCalibrationApi.js.map +1 -1
  85. package/build/library/sdk/api/postProcessingApi.d.ts +4 -6
  86. package/build/library/sdk/api/postProcessingApi.js +279 -255
  87. package/build/library/sdk/api/postProcessingApi.js.map +1 -1
  88. package/build/library/sdk/api/projectsApi.d.ts +4 -6
  89. package/build/library/sdk/api/projectsApi.js +2758 -2818
  90. package/build/library/sdk/api/projectsApi.js.map +1 -1
  91. package/build/library/sdk/api/rawDataApi.d.ts +4 -6
  92. package/build/library/sdk/api/rawDataApi.js +3055 -3131
  93. package/build/library/sdk/api/rawDataApi.js.map +1 -1
  94. package/build/library/sdk/api/testApi.d.ts +4 -6
  95. package/build/library/sdk/api/testApi.js +152 -108
  96. package/build/library/sdk/api/testApi.js.map +1 -1
  97. package/build/library/sdk/api/themesApi.d.ts +4 -6
  98. package/build/library/sdk/api/themesApi.js +341 -305
  99. package/build/library/sdk/api/themesApi.js.map +1 -1
  100. package/build/library/sdk/api/thirdPartyAuthApi.d.ts +4 -6
  101. package/build/library/sdk/api/thirdPartyAuthApi.js +387 -353
  102. package/build/library/sdk/api/thirdPartyAuthApi.js.map +1 -1
  103. package/build/library/sdk/api/uploadPortalApi.d.ts +4 -6
  104. package/build/library/sdk/api/uploadPortalApi.js +375 -355
  105. package/build/library/sdk/api/uploadPortalApi.js.map +1 -1
  106. package/build/library/sdk/api/userApi.d.ts +4 -6
  107. package/build/library/sdk/api/userApi.js +2345 -2452
  108. package/build/library/sdk/api/userApi.js.map +1 -1
  109. package/build/library/sdk/api/vlmApi.d.ts +4 -6
  110. package/build/library/sdk/api/vlmApi.js +277 -253
  111. package/build/library/sdk/api/vlmApi.js.map +1 -1
  112. package/build/library/sdk/api/whitelabelsApi.d.ts +4 -6
  113. package/build/library/sdk/api/whitelabelsApi.js +408 -398
  114. package/build/library/sdk/api/whitelabelsApi.js.map +1 -1
  115. package/build/library/sdk/model/deployPretrainedModelRequest.d.ts +4 -0
  116. package/build/library/sdk/model/deployPretrainedModelRequest.js +5 -0
  117. package/build/library/sdk/model/deployPretrainedModelRequest.js.map +1 -1
  118. package/build/library/sdk/model/models.d.ts +47 -7
  119. package/build/library/sdk/model/models.js +33 -22
  120. package/build/library/sdk/model/models.js.map +1 -1
  121. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.d.ts +47 -0
  122. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js +55 -0
  123. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js.map +1 -0
  124. package/build/library/sdk/model/uploadPretrainedModelRequest.d.ts +4 -0
  125. package/build/library/sdk/model/uploadPretrainedModelRequest.js +5 -0
  126. package/build/library/sdk/model/uploadPretrainedModelRequest.js.map +1 -1
  127. package/package.json +3 -2
@@ -12,14 +12,31 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.PostProcessingApi = exports.PostProcessingApiApiKeys = 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 PostProcessingApiApiKeys;
30
47
  PostProcessingApiApiKeys[PostProcessingApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(PostProcessingApiApiKeys = exports.PostProcessingApiApiKeys || (exports.PostProcessingApiApiKeys = {}));
32
49
  class PostProcessingApi {
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 PostProcessingApi {
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
  }
@@ -92,9 +126,11 @@ class PostProcessingApi {
92
126
  .replace('{' + 'postProcessingId' + '}', encodeURIComponent(String(postProcessingId)))
93
127
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
94
128
  let localVarQueryParameters = {};
95
- let localVarHeaderParams = Object.assign({
96
- 'User-Agent': 'edgeimpulse-api nodejs'
97
- }, this.defaultHeaders);
129
+ let localVarHeaderParams = {
130
+ 'User-Agent': 'edgeimpulse-api nodejs',
131
+ 'Content-Type': 'application/json',
132
+ ...this.defaultHeaders,
133
+ };
98
134
  const produces = ['application/json'];
99
135
  // give precedence to 'application/json'
100
136
  if (produces.indexOf('application/json') >= 0) {
@@ -103,7 +139,7 @@ class PostProcessingApi {
103
139
  else {
104
140
  localVarHeaderParams.Accept = produces.join(',');
105
141
  }
106
- let localVarFormParams = {};
142
+ let localVarFormParams;
107
143
  // verify required parameter 'projectId' is not null or undefined
108
144
  if (projectId === null || projectId === undefined) {
109
145
  throw new Error('Required parameter projectId was null or undefined when calling generatePostProcessingFeaturesForSample.');
@@ -120,56 +156,52 @@ class PostProcessingApi {
120
156
  if (postProcessingFeaturesForSampleRequest === null || postProcessingFeaturesForSampleRequest === undefined) {
121
157
  throw new Error('Required parameter postProcessingFeaturesForSampleRequest was null or undefined when calling generatePostProcessingFeaturesForSample.');
122
158
  }
123
- Object.assign(localVarHeaderParams, options.headers);
124
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
125
- let localVarUseFormData = false;
159
+ localVarHeaderParams = {
160
+ ...localVarHeaderParams,
161
+ ...options.headers,
162
+ ...this.opts.extraHeaders,
163
+ };
164
+ const queryString = Object.entries(localVarQueryParameters)
165
+ .filter(([, value]) => value !== undefined)
166
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
167
+ .join('&');
168
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
126
169
  let localVarRequestOptions = {
127
170
  method: 'POST',
128
- qs: localVarQueryParameters,
129
- headers: localVarHeaderParams,
130
- uri: localVarPath,
131
- useQuerystring: this._useQuerystring,
132
- agentOptions: { keepAlive: false },
133
- json: true,
134
- body: models_1.ObjectSerializer.serialize(postProcessingFeaturesForSampleRequest, "PostProcessingFeaturesForSampleRequest")
171
+ headers: { ...localVarHeaderParams },
135
172
  };
136
- let authenticationPromise = Promise.resolve();
137
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
138
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
139
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
140
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
141
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
142
- return authenticationPromise.then(() => {
143
- if (Object.keys(localVarFormParams).length) {
144
- if (localVarUseFormData) {
145
- localVarRequestOptions.formData = localVarFormParams;
146
- }
147
- else {
148
- localVarRequestOptions.form = localVarFormParams;
149
- }
173
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(postProcessingFeaturesForSampleRequest, "PostProcessingFeaturesForSampleRequest"));
174
+ let requestOptions = localVarRequestOptions;
175
+ let url = localVarUrl;
176
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
177
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
178
+ url = auth_ApiKeyAuthentication.url;
179
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
180
+ requestOptions = auth_JWTAuthentication.requestOptions;
181
+ url = auth_JWTAuthentication.url;
182
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
183
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
184
+ url = auth_JWTHttpHeaderAuthentication.url;
185
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
186
+ requestOptions = auth_OAuth2.requestOptions;
187
+ url = auth_OAuth2.url;
188
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
189
+ requestOptions = authDefault.requestOptions;
190
+ url = authDefault.url;
191
+ if (localVarFormParams) {
192
+ delete requestOptions.headers['Content-Type'];
193
+ if (localVarFormParams instanceof FormData) {
194
+ // FormData: fetch will handle Content-Type automatically.
195
+ requestOptions.body = localVarFormParams;
196
+ }
197
+ else if (Object.keys(localVarFormParams).length > 0) {
198
+ // URL-encoded form
199
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
200
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
150
201
  }
151
- return new Promise((resolve, reject) => {
152
- localVarRequest(localVarRequestOptions, (error, response, body) => {
153
- if (error) {
154
- reject(error);
155
- }
156
- else {
157
- body = models_1.ObjectSerializer.deserialize(body, "GetPostProcessingFeaturesForSampleResponse | StartJobResponse");
158
- if (typeof body.success === 'boolean' && !body.success) {
159
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
160
- reject(new Error(body.error || errString));
161
- }
162
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
163
- resolve(body);
164
- }
165
- else {
166
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
167
- reject(errString);
168
- }
169
- }
170
- });
171
- });
172
- });
202
+ }
203
+ const response = await fetch(url, requestOptions);
204
+ return this.handleResponse(response, 'GetPostProcessingFeaturesForSampleResponse | StartJobResponse');
173
205
  }
174
206
  /**
175
207
  * Internal route for tests: Get features (after DSP block) of a sample that was already classified using post-processing.
@@ -185,9 +217,11 @@ class PostProcessingApi {
185
217
  .replace('{' + 'postProcessingId' + '}', encodeURIComponent(String(postProcessingId)))
186
218
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
187
219
  let localVarQueryParameters = {};
188
- let localVarHeaderParams = Object.assign({
189
- 'User-Agent': 'edgeimpulse-api nodejs'
190
- }, this.defaultHeaders);
220
+ let localVarHeaderParams = {
221
+ 'User-Agent': 'edgeimpulse-api nodejs',
222
+ 'Content-Type': 'application/json',
223
+ ...this.defaultHeaders,
224
+ };
191
225
  const produces = ['application/json'];
192
226
  // give precedence to 'application/json'
193
227
  if (produces.indexOf('application/json') >= 0) {
@@ -196,7 +230,7 @@ class PostProcessingApi {
196
230
  else {
197
231
  localVarHeaderParams.Accept = produces.join(',');
198
232
  }
199
- let localVarFormParams = {};
233
+ let localVarFormParams;
200
234
  // verify required parameter 'projectId' is not null or undefined
201
235
  if (projectId === null || projectId === undefined) {
202
236
  throw new Error('Required parameter projectId was null or undefined when calling getFeaturesForPostProcessingSample.');
@@ -216,55 +250,51 @@ class PostProcessingApi {
216
250
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.frameIndex) !== undefined) {
217
251
  localVarQueryParameters['frameIndex'] = models_1.ObjectSerializer.serialize(queryParams.frameIndex, "number");
218
252
  }
219
- Object.assign(localVarHeaderParams, options.headers);
220
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
221
- let localVarUseFormData = false;
253
+ localVarHeaderParams = {
254
+ ...localVarHeaderParams,
255
+ ...options.headers,
256
+ ...this.opts.extraHeaders,
257
+ };
258
+ const queryString = Object.entries(localVarQueryParameters)
259
+ .filter(([, value]) => value !== undefined)
260
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
261
+ .join('&');
262
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
222
263
  let localVarRequestOptions = {
223
264
  method: 'GET',
224
- qs: localVarQueryParameters,
225
- headers: localVarHeaderParams,
226
- uri: localVarPath,
227
- useQuerystring: this._useQuerystring,
228
- agentOptions: { keepAlive: false },
229
- json: true,
265
+ headers: { ...localVarHeaderParams },
230
266
  };
231
- let authenticationPromise = Promise.resolve();
232
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
233
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
234
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
235
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
236
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
237
- return authenticationPromise.then(() => {
238
- if (Object.keys(localVarFormParams).length) {
239
- if (localVarUseFormData) {
240
- localVarRequestOptions.formData = localVarFormParams;
241
- }
242
- else {
243
- localVarRequestOptions.form = localVarFormParams;
244
- }
267
+ let requestOptions = localVarRequestOptions;
268
+ let url = localVarUrl;
269
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
270
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
271
+ url = auth_ApiKeyAuthentication.url;
272
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
273
+ requestOptions = auth_JWTAuthentication.requestOptions;
274
+ url = auth_JWTAuthentication.url;
275
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
276
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
277
+ url = auth_JWTHttpHeaderAuthentication.url;
278
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
279
+ requestOptions = auth_OAuth2.requestOptions;
280
+ url = auth_OAuth2.url;
281
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
282
+ requestOptions = authDefault.requestOptions;
283
+ url = authDefault.url;
284
+ if (localVarFormParams) {
285
+ delete requestOptions.headers['Content-Type'];
286
+ if (localVarFormParams instanceof FormData) {
287
+ // FormData: fetch will handle Content-Type automatically.
288
+ requestOptions.body = localVarFormParams;
289
+ }
290
+ else if (Object.keys(localVarFormParams).length > 0) {
291
+ // URL-encoded form
292
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
293
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
245
294
  }
246
- return new Promise((resolve, reject) => {
247
- localVarRequest(localVarRequestOptions, (error, response, body) => {
248
- if (error) {
249
- reject(error);
250
- }
251
- else {
252
- body = models_1.ObjectSerializer.deserialize(body, "GetFeaturesForPostProcessingSampleResponse");
253
- if (typeof body.success === 'boolean' && !body.success) {
254
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
255
- reject(new Error(body.error || errString));
256
- }
257
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
258
- resolve(body);
259
- }
260
- else {
261
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
262
- reject(errString);
263
- }
264
- }
265
- });
266
- });
267
- });
295
+ }
296
+ const response = await fetch(url, requestOptions);
297
+ return this.handleResponse(response, 'GetFeaturesForPostProcessingSampleResponse');
268
298
  }
269
299
  /**
270
300
  * Retrieve the configuration parameters for a post-processing block. Use the impulse functions to retrieve all post-processing blocks.
@@ -277,9 +307,11 @@ class PostProcessingApi {
277
307
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
278
308
  .replace('{' + 'postProcessingId' + '}', encodeURIComponent(String(postProcessingId)));
279
309
  let localVarQueryParameters = {};
280
- let localVarHeaderParams = Object.assign({
281
- 'User-Agent': 'edgeimpulse-api nodejs'
282
- }, this.defaultHeaders);
310
+ let localVarHeaderParams = {
311
+ 'User-Agent': 'edgeimpulse-api nodejs',
312
+ 'Content-Type': 'application/json',
313
+ ...this.defaultHeaders,
314
+ };
283
315
  const produces = ['application/json'];
284
316
  // give precedence to 'application/json'
285
317
  if (produces.indexOf('application/json') >= 0) {
@@ -288,7 +320,7 @@ class PostProcessingApi {
288
320
  else {
289
321
  localVarHeaderParams.Accept = produces.join(',');
290
322
  }
291
- let localVarFormParams = {};
323
+ let localVarFormParams;
292
324
  // verify required parameter 'projectId' is not null or undefined
293
325
  if (projectId === null || projectId === undefined) {
294
326
  throw new Error('Required parameter projectId was null or undefined when calling getPostProcessingConfig.');
@@ -297,55 +329,51 @@ class PostProcessingApi {
297
329
  if (postProcessingId === null || postProcessingId === undefined) {
298
330
  throw new Error('Required parameter postProcessingId was null or undefined when calling getPostProcessingConfig.');
299
331
  }
300
- Object.assign(localVarHeaderParams, options.headers);
301
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
302
- let localVarUseFormData = false;
332
+ localVarHeaderParams = {
333
+ ...localVarHeaderParams,
334
+ ...options.headers,
335
+ ...this.opts.extraHeaders,
336
+ };
337
+ const queryString = Object.entries(localVarQueryParameters)
338
+ .filter(([, value]) => value !== undefined)
339
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
340
+ .join('&');
341
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
303
342
  let localVarRequestOptions = {
304
343
  method: 'GET',
305
- qs: localVarQueryParameters,
306
- headers: localVarHeaderParams,
307
- uri: localVarPath,
308
- useQuerystring: this._useQuerystring,
309
- agentOptions: { keepAlive: false },
310
- json: true,
344
+ headers: { ...localVarHeaderParams },
311
345
  };
312
- let authenticationPromise = Promise.resolve();
313
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
314
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
315
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
316
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
317
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
318
- return authenticationPromise.then(() => {
319
- if (Object.keys(localVarFormParams).length) {
320
- if (localVarUseFormData) {
321
- localVarRequestOptions.formData = localVarFormParams;
322
- }
323
- else {
324
- localVarRequestOptions.form = localVarFormParams;
325
- }
346
+ let requestOptions = localVarRequestOptions;
347
+ let url = localVarUrl;
348
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
349
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
350
+ url = auth_ApiKeyAuthentication.url;
351
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
352
+ requestOptions = auth_JWTAuthentication.requestOptions;
353
+ url = auth_JWTAuthentication.url;
354
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
355
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
356
+ url = auth_JWTHttpHeaderAuthentication.url;
357
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
358
+ requestOptions = auth_OAuth2.requestOptions;
359
+ url = auth_OAuth2.url;
360
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
361
+ requestOptions = authDefault.requestOptions;
362
+ url = authDefault.url;
363
+ if (localVarFormParams) {
364
+ delete requestOptions.headers['Content-Type'];
365
+ if (localVarFormParams instanceof FormData) {
366
+ // FormData: fetch will handle Content-Type automatically.
367
+ requestOptions.body = localVarFormParams;
368
+ }
369
+ else if (Object.keys(localVarFormParams).length > 0) {
370
+ // URL-encoded form
371
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
372
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
326
373
  }
327
- return new Promise((resolve, reject) => {
328
- localVarRequest(localVarRequestOptions, (error, response, body) => {
329
- if (error) {
330
- reject(error);
331
- }
332
- else {
333
- body = models_1.ObjectSerializer.deserialize(body, "PostProcessingConfigResponse");
334
- if (typeof body.success === 'boolean' && !body.success) {
335
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
336
- reject(new Error(body.error || errString));
337
- }
338
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
339
- resolve(body);
340
- }
341
- else {
342
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
343
- reject(errString);
344
- }
345
- }
346
- });
347
- });
348
- });
374
+ }
375
+ const response = await fetch(url, requestOptions);
376
+ return this.handleResponse(response, 'PostProcessingConfigResponse');
349
377
  }
350
378
  /**
351
379
  * Retrieve post-processing results for a specific sample, e.g. whether it has generated features already.
@@ -361,9 +389,11 @@ class PostProcessingApi {
361
389
  .replace('{' + 'postProcessingId' + '}', encodeURIComponent(String(postProcessingId)))
362
390
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
363
391
  let localVarQueryParameters = {};
364
- let localVarHeaderParams = Object.assign({
365
- 'User-Agent': 'edgeimpulse-api nodejs'
366
- }, this.defaultHeaders);
392
+ let localVarHeaderParams = {
393
+ 'User-Agent': 'edgeimpulse-api nodejs',
394
+ 'Content-Type': 'application/json',
395
+ ...this.defaultHeaders,
396
+ };
367
397
  const produces = ['application/json'];
368
398
  // give precedence to 'application/json'
369
399
  if (produces.indexOf('application/json') >= 0) {
@@ -372,7 +402,7 @@ class PostProcessingApi {
372
402
  else {
373
403
  localVarHeaderParams.Accept = produces.join(',');
374
404
  }
375
- let localVarFormParams = {};
405
+ let localVarFormParams;
376
406
  // verify required parameter 'projectId' is not null or undefined
377
407
  if (projectId === null || projectId === undefined) {
378
408
  throw new Error('Required parameter projectId was null or undefined when calling getPostProcessingResultsForSample.');
@@ -389,56 +419,52 @@ class PostProcessingApi {
389
419
  if (postProcessingFeaturesForSampleRequest === null || postProcessingFeaturesForSampleRequest === undefined) {
390
420
  throw new Error('Required parameter postProcessingFeaturesForSampleRequest was null or undefined when calling getPostProcessingResultsForSample.');
391
421
  }
392
- Object.assign(localVarHeaderParams, options.headers);
393
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
394
- let localVarUseFormData = false;
422
+ localVarHeaderParams = {
423
+ ...localVarHeaderParams,
424
+ ...options.headers,
425
+ ...this.opts.extraHeaders,
426
+ };
427
+ const queryString = Object.entries(localVarQueryParameters)
428
+ .filter(([, value]) => value !== undefined)
429
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
430
+ .join('&');
431
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
395
432
  let localVarRequestOptions = {
396
433
  method: 'POST',
397
- qs: localVarQueryParameters,
398
- headers: localVarHeaderParams,
399
- uri: localVarPath,
400
- useQuerystring: this._useQuerystring,
401
- agentOptions: { keepAlive: false },
402
- json: true,
403
- body: models_1.ObjectSerializer.serialize(postProcessingFeaturesForSampleRequest, "PostProcessingFeaturesForSampleRequest")
434
+ headers: { ...localVarHeaderParams },
404
435
  };
405
- let authenticationPromise = Promise.resolve();
406
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
407
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
408
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
409
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
410
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
411
- return authenticationPromise.then(() => {
412
- if (Object.keys(localVarFormParams).length) {
413
- if (localVarUseFormData) {
414
- localVarRequestOptions.formData = localVarFormParams;
415
- }
416
- else {
417
- localVarRequestOptions.form = localVarFormParams;
418
- }
436
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(postProcessingFeaturesForSampleRequest, "PostProcessingFeaturesForSampleRequest"));
437
+ let requestOptions = localVarRequestOptions;
438
+ let url = localVarUrl;
439
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
440
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
441
+ url = auth_ApiKeyAuthentication.url;
442
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
443
+ requestOptions = auth_JWTAuthentication.requestOptions;
444
+ url = auth_JWTAuthentication.url;
445
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
446
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
447
+ url = auth_JWTHttpHeaderAuthentication.url;
448
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
449
+ requestOptions = auth_OAuth2.requestOptions;
450
+ url = auth_OAuth2.url;
451
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
452
+ requestOptions = authDefault.requestOptions;
453
+ url = authDefault.url;
454
+ if (localVarFormParams) {
455
+ delete requestOptions.headers['Content-Type'];
456
+ if (localVarFormParams instanceof FormData) {
457
+ // FormData: fetch will handle Content-Type automatically.
458
+ requestOptions.body = localVarFormParams;
459
+ }
460
+ else if (Object.keys(localVarFormParams).length > 0) {
461
+ // URL-encoded form
462
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
463
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
419
464
  }
420
- return new Promise((resolve, reject) => {
421
- localVarRequest(localVarRequestOptions, (error, response, body) => {
422
- if (error) {
423
- reject(error);
424
- }
425
- else {
426
- body = models_1.ObjectSerializer.deserialize(body, "GetPostProcessingResultsForSampleResponse");
427
- if (typeof body.success === 'boolean' && !body.success) {
428
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
429
- reject(new Error(body.error || errString));
430
- }
431
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
432
- resolve(body);
433
- }
434
- else {
435
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
436
- reject(errString);
437
- }
438
- }
439
- });
440
- });
441
- });
465
+ }
466
+ const response = await fetch(url, requestOptions);
467
+ return this.handleResponse(response, 'GetPostProcessingResultsForSampleResponse');
442
468
  }
443
469
  /**
444
470
  * Set configuration parameters for a post-processing block. Only values set in the body will be overwritten.
@@ -452,9 +478,11 @@ class PostProcessingApi {
452
478
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
453
479
  .replace('{' + 'postProcessingId' + '}', encodeURIComponent(String(postProcessingId)));
454
480
  let localVarQueryParameters = {};
455
- let localVarHeaderParams = Object.assign({
456
- 'User-Agent': 'edgeimpulse-api nodejs'
457
- }, this.defaultHeaders);
481
+ let localVarHeaderParams = {
482
+ 'User-Agent': 'edgeimpulse-api nodejs',
483
+ 'Content-Type': 'application/json',
484
+ ...this.defaultHeaders,
485
+ };
458
486
  const produces = ['application/json'];
459
487
  // give precedence to 'application/json'
460
488
  if (produces.indexOf('application/json') >= 0) {
@@ -463,7 +491,7 @@ class PostProcessingApi {
463
491
  else {
464
492
  localVarHeaderParams.Accept = produces.join(',');
465
493
  }
466
- let localVarFormParams = {};
494
+ let localVarFormParams;
467
495
  // verify required parameter 'projectId' is not null or undefined
468
496
  if (projectId === null || projectId === undefined) {
469
497
  throw new Error('Required parameter projectId was null or undefined when calling setPostProcessingConfig.');
@@ -476,56 +504,52 @@ class PostProcessingApi {
476
504
  if (postProcessingConfigRequest === null || postProcessingConfigRequest === undefined) {
477
505
  throw new Error('Required parameter postProcessingConfigRequest was null or undefined when calling setPostProcessingConfig.');
478
506
  }
479
- Object.assign(localVarHeaderParams, options.headers);
480
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
481
- let localVarUseFormData = false;
507
+ localVarHeaderParams = {
508
+ ...localVarHeaderParams,
509
+ ...options.headers,
510
+ ...this.opts.extraHeaders,
511
+ };
512
+ const queryString = Object.entries(localVarQueryParameters)
513
+ .filter(([, value]) => value !== undefined)
514
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
515
+ .join('&');
516
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
482
517
  let localVarRequestOptions = {
483
518
  method: 'POST',
484
- qs: localVarQueryParameters,
485
- headers: localVarHeaderParams,
486
- uri: localVarPath,
487
- useQuerystring: this._useQuerystring,
488
- agentOptions: { keepAlive: false },
489
- json: true,
490
- body: models_1.ObjectSerializer.serialize(postProcessingConfigRequest, "PostProcessingConfigRequest")
519
+ headers: { ...localVarHeaderParams },
491
520
  };
492
- let authenticationPromise = Promise.resolve();
493
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
494
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
495
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
496
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
497
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
498
- return authenticationPromise.then(() => {
499
- if (Object.keys(localVarFormParams).length) {
500
- if (localVarUseFormData) {
501
- localVarRequestOptions.formData = localVarFormParams;
502
- }
503
- else {
504
- localVarRequestOptions.form = localVarFormParams;
505
- }
521
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(postProcessingConfigRequest, "PostProcessingConfigRequest"));
522
+ let requestOptions = localVarRequestOptions;
523
+ let url = localVarUrl;
524
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
525
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
526
+ url = auth_ApiKeyAuthentication.url;
527
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
528
+ requestOptions = auth_JWTAuthentication.requestOptions;
529
+ url = auth_JWTAuthentication.url;
530
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
531
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
532
+ url = auth_JWTHttpHeaderAuthentication.url;
533
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
534
+ requestOptions = auth_OAuth2.requestOptions;
535
+ url = auth_OAuth2.url;
536
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
537
+ requestOptions = authDefault.requestOptions;
538
+ url = authDefault.url;
539
+ if (localVarFormParams) {
540
+ delete requestOptions.headers['Content-Type'];
541
+ if (localVarFormParams instanceof FormData) {
542
+ // FormData: fetch will handle Content-Type automatically.
543
+ requestOptions.body = localVarFormParams;
544
+ }
545
+ else if (Object.keys(localVarFormParams).length > 0) {
546
+ // URL-encoded form
547
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
548
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
506
549
  }
507
- return new Promise((resolve, reject) => {
508
- localVarRequest(localVarRequestOptions, (error, response, body) => {
509
- if (error) {
510
- reject(error);
511
- }
512
- else {
513
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
514
- if (typeof body.success === 'boolean' && !body.success) {
515
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
516
- reject(new Error(body.error || errString));
517
- }
518
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
519
- resolve(body);
520
- }
521
- else {
522
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
523
- reject(errString);
524
- }
525
- }
526
- });
527
- });
528
- });
550
+ }
551
+ const response = await fetch(url, requestOptions);
552
+ return this.handleResponse(response, 'GenericApiResponse');
529
553
  }
530
554
  }
531
555
  exports.PostProcessingApi = PostProcessingApi;