@edgeiq/edgeiq-api-js 1.9.7 → 1.9.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.
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { EdgeIQAPI } from '..';
11
- import { Endpoints } from '../constants';
11
+ import { Endpoints, FILE_UPLOAD_TIMEOUT } from '../constants';
12
12
  import { BaseModelClass } from '../core/ModelClass';
13
13
  import { parseFilters } from '../filtersParser';
14
14
  import { getReturnDeleteMessage, isApiError, parseResourceError, } from '../helpers';
@@ -158,13 +158,14 @@ export const Companies = class extends BaseModelClass {
158
158
  return __awaiter(this, void 0, void 0, function* () {
159
159
  try {
160
160
  this.logAction(`Updating logo of company with id ${id}`);
161
- const axios = EdgeIQAPI.getAxios(true);
161
+ const axios = EdgeIQAPI.getAxios();
162
162
  const form = new FormData();
163
163
  form.append('file', logo);
164
164
  const result = yield axios.post(`${Endpoints.company}/${id}/logo`, form, {
165
165
  headers: {
166
166
  'Content-Type': 'multipart/form-data',
167
167
  },
168
+ timeout: FILE_UPLOAD_TIMEOUT,
168
169
  });
169
170
  return result === null || result === void 0 ? void 0 : result.data;
170
171
  }
@@ -168,3 +168,4 @@ export declare const DefaultPagination: {
168
168
  page: number;
169
169
  itemsPerPage: number;
170
170
  };
171
+ export declare const FILE_UPLOAD_TIMEOUT = 300000;
package/dist/constants.js CHANGED
@@ -170,3 +170,4 @@ export const DefaultPagination = {
170
170
  page: 1,
171
171
  itemsPerPage: 12,
172
172
  };
173
+ export const FILE_UPLOAD_TIMEOUT = 300000;
@@ -12,7 +12,7 @@ export declare class EdgeIQAPI {
12
12
  private static instance;
13
13
  constructor();
14
14
  static init(options?: EdgeIQAPIOptions): void;
15
- static getAxios(forFileUpload?: boolean): AxiosInstance;
15
+ static getAxios(): AxiosInstance;
16
16
  static setSessionToken(token: string): void;
17
17
  static logAction(message: string): void;
18
18
  static logError(error: string): void;
@@ -35,10 +35,7 @@ export class EdgeIQAPI {
35
35
  return handleResponseError(error);
36
36
  });
37
37
  }
38
- static getAxios(forFileUpload = false) {
39
- if (forFileUpload) {
40
- return Object.assign(Object.assign({}, EdgeIQAPI.axios), { defaults: Object.assign(Object.assign({}, EdgeIQAPI.axios.defaults), { timeout: 300000 }) });
41
- }
38
+ static getAxios() {
42
39
  return EdgeIQAPI.axios;
43
40
  }
44
41
  static setSessionToken(token) {
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { EdgeIQAPI, } from '..';
11
- import { Endpoints, getAttachMessage } from '../constants';
11
+ import { Endpoints, FILE_UPLOAD_TIMEOUT, getAttachMessage } from '../constants';
12
12
  import { BaseModelClass } from '../core/ModelClass';
13
13
  import { parseFilters } from '../filtersParser';
14
14
  import { getReturnDeleteMessage, isApiError } from '../helpers';
@@ -338,13 +338,14 @@ export const Devices = class extends BaseModelClass {
338
338
  return __awaiter(this, void 0, void 0, function* () {
339
339
  try {
340
340
  this.logAction(`Uploading CSV file with devices`);
341
- const axios = EdgeIQAPI.getAxios(true);
341
+ const axios = EdgeIQAPI.getAxios();
342
342
  const form = new FormData();
343
343
  form.append('gateway_csv_upload', file);
344
344
  const result = yield axios.post(`${Endpoints.device}/csv_bulk_upload`, form, {
345
345
  headers: {
346
346
  'Content-Type': 'multipart/form-data',
347
347
  },
348
+ timeout: FILE_UPLOAD_TIMEOUT,
348
349
  });
349
350
  return result === null || result === void 0 ? void 0 : result.data;
350
351
  }
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { EdgeIQAPI } from '..';
11
- import { Endpoints } from '../constants';
11
+ import { Endpoints, FILE_UPLOAD_TIMEOUT } from '../constants';
12
12
  import { BaseModelClass } from '../core/ModelClass';
13
13
  import { parseFilters } from '../filtersParser';
14
14
  import { getReturnDeleteMessage, isApiError } from '../helpers';
@@ -184,13 +184,14 @@ export const DiscoveredDevices = class extends BaseModelClass {
184
184
  return __awaiter(this, void 0, void 0, function* () {
185
185
  try {
186
186
  this.logAction(`Uploading CSV bulk promotion file`);
187
- const axios = EdgeIQAPI.getAxios(true);
187
+ const axios = EdgeIQAPI.getAxios();
188
188
  const form = new FormData();
189
189
  form.append('csv_upload', file);
190
190
  const result = yield axios.post(`${Endpoints.discoveredDevice}/csv_bulk_upload_promote`, form, {
191
191
  headers: {
192
192
  'Content-Type': 'multipart/form-data',
193
193
  },
194
+ timeout: FILE_UPLOAD_TIMEOUT,
194
195
  });
195
196
  return result === null || result === void 0 ? void 0 : result.data;
196
197
  }
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { EdgeIQAPI } from '..';
11
- import { Endpoints } from '../constants';
11
+ import { Endpoints, FILE_UPLOAD_TIMEOUT } from '../constants';
12
12
  import { BaseModelClass } from '../core/ModelClass';
13
13
  import { parseFilters } from '../filtersParser';
14
14
  import { getReturnDeleteMessage, isApiError } from '../helpers';
@@ -109,13 +109,14 @@ export const EIQFiles = class extends BaseModelClass {
109
109
  return __awaiter(this, void 0, void 0, function* () {
110
110
  try {
111
111
  this.logAction(`Uploading file to device`);
112
- const axios = EdgeIQAPI.getAxios(true);
112
+ const axios = EdgeIQAPI.getAxios();
113
113
  const form = new FormData();
114
114
  form.append('file', file);
115
115
  const result = yield axios.post(`${Endpoints.file}/${id}`, form, {
116
116
  headers: {
117
117
  'Content-Type': 'multipart/form-data',
118
118
  },
119
+ timeout: FILE_UPLOAD_TIMEOUT,
119
120
  });
120
121
  return result === null || result === void 0 ? void 0 : result.data;
121
122
  }
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { EdgeIQAPI } from '..';
11
- import { Endpoints, getAttachMessage } from '../constants';
11
+ import { Endpoints, FILE_UPLOAD_TIMEOUT, getAttachMessage } from '../constants';
12
12
  import { BaseModelClass } from '../core/ModelClass';
13
13
  import { parseFilters } from '../filtersParser';
14
14
  import { getReturnDeleteMessage, isApiError } from '../helpers';
@@ -208,13 +208,14 @@ export const SoftwareUpdates = class extends BaseModelClass {
208
208
  return __awaiter(this, void 0, void 0, function* () {
209
209
  try {
210
210
  this.logAction(`Uploading file to software update`);
211
- const axios = EdgeIQAPI.getAxios(true);
211
+ const axios = EdgeIQAPI.getAxios();
212
212
  const form = new FormData();
213
213
  files.forEach((file) => form.append('files[]', file));
214
214
  const result = yield axios.post(`${Endpoints.softwareUpdate}/${id}/upload`, form, {
215
215
  headers: {
216
216
  'Content-Type': 'multipart/form-data',
217
217
  },
218
+ timeout: FILE_UPLOAD_TIMEOUT,
218
219
  });
219
220
  return result === null || result === void 0 ? void 0 : result.data;
220
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeiq/edgeiq-api-js",
3
- "version": "1.9.7",
3
+ "version": "1.9.8",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",