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.ClassifyApi = exports.ClassifyApiApiKeys = 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 ClassifyApiApiKeys;
30
47
  ClassifyApiApiKeys[ClassifyApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(ClassifyApiApiKeys = exports.ClassifyApiApiKeys || (exports.ClassifyApiApiKeys = {}));
32
49
  class ClassifyApi {
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 ClassifyApi {
54
91
  }
55
92
  this.opts = opts !== null && opts !== void 0 ? opts : {};
56
93
  }
57
- set useQuerystring(value) {
58
- this._useQuerystring = value;
59
- }
60
94
  set basePath(basePath) {
61
95
  this._basePath = basePath;
62
96
  }
@@ -89,9 +123,11 @@ class ClassifyApi {
89
123
  const localVarPath = this.basePath + '/api/{projectId}/classify/image'
90
124
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
91
125
  let localVarQueryParameters = {};
92
- let localVarHeaderParams = Object.assign({
93
- 'User-Agent': 'edgeimpulse-api nodejs'
94
- }, this.defaultHeaders);
126
+ let localVarHeaderParams = {
127
+ 'User-Agent': 'edgeimpulse-api nodejs',
128
+ 'Content-Type': 'application/json',
129
+ ...this.defaultHeaders,
130
+ };
95
131
  const produces = ['application/json'];
96
132
  // give precedence to 'application/json'
97
133
  if (produces.indexOf('application/json') >= 0) {
@@ -100,7 +136,7 @@ class ClassifyApi {
100
136
  else {
101
137
  localVarHeaderParams.Accept = produces.join(',');
102
138
  }
103
- let localVarFormParams = {};
139
+ let localVarFormParams;
104
140
  // verify required parameter 'projectId' is not null or undefined
105
141
  if (projectId === null || projectId === undefined) {
106
142
  throw new Error('Required parameter projectId was null or undefined when calling classifyImage.');
@@ -112,59 +148,69 @@ class ClassifyApi {
112
148
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
113
149
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
114
150
  }
115
- Object.assign(localVarHeaderParams, options.headers);
116
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
117
- let localVarUseFormData = false;
151
+ localVarHeaderParams = {
152
+ ...localVarHeaderParams,
153
+ ...options.headers,
154
+ ...this.opts.extraHeaders,
155
+ };
118
156
  if (params.image !== undefined) {
119
- localVarFormParams['image'] = params.image;
157
+ if (!(localVarFormParams instanceof FormData)) {
158
+ const existingParams = localVarFormParams;
159
+ localVarFormParams = new FormData();
160
+ if (existingParams && typeof existingParams === 'object') {
161
+ Object.keys(existingParams).forEach(key => {
162
+ localVarFormParams.append(key, existingParams[key]);
163
+ });
164
+ }
165
+ }
166
+ const imageFiles = Array.isArray(params.image) ? params.image : [params.image];
167
+ const Blob = globalThis.Blob || require('buffer').Blob;
168
+ imageFiles.forEach((f) => {
169
+ localVarFormParams.append('image', new Blob([f.value], {
170
+ type: f.options.contentType
171
+ }), f.options.filename);
172
+ });
120
173
  }
121
- localVarUseFormData = true;
174
+ const queryString = Object.entries(localVarQueryParameters)
175
+ .filter(([, value]) => value !== undefined)
176
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
177
+ .join('&');
178
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
122
179
  let localVarRequestOptions = {
123
180
  method: 'POST',
124
- qs: localVarQueryParameters,
125
- headers: localVarHeaderParams,
126
- uri: localVarPath,
127
- useQuerystring: this._useQuerystring,
128
- agentOptions: { keepAlive: false },
129
- json: true,
181
+ headers: { ...localVarHeaderParams },
130
182
  };
131
- let authenticationPromise = Promise.resolve();
132
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
133
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
134
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
135
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
136
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
137
- return authenticationPromise.then(() => {
138
- if (Object.keys(localVarFormParams).length) {
139
- if (localVarUseFormData) {
140
- localVarRequestOptions.formData = localVarFormParams;
141
- }
142
- else {
143
- localVarRequestOptions.form = localVarFormParams;
144
- }
183
+ let requestOptions = localVarRequestOptions;
184
+ let url = localVarUrl;
185
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
186
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
187
+ url = auth_ApiKeyAuthentication.url;
188
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
189
+ requestOptions = auth_JWTAuthentication.requestOptions;
190
+ url = auth_JWTAuthentication.url;
191
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
192
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
193
+ url = auth_JWTHttpHeaderAuthentication.url;
194
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
195
+ requestOptions = auth_OAuth2.requestOptions;
196
+ url = auth_OAuth2.url;
197
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
198
+ requestOptions = authDefault.requestOptions;
199
+ url = authDefault.url;
200
+ if (localVarFormParams) {
201
+ delete requestOptions.headers['Content-Type'];
202
+ if (localVarFormParams instanceof FormData) {
203
+ // FormData: fetch will handle Content-Type automatically.
204
+ requestOptions.body = localVarFormParams;
145
205
  }
146
- return new Promise((resolve, reject) => {
147
- localVarRequest(localVarRequestOptions, (error, response, body) => {
148
- if (error) {
149
- reject(error);
150
- }
151
- else {
152
- body = models_1.ObjectSerializer.deserialize(body, "TestPretrainedModelResponse");
153
- if (typeof body.success === 'boolean' && !body.success) {
154
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
155
- reject(new Error(body.error || errString));
156
- }
157
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
158
- resolve(body);
159
- }
160
- else {
161
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
162
- reject(errString);
163
- }
164
- }
165
- });
166
- });
167
- });
206
+ else if (Object.keys(localVarFormParams).length > 0) {
207
+ // URL-encoded form
208
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
209
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
210
+ }
211
+ }
212
+ const response = await fetch(url, requestOptions);
213
+ return this.handleResponse(response, 'TestPretrainedModelResponse');
168
214
  }
169
215
  /**
170
216
  * This API is deprecated, use classifySampleV2 instead (`/v1/api/{projectId}/classify/v2/{sampleId}`). Classify a complete file against the current impulse. This will move the sliding window (dependent on the sliding window length and the sliding window increase parameters in the impulse) over the complete file, and classify for every window that is extracted.
@@ -179,9 +225,11 @@ class ClassifyApi {
179
225
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
180
226
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
181
227
  let localVarQueryParameters = {};
182
- let localVarHeaderParams = Object.assign({
183
- 'User-Agent': 'edgeimpulse-api nodejs'
184
- }, this.defaultHeaders);
228
+ let localVarHeaderParams = {
229
+ 'User-Agent': 'edgeimpulse-api nodejs',
230
+ 'Content-Type': 'application/json',
231
+ ...this.defaultHeaders,
232
+ };
185
233
  const produces = ['application/json'];
186
234
  // give precedence to 'application/json'
187
235
  if (produces.indexOf('application/json') >= 0) {
@@ -190,7 +238,7 @@ class ClassifyApi {
190
238
  else {
191
239
  localVarHeaderParams.Accept = produces.join(',');
192
240
  }
193
- let localVarFormParams = {};
241
+ let localVarFormParams;
194
242
  // verify required parameter 'projectId' is not null or undefined
195
243
  if (projectId === null || projectId === undefined) {
196
244
  throw new Error('Required parameter projectId was null or undefined when calling classifySample.');
@@ -205,55 +253,51 @@ class ClassifyApi {
205
253
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
206
254
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
207
255
  }
208
- Object.assign(localVarHeaderParams, options.headers);
209
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
210
- let localVarUseFormData = false;
256
+ localVarHeaderParams = {
257
+ ...localVarHeaderParams,
258
+ ...options.headers,
259
+ ...this.opts.extraHeaders,
260
+ };
261
+ const queryString = Object.entries(localVarQueryParameters)
262
+ .filter(([, value]) => value !== undefined)
263
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
264
+ .join('&');
265
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
211
266
  let localVarRequestOptions = {
212
267
  method: 'GET',
213
- qs: localVarQueryParameters,
214
- headers: localVarHeaderParams,
215
- uri: localVarPath,
216
- useQuerystring: this._useQuerystring,
217
- agentOptions: { keepAlive: false },
218
- json: true,
268
+ headers: { ...localVarHeaderParams },
219
269
  };
220
- let authenticationPromise = Promise.resolve();
221
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
222
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
223
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
224
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
225
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
226
- return authenticationPromise.then(() => {
227
- if (Object.keys(localVarFormParams).length) {
228
- if (localVarUseFormData) {
229
- localVarRequestOptions.formData = localVarFormParams;
230
- }
231
- else {
232
- localVarRequestOptions.form = localVarFormParams;
233
- }
270
+ let requestOptions = localVarRequestOptions;
271
+ let url = localVarUrl;
272
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
273
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
274
+ url = auth_ApiKeyAuthentication.url;
275
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
276
+ requestOptions = auth_JWTAuthentication.requestOptions;
277
+ url = auth_JWTAuthentication.url;
278
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
279
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
280
+ url = auth_JWTHttpHeaderAuthentication.url;
281
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
282
+ requestOptions = auth_OAuth2.requestOptions;
283
+ url = auth_OAuth2.url;
284
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
285
+ requestOptions = authDefault.requestOptions;
286
+ url = authDefault.url;
287
+ if (localVarFormParams) {
288
+ delete requestOptions.headers['Content-Type'];
289
+ if (localVarFormParams instanceof FormData) {
290
+ // FormData: fetch will handle Content-Type automatically.
291
+ requestOptions.body = localVarFormParams;
234
292
  }
235
- return new Promise((resolve, reject) => {
236
- localVarRequest(localVarRequestOptions, (error, response, body) => {
237
- if (error) {
238
- reject(error);
239
- }
240
- else {
241
- body = models_1.ObjectSerializer.deserialize(body, "ClassifySampleResponse");
242
- if (typeof body.success === 'boolean' && !body.success) {
243
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
244
- reject(new Error(body.error || errString));
245
- }
246
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
247
- resolve(body);
248
- }
249
- else {
250
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
251
- reject(errString);
252
- }
253
- }
254
- });
255
- });
256
- });
293
+ else if (Object.keys(localVarFormParams).length > 0) {
294
+ // URL-encoded form
295
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
296
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
297
+ }
298
+ }
299
+ const response = await fetch(url, requestOptions);
300
+ return this.handleResponse(response, 'ClassifySampleResponse');
257
301
  }
258
302
  /**
259
303
  * This API is deprecated, use classifySampleByLearnBlockV2 (`/v1/api/{projectId}/classify/anomaly-gmm/v2/{blockId}/{sampleId}`) instead. Classify a complete file against the specified learn block. This will move the sliding window (dependent on the sliding window length and the sliding window increase parameters in the impulse) over the complete file, and classify for every window that is extracted.
@@ -268,9 +312,11 @@ class ClassifyApi {
268
312
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)))
269
313
  .replace('{' + 'blockId' + '}', encodeURIComponent(String(blockId)));
270
314
  let localVarQueryParameters = {};
271
- let localVarHeaderParams = Object.assign({
272
- 'User-Agent': 'edgeimpulse-api nodejs'
273
- }, this.defaultHeaders);
315
+ let localVarHeaderParams = {
316
+ 'User-Agent': 'edgeimpulse-api nodejs',
317
+ 'Content-Type': 'application/json',
318
+ ...this.defaultHeaders,
319
+ };
274
320
  const produces = ['application/json'];
275
321
  // give precedence to 'application/json'
276
322
  if (produces.indexOf('application/json') >= 0) {
@@ -279,7 +325,7 @@ class ClassifyApi {
279
325
  else {
280
326
  localVarHeaderParams.Accept = produces.join(',');
281
327
  }
282
- let localVarFormParams = {};
328
+ let localVarFormParams;
283
329
  // verify required parameter 'projectId' is not null or undefined
284
330
  if (projectId === null || projectId === undefined) {
285
331
  throw new Error('Required parameter projectId was null or undefined when calling classifySampleByLearnBlock.');
@@ -292,55 +338,51 @@ class ClassifyApi {
292
338
  if (blockId === null || blockId === undefined) {
293
339
  throw new Error('Required parameter blockId was null or undefined when calling classifySampleByLearnBlock.');
294
340
  }
295
- Object.assign(localVarHeaderParams, options.headers);
296
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
297
- let localVarUseFormData = false;
341
+ localVarHeaderParams = {
342
+ ...localVarHeaderParams,
343
+ ...options.headers,
344
+ ...this.opts.extraHeaders,
345
+ };
346
+ const queryString = Object.entries(localVarQueryParameters)
347
+ .filter(([, value]) => value !== undefined)
348
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
349
+ .join('&');
350
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
298
351
  let localVarRequestOptions = {
299
352
  method: 'GET',
300
- qs: localVarQueryParameters,
301
- headers: localVarHeaderParams,
302
- uri: localVarPath,
303
- useQuerystring: this._useQuerystring,
304
- agentOptions: { keepAlive: false },
305
- json: true,
353
+ headers: { ...localVarHeaderParams },
306
354
  };
307
- let authenticationPromise = Promise.resolve();
308
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
309
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
310
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
311
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
312
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
313
- return authenticationPromise.then(() => {
314
- if (Object.keys(localVarFormParams).length) {
315
- if (localVarUseFormData) {
316
- localVarRequestOptions.formData = localVarFormParams;
317
- }
318
- else {
319
- localVarRequestOptions.form = localVarFormParams;
320
- }
355
+ let requestOptions = localVarRequestOptions;
356
+ let url = localVarUrl;
357
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
358
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
359
+ url = auth_ApiKeyAuthentication.url;
360
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
361
+ requestOptions = auth_JWTAuthentication.requestOptions;
362
+ url = auth_JWTAuthentication.url;
363
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
364
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
365
+ url = auth_JWTHttpHeaderAuthentication.url;
366
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
367
+ requestOptions = auth_OAuth2.requestOptions;
368
+ url = auth_OAuth2.url;
369
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
370
+ requestOptions = authDefault.requestOptions;
371
+ url = authDefault.url;
372
+ if (localVarFormParams) {
373
+ delete requestOptions.headers['Content-Type'];
374
+ if (localVarFormParams instanceof FormData) {
375
+ // FormData: fetch will handle Content-Type automatically.
376
+ requestOptions.body = localVarFormParams;
321
377
  }
322
- return new Promise((resolve, reject) => {
323
- localVarRequest(localVarRequestOptions, (error, response, body) => {
324
- if (error) {
325
- reject(error);
326
- }
327
- else {
328
- body = models_1.ObjectSerializer.deserialize(body, "ClassifySampleResponse");
329
- if (typeof body.success === 'boolean' && !body.success) {
330
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
331
- reject(new Error(body.error || errString));
332
- }
333
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
334
- resolve(body);
335
- }
336
- else {
337
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
338
- reject(errString);
339
- }
340
- }
341
- });
342
- });
343
- });
378
+ else if (Object.keys(localVarFormParams).length > 0) {
379
+ // URL-encoded form
380
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
381
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
382
+ }
383
+ }
384
+ const response = await fetch(url, requestOptions);
385
+ return this.handleResponse(response, 'ClassifySampleResponse');
344
386
  }
345
387
  /**
346
388
  * Classify a complete file against the specified learn block. This will move the sliding window (dependent on the sliding window length and the sliding window increase parameters in the impulse) over the complete file, and classify for every window that is extracted. Depending on the size of your file, whether your sample is resampled, and whether the result is cached you\'ll get either the result or a job back. If you receive a job, then wait for the completion of the job, and then call this function again to receive the results. The unoptimized (float32) model is used by default, and classification with an optimized (int8) model can be slower.
@@ -357,9 +399,11 @@ class ClassifyApi {
357
399
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)))
358
400
  .replace('{' + 'blockId' + '}', encodeURIComponent(String(blockId)));
359
401
  let localVarQueryParameters = {};
360
- let localVarHeaderParams = Object.assign({
361
- 'User-Agent': 'edgeimpulse-api nodejs'
362
- }, this.defaultHeaders);
402
+ let localVarHeaderParams = {
403
+ 'User-Agent': 'edgeimpulse-api nodejs',
404
+ 'Content-Type': 'application/json',
405
+ ...this.defaultHeaders,
406
+ };
363
407
  const produces = ['application/json'];
364
408
  // give precedence to 'application/json'
365
409
  if (produces.indexOf('application/json') >= 0) {
@@ -368,7 +412,7 @@ class ClassifyApi {
368
412
  else {
369
413
  localVarHeaderParams.Accept = produces.join(',');
370
414
  }
371
- let localVarFormParams = {};
415
+ let localVarFormParams;
372
416
  // verify required parameter 'projectId' is not null or undefined
373
417
  if (projectId === null || projectId === undefined) {
374
418
  throw new Error('Required parameter projectId was null or undefined when calling classifySampleByLearnBlockV2.');
@@ -387,55 +431,51 @@ class ClassifyApi {
387
431
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.truncateStructuredLabels) !== undefined) {
388
432
  localVarQueryParameters['truncateStructuredLabels'] = models_1.ObjectSerializer.serialize(queryParams.truncateStructuredLabels, "boolean");
389
433
  }
390
- Object.assign(localVarHeaderParams, options.headers);
391
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
392
- let localVarUseFormData = false;
434
+ localVarHeaderParams = {
435
+ ...localVarHeaderParams,
436
+ ...options.headers,
437
+ ...this.opts.extraHeaders,
438
+ };
439
+ const queryString = Object.entries(localVarQueryParameters)
440
+ .filter(([, value]) => value !== undefined)
441
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
442
+ .join('&');
443
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
393
444
  let localVarRequestOptions = {
394
445
  method: 'POST',
395
- qs: localVarQueryParameters,
396
- headers: localVarHeaderParams,
397
- uri: localVarPath,
398
- useQuerystring: this._useQuerystring,
399
- agentOptions: { keepAlive: false },
400
- json: true,
446
+ headers: { ...localVarHeaderParams },
401
447
  };
402
- let authenticationPromise = Promise.resolve();
403
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
404
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
405
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
406
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
407
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
408
- return authenticationPromise.then(() => {
409
- if (Object.keys(localVarFormParams).length) {
410
- if (localVarUseFormData) {
411
- localVarRequestOptions.formData = localVarFormParams;
412
- }
413
- else {
414
- localVarRequestOptions.form = localVarFormParams;
415
- }
448
+ let requestOptions = localVarRequestOptions;
449
+ let url = localVarUrl;
450
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
451
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
452
+ url = auth_ApiKeyAuthentication.url;
453
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
454
+ requestOptions = auth_JWTAuthentication.requestOptions;
455
+ url = auth_JWTAuthentication.url;
456
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
457
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
458
+ url = auth_JWTHttpHeaderAuthentication.url;
459
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
460
+ requestOptions = auth_OAuth2.requestOptions;
461
+ url = auth_OAuth2.url;
462
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
463
+ requestOptions = authDefault.requestOptions;
464
+ url = authDefault.url;
465
+ if (localVarFormParams) {
466
+ delete requestOptions.headers['Content-Type'];
467
+ if (localVarFormParams instanceof FormData) {
468
+ // FormData: fetch will handle Content-Type automatically.
469
+ requestOptions.body = localVarFormParams;
416
470
  }
417
- return new Promise((resolve, reject) => {
418
- localVarRequest(localVarRequestOptions, (error, response, body) => {
419
- if (error) {
420
- reject(error);
421
- }
422
- else {
423
- body = models_1.ObjectSerializer.deserialize(body, "ClassifySampleResponse | StartJobResponse");
424
- if (typeof body.success === 'boolean' && !body.success) {
425
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
426
- reject(new Error(body.error || errString));
427
- }
428
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
429
- resolve(body);
430
- }
431
- else {
432
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
433
- reject(errString);
434
- }
435
- }
436
- });
437
- });
438
- });
471
+ else if (Object.keys(localVarFormParams).length > 0) {
472
+ // URL-encoded form
473
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
474
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
475
+ }
476
+ }
477
+ const response = await fetch(url, requestOptions);
478
+ return this.handleResponse(response, 'ClassifySampleResponse | StartJobResponse');
439
479
  }
440
480
  /**
441
481
  * Classify a complete file against the current impulse, for all given variants. Depending on the size of your file and whether the sample is resampled, you may get a job ID in the response.
@@ -452,9 +492,11 @@ class ClassifyApi {
452
492
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
453
493
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
454
494
  let localVarQueryParameters = {};
455
- let localVarHeaderParams = Object.assign({
456
- 'User-Agent': 'edgeimpulse-api nodejs'
457
- }, this.defaultHeaders);
495
+ let localVarHeaderParams = {
496
+ 'User-Agent': 'edgeimpulse-api nodejs',
497
+ 'Content-Type': 'application/json',
498
+ ...this.defaultHeaders,
499
+ };
458
500
  const produces = ['application/json'];
459
501
  // give precedence to 'application/json'
460
502
  if (produces.indexOf('application/json') >= 0) {
@@ -463,7 +505,7 @@ class ClassifyApi {
463
505
  else {
464
506
  localVarHeaderParams.Accept = produces.join(',');
465
507
  }
466
- let localVarFormParams = {};
508
+ let localVarFormParams;
467
509
  // verify required parameter 'projectId' is not null or undefined
468
510
  if (projectId === null || projectId === undefined) {
469
511
  throw new Error('Required parameter projectId was null or undefined when calling classifySampleForVariants.');
@@ -488,55 +530,51 @@ class ClassifyApi {
488
530
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.truncateStructuredLabels) !== undefined) {
489
531
  localVarQueryParameters['truncateStructuredLabels'] = models_1.ObjectSerializer.serialize(queryParams.truncateStructuredLabels, "boolean");
490
532
  }
491
- Object.assign(localVarHeaderParams, options.headers);
492
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
493
- let localVarUseFormData = false;
533
+ localVarHeaderParams = {
534
+ ...localVarHeaderParams,
535
+ ...options.headers,
536
+ ...this.opts.extraHeaders,
537
+ };
538
+ const queryString = Object.entries(localVarQueryParameters)
539
+ .filter(([, value]) => value !== undefined)
540
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
541
+ .join('&');
542
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
494
543
  let localVarRequestOptions = {
495
544
  method: 'POST',
496
- qs: localVarQueryParameters,
497
- headers: localVarHeaderParams,
498
- uri: localVarPath,
499
- useQuerystring: this._useQuerystring,
500
- agentOptions: { keepAlive: false },
501
- json: true,
545
+ headers: { ...localVarHeaderParams },
502
546
  };
503
- let authenticationPromise = Promise.resolve();
504
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
505
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
506
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
507
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
508
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
509
- return authenticationPromise.then(() => {
510
- if (Object.keys(localVarFormParams).length) {
511
- if (localVarUseFormData) {
512
- localVarRequestOptions.formData = localVarFormParams;
513
- }
514
- else {
515
- localVarRequestOptions.form = localVarFormParams;
516
- }
547
+ let requestOptions = localVarRequestOptions;
548
+ let url = localVarUrl;
549
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
550
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
551
+ url = auth_ApiKeyAuthentication.url;
552
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
553
+ requestOptions = auth_JWTAuthentication.requestOptions;
554
+ url = auth_JWTAuthentication.url;
555
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
556
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
557
+ url = auth_JWTHttpHeaderAuthentication.url;
558
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
559
+ requestOptions = auth_OAuth2.requestOptions;
560
+ url = auth_OAuth2.url;
561
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
562
+ requestOptions = authDefault.requestOptions;
563
+ url = authDefault.url;
564
+ if (localVarFormParams) {
565
+ delete requestOptions.headers['Content-Type'];
566
+ if (localVarFormParams instanceof FormData) {
567
+ // FormData: fetch will handle Content-Type automatically.
568
+ requestOptions.body = localVarFormParams;
517
569
  }
518
- return new Promise((resolve, reject) => {
519
- localVarRequest(localVarRequestOptions, (error, response, body) => {
520
- if (error) {
521
- reject(error);
522
- }
523
- else {
524
- body = models_1.ObjectSerializer.deserialize(body, "ClassifySampleResponseMultipleVariants | StartJobResponse");
525
- if (typeof body.success === 'boolean' && !body.success) {
526
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
527
- reject(new Error(body.error || errString));
528
- }
529
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
530
- resolve(body);
531
- }
532
- else {
533
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
534
- reject(errString);
535
- }
536
- }
537
- });
538
- });
539
- });
570
+ else if (Object.keys(localVarFormParams).length > 0) {
571
+ // URL-encoded form
572
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
573
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
574
+ }
575
+ }
576
+ const response = await fetch(url, requestOptions);
577
+ return this.handleResponse(response, 'ClassifySampleResponseMultipleVariants | StartJobResponse');
540
578
  }
541
579
  /**
542
580
  * Classify a complete file against the current impulse. This will move the sliding window (dependent on the sliding window length and the sliding window increase parameters in the impulse) over the complete file, and classify for every window that is extracted. Depending on the size of your file, whether your sample is resampled, and whether the result is cached you\'ll get either the result or a job back. If you receive a job, then wait for the completion of the job, and then call this function again to receive the results. The unoptimized (float32) model is used by default, and classification with an optimized (int8) model can be slower.
@@ -553,9 +591,11 @@ class ClassifyApi {
553
591
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
554
592
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
555
593
  let localVarQueryParameters = {};
556
- let localVarHeaderParams = Object.assign({
557
- 'User-Agent': 'edgeimpulse-api nodejs'
558
- }, this.defaultHeaders);
594
+ let localVarHeaderParams = {
595
+ 'User-Agent': 'edgeimpulse-api nodejs',
596
+ 'Content-Type': 'application/json',
597
+ ...this.defaultHeaders,
598
+ };
559
599
  const produces = ['application/json'];
560
600
  // give precedence to 'application/json'
561
601
  if (produces.indexOf('application/json') >= 0) {
@@ -564,7 +604,7 @@ class ClassifyApi {
564
604
  else {
565
605
  localVarHeaderParams.Accept = produces.join(',');
566
606
  }
567
- let localVarFormParams = {};
607
+ let localVarFormParams;
568
608
  // verify required parameter 'projectId' is not null or undefined
569
609
  if (projectId === null || projectId === undefined) {
570
610
  throw new Error('Required parameter projectId was null or undefined when calling classifySampleV2.');
@@ -585,55 +625,51 @@ class ClassifyApi {
585
625
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.truncateStructuredLabels) !== undefined) {
586
626
  localVarQueryParameters['truncateStructuredLabels'] = models_1.ObjectSerializer.serialize(queryParams.truncateStructuredLabels, "boolean");
587
627
  }
588
- Object.assign(localVarHeaderParams, options.headers);
589
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
590
- let localVarUseFormData = false;
628
+ localVarHeaderParams = {
629
+ ...localVarHeaderParams,
630
+ ...options.headers,
631
+ ...this.opts.extraHeaders,
632
+ };
633
+ const queryString = Object.entries(localVarQueryParameters)
634
+ .filter(([, value]) => value !== undefined)
635
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
636
+ .join('&');
637
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
591
638
  let localVarRequestOptions = {
592
639
  method: 'POST',
593
- qs: localVarQueryParameters,
594
- headers: localVarHeaderParams,
595
- uri: localVarPath,
596
- useQuerystring: this._useQuerystring,
597
- agentOptions: { keepAlive: false },
598
- json: true,
640
+ headers: { ...localVarHeaderParams },
599
641
  };
600
- let authenticationPromise = Promise.resolve();
601
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
602
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
603
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
604
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
605
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
606
- return authenticationPromise.then(() => {
607
- if (Object.keys(localVarFormParams).length) {
608
- if (localVarUseFormData) {
609
- localVarRequestOptions.formData = localVarFormParams;
610
- }
611
- else {
612
- localVarRequestOptions.form = localVarFormParams;
613
- }
642
+ let requestOptions = localVarRequestOptions;
643
+ let url = localVarUrl;
644
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
645
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
646
+ url = auth_ApiKeyAuthentication.url;
647
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
648
+ requestOptions = auth_JWTAuthentication.requestOptions;
649
+ url = auth_JWTAuthentication.url;
650
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
651
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
652
+ url = auth_JWTHttpHeaderAuthentication.url;
653
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
654
+ requestOptions = auth_OAuth2.requestOptions;
655
+ url = auth_OAuth2.url;
656
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
657
+ requestOptions = authDefault.requestOptions;
658
+ url = authDefault.url;
659
+ if (localVarFormParams) {
660
+ delete requestOptions.headers['Content-Type'];
661
+ if (localVarFormParams instanceof FormData) {
662
+ // FormData: fetch will handle Content-Type automatically.
663
+ requestOptions.body = localVarFormParams;
614
664
  }
615
- return new Promise((resolve, reject) => {
616
- localVarRequest(localVarRequestOptions, (error, response, body) => {
617
- if (error) {
618
- reject(error);
619
- }
620
- else {
621
- body = models_1.ObjectSerializer.deserialize(body, "ClassifySampleResponse | StartJobResponse");
622
- if (typeof body.success === 'boolean' && !body.success) {
623
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
624
- reject(new Error(body.error || errString));
625
- }
626
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
627
- resolve(body);
628
- }
629
- else {
630
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
631
- reject(errString);
632
- }
633
- }
634
- });
635
- });
636
- });
665
+ else if (Object.keys(localVarFormParams).length > 0) {
666
+ // URL-encoded form
667
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
668
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
669
+ }
670
+ }
671
+ const response = await fetch(url, requestOptions);
672
+ return this.handleResponse(response, 'ClassifySampleResponse | StartJobResponse');
637
673
  }
638
674
  /**
639
675
  * Get classify job result, containing the result for the complete testing dataset.
@@ -648,9 +684,11 @@ class ClassifyApi {
648
684
  const localVarPath = this.basePath + '/api/{projectId}/classify/all/result'
649
685
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
650
686
  let localVarQueryParameters = {};
651
- let localVarHeaderParams = Object.assign({
652
- 'User-Agent': 'edgeimpulse-api nodejs'
653
- }, this.defaultHeaders);
687
+ let localVarHeaderParams = {
688
+ 'User-Agent': 'edgeimpulse-api nodejs',
689
+ 'Content-Type': 'application/json',
690
+ ...this.defaultHeaders,
691
+ };
654
692
  const produces = ['application/json'];
655
693
  // give precedence to 'application/json'
656
694
  if (produces.indexOf('application/json') >= 0) {
@@ -659,7 +697,7 @@ class ClassifyApi {
659
697
  else {
660
698
  localVarHeaderParams.Accept = produces.join(',');
661
699
  }
662
- let localVarFormParams = {};
700
+ let localVarFormParams;
663
701
  // verify required parameter 'projectId' is not null or undefined
664
702
  if (projectId === null || projectId === undefined) {
665
703
  throw new Error('Required parameter projectId was null or undefined when calling getClassifyJobResult.');
@@ -676,55 +714,51 @@ class ClassifyApi {
676
714
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.truncateStructuredLabels) !== undefined) {
677
715
  localVarQueryParameters['truncateStructuredLabels'] = models_1.ObjectSerializer.serialize(queryParams.truncateStructuredLabels, "boolean");
678
716
  }
679
- Object.assign(localVarHeaderParams, options.headers);
680
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
681
- let localVarUseFormData = false;
717
+ localVarHeaderParams = {
718
+ ...localVarHeaderParams,
719
+ ...options.headers,
720
+ ...this.opts.extraHeaders,
721
+ };
722
+ const queryString = Object.entries(localVarQueryParameters)
723
+ .filter(([, value]) => value !== undefined)
724
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
725
+ .join('&');
726
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
682
727
  let localVarRequestOptions = {
683
728
  method: 'GET',
684
- qs: localVarQueryParameters,
685
- headers: localVarHeaderParams,
686
- uri: localVarPath,
687
- useQuerystring: this._useQuerystring,
688
- agentOptions: { keepAlive: false },
689
- json: true,
729
+ headers: { ...localVarHeaderParams },
690
730
  };
691
- let authenticationPromise = Promise.resolve();
692
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
693
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
694
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
695
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
696
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
697
- return authenticationPromise.then(() => {
698
- if (Object.keys(localVarFormParams).length) {
699
- if (localVarUseFormData) {
700
- localVarRequestOptions.formData = localVarFormParams;
701
- }
702
- else {
703
- localVarRequestOptions.form = localVarFormParams;
704
- }
731
+ let requestOptions = localVarRequestOptions;
732
+ let url = localVarUrl;
733
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
734
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
735
+ url = auth_ApiKeyAuthentication.url;
736
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
737
+ requestOptions = auth_JWTAuthentication.requestOptions;
738
+ url = auth_JWTAuthentication.url;
739
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
740
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
741
+ url = auth_JWTHttpHeaderAuthentication.url;
742
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
743
+ requestOptions = auth_OAuth2.requestOptions;
744
+ url = auth_OAuth2.url;
745
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
746
+ requestOptions = authDefault.requestOptions;
747
+ url = authDefault.url;
748
+ if (localVarFormParams) {
749
+ delete requestOptions.headers['Content-Type'];
750
+ if (localVarFormParams instanceof FormData) {
751
+ // FormData: fetch will handle Content-Type automatically.
752
+ requestOptions.body = localVarFormParams;
705
753
  }
706
- return new Promise((resolve, reject) => {
707
- localVarRequest(localVarRequestOptions, (error, response, body) => {
708
- if (error) {
709
- reject(error);
710
- }
711
- else {
712
- body = models_1.ObjectSerializer.deserialize(body, "ClassifyJobResponse");
713
- if (typeof body.success === 'boolean' && !body.success) {
714
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
715
- reject(new Error(body.error || errString));
716
- }
717
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
718
- resolve(body);
719
- }
720
- else {
721
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
722
- reject(errString);
723
- }
724
- }
725
- });
726
- });
727
- });
754
+ else if (Object.keys(localVarFormParams).length > 0) {
755
+ // URL-encoded form
756
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
757
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
758
+ }
759
+ }
760
+ const response = await fetch(url, requestOptions);
761
+ return this.handleResponse(response, 'ClassifyJobResponse');
728
762
  }
729
763
  /**
730
764
  * Get classify job result, containing the predictions for a given page.
@@ -756,9 +790,11 @@ class ClassifyApi {
756
790
  const localVarPath = this.basePath + '/api/{projectId}/classify/all/result/page'
757
791
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
758
792
  let localVarQueryParameters = {};
759
- let localVarHeaderParams = Object.assign({
760
- 'User-Agent': 'edgeimpulse-api nodejs'
761
- }, this.defaultHeaders);
793
+ let localVarHeaderParams = {
794
+ 'User-Agent': 'edgeimpulse-api nodejs',
795
+ 'Content-Type': 'application/json',
796
+ ...this.defaultHeaders,
797
+ };
762
798
  const produces = ['application/json'];
763
799
  // give precedence to 'application/json'
764
800
  if (produces.indexOf('application/json') >= 0) {
@@ -767,7 +803,7 @@ class ClassifyApi {
767
803
  else {
768
804
  localVarHeaderParams.Accept = produces.join(',');
769
805
  }
770
- let localVarFormParams = {};
806
+ let localVarFormParams;
771
807
  // verify required parameter 'projectId' is not null or undefined
772
808
  if (projectId === null || projectId === undefined) {
773
809
  throw new Error('Required parameter projectId was null or undefined when calling getClassifyJobResultPage.');
@@ -835,55 +871,51 @@ class ClassifyApi {
835
871
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.maxDate) !== undefined) {
836
872
  localVarQueryParameters['maxDate'] = models_1.ObjectSerializer.serialize(queryParams.maxDate, "Date");
837
873
  }
838
- Object.assign(localVarHeaderParams, options.headers);
839
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
840
- let localVarUseFormData = false;
874
+ localVarHeaderParams = {
875
+ ...localVarHeaderParams,
876
+ ...options.headers,
877
+ ...this.opts.extraHeaders,
878
+ };
879
+ const queryString = Object.entries(localVarQueryParameters)
880
+ .filter(([, value]) => value !== undefined)
881
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
882
+ .join('&');
883
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
841
884
  let localVarRequestOptions = {
842
885
  method: 'GET',
843
- qs: localVarQueryParameters,
844
- headers: localVarHeaderParams,
845
- uri: localVarPath,
846
- useQuerystring: this._useQuerystring,
847
- agentOptions: { keepAlive: false },
848
- json: true,
886
+ headers: { ...localVarHeaderParams },
849
887
  };
850
- let authenticationPromise = Promise.resolve();
851
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
852
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
853
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
854
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
855
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
856
- return authenticationPromise.then(() => {
857
- if (Object.keys(localVarFormParams).length) {
858
- if (localVarUseFormData) {
859
- localVarRequestOptions.formData = localVarFormParams;
860
- }
861
- else {
862
- localVarRequestOptions.form = localVarFormParams;
863
- }
888
+ let requestOptions = localVarRequestOptions;
889
+ let url = localVarUrl;
890
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
891
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
892
+ url = auth_ApiKeyAuthentication.url;
893
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
894
+ requestOptions = auth_JWTAuthentication.requestOptions;
895
+ url = auth_JWTAuthentication.url;
896
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
897
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
898
+ url = auth_JWTHttpHeaderAuthentication.url;
899
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
900
+ requestOptions = auth_OAuth2.requestOptions;
901
+ url = auth_OAuth2.url;
902
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
903
+ requestOptions = authDefault.requestOptions;
904
+ url = authDefault.url;
905
+ if (localVarFormParams) {
906
+ delete requestOptions.headers['Content-Type'];
907
+ if (localVarFormParams instanceof FormData) {
908
+ // FormData: fetch will handle Content-Type automatically.
909
+ requestOptions.body = localVarFormParams;
864
910
  }
865
- return new Promise((resolve, reject) => {
866
- localVarRequest(localVarRequestOptions, (error, response, body) => {
867
- if (error) {
868
- reject(error);
869
- }
870
- else {
871
- body = models_1.ObjectSerializer.deserialize(body, "ClassifyJobResponsePage");
872
- if (typeof body.success === 'boolean' && !body.success) {
873
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
874
- reject(new Error(body.error || errString));
875
- }
876
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
877
- resolve(body);
878
- }
879
- else {
880
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
881
- reject(errString);
882
- }
883
- }
884
- });
885
- });
886
- });
911
+ else if (Object.keys(localVarFormParams).length > 0) {
912
+ // URL-encoded form
913
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
914
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
915
+ }
916
+ }
917
+ const response = await fetch(url, requestOptions);
918
+ return this.handleResponse(response, 'ClassifyJobResponsePage');
887
919
  }
888
920
  /**
889
921
  * Get metrics, calculated during a classify all job, for all available model variants. This is experimental and may change in the future.
@@ -895,9 +927,11 @@ class ClassifyApi {
895
927
  const localVarPath = this.basePath + '/api/{projectId}/classify/all/metrics'
896
928
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
897
929
  let localVarQueryParameters = {};
898
- let localVarHeaderParams = Object.assign({
899
- 'User-Agent': 'edgeimpulse-api nodejs'
900
- }, this.defaultHeaders);
930
+ let localVarHeaderParams = {
931
+ 'User-Agent': 'edgeimpulse-api nodejs',
932
+ 'Content-Type': 'application/json',
933
+ ...this.defaultHeaders,
934
+ };
901
935
  const produces = ['application/json'];
902
936
  // give precedence to 'application/json'
903
937
  if (produces.indexOf('application/json') >= 0) {
@@ -906,7 +940,7 @@ class ClassifyApi {
906
940
  else {
907
941
  localVarHeaderParams.Accept = produces.join(',');
908
942
  }
909
- let localVarFormParams = {};
943
+ let localVarFormParams;
910
944
  // verify required parameter 'projectId' is not null or undefined
911
945
  if (projectId === null || projectId === undefined) {
912
946
  throw new Error('Required parameter projectId was null or undefined when calling getClassifyMetricsAllVariants.');
@@ -914,55 +948,51 @@ class ClassifyApi {
914
948
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
915
949
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
916
950
  }
917
- Object.assign(localVarHeaderParams, options.headers);
918
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
919
- let localVarUseFormData = false;
951
+ localVarHeaderParams = {
952
+ ...localVarHeaderParams,
953
+ ...options.headers,
954
+ ...this.opts.extraHeaders,
955
+ };
956
+ const queryString = Object.entries(localVarQueryParameters)
957
+ .filter(([, value]) => value !== undefined)
958
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
959
+ .join('&');
960
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
920
961
  let localVarRequestOptions = {
921
962
  method: 'GET',
922
- qs: localVarQueryParameters,
923
- headers: localVarHeaderParams,
924
- uri: localVarPath,
925
- useQuerystring: this._useQuerystring,
926
- agentOptions: { keepAlive: false },
927
- json: true,
963
+ headers: { ...localVarHeaderParams },
928
964
  };
929
- let authenticationPromise = Promise.resolve();
930
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
931
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
932
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
933
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
934
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
935
- return authenticationPromise.then(() => {
936
- if (Object.keys(localVarFormParams).length) {
937
- if (localVarUseFormData) {
938
- localVarRequestOptions.formData = localVarFormParams;
939
- }
940
- else {
941
- localVarRequestOptions.form = localVarFormParams;
942
- }
965
+ let requestOptions = localVarRequestOptions;
966
+ let url = localVarUrl;
967
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
968
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
969
+ url = auth_ApiKeyAuthentication.url;
970
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
971
+ requestOptions = auth_JWTAuthentication.requestOptions;
972
+ url = auth_JWTAuthentication.url;
973
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
974
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
975
+ url = auth_JWTHttpHeaderAuthentication.url;
976
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
977
+ requestOptions = auth_OAuth2.requestOptions;
978
+ url = auth_OAuth2.url;
979
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
980
+ requestOptions = authDefault.requestOptions;
981
+ url = authDefault.url;
982
+ if (localVarFormParams) {
983
+ delete requestOptions.headers['Content-Type'];
984
+ if (localVarFormParams instanceof FormData) {
985
+ // FormData: fetch will handle Content-Type automatically.
986
+ requestOptions.body = localVarFormParams;
943
987
  }
944
- return new Promise((resolve, reject) => {
945
- localVarRequest(localVarRequestOptions, (error, response, body) => {
946
- if (error) {
947
- reject(error);
948
- }
949
- else {
950
- body = models_1.ObjectSerializer.deserialize(body, "MetricsAllVariantsResponse");
951
- if (typeof body.success === 'boolean' && !body.success) {
952
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
953
- reject(new Error(body.error || errString));
954
- }
955
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
956
- resolve(body);
957
- }
958
- else {
959
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
960
- reject(errString);
961
- }
962
- }
963
- });
964
- });
965
- });
988
+ else if (Object.keys(localVarFormParams).length > 0) {
989
+ // URL-encoded form
990
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
991
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
992
+ }
993
+ }
994
+ const response = await fetch(url, requestOptions);
995
+ return this.handleResponse(response, 'MetricsAllVariantsResponse');
966
996
  }
967
997
  /**
968
998
  * Get raw sample features for a particular window. This is only available after a live classification job has completed and raw features have been cached.
@@ -979,9 +1009,11 @@ class ClassifyApi {
979
1009
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)))
980
1010
  .replace('{' + 'windowIndex' + '}', encodeURIComponent(String(windowIndex)));
981
1011
  let localVarQueryParameters = {};
982
- let localVarHeaderParams = Object.assign({
983
- 'User-Agent': 'edgeimpulse-api nodejs'
984
- }, this.defaultHeaders);
1012
+ let localVarHeaderParams = {
1013
+ 'User-Agent': 'edgeimpulse-api nodejs',
1014
+ 'Content-Type': 'application/json',
1015
+ ...this.defaultHeaders,
1016
+ };
985
1017
  const produces = ['application/json'];
986
1018
  // give precedence to 'application/json'
987
1019
  if (produces.indexOf('application/json') >= 0) {
@@ -990,7 +1022,7 @@ class ClassifyApi {
990
1022
  else {
991
1023
  localVarHeaderParams.Accept = produces.join(',');
992
1024
  }
993
- let localVarFormParams = {};
1025
+ let localVarFormParams;
994
1026
  // verify required parameter 'projectId' is not null or undefined
995
1027
  if (projectId === null || projectId === undefined) {
996
1028
  throw new Error('Required parameter projectId was null or undefined when calling getSampleWindowFromCache.');
@@ -1009,55 +1041,51 @@ class ClassifyApi {
1009
1041
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.truncateStructuredLabels) !== undefined) {
1010
1042
  localVarQueryParameters['truncateStructuredLabels'] = models_1.ObjectSerializer.serialize(queryParams.truncateStructuredLabels, "boolean");
1011
1043
  }
1012
- Object.assign(localVarHeaderParams, options.headers);
1013
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1014
- let localVarUseFormData = false;
1044
+ localVarHeaderParams = {
1045
+ ...localVarHeaderParams,
1046
+ ...options.headers,
1047
+ ...this.opts.extraHeaders,
1048
+ };
1049
+ const queryString = Object.entries(localVarQueryParameters)
1050
+ .filter(([, value]) => value !== undefined)
1051
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1052
+ .join('&');
1053
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1015
1054
  let localVarRequestOptions = {
1016
1055
  method: 'GET',
1017
- qs: localVarQueryParameters,
1018
- headers: localVarHeaderParams,
1019
- uri: localVarPath,
1020
- useQuerystring: this._useQuerystring,
1021
- agentOptions: { keepAlive: false },
1022
- json: true,
1056
+ headers: { ...localVarHeaderParams },
1023
1057
  };
1024
- let authenticationPromise = Promise.resolve();
1025
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1026
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1027
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1028
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1029
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1030
- return authenticationPromise.then(() => {
1031
- if (Object.keys(localVarFormParams).length) {
1032
- if (localVarUseFormData) {
1033
- localVarRequestOptions.formData = localVarFormParams;
1034
- }
1035
- else {
1036
- localVarRequestOptions.form = localVarFormParams;
1037
- }
1058
+ let requestOptions = localVarRequestOptions;
1059
+ let url = localVarUrl;
1060
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1061
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1062
+ url = auth_ApiKeyAuthentication.url;
1063
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1064
+ requestOptions = auth_JWTAuthentication.requestOptions;
1065
+ url = auth_JWTAuthentication.url;
1066
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1067
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1068
+ url = auth_JWTHttpHeaderAuthentication.url;
1069
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1070
+ requestOptions = auth_OAuth2.requestOptions;
1071
+ url = auth_OAuth2.url;
1072
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1073
+ requestOptions = authDefault.requestOptions;
1074
+ url = authDefault.url;
1075
+ if (localVarFormParams) {
1076
+ delete requestOptions.headers['Content-Type'];
1077
+ if (localVarFormParams instanceof FormData) {
1078
+ // FormData: fetch will handle Content-Type automatically.
1079
+ requestOptions.body = localVarFormParams;
1038
1080
  }
1039
- return new Promise((resolve, reject) => {
1040
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1041
- if (error) {
1042
- reject(error);
1043
- }
1044
- else {
1045
- body = models_1.ObjectSerializer.deserialize(body, "GetSampleResponse");
1046
- if (typeof body.success === 'boolean' && !body.success) {
1047
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1048
- reject(new Error(body.error || errString));
1049
- }
1050
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1051
- resolve(body);
1052
- }
1053
- else {
1054
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1055
- reject(errString);
1056
- }
1057
- }
1058
- });
1059
- });
1060
- });
1081
+ else if (Object.keys(localVarFormParams).length > 0) {
1082
+ // URL-encoded form
1083
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1084
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1085
+ }
1086
+ }
1087
+ const response = await fetch(url, requestOptions);
1088
+ return this.handleResponse(response, 'GetSampleResponse');
1061
1089
  }
1062
1090
  }
1063
1091
  exports.ClassifyApi = ClassifyApi;