@edgeiq/edgeiq-api-js 1.0.0
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.
- package/README.md +74 -0
- package/dist/__tests__/auth.test.d.ts +1 -0
- package/dist/__tests__/auth.test.js +110 -0
- package/dist/__tests__/companies.test.d.ts +1 -0
- package/dist/__tests__/companies.test.js +196 -0
- package/dist/__tests__/deviceTypes.test.d.ts +1 -0
- package/dist/__tests__/deviceTypes.test.js +172 -0
- package/dist/__tests__/devices.test.d.ts +1 -0
- package/dist/__tests__/devices.test.js +204 -0
- package/dist/__tests__/ingestors.test.d.ts +1 -0
- package/dist/__tests__/ingestors.test.js +172 -0
- package/dist/__tests__/integrations.test.d.ts +1 -0
- package/dist/__tests__/integrations.test.js +192 -0
- package/dist/__tests__/pollableAttributes.test.d.ts +1 -0
- package/dist/__tests__/pollableAttributes.test.js +172 -0
- package/dist/__tests__/rules.test.d.ts +1 -0
- package/dist/__tests__/rules.test.js +172 -0
- package/dist/__tests__/testConstants.d.ts +7 -0
- package/dist/__tests__/testConstants.js +14 -0
- package/dist/__tests__/translators.test.d.ts +1 -0
- package/dist/__tests__/translators.test.js +172 -0
- package/dist/__tests__/users.test.d.ts +1 -0
- package/dist/__tests__/users.test.js +208 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.js +95 -0
- package/dist/bulkResponses/index.d.ts +8 -0
- package/dist/bulkResponses/index.js +124 -0
- package/dist/bulkResponses/models.d.ts +43 -0
- package/dist/bulkResponses/models.js +2 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.js +224 -0
- package/dist/commands/models.d.ts +28 -0
- package/dist/commands/models.js +2 -0
- package/dist/companies/index.d.ts +7 -0
- package/dist/companies/index.js +198 -0
- package/dist/companies/models.d.ts +94 -0
- package/dist/companies/models.js +2 -0
- package/dist/constants.d.ts +122 -0
- package/dist/constants.js +138 -0
- package/dist/core/ModelClass.d.ts +13 -0
- package/dist/core/ModelClass.js +19 -0
- package/dist/core/handleResponseError.d.ts +2 -0
- package/dist/core/handleResponseError.js +162 -0
- package/dist/core/index.d.ts +19 -0
- package/dist/core/index.js +63 -0
- package/dist/deviceConfigs/index.d.ts +9 -0
- package/dist/deviceConfigs/index.js +224 -0
- package/dist/deviceConfigs/models.d.ts +38 -0
- package/dist/deviceConfigs/models.js +2 -0
- package/dist/deviceLocationObservations/index.d.ts +5 -0
- package/dist/deviceLocationObservations/index.js +189 -0
- package/dist/deviceLocationObservations/models.d.ts +26 -0
- package/dist/deviceLocationObservations/models.js +2 -0
- package/dist/deviceTemplates/index.d.ts +9 -0
- package/dist/deviceTemplates/index.js +226 -0
- package/dist/deviceTemplates/models.d.ts +36 -0
- package/dist/deviceTemplates/models.js +2 -0
- package/dist/deviceTransferRequests/index.d.ts +7 -0
- package/dist/deviceTransferRequests/index.js +198 -0
- package/dist/deviceTransferRequests/models.d.ts +26 -0
- package/dist/deviceTransferRequests/models.js +2 -0
- package/dist/deviceTypes/index.d.ts +19 -0
- package/dist/deviceTypes/index.js +440 -0
- package/dist/deviceTypes/models.d.ts +104 -0
- package/dist/deviceTypes/models.js +2 -0
- package/dist/devices/index.d.ts +18 -0
- package/dist/devices/index.js +431 -0
- package/dist/devices/models.d.ts +113 -0
- package/dist/devices/models.js +2 -0
- package/dist/downstreamSystems/index.d.ts +7 -0
- package/dist/downstreamSystems/index.js +198 -0
- package/dist/downstreamSystems/models.d.ts +17 -0
- package/dist/downstreamSystems/models.js +2 -0
- package/dist/escrowDevices/index.d.ts +9 -0
- package/dist/escrowDevices/index.js +224 -0
- package/dist/escrowDevices/models.d.ts +20 -0
- package/dist/escrowDevices/models.js +2 -0
- package/dist/example/index.d.ts +1 -0
- package/dist/example/index.js +5 -0
- package/dist/filtersParser.d.ts +5 -0
- package/dist/filtersParser.js +43 -0
- package/dist/gatewayCommands/index.d.ts +10 -0
- package/dist/gatewayCommands/index.js +261 -0
- package/dist/gatewayCommands/models.d.ts +41 -0
- package/dist/gatewayCommands/models.js +2 -0
- package/dist/helpers.d.ts +3 -0
- package/dist/helpers.js +11 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +92 -0
- package/dist/ingestors/index.d.ts +9 -0
- package/dist/ingestors/index.js +224 -0
- package/dist/ingestors/models.d.ts +37 -0
- package/dist/ingestors/models.js +2 -0
- package/dist/integrations/index.d.ts +9 -0
- package/dist/integrations/index.js +306 -0
- package/dist/integrations/models.d.ts +61 -0
- package/dist/integrations/models.js +2 -0
- package/dist/models/index.d.ts +1893 -0
- package/dist/models/index.js +2 -0
- package/dist/models.d.ts +66 -0
- package/dist/models.js +2 -0
- package/dist/pollableAttributes/index.d.ts +7 -0
- package/dist/pollableAttributes/index.js +198 -0
- package/dist/pollableAttributes/models.d.ts +28 -0
- package/dist/pollableAttributes/models.js +2 -0
- package/dist/regions/index.d.ts +5 -0
- package/dist/regions/index.js +173 -0
- package/dist/regions/models.d.ts +17 -0
- package/dist/regions/models.js +2 -0
- package/dist/reports/index.d.ts +8 -0
- package/dist/reports/index.js +199 -0
- package/dist/reports/models.d.ts +25 -0
- package/dist/reports/models.js +2 -0
- package/dist/rules/index.d.ts +9 -0
- package/dist/rules/index.js +224 -0
- package/dist/rules/models.d.ts +108 -0
- package/dist/rules/models.js +2 -0
- package/dist/secrets/index.d.ts +5 -0
- package/dist/secrets/index.js +173 -0
- package/dist/secrets/models.d.ts +16 -0
- package/dist/secrets/models.js +2 -0
- package/dist/softwareUpdates/index.d.ts +9 -0
- package/dist/softwareUpdates/index.js +224 -0
- package/dist/softwareUpdates/models.d.ts +22 -0
- package/dist/softwareUpdates/models.js +2 -0
- package/dist/systemCommandJobs/index.d.ts +5 -0
- package/dist/systemCommandJobs/index.js +173 -0
- package/dist/systemCommandJobs/models.d.ts +32 -0
- package/dist/systemCommandJobs/models.js +2 -0
- package/dist/systemCommands/index.d.ts +7 -0
- package/dist/systemCommands/index.js +198 -0
- package/dist/systemCommands/models.d.ts +32 -0
- package/dist/systemCommands/models.js +2 -0
- package/dist/testConstants.d.ts +42 -0
- package/dist/testConstants.js +214 -0
- package/dist/translators/index.d.ts +9 -0
- package/dist/translators/index.js +224 -0
- package/dist/translators/models.d.ts +21 -0
- package/dist/translators/models.js +2 -0
- package/dist/userTypes/index.d.ts +7 -0
- package/dist/userTypes/index.js +198 -0
- package/dist/userTypes/models.d.ts +79 -0
- package/dist/userTypes/models.js +2 -0
- package/dist/users/index.d.ts +10 -0
- package/dist/users/index.js +252 -0
- package/dist/users/models.d.ts +41 -0
- package/dist/users/models.js +2 -0
- package/package.json +56 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultPagination = exports.MethodsActions = exports.Endpoints = exports.BaseEndpoints = exports.getAttachMessage = exports.ErrorParts = exports.ResponseErrorsMessages = exports.ResponseErrorsNames = exports.Errors = exports.defaultBaseUrl = void 0;
|
|
4
|
+
exports.defaultBaseUrl = 'https://api.edgeiq.io/api/v1/platform/';
|
|
5
|
+
exports.Errors = {
|
|
6
|
+
noInstance: 'Use EdgeIQAPI.init() instead',
|
|
7
|
+
instanceInitiated: 'Instantiation failed: EdgeIQAPI has already been initiated.',
|
|
8
|
+
};
|
|
9
|
+
exports.ResponseErrorsNames = {
|
|
10
|
+
disconnected: 'No connection error',
|
|
11
|
+
unauthorized: 'Unauthorization error',
|
|
12
|
+
timeout: 'Timeout error',
|
|
13
|
+
credentials: 'Credentials error',
|
|
14
|
+
issueCommand: 'Issue command error',
|
|
15
|
+
csvUpload: 'CSV upload error',
|
|
16
|
+
fileUpload: 'File upload error',
|
|
17
|
+
duplicatedDevice: 'Duplicated device unique id',
|
|
18
|
+
deviceCharacters: 'Invalid unique id characters',
|
|
19
|
+
duplicateKey: 'Duplicate key error',
|
|
20
|
+
uniqueConstraint: 'Unique constraint error',
|
|
21
|
+
deviceConfig: 'Device config error',
|
|
22
|
+
unEditableIntegration: 'Uneditable Integration type',
|
|
23
|
+
integrationMissinValues: 'Integration missing required values',
|
|
24
|
+
createError: 'Unable to create resource',
|
|
25
|
+
unexpected: 'Unexpected error',
|
|
26
|
+
deviceLocationMissingValues: 'Device location observation missing required values',
|
|
27
|
+
};
|
|
28
|
+
exports.ResponseErrorsMessages = {
|
|
29
|
+
disconnected: 'Please check your internet connection. If your internet appear to be fine, our services may be undergoing maintenance. Please try again in a few minutes.',
|
|
30
|
+
unauthorized: 'You are not authorized to perform this action. Logging you out. Login to refresh your session permissions.',
|
|
31
|
+
timeout: 'Your session has expired. Please login to resume your session.',
|
|
32
|
+
credentials: 'There was a problem checking these credentials. Please try again.',
|
|
33
|
+
noUser: 'That username wasn’t found in the system.',
|
|
34
|
+
invalidPassword: 'Invalid password',
|
|
35
|
+
token: 'Invalid token.',
|
|
36
|
+
notFound: 'not found',
|
|
37
|
+
issueCommand: 'There was an error issuing this command. Please try again.',
|
|
38
|
+
csvUpload: 'There was an error performing this CSV operation. Please try again.',
|
|
39
|
+
fileUpload: 'There was an error uploading files for this software package. Please try again.',
|
|
40
|
+
deviceId: function (unique_id) {
|
|
41
|
+
return "A Device with unique id '" + unique_id + "' already exists";
|
|
42
|
+
},
|
|
43
|
+
deviceCharacters: 'A unique ID can only contain lower case letters, numbers or special characters -, : or _',
|
|
44
|
+
emailUsed: function (email) {
|
|
45
|
+
return "A user with email '" + email + "' already exists";
|
|
46
|
+
},
|
|
47
|
+
uniqueConstraint: function (model) {
|
|
48
|
+
return "A " + model + " with the same key already exists";
|
|
49
|
+
},
|
|
50
|
+
unEditableIntegration: function (type) {
|
|
51
|
+
return "Intregration of type " + type + " cannot be edited";
|
|
52
|
+
},
|
|
53
|
+
integrationMissinValues: function (type, values) {
|
|
54
|
+
return "The " + (values.length === 1 ? 'value' : 'values') + " " + values.join(', ') + " " + (values.length === 1 ? 'is' : 'are') + " required for integration of type: " + type;
|
|
55
|
+
},
|
|
56
|
+
unexpected: 'Unexpected error has ocurred',
|
|
57
|
+
};
|
|
58
|
+
exports.ErrorParts = {
|
|
59
|
+
deviceExists: 'A Device with unique id',
|
|
60
|
+
uniqueIdError: "\"unique_id\" can only contain lower case letters, numbers or the special charaters \"-\", \":\", or \"_\"",
|
|
61
|
+
duplicateKey: 'duplicate key error collection',
|
|
62
|
+
uniqueConstraint: 'duplicate key value violates unique constraint',
|
|
63
|
+
};
|
|
64
|
+
var getAttachMessage = function (model, action, baseModel) {
|
|
65
|
+
return model + " " + (action === 'attach' ? 'attached to' : 'detached from') + " " + baseModel;
|
|
66
|
+
};
|
|
67
|
+
exports.getAttachMessage = getAttachMessage;
|
|
68
|
+
exports.BaseEndpoints = {
|
|
69
|
+
auth: 'user',
|
|
70
|
+
bulkResponse: 'bulk_responses',
|
|
71
|
+
command: 'commands',
|
|
72
|
+
company: 'companies',
|
|
73
|
+
deviceConfig: 'device_configs',
|
|
74
|
+
deviceTransferRequest: 'device_transfer_requests',
|
|
75
|
+
deviceTemplate: 'device_templates',
|
|
76
|
+
deviceType: 'device_types',
|
|
77
|
+
device: 'devices',
|
|
78
|
+
deviceLocationObservation: 'device_location_observations',
|
|
79
|
+
downstreamSystem: 'downstream_systems',
|
|
80
|
+
escrowDevice: 'escrow_devices',
|
|
81
|
+
file: 'files',
|
|
82
|
+
gatewayCommand: 'gateway_commands',
|
|
83
|
+
gatewayCsvUpload: 'gateway_csv_upload',
|
|
84
|
+
ingestor: 'ingestors',
|
|
85
|
+
integration: 'integrations',
|
|
86
|
+
pollableAttribute: 'pollable_attributes',
|
|
87
|
+
region: 'regions',
|
|
88
|
+
report: 'reports',
|
|
89
|
+
rule: 'rules',
|
|
90
|
+
secret: 'secrets',
|
|
91
|
+
softwareUpdate: 'software_updates',
|
|
92
|
+
systemCommand: 'system_commands',
|
|
93
|
+
systemCommandJob: 'system_command_jobs',
|
|
94
|
+
translator: 'translators',
|
|
95
|
+
userType: 'user_types',
|
|
96
|
+
user: 'users',
|
|
97
|
+
};
|
|
98
|
+
exports.Endpoints = {
|
|
99
|
+
me: 'me',
|
|
100
|
+
login: exports.BaseEndpoints.auth + "/authenticate",
|
|
101
|
+
apiTokenReset: exports.BaseEndpoints.auth + "/api_token_reset",
|
|
102
|
+
passwordReset: exports.BaseEndpoints.auth + "/password_reset",
|
|
103
|
+
bulkResponse: "" + exports.BaseEndpoints.bulkResponse,
|
|
104
|
+
command: "" + exports.BaseEndpoints.command,
|
|
105
|
+
company: "" + exports.BaseEndpoints.company,
|
|
106
|
+
deviceConfig: "" + exports.BaseEndpoints.deviceConfig,
|
|
107
|
+
deviceTransferRequest: "" + exports.BaseEndpoints.deviceTransferRequest,
|
|
108
|
+
deviceTemplate: "" + exports.BaseEndpoints.deviceTemplate,
|
|
109
|
+
deviceType: "" + exports.BaseEndpoints.deviceType,
|
|
110
|
+
device: "" + exports.BaseEndpoints.device,
|
|
111
|
+
deviceLocationObservation: "" + exports.BaseEndpoints.deviceLocationObservation,
|
|
112
|
+
downstreamSystem: "" + exports.BaseEndpoints.downstreamSystem,
|
|
113
|
+
escrowDevice: "" + exports.BaseEndpoints.user,
|
|
114
|
+
gatewayCommand: "" + exports.BaseEndpoints.gatewayCommand,
|
|
115
|
+
ingestor: "" + exports.BaseEndpoints.ingestor,
|
|
116
|
+
integration: "" + exports.BaseEndpoints.integration,
|
|
117
|
+
pollableAttribute: "" + exports.BaseEndpoints.pollableAttribute,
|
|
118
|
+
region: "" + exports.BaseEndpoints.region,
|
|
119
|
+
report: "" + exports.BaseEndpoints.report,
|
|
120
|
+
rule: "" + exports.BaseEndpoints.rule,
|
|
121
|
+
secret: "" + exports.BaseEndpoints.secret,
|
|
122
|
+
softwareUpdate: "" + exports.BaseEndpoints.softwareUpdate,
|
|
123
|
+
systemCommand: "" + exports.BaseEndpoints.systemCommand,
|
|
124
|
+
systemCommandJob: "" + exports.BaseEndpoints.systemCommandJob,
|
|
125
|
+
translator: "" + exports.BaseEndpoints.translator,
|
|
126
|
+
userType: "" + exports.BaseEndpoints.report,
|
|
127
|
+
user: "" + exports.BaseEndpoints.user,
|
|
128
|
+
};
|
|
129
|
+
exports.MethodsActions = {
|
|
130
|
+
post: 'creating',
|
|
131
|
+
put: 'updating',
|
|
132
|
+
delete: 'deleting',
|
|
133
|
+
get: 'loading',
|
|
134
|
+
};
|
|
135
|
+
exports.DefaultPagination = {
|
|
136
|
+
page: 1,
|
|
137
|
+
itemsPerPage: 12,
|
|
138
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { PaginationFilter } from '../models';
|
|
3
|
+
export interface BaseModelInterface<TClass, TClassInput, TFilters, TPaginatedClass> {
|
|
4
|
+
create(item: TClassInput): Promise<TClass>;
|
|
5
|
+
list(filters?: TFilters, pagination?: PaginationFilter): Promise<TPaginatedClass>;
|
|
6
|
+
getOneById(id: string): Promise<TClass>;
|
|
7
|
+
delete(id: string): Promise<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class BaseModelClass {
|
|
10
|
+
static getAxios(): AxiosInstance;
|
|
11
|
+
static logAction(message: string): void;
|
|
12
|
+
static logError(error: string): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseModelClass = void 0;
|
|
4
|
+
var _1 = require(".");
|
|
5
|
+
var BaseModelClass = (function () {
|
|
6
|
+
function BaseModelClass() {
|
|
7
|
+
}
|
|
8
|
+
BaseModelClass.getAxios = function () {
|
|
9
|
+
return _1.EdgeIQAPI.getAxios();
|
|
10
|
+
};
|
|
11
|
+
BaseModelClass.logAction = function (message) {
|
|
12
|
+
_1.EdgeIQAPI.logAction(message);
|
|
13
|
+
};
|
|
14
|
+
BaseModelClass.logError = function (error) {
|
|
15
|
+
_1.EdgeIQAPI.logError(error);
|
|
16
|
+
};
|
|
17
|
+
return BaseModelClass;
|
|
18
|
+
}());
|
|
19
|
+
exports.BaseModelClass = BaseModelClass;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleResponseError = void 0;
|
|
4
|
+
var constants_1 = require("../constants");
|
|
5
|
+
var handleResponseError = function (error) {
|
|
6
|
+
if (!error.response) {
|
|
7
|
+
return handleDisconnected();
|
|
8
|
+
}
|
|
9
|
+
var status = error.response.status;
|
|
10
|
+
var url = error.response.request.path;
|
|
11
|
+
if ((status === 401 || status === 404) && url.indexOf(constants_1.Endpoints.login) >= 0) {
|
|
12
|
+
return handleCredentials(error);
|
|
13
|
+
}
|
|
14
|
+
if (status === 401 && url.indexOf(constants_1.Endpoints.apiTokenReset) >= 0) {
|
|
15
|
+
return handleCredentials(error);
|
|
16
|
+
}
|
|
17
|
+
if (status === 400 && url.indexOf(constants_1.Endpoints.passwordReset) >= 0) {
|
|
18
|
+
return handlePasswordReset(error);
|
|
19
|
+
}
|
|
20
|
+
if (status === 401) {
|
|
21
|
+
return handleSessionTimeout();
|
|
22
|
+
}
|
|
23
|
+
if (status === 403) {
|
|
24
|
+
return handleUnauthorized();
|
|
25
|
+
}
|
|
26
|
+
return handleOtherErrors(error);
|
|
27
|
+
};
|
|
28
|
+
exports.handleResponseError = handleResponseError;
|
|
29
|
+
var handleUnauthorized = function () {
|
|
30
|
+
return Promise.reject(createError(constants_1.ResponseErrorsMessages.unauthorized, constants_1.ResponseErrorsNames.unauthorized));
|
|
31
|
+
};
|
|
32
|
+
var handleDisconnected = function () {
|
|
33
|
+
return Promise.reject(createError(constants_1.ResponseErrorsMessages.disconnected, constants_1.ResponseErrorsNames.disconnected));
|
|
34
|
+
};
|
|
35
|
+
var handleSessionTimeout = function () {
|
|
36
|
+
return Promise.reject(createError(constants_1.ResponseErrorsMessages.timeout, constants_1.ResponseErrorsNames.timeout));
|
|
37
|
+
};
|
|
38
|
+
var handleCredentials = function (error) {
|
|
39
|
+
var _a;
|
|
40
|
+
var uiErrorMessage = constants_1.ResponseErrorsMessages.credentials;
|
|
41
|
+
var responseErrorMessage = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data.messages[0];
|
|
42
|
+
if (responseErrorMessage &&
|
|
43
|
+
responseErrorMessage.toLowerCase() === constants_1.ResponseErrorsMessages.notFound) {
|
|
44
|
+
uiErrorMessage = constants_1.ResponseErrorsMessages.noUser;
|
|
45
|
+
}
|
|
46
|
+
else if (responseErrorMessage === constants_1.ResponseErrorsMessages.invalidPassword) {
|
|
47
|
+
uiErrorMessage = constants_1.ResponseErrorsMessages.invalidPassword;
|
|
48
|
+
}
|
|
49
|
+
return Promise.reject(createError(uiErrorMessage, constants_1.ResponseErrorsNames.credentials));
|
|
50
|
+
};
|
|
51
|
+
var handlePasswordReset = function (error) {
|
|
52
|
+
var _a, _b, _c;
|
|
53
|
+
if ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) {
|
|
54
|
+
var errorMessage = error.response.data.error.toLowerCase();
|
|
55
|
+
if (errorMessage === constants_1.ResponseErrorsMessages.token.toLocaleLowerCase()) {
|
|
56
|
+
return Promise.reject(constants_1.ResponseErrorsMessages.token);
|
|
57
|
+
}
|
|
58
|
+
else if (errorMessage ===
|
|
59
|
+
constants_1.ResponseErrorsMessages.invalidPassword.toLocaleLowerCase()) {
|
|
60
|
+
return Promise.reject(constants_1.ResponseErrorsMessages.invalidPassword);
|
|
61
|
+
}
|
|
62
|
+
return Promise.reject(createError((_c = error.response.data.messages) === null || _c === void 0 ? void 0 : _c.join('\n'), constants_1.ResponseErrorsNames.credentials));
|
|
63
|
+
}
|
|
64
|
+
return Promise.reject(createError(constants_1.ResponseErrorsMessages.unexpected, constants_1.ResponseErrorsNames.unexpected));
|
|
65
|
+
};
|
|
66
|
+
var handleOtherErrors = function (error) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
var path = null;
|
|
69
|
+
var model = null;
|
|
70
|
+
var action = '';
|
|
71
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.request) &&
|
|
72
|
+
error.response.request.path &&
|
|
73
|
+
error.response.config &&
|
|
74
|
+
error.response.config.method) {
|
|
75
|
+
path = error.response.request.path.split('platform/')[1];
|
|
76
|
+
model = path.split('?')[0];
|
|
77
|
+
model = model.split('/')[0];
|
|
78
|
+
}
|
|
79
|
+
switch ((_b = error.response) === null || _b === void 0 ? void 0 : _b.config.method) {
|
|
80
|
+
case 'put':
|
|
81
|
+
if (model === constants_1.BaseEndpoints.deviceConfig &&
|
|
82
|
+
error.response.data.messages) {
|
|
83
|
+
error.response.data = error.response.data.messages.join('\n');
|
|
84
|
+
return Promise.reject(createError(error.response.data, constants_1.ResponseErrorsNames.deviceConfig));
|
|
85
|
+
}
|
|
86
|
+
action = constants_1.MethodsActions.put;
|
|
87
|
+
break;
|
|
88
|
+
case 'post':
|
|
89
|
+
if (path.indexOf(constants_1.BaseEndpoints.gatewayCommand) !== -1) {
|
|
90
|
+
return Promise.reject(createError(constants_1.ResponseErrorsMessages.issueCommand, constants_1.ResponseErrorsNames.issueCommand));
|
|
91
|
+
}
|
|
92
|
+
else if (path.indexOf(constants_1.BaseEndpoints.gatewayCsvUpload) !== -1) {
|
|
93
|
+
return Promise.reject(createError(constants_1.ResponseErrorsMessages.csvUpload, constants_1.ResponseErrorsNames.csvUpload));
|
|
94
|
+
}
|
|
95
|
+
else if (path.indexOf(constants_1.BaseEndpoints.file) !== -1) {
|
|
96
|
+
return Promise.reject(createError(constants_1.ResponseErrorsMessages.fileUpload, constants_1.ResponseErrorsNames.fileUpload));
|
|
97
|
+
}
|
|
98
|
+
if (error.response.data.messages) {
|
|
99
|
+
var text = error.response.data.messages[0];
|
|
100
|
+
if (model === constants_1.BaseEndpoints.device) {
|
|
101
|
+
if (text.indexOf(constants_1.ErrorParts.deviceExists) !== -1) {
|
|
102
|
+
error.response.data = createError(text, constants_1.ResponseErrorsNames.duplicatedDevice);
|
|
103
|
+
}
|
|
104
|
+
else if (error.response.data.messages[0] === constants_1.ErrorParts.uniqueIdError) {
|
|
105
|
+
error.response.data = createError(constants_1.ResponseErrorsMessages.deviceCharacters, constants_1.ResponseErrorsNames.deviceCharacters);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (model === constants_1.BaseEndpoints.deviceConfig) {
|
|
109
|
+
error.response.data = createError(error.response.data.messages.join('\n'), constants_1.ResponseErrorsNames.deviceConfig);
|
|
110
|
+
}
|
|
111
|
+
else if (text.indexOf(constants_1.ErrorParts.uniqueConstraint) !== -1) {
|
|
112
|
+
error.response.data = createError(constants_1.ResponseErrorsMessages.uniqueConstraint(model), constants_1.ResponseErrorsNames.uniqueConstraint);
|
|
113
|
+
}
|
|
114
|
+
else if (text.indexOf(constants_1.ErrorParts.duplicateKey) !== -1) {
|
|
115
|
+
error.response.data = createError(text, constants_1.ResponseErrorsNames.duplicateKey);
|
|
116
|
+
}
|
|
117
|
+
else if (error.response.data.error === constants_1.ResponseErrorsNames.createError) {
|
|
118
|
+
error.response.data = createError(error.response.data.messages.join('\n'), constants_1.ResponseErrorsNames.createError);
|
|
119
|
+
}
|
|
120
|
+
return Promise.reject(error.response.data);
|
|
121
|
+
}
|
|
122
|
+
action = constants_1.MethodsActions.post;
|
|
123
|
+
break;
|
|
124
|
+
case 'delete':
|
|
125
|
+
action = constants_1.MethodsActions.delete;
|
|
126
|
+
break;
|
|
127
|
+
case 'get':
|
|
128
|
+
action = constants_1.MethodsActions.get;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
var errorMessage = mapModelError(model, action);
|
|
132
|
+
return Promise.reject(createError(errorMessage, constants_1.ResponseErrorsNames.unexpected));
|
|
133
|
+
};
|
|
134
|
+
function mapModelError(path, action) {
|
|
135
|
+
var models = {
|
|
136
|
+
devices: 'device ',
|
|
137
|
+
user_types: 'role ',
|
|
138
|
+
users: 'user ',
|
|
139
|
+
rules: 'policy ',
|
|
140
|
+
integrations: 'integration ',
|
|
141
|
+
device_types: 'device type ',
|
|
142
|
+
device_errors: 'device error ',
|
|
143
|
+
device_configs: 'device config ',
|
|
144
|
+
software_updates: 'software update ',
|
|
145
|
+
device_ha_groups: 'device HA group ',
|
|
146
|
+
reports: 'report ',
|
|
147
|
+
notifications: 'alert ',
|
|
148
|
+
gateway_commands: 'command ',
|
|
149
|
+
bulk_responses: 'bulk job ',
|
|
150
|
+
companies: 'account ',
|
|
151
|
+
};
|
|
152
|
+
if (models[path]) {
|
|
153
|
+
return "There was an error " + action + " " + models[path] + " data.";
|
|
154
|
+
}
|
|
155
|
+
return 'An error has occurred.';
|
|
156
|
+
}
|
|
157
|
+
function createError(message, name) {
|
|
158
|
+
return {
|
|
159
|
+
message: message,
|
|
160
|
+
name: name,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare type EdgeIQAPIOptions = {
|
|
3
|
+
url?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
enableLogging?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare class EdgeIQAPI {
|
|
8
|
+
private static url;
|
|
9
|
+
private static timeout;
|
|
10
|
+
private static enableLogging;
|
|
11
|
+
private static axios;
|
|
12
|
+
private static instance;
|
|
13
|
+
constructor();
|
|
14
|
+
static init(options?: EdgeIQAPIOptions): void;
|
|
15
|
+
static getAxios(): AxiosInstance;
|
|
16
|
+
static setSessionToken(token: string): void;
|
|
17
|
+
static logAction(message: string): void;
|
|
18
|
+
static logError(error: string): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EdgeIQAPI = void 0;
|
|
7
|
+
var axios_1 = __importDefault(require("axios"));
|
|
8
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
var constants_1 = require("../constants");
|
|
10
|
+
var handleResponseError_1 = require("./handleResponseError");
|
|
11
|
+
var EdgeIQAPI = (function () {
|
|
12
|
+
function EdgeIQAPI() {
|
|
13
|
+
throw new Error(constants_1.Errors.noInstance);
|
|
14
|
+
}
|
|
15
|
+
EdgeIQAPI.init = function (options) {
|
|
16
|
+
if (EdgeIQAPI.instance) {
|
|
17
|
+
throw new Error(constants_1.Errors.instanceInitiated);
|
|
18
|
+
}
|
|
19
|
+
if (options === null || options === void 0 ? void 0 : options.url) {
|
|
20
|
+
EdgeIQAPI.url = options.url;
|
|
21
|
+
}
|
|
22
|
+
if (options === null || options === void 0 ? void 0 : options.timeout) {
|
|
23
|
+
EdgeIQAPI.timeout = options.timeout;
|
|
24
|
+
}
|
|
25
|
+
if (options === null || options === void 0 ? void 0 : options.enableLogging) {
|
|
26
|
+
EdgeIQAPI.enableLogging = options.enableLogging;
|
|
27
|
+
}
|
|
28
|
+
EdgeIQAPI.axios = axios_1.default.create({
|
|
29
|
+
baseURL: EdgeIQAPI.url,
|
|
30
|
+
timeout: EdgeIQAPI.timeout,
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
EdgeIQAPI.axios.interceptors.request.use(function (config) {
|
|
36
|
+
return config;
|
|
37
|
+
}, function (error) { return Promise.reject(error); });
|
|
38
|
+
EdgeIQAPI.axios.interceptors.response.use(function (response) {
|
|
39
|
+
return response;
|
|
40
|
+
}, function (error) {
|
|
41
|
+
return (0, handleResponseError_1.handleResponseError)(error);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
EdgeIQAPI.getAxios = function () {
|
|
45
|
+
return EdgeIQAPI.axios;
|
|
46
|
+
};
|
|
47
|
+
EdgeIQAPI.setSessionToken = function (token) {
|
|
48
|
+
EdgeIQAPI.axios.defaults.headers.Authorization = token;
|
|
49
|
+
};
|
|
50
|
+
EdgeIQAPI.logAction = function (message) {
|
|
51
|
+
if (EdgeIQAPI.enableLogging) {
|
|
52
|
+
console.info(chalk_1.default.blue(message));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
EdgeIQAPI.logError = function (error) {
|
|
56
|
+
console.info(chalk_1.default.red(error));
|
|
57
|
+
};
|
|
58
|
+
EdgeIQAPI.url = constants_1.defaultBaseUrl;
|
|
59
|
+
EdgeIQAPI.timeout = 30000;
|
|
60
|
+
EdgeIQAPI.enableLogging = false;
|
|
61
|
+
return EdgeIQAPI;
|
|
62
|
+
}());
|
|
63
|
+
exports.EdgeIQAPI = EdgeIQAPI;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseModelInterface } from '../core/ModelClass';
|
|
2
|
+
import { BulkActionResponse } from '../models';
|
|
3
|
+
import { DeviceConfig, DeviceConfigInput, DeviceConfigsFilters, PaginatedDeviceConfigs } from './models';
|
|
4
|
+
interface DeviceConfigsInterface extends BaseModelInterface<DeviceConfig, DeviceConfigInput, DeviceConfigsFilters, PaginatedDeviceConfigs> {
|
|
5
|
+
update(deviceConfig: DeviceConfig): Promise<DeviceConfig>;
|
|
6
|
+
deleteMultiple(ids: string[]): Promise<BulkActionResponse>;
|
|
7
|
+
}
|
|
8
|
+
export declare const DeviceConfigs: DeviceConfigsInterface;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.DeviceConfigs = void 0;
|
|
55
|
+
var __1 = require("..");
|
|
56
|
+
var constants_1 = require("../constants");
|
|
57
|
+
var ModelClass_1 = require("../core/ModelClass");
|
|
58
|
+
var filtersParser_1 = require("../filtersParser");
|
|
59
|
+
var helpers_1 = require("../helpers");
|
|
60
|
+
exports.DeviceConfigs = (function (_super) {
|
|
61
|
+
__extends(class_1, _super);
|
|
62
|
+
function class_1() {
|
|
63
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
64
|
+
}
|
|
65
|
+
class_1.create = function (deviceConfig) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var axios, data, result, error_1;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
_a.trys.push([0, 2, , 3]);
|
|
72
|
+
this.logAction("Creating device config with name: " + deviceConfig.name);
|
|
73
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
74
|
+
data = JSON.stringify(deviceConfig);
|
|
75
|
+
return [4, axios.post(constants_1.Endpoints.deviceConfig, data)];
|
|
76
|
+
case 1:
|
|
77
|
+
result = _a.sent();
|
|
78
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
79
|
+
case 2:
|
|
80
|
+
error_1 = _a.sent();
|
|
81
|
+
if ((0, helpers_1.isApiError)(error_1)) {
|
|
82
|
+
throw error_1;
|
|
83
|
+
}
|
|
84
|
+
throw error_1;
|
|
85
|
+
case 3: return [2];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
class_1.update = function (deviceConfig) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var axios, data, result, error_2;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
_a.trys.push([0, 2, , 3]);
|
|
97
|
+
this.logAction("Updating device config with unique ID: " + deviceConfig._id);
|
|
98
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
99
|
+
data = JSON.stringify(deviceConfig);
|
|
100
|
+
return [4, axios.put(constants_1.Endpoints.deviceConfig + "/" + deviceConfig._id, data)];
|
|
101
|
+
case 1:
|
|
102
|
+
result = _a.sent();
|
|
103
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
104
|
+
case 2:
|
|
105
|
+
error_2 = _a.sent();
|
|
106
|
+
if ((0, helpers_1.isApiError)(error_2)) {
|
|
107
|
+
throw error_2;
|
|
108
|
+
}
|
|
109
|
+
throw error_2;
|
|
110
|
+
case 3: return [2];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
class_1.list = function (filters, pagination) {
|
|
116
|
+
var _a, _b, _c, _d;
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var axios, result, error_3;
|
|
119
|
+
return __generator(this, function (_e) {
|
|
120
|
+
switch (_e.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
_e.trys.push([0, 2, , 3]);
|
|
123
|
+
this.logAction("Listing device configs with following filters: " + (filters !== null && filters !== void 0 ? filters : '{}') + ".\n And pagination " + (pagination !== null && pagination !== void 0 ? pagination : '{}'));
|
|
124
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
125
|
+
return [4, axios.get(constants_1.Endpoints.deviceConfig, {
|
|
126
|
+
params: (0, filtersParser_1.parseFilters)(filters, pagination),
|
|
127
|
+
})];
|
|
128
|
+
case 1:
|
|
129
|
+
result = _e.sent();
|
|
130
|
+
return [2, {
|
|
131
|
+
deviceConfigs: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
|
|
132
|
+
pagination: {
|
|
133
|
+
page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
|
|
134
|
+
itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
|
|
135
|
+
total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
|
|
136
|
+
},
|
|
137
|
+
}];
|
|
138
|
+
case 2:
|
|
139
|
+
error_3 = _e.sent();
|
|
140
|
+
if ((0, helpers_1.isApiError)(error_3)) {
|
|
141
|
+
throw error_3;
|
|
142
|
+
}
|
|
143
|
+
throw error_3;
|
|
144
|
+
case 3: return [2];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
class_1.getOneById = function (id) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var axios, result, error_4;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
_a.trys.push([0, 2, , 3]);
|
|
156
|
+
this.logAction("Getting device config with id: " + id);
|
|
157
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
158
|
+
return [4, axios.get(constants_1.Endpoints.deviceConfig + "/" + id)];
|
|
159
|
+
case 1:
|
|
160
|
+
result = _a.sent();
|
|
161
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
162
|
+
case 2:
|
|
163
|
+
error_4 = _a.sent();
|
|
164
|
+
if ((0, helpers_1.isApiError)(error_4)) {
|
|
165
|
+
throw error_4;
|
|
166
|
+
}
|
|
167
|
+
throw error_4;
|
|
168
|
+
case 3: return [2];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
class_1.delete = function (id) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var axios, error_5;
|
|
176
|
+
return __generator(this, function (_a) {
|
|
177
|
+
switch (_a.label) {
|
|
178
|
+
case 0:
|
|
179
|
+
_a.trys.push([0, 2, , 3]);
|
|
180
|
+
this.logAction("Deleting device config with id " + id);
|
|
181
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
182
|
+
return [4, axios.delete(constants_1.Endpoints.deviceConfig + "/" + id)];
|
|
183
|
+
case 1:
|
|
184
|
+
_a.sent();
|
|
185
|
+
return [2, (0, helpers_1.getReturnDeleteMessage)('device config')];
|
|
186
|
+
case 2:
|
|
187
|
+
error_5 = _a.sent();
|
|
188
|
+
if ((0, helpers_1.isApiError)(error_5)) {
|
|
189
|
+
throw error_5;
|
|
190
|
+
}
|
|
191
|
+
throw error_5;
|
|
192
|
+
case 3: return [2];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
class_1.deleteMultiple = function (ids) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var axios, result, error_6;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
_a.trys.push([0, 2, , 3]);
|
|
204
|
+
this.logAction("Deleting device configs with id " + ids.join(', '));
|
|
205
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
206
|
+
return [4, axios.delete(constants_1.Endpoints.deviceConfig + "/bulk", {
|
|
207
|
+
data: { ids: ids },
|
|
208
|
+
})];
|
|
209
|
+
case 1:
|
|
210
|
+
result = _a.sent();
|
|
211
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
212
|
+
case 2:
|
|
213
|
+
error_6 = _a.sent();
|
|
214
|
+
if ((0, helpers_1.isApiError)(error_6)) {
|
|
215
|
+
throw error_6;
|
|
216
|
+
}
|
|
217
|
+
throw error_6;
|
|
218
|
+
case 3: return [2];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
return class_1;
|
|
224
|
+
}(ModelClass_1.BaseModelClass));
|