@edgeiq/edgeiq-api-js 1.2.1 → 1.2.4
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/dist/__tests__/command.test.d.ts +1 -0
- package/dist/__tests__/command.test.js +201 -0
- package/dist/__tests__/deviceErrors.test.d.ts +1 -0
- package/dist/__tests__/deviceErrors.test.js +72 -0
- package/dist/commands/index.d.ts +5 -1
- package/dist/commands/index.js +120 -0
- package/dist/commands/models.d.ts +11 -1
- package/dist/commands/models.js +13 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +3 -0
- package/dist/deviceErrors/index.d.ts +8 -0
- package/dist/deviceErrors/index.js +124 -0
- package/dist/deviceErrors/models.d.ts +19 -0
- package/dist/deviceErrors/models.js +2 -0
- package/dist/deviceTypes/index.d.ts +2 -1
- package/dist/deviceTypes/index.js +24 -0
- package/dist/devices/index.d.ts +2 -1
- package/dist/devices/index.js +29 -5
- package/dist/discoveredDevices/index.js +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/stats/index.d.ts +1 -0
- package/dist/stats/index.js +30 -6
- package/dist/testConstants.d.ts +2 -1
- package/dist/testConstants.js +9 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var __1 = require("..");
|
|
40
|
+
var __2 = require("..");
|
|
41
|
+
var constants_1 = require("../constants");
|
|
42
|
+
var helpers_1 = require("../helpers");
|
|
43
|
+
var testConstants_1 = require("../testConstants");
|
|
44
|
+
describe('Commands', function () {
|
|
45
|
+
__1.EdgeIQAPI.init();
|
|
46
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
var result;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0: return [4, __2.Authentication.login(testConstants_1.TestAuth.username, testConstants_1.TestAuth.pass)];
|
|
51
|
+
case 1:
|
|
52
|
+
result = _a.sent();
|
|
53
|
+
expect(result.session_token).not.toBeNull();
|
|
54
|
+
return [2];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}); });
|
|
58
|
+
var targetDevice;
|
|
59
|
+
var targetDeviceType;
|
|
60
|
+
it('Given a device and device type', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
var deviceOptions, dresult, deviceTypeOptions, dtresult;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
deviceOptions = JSON.parse(JSON.stringify(testConstants_1.TestDevice));
|
|
66
|
+
deviceOptions.unique_id = 'js_sdk_command_test_device';
|
|
67
|
+
return [4, __1.Devices.create(deviceOptions)];
|
|
68
|
+
case 1:
|
|
69
|
+
dresult = _a.sent();
|
|
70
|
+
expect(dresult._id).not.toBeNull();
|
|
71
|
+
targetDevice = dresult;
|
|
72
|
+
deviceTypeOptions = JSON.parse(JSON.stringify(testConstants_1.TestDeviceType));
|
|
73
|
+
deviceTypeOptions.name = 'js_sdk_command_test_device_type';
|
|
74
|
+
return [4, __1.DeviceTypes.create(testConstants_1.TestDeviceType)];
|
|
75
|
+
case 2:
|
|
76
|
+
dtresult = _a.sent();
|
|
77
|
+
expect(dtresult._id).not.toBeNull();
|
|
78
|
+
targetDeviceType = dtresult;
|
|
79
|
+
return [2];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}); });
|
|
83
|
+
var createdCommand;
|
|
84
|
+
it('Creates a command', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
+
var result;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0: return [4, __1.Commands.create(testConstants_1.TestCommand)];
|
|
89
|
+
case 1:
|
|
90
|
+
result = _a.sent();
|
|
91
|
+
expect(result._id).not.toBeNull();
|
|
92
|
+
expect(result.name).toBe(testConstants_1.TestCommand.name);
|
|
93
|
+
expect(result.sender_type).toBe(testConstants_1.TestCommand.sender_type);
|
|
94
|
+
createdCommand = result;
|
|
95
|
+
return [2];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}); });
|
|
99
|
+
it('Lists commands', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
var filters, result, firstCommand;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
filters = {
|
|
105
|
+
name: {
|
|
106
|
+
operator: 'eq',
|
|
107
|
+
value: testConstants_1.TestCommand.name,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
return [4, __1.Commands.list(filters)];
|
|
111
|
+
case 1:
|
|
112
|
+
result = _a.sent();
|
|
113
|
+
expect(result.commands).toBeDefined();
|
|
114
|
+
expect(result.commands).toBeInstanceOf(Array);
|
|
115
|
+
expect(result.commands).toHaveLength(1);
|
|
116
|
+
firstCommand = result.commands[0];
|
|
117
|
+
expect(firstCommand === null || firstCommand === void 0 ? void 0 : firstCommand.name).toEqual(testConstants_1.TestCommand.name);
|
|
118
|
+
expect(result.pagination.page).toBe(constants_1.DefaultPagination.page);
|
|
119
|
+
expect(result.pagination.total).toBe(1);
|
|
120
|
+
expect(result.pagination.itemsPerPage).toBe(constants_1.DefaultPagination.itemsPerPage);
|
|
121
|
+
return [2];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); });
|
|
125
|
+
it('Attaches to a device', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
+
var assignResult, deviceCommands, removeResult;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0: return [4, __1.Commands.assignToDevice(createdCommand._id, targetDevice._id)];
|
|
130
|
+
case 1:
|
|
131
|
+
assignResult = _a.sent();
|
|
132
|
+
expect(assignResult).toEqual((0, constants_1.getAttachMessage)('Command', 'attach', 'device'));
|
|
133
|
+
return [4, __1.Devices.getCommands(targetDevice._id)];
|
|
134
|
+
case 2:
|
|
135
|
+
deviceCommands = _a.sent();
|
|
136
|
+
expect(deviceCommands).toHaveLength(1);
|
|
137
|
+
return [4, __1.Commands.removeFromDevice(createdCommand._id, targetDevice._id)];
|
|
138
|
+
case 3:
|
|
139
|
+
removeResult = _a.sent();
|
|
140
|
+
expect(removeResult).toEqual((0, constants_1.getAttachMessage)('Command', 'detach', 'device'));
|
|
141
|
+
return [4, __1.Devices.getCommands(targetDevice._id)];
|
|
142
|
+
case 4:
|
|
143
|
+
deviceCommands = _a.sent();
|
|
144
|
+
expect(deviceCommands).toHaveLength(0);
|
|
145
|
+
return [2];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}); });
|
|
149
|
+
it('Attaches to a device type', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
150
|
+
var assignResult, deviceTypeCommands, removeResult;
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0: return [4, __1.Commands.assignToDeviceType(createdCommand._id, targetDeviceType._id)];
|
|
154
|
+
case 1:
|
|
155
|
+
assignResult = _a.sent();
|
|
156
|
+
expect(assignResult).toEqual((0, constants_1.getAttachMessage)('Command', 'attach', 'device type'));
|
|
157
|
+
return [4, __1.DeviceTypes.getCommands(targetDeviceType._id)];
|
|
158
|
+
case 2:
|
|
159
|
+
deviceTypeCommands = _a.sent();
|
|
160
|
+
expect(deviceTypeCommands).toHaveLength(1);
|
|
161
|
+
return [4, __1.Commands.removeFromDeviceType(createdCommand._id, targetDeviceType._id)];
|
|
162
|
+
case 3:
|
|
163
|
+
removeResult = _a.sent();
|
|
164
|
+
expect(removeResult).toEqual((0, constants_1.getAttachMessage)('Command', 'detach', 'device type'));
|
|
165
|
+
return [4, __1.DeviceTypes.getCommands(targetDeviceType._id)];
|
|
166
|
+
case 4:
|
|
167
|
+
deviceTypeCommands = _a.sent();
|
|
168
|
+
expect(deviceTypeCommands).toHaveLength(0);
|
|
169
|
+
return [2];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}); });
|
|
173
|
+
it('Deletes a command', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var result;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0: return [4, __1.Commands.delete(createdCommand._id)];
|
|
178
|
+
case 1:
|
|
179
|
+
result = _a.sent();
|
|
180
|
+
expect(result).toBe((0, helpers_1.getReturnDeleteMessage)('command'));
|
|
181
|
+
return [2];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}); });
|
|
185
|
+
it('cleans up', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
186
|
+
var dresult, dtresult;
|
|
187
|
+
return __generator(this, function (_a) {
|
|
188
|
+
switch (_a.label) {
|
|
189
|
+
case 0: return [4, __1.Devices.delete(targetDevice._id)];
|
|
190
|
+
case 1:
|
|
191
|
+
dresult = _a.sent();
|
|
192
|
+
return [4, __1.DeviceTypes.delete(targetDeviceType._id)];
|
|
193
|
+
case 2:
|
|
194
|
+
dtresult = _a.sent();
|
|
195
|
+
expect(dresult).toBe((0, helpers_1.getReturnDeleteMessage)('device'));
|
|
196
|
+
expect(dtresult).toBe((0, helpers_1.getReturnDeleteMessage)('device type'));
|
|
197
|
+
return [2];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); });
|
|
201
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var __1 = require("..");
|
|
40
|
+
var __2 = require("..");
|
|
41
|
+
var deviceErrors_1 = require("../deviceErrors");
|
|
42
|
+
var testConstants_1 = require("../testConstants");
|
|
43
|
+
describe('deviceErrors', function () {
|
|
44
|
+
__1.EdgeIQAPI.init();
|
|
45
|
+
it('Logs User', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var result;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4, __2.Authentication.login(testConstants_1.TestAuth.username, testConstants_1.TestAuth.pass)];
|
|
50
|
+
case 1:
|
|
51
|
+
result = _a.sent();
|
|
52
|
+
expect(result.session_token).not.toBeNull();
|
|
53
|
+
return [2];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}); });
|
|
57
|
+
it('List the deviceErrors', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var filters, result;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
filters = {};
|
|
63
|
+
return [4, deviceErrors_1.DeviceErrors.list(filters)];
|
|
64
|
+
case 1:
|
|
65
|
+
result = _a.sent();
|
|
66
|
+
expect(result.resources).toBeDefined();
|
|
67
|
+
expect(result.resources).toBeInstanceOf(Array);
|
|
68
|
+
return [2];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}); });
|
|
72
|
+
});
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -2,8 +2,12 @@ import { BaseModelInterface } from '../core/ModelClass';
|
|
|
2
2
|
import { BulkActionResponse } from '../models';
|
|
3
3
|
import { Command, CommandInput, CommandsFilters, PaginatedCommands } from './models';
|
|
4
4
|
interface CommandsInterface extends BaseModelInterface<Command, CommandInput, CommandsFilters, PaginatedCommands> {
|
|
5
|
-
update(command: Command): Promise<Command>;
|
|
6
5
|
deleteMultiple(ids: string[]): Promise<BulkActionResponse>;
|
|
6
|
+
assignToDevice(commandId: string, deviceId: string): Promise<string>;
|
|
7
|
+
assignToDeviceType(commandId: string, deviceTypeId: string): Promise<string>;
|
|
8
|
+
removeFromDevice(commandId: string, deviceId: string): Promise<string>;
|
|
9
|
+
removeFromDeviceType(commandId: string, deviceTypeId: string): Promise<string>;
|
|
10
|
+
executeOnDevice(commandId: string, deviceId: string): Promise<string>;
|
|
7
11
|
}
|
|
8
12
|
export declare const Commands: CommandsInterface;
|
|
9
13
|
export {};
|
package/dist/commands/index.js
CHANGED
|
@@ -220,5 +220,125 @@ exports.Commands = (function (_super) {
|
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
222
|
};
|
|
223
|
+
class_1.assignToDevice = function (commandId, deviceId) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
var axios, error_7;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0:
|
|
229
|
+
_a.trys.push([0, 2, , 3]);
|
|
230
|
+
this.logAction("assigning command " + commandId + " to device " + deviceId);
|
|
231
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
232
|
+
return [4, axios.put(constants_1.Endpoints.command + "/" + commandId + "/" + constants_1.Endpoints.device + "/" + deviceId)];
|
|
233
|
+
case 1:
|
|
234
|
+
_a.sent();
|
|
235
|
+
return [2, (0, constants_1.getAttachMessage)('Command', 'attach', 'device')];
|
|
236
|
+
case 2:
|
|
237
|
+
error_7 = _a.sent();
|
|
238
|
+
if ((0, helpers_1.isApiError)(error_7)) {
|
|
239
|
+
throw error_7;
|
|
240
|
+
}
|
|
241
|
+
throw error_7;
|
|
242
|
+
case 3: return [2];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
class_1.assignToDeviceType = function (commandId, deviceTypeId) {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
249
|
+
var axios, error_8;
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0:
|
|
253
|
+
_a.trys.push([0, 2, , 3]);
|
|
254
|
+
this.logAction("assigning command " + commandId + " to device type " + deviceTypeId);
|
|
255
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
256
|
+
return [4, axios.put(constants_1.Endpoints.command + "/" + commandId + "/" + constants_1.Endpoints.deviceType + "/" + deviceTypeId)];
|
|
257
|
+
case 1:
|
|
258
|
+
_a.sent();
|
|
259
|
+
return [2, (0, constants_1.getAttachMessage)('Command', 'attach', 'device type')];
|
|
260
|
+
case 2:
|
|
261
|
+
error_8 = _a.sent();
|
|
262
|
+
if ((0, helpers_1.isApiError)(error_8)) {
|
|
263
|
+
throw error_8;
|
|
264
|
+
}
|
|
265
|
+
throw error_8;
|
|
266
|
+
case 3: return [2];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
class_1.removeFromDevice = function (commandId, deviceId) {
|
|
272
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
273
|
+
var axios, error_9;
|
|
274
|
+
return __generator(this, function (_a) {
|
|
275
|
+
switch (_a.label) {
|
|
276
|
+
case 0:
|
|
277
|
+
_a.trys.push([0, 2, , 3]);
|
|
278
|
+
this.logAction("detaching command " + commandId + " from device " + deviceId);
|
|
279
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
280
|
+
return [4, axios.delete(constants_1.Endpoints.command + "/" + commandId + "/" + constants_1.Endpoints.device + "/" + deviceId)];
|
|
281
|
+
case 1:
|
|
282
|
+
_a.sent();
|
|
283
|
+
return [2, (0, constants_1.getAttachMessage)('Command', 'detach', 'device')];
|
|
284
|
+
case 2:
|
|
285
|
+
error_9 = _a.sent();
|
|
286
|
+
if ((0, helpers_1.isApiError)(error_9)) {
|
|
287
|
+
throw error_9;
|
|
288
|
+
}
|
|
289
|
+
throw error_9;
|
|
290
|
+
case 3: return [2];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
class_1.removeFromDeviceType = function (commandId, deviceTypeId) {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
297
|
+
var axios, error_10;
|
|
298
|
+
return __generator(this, function (_a) {
|
|
299
|
+
switch (_a.label) {
|
|
300
|
+
case 0:
|
|
301
|
+
_a.trys.push([0, 2, , 3]);
|
|
302
|
+
this.logAction("detaching command " + commandId + " from device type " + deviceTypeId);
|
|
303
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
304
|
+
return [4, axios.delete(constants_1.Endpoints.command + "/" + commandId + "/" + constants_1.Endpoints.deviceType + "/" + deviceTypeId)];
|
|
305
|
+
case 1:
|
|
306
|
+
_a.sent();
|
|
307
|
+
return [2, (0, constants_1.getAttachMessage)('Command', 'detach', 'device type')];
|
|
308
|
+
case 2:
|
|
309
|
+
error_10 = _a.sent();
|
|
310
|
+
if ((0, helpers_1.isApiError)(error_10)) {
|
|
311
|
+
throw error_10;
|
|
312
|
+
}
|
|
313
|
+
throw error_10;
|
|
314
|
+
case 3: return [2];
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
class_1.executeOnDevice = function (commandId, deviceId) {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
+
var axios, error_11;
|
|
322
|
+
return __generator(this, function (_a) {
|
|
323
|
+
switch (_a.label) {
|
|
324
|
+
case 0:
|
|
325
|
+
_a.trys.push([0, 2, , 3]);
|
|
326
|
+
this.logAction("executing command " + commandId + " on device " + deviceId);
|
|
327
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
328
|
+
return [4, axios.post(constants_1.Endpoints.device + "/" + deviceId + "/" + constants_1.Endpoints.command + "/" + commandId + "/execute")];
|
|
329
|
+
case 1:
|
|
330
|
+
_a.sent();
|
|
331
|
+
return [2, 'Command execution queued'];
|
|
332
|
+
case 2:
|
|
333
|
+
error_11 = _a.sent();
|
|
334
|
+
if ((0, helpers_1.isApiError)(error_11)) {
|
|
335
|
+
throw error_11;
|
|
336
|
+
}
|
|
337
|
+
throw error_11;
|
|
338
|
+
case 3: return [2];
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
};
|
|
223
343
|
return class_1;
|
|
224
344
|
}(ModelClass_1.BaseModelClass));
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { Base, Filter, Filters, Pagination } from '../models';
|
|
2
|
-
export declare
|
|
2
|
+
export declare enum SenderType {
|
|
3
|
+
tcp_sender = "tcp_sender",
|
|
4
|
+
http_sender = "http_sender",
|
|
5
|
+
dev_sender = "dev_sender",
|
|
6
|
+
rest_fwd_sender = "rest_fwd_sender",
|
|
7
|
+
plugin_sender = "plugin_sender",
|
|
8
|
+
shell_sender = "shell_sender",
|
|
9
|
+
opcua_sender = "opcua_sender",
|
|
10
|
+
modbus_sender = "modbus_sender",
|
|
11
|
+
bacnet_sender = "bacnet_sender"
|
|
12
|
+
}
|
|
3
13
|
export interface CommandInput {
|
|
4
14
|
name: string;
|
|
5
15
|
sender_type: SenderType;
|
package/dist/commands/models.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SenderType = void 0;
|
|
4
|
+
var SenderType;
|
|
5
|
+
(function (SenderType) {
|
|
6
|
+
SenderType["tcp_sender"] = "tcp_sender";
|
|
7
|
+
SenderType["http_sender"] = "http_sender";
|
|
8
|
+
SenderType["dev_sender"] = "dev_sender";
|
|
9
|
+
SenderType["rest_fwd_sender"] = "rest_fwd_sender";
|
|
10
|
+
SenderType["plugin_sender"] = "plugin_sender";
|
|
11
|
+
SenderType["shell_sender"] = "shell_sender";
|
|
12
|
+
SenderType["opcua_sender"] = "opcua_sender";
|
|
13
|
+
SenderType["modbus_sender"] = "modbus_sender";
|
|
14
|
+
SenderType["bacnet_sender"] = "bacnet_sender";
|
|
15
|
+
})(SenderType = exports.SenderType || (exports.SenderType = {}));
|
package/dist/constants.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export declare const BaseEndpoints: {
|
|
|
57
57
|
command: string;
|
|
58
58
|
company: string;
|
|
59
59
|
deviceConfig: string;
|
|
60
|
+
deviceError: string;
|
|
60
61
|
deviceTransferRequest: string;
|
|
61
62
|
deviceTemplate: string;
|
|
62
63
|
deviceType: string;
|
|
@@ -94,6 +95,7 @@ export declare const Endpoints: {
|
|
|
94
95
|
command: string;
|
|
95
96
|
company: string;
|
|
96
97
|
deviceConfig: string;
|
|
98
|
+
deviceError: string;
|
|
97
99
|
deviceTransferRequest: string;
|
|
98
100
|
deviceTemplate: string;
|
|
99
101
|
deviceType: string;
|
|
@@ -112,6 +114,7 @@ export declare const Endpoints: {
|
|
|
112
114
|
secret: string;
|
|
113
115
|
softwareUpdate: string;
|
|
114
116
|
statsDevicesByHeartbeat: string;
|
|
117
|
+
statsDiscoveredDevicesByHeartbeat: string;
|
|
115
118
|
statsDevicesByType: string;
|
|
116
119
|
statsCellUsage: string;
|
|
117
120
|
systemCommand: string;
|
package/dist/constants.js
CHANGED
|
@@ -73,6 +73,7 @@ exports.BaseEndpoints = {
|
|
|
73
73
|
command: 'commands',
|
|
74
74
|
company: 'companies',
|
|
75
75
|
deviceConfig: 'device_configs',
|
|
76
|
+
deviceError: 'device_errors',
|
|
76
77
|
deviceTransferRequest: 'device_transfer_requests',
|
|
77
78
|
deviceTemplate: 'device_templates',
|
|
78
79
|
deviceType: 'device_types',
|
|
@@ -110,6 +111,7 @@ exports.Endpoints = {
|
|
|
110
111
|
command: "" + exports.BaseEndpoints.command,
|
|
111
112
|
company: "" + exports.BaseEndpoints.company,
|
|
112
113
|
deviceConfig: "" + exports.BaseEndpoints.deviceConfig,
|
|
114
|
+
deviceError: "" + exports.BaseEndpoints.deviceError,
|
|
113
115
|
deviceTransferRequest: "" + exports.BaseEndpoints.deviceTransferRequest,
|
|
114
116
|
deviceTemplate: "" + exports.BaseEndpoints.deviceTemplate,
|
|
115
117
|
deviceType: "" + exports.BaseEndpoints.deviceType,
|
|
@@ -128,6 +130,7 @@ exports.Endpoints = {
|
|
|
128
130
|
secret: "" + exports.BaseEndpoints.secret,
|
|
129
131
|
softwareUpdate: "" + exports.BaseEndpoints.softwareUpdate,
|
|
130
132
|
statsDevicesByHeartbeat: exports.BaseEndpoints.stats + "/devices/count_by_heartbeat_status",
|
|
133
|
+
statsDiscoveredDevicesByHeartbeat: exports.BaseEndpoints.stats + "/discovered_devices/count_by_heartbeat_status",
|
|
131
134
|
statsDevicesByType: exports.BaseEndpoints.stats + "/devices/count_by_type",
|
|
132
135
|
statsCellUsage: exports.BaseEndpoints.stats + "/cumulative_cell_usage",
|
|
133
136
|
systemCommand: "" + exports.BaseEndpoints.systemCommand,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PaginationFilter } from '../models';
|
|
2
|
+
import { DeviceError, DeviceErrorsFilters, PaginatedDeviceErrors } from './models';
|
|
3
|
+
interface DeviceErrorsInterface {
|
|
4
|
+
list(filters?: DeviceErrorsFilters, pagination?: PaginationFilter): Promise<PaginatedDeviceErrors>;
|
|
5
|
+
getOneById(id: string): Promise<DeviceError>;
|
|
6
|
+
}
|
|
7
|
+
export declare const DeviceErrors: DeviceErrorsInterface;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
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.DeviceErrors = 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.DeviceErrors = (function (_super) {
|
|
61
|
+
__extends(class_1, _super);
|
|
62
|
+
function class_1() {
|
|
63
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
64
|
+
}
|
|
65
|
+
class_1.list = function (filters, pagination) {
|
|
66
|
+
var _a, _b, _c, _d;
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var axios, result, error_1;
|
|
69
|
+
return __generator(this, function (_e) {
|
|
70
|
+
switch (_e.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
_e.trys.push([0, 2, , 3]);
|
|
73
|
+
this.logAction("Listing device errors with following filters: " + (filters !== null && filters !== void 0 ? filters : '{}') + ".\n And pagination " + (pagination !== null && pagination !== void 0 ? pagination : '{}'));
|
|
74
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
75
|
+
return [4, axios.get(constants_1.Endpoints.deviceError, {
|
|
76
|
+
params: (0, filtersParser_1.parseFilters)(filters, pagination),
|
|
77
|
+
})];
|
|
78
|
+
case 1:
|
|
79
|
+
result = _e.sent();
|
|
80
|
+
return [2, {
|
|
81
|
+
resources: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
|
|
82
|
+
pagination: {
|
|
83
|
+
page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
|
|
84
|
+
itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
|
|
85
|
+
total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
|
|
86
|
+
},
|
|
87
|
+
}];
|
|
88
|
+
case 2:
|
|
89
|
+
error_1 = _e.sent();
|
|
90
|
+
if ((0, helpers_1.isApiError)(error_1)) {
|
|
91
|
+
throw error_1;
|
|
92
|
+
}
|
|
93
|
+
throw error_1;
|
|
94
|
+
case 3: return [2];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
class_1.getOneById = function (id) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var axios, result, error_2;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
_a.trys.push([0, 2, , 3]);
|
|
106
|
+
this.logAction("Getting DeviceError with id: " + id);
|
|
107
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
108
|
+
return [4, axios.get(constants_1.Endpoints.deviceError + "/" + id)];
|
|
109
|
+
case 1:
|
|
110
|
+
result = _a.sent();
|
|
111
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
112
|
+
case 2:
|
|
113
|
+
error_2 = _a.sent();
|
|
114
|
+
if ((0, helpers_1.isApiError)(error_2)) {
|
|
115
|
+
throw error_2;
|
|
116
|
+
}
|
|
117
|
+
throw error_2;
|
|
118
|
+
case 3: return [2];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
return class_1;
|
|
124
|
+
}(ModelClass_1.BaseModelClass));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Base, Filter, Filters, Pagination } from '../models';
|
|
2
|
+
export interface DeviceError extends Base {
|
|
3
|
+
type: string;
|
|
4
|
+
level: number;
|
|
5
|
+
error: string;
|
|
6
|
+
device_id: string;
|
|
7
|
+
rule_action_count: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DeviceErrorsFilters extends Filters {
|
|
10
|
+
device_id?: Filter;
|
|
11
|
+
type?: Filter;
|
|
12
|
+
level?: Filter;
|
|
13
|
+
rule_action_count?: Filter;
|
|
14
|
+
error?: Filter;
|
|
15
|
+
}
|
|
16
|
+
export interface PaginatedDeviceErrors {
|
|
17
|
+
resources: DeviceError[];
|
|
18
|
+
pagination: Pagination;
|
|
19
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ingestor, PollableAttribute, Rule } from '..';
|
|
1
|
+
import { Ingestor, PollableAttribute, Rule, Command } from '..';
|
|
2
2
|
import { BaseModelInterface } from '../core/ModelClass';
|
|
3
3
|
import { BulkActionResponse } from '../models';
|
|
4
4
|
import { DeviceType, DeviceTypeInput, DeviceTypesFilters, PaginatedDeviceTypes } from './models';
|
|
@@ -14,6 +14,7 @@ interface DeviceTypesInterface extends BaseModelInterface<DeviceType, DeviceType
|
|
|
14
14
|
attachRule(id: string, ruleId: string): Promise<string>;
|
|
15
15
|
detachRule(id: string, ruleId: string): Promise<string>;
|
|
16
16
|
getRules(id: string): Promise<Rule[]>;
|
|
17
|
+
getCommands(id: string): Promise<Command[]>;
|
|
17
18
|
}
|
|
18
19
|
export declare const DeviceTypes: DeviceTypesInterface;
|
|
19
20
|
export {};
|
|
@@ -436,5 +436,29 @@ exports.DeviceTypes = (function (_super) {
|
|
|
436
436
|
});
|
|
437
437
|
});
|
|
438
438
|
};
|
|
439
|
+
class_1.getCommands = function (id) {
|
|
440
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
441
|
+
var axios, result, error_16;
|
|
442
|
+
return __generator(this, function (_a) {
|
|
443
|
+
switch (_a.label) {
|
|
444
|
+
case 0:
|
|
445
|
+
_a.trys.push([0, 2, , 3]);
|
|
446
|
+
this.logAction("Getting commands attached to device type with id " + id);
|
|
447
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
448
|
+
return [4, axios.get(constants_1.Endpoints.deviceType + "/" + id + "/" + constants_1.Endpoints.command)];
|
|
449
|
+
case 1:
|
|
450
|
+
result = _a.sent();
|
|
451
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
452
|
+
case 2:
|
|
453
|
+
error_16 = _a.sent();
|
|
454
|
+
if ((0, helpers_1.isApiError)(error_16)) {
|
|
455
|
+
throw error_16;
|
|
456
|
+
}
|
|
457
|
+
throw error_16;
|
|
458
|
+
case 3: return [2];
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
};
|
|
439
463
|
return class_1;
|
|
440
464
|
}(ModelClass_1.BaseModelClass));
|
package/dist/devices/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ingestor, Rule } from '..';
|
|
1
|
+
import { Ingestor, Rule, Command } from '..';
|
|
2
2
|
import { BaseModelInterface } from '../core/ModelClass';
|
|
3
3
|
import { BulkActionResponse } from '../models';
|
|
4
4
|
import { DevicesFilters, Device, DeviceInput, PaginatedDevices } from './models';
|
|
@@ -14,6 +14,7 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
|
|
|
14
14
|
bulkAttachRules(id: string, rulesIds: string[]): Promise<BulkActionResponse>;
|
|
15
15
|
detachRule(id: string, ruleId: string): Promise<string>;
|
|
16
16
|
getRules(id: string): Promise<Rule[]>;
|
|
17
|
+
getCommands(id: string): Promise<Command[]>;
|
|
17
18
|
csvBulkUpload(file: File): Promise<BulkActionResponse>;
|
|
18
19
|
}
|
|
19
20
|
export declare const Devices: DevicesInterface;
|
package/dist/devices/index.js
CHANGED
|
@@ -453,9 +453,33 @@ exports.Devices = (function (_super) {
|
|
|
453
453
|
});
|
|
454
454
|
});
|
|
455
455
|
};
|
|
456
|
+
class_1.getCommands = function (id) {
|
|
457
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
458
|
+
var axios, result, error_16;
|
|
459
|
+
return __generator(this, function (_a) {
|
|
460
|
+
switch (_a.label) {
|
|
461
|
+
case 0:
|
|
462
|
+
_a.trys.push([0, 2, , 3]);
|
|
463
|
+
this.logAction("Getting commands attached to device with id " + id);
|
|
464
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
465
|
+
return [4, axios.get(constants_1.Endpoints.device + "/" + id + "/" + constants_1.Endpoints.command)];
|
|
466
|
+
case 1:
|
|
467
|
+
result = _a.sent();
|
|
468
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
469
|
+
case 2:
|
|
470
|
+
error_16 = _a.sent();
|
|
471
|
+
if ((0, helpers_1.isApiError)(error_16)) {
|
|
472
|
+
throw error_16;
|
|
473
|
+
}
|
|
474
|
+
throw error_16;
|
|
475
|
+
case 3: return [2];
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
};
|
|
456
480
|
class_1.csvBulkUpload = function (file) {
|
|
457
481
|
return __awaiter(this, void 0, void 0, function () {
|
|
458
|
-
var axios, form, result,
|
|
482
|
+
var axios, form, result, error_17;
|
|
459
483
|
return __generator(this, function (_a) {
|
|
460
484
|
switch (_a.label) {
|
|
461
485
|
case 0:
|
|
@@ -473,11 +497,11 @@ exports.Devices = (function (_super) {
|
|
|
473
497
|
result = _a.sent();
|
|
474
498
|
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
475
499
|
case 2:
|
|
476
|
-
|
|
477
|
-
if ((0, helpers_1.isApiError)(
|
|
478
|
-
throw
|
|
500
|
+
error_17 = _a.sent();
|
|
501
|
+
if ((0, helpers_1.isApiError)(error_17)) {
|
|
502
|
+
throw error_17;
|
|
479
503
|
}
|
|
480
|
-
throw
|
|
504
|
+
throw error_17;
|
|
481
505
|
case 3: return [2];
|
|
482
506
|
}
|
|
483
507
|
});
|
|
@@ -284,7 +284,8 @@ exports.DiscoveredDevices = (function (_super) {
|
|
|
284
284
|
this.logAction("Promoting discovered devices in bulk");
|
|
285
285
|
axios = __1.EdgeIQAPI.getAxios();
|
|
286
286
|
return [4, axios.post(constants_1.Endpoints.discoveredDevice + "/bulk_promote", {
|
|
287
|
-
|
|
287
|
+
ids: ids,
|
|
288
|
+
device_type_id: deviceTypeId,
|
|
288
289
|
})];
|
|
289
290
|
case 1:
|
|
290
291
|
result = _a.sent();
|
|
@@ -311,7 +312,7 @@ exports.DiscoveredDevices = (function (_super) {
|
|
|
311
312
|
axios = __1.EdgeIQAPI.getAxios();
|
|
312
313
|
form = new FormData();
|
|
313
314
|
form.append('csv_upload', file);
|
|
314
|
-
return [4, axios.post(constants_1.Endpoints.
|
|
315
|
+
return [4, axios.post(constants_1.Endpoints.discoveredDevice + "/csv_bulk_upload_promote", form, {
|
|
315
316
|
headers: {
|
|
316
317
|
'Content-Type': 'multipart/form-data',
|
|
317
318
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { SystemCommandJobs } from './systemCommandJobs';
|
|
|
28
28
|
export { Translators } from './translators';
|
|
29
29
|
export { Users } from './users';
|
|
30
30
|
export { UserTypes } from './userTypes';
|
|
31
|
+
export { DeviceErrors } from './deviceErrors';
|
|
31
32
|
export * from './models';
|
|
32
33
|
export * from './bulkResponses/models';
|
|
33
34
|
export * from './commands/models';
|
|
@@ -56,3 +57,4 @@ export * from './systemCommandJobs/models';
|
|
|
56
57
|
export * from './translators/models';
|
|
57
58
|
export * from './users/models';
|
|
58
59
|
export * from './userTypes/models';
|
|
60
|
+
export * from './deviceErrors/models';
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.UserTypes = exports.Users = exports.Translators = exports.SystemCommandJobs = exports.SystemCommands = exports.Stats = exports.SoftwareUpdates = exports.Secrets = exports.Rules = exports.Reports = exports.Regions = exports.PollableAttributes = exports.Notifications = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.Companies = exports.Commands = exports.BulkResponses = exports.Authentication = exports.EdgeIQAPI = void 0;
|
|
13
|
+
exports.DeviceErrors = exports.UserTypes = exports.Users = exports.Translators = exports.SystemCommandJobs = exports.SystemCommands = exports.Stats = exports.SoftwareUpdates = exports.Secrets = exports.Rules = exports.Reports = exports.Regions = exports.PollableAttributes = exports.Notifications = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.Companies = exports.Commands = exports.BulkResponses = exports.Authentication = exports.EdgeIQAPI = void 0;
|
|
14
14
|
var core_1 = require("./core");
|
|
15
15
|
Object.defineProperty(exports, "EdgeIQAPI", { enumerable: true, get: function () { return core_1.EdgeIQAPI; } });
|
|
16
16
|
var auth_1 = require("./auth");
|
|
@@ -71,6 +71,8 @@ var users_1 = require("./users");
|
|
|
71
71
|
Object.defineProperty(exports, "Users", { enumerable: true, get: function () { return users_1.Users; } });
|
|
72
72
|
var userTypes_1 = require("./userTypes");
|
|
73
73
|
Object.defineProperty(exports, "UserTypes", { enumerable: true, get: function () { return userTypes_1.UserTypes; } });
|
|
74
|
+
var deviceErrors_1 = require("./deviceErrors");
|
|
75
|
+
Object.defineProperty(exports, "DeviceErrors", { enumerable: true, get: function () { return deviceErrors_1.DeviceErrors; } });
|
|
74
76
|
__exportStar(require("./models"), exports);
|
|
75
77
|
__exportStar(require("./bulkResponses/models"), exports);
|
|
76
78
|
__exportStar(require("./commands/models"), exports);
|
|
@@ -99,3 +101,4 @@ __exportStar(require("./systemCommandJobs/models"), exports);
|
|
|
99
101
|
__exportStar(require("./translators/models"), exports);
|
|
100
102
|
__exportStar(require("./users/models"), exports);
|
|
101
103
|
__exportStar(require("./userTypes/models"), exports);
|
|
104
|
+
__exportStar(require("./deviceErrors/models"), exports);
|
package/dist/stats/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { DevicesFilters } from '..';
|
|
|
2
2
|
import { CumulativeCellUsage, DevicesCountByHeartbeat, DevicesCountByType } from './models';
|
|
3
3
|
declare const Stats: {
|
|
4
4
|
devicesByHeartbeat: (filters?: DevicesFilters | undefined) => Promise<DevicesCountByHeartbeat>;
|
|
5
|
+
discoveredDevicesByHeartbeat: (filters?: DevicesFilters | undefined) => Promise<DevicesCountByHeartbeat>;
|
|
5
6
|
devicesByType: (filters?: DevicesFilters | undefined) => Promise<DevicesCountByType>;
|
|
6
7
|
cellUsage: () => Promise<CumulativeCellUsage>;
|
|
7
8
|
};
|
package/dist/stats/index.js
CHANGED
|
@@ -66,15 +66,15 @@ var Stats = {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
}); },
|
|
69
|
-
|
|
69
|
+
discoveredDevicesByHeartbeat: function (filters) { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
70
|
var axios, result, error_2;
|
|
71
71
|
return __generator(this, function (_a) {
|
|
72
72
|
switch (_a.label) {
|
|
73
73
|
case 0:
|
|
74
74
|
_a.trys.push([0, 2, , 3]);
|
|
75
|
-
__1.EdgeIQAPI.logAction("Getting devices count by
|
|
75
|
+
__1.EdgeIQAPI.logAction("Getting discovered devices count by heartbeat status");
|
|
76
76
|
axios = __1.EdgeIQAPI.getAxios();
|
|
77
|
-
return [4, axios.get(constants_1.Endpoints.
|
|
77
|
+
return [4, axios.get(constants_1.Endpoints.statsDiscoveredDevicesByHeartbeat, {
|
|
78
78
|
params: (0, filtersParser_1.parseFilters)(filters),
|
|
79
79
|
})];
|
|
80
80
|
case 1:
|
|
@@ -90,15 +90,17 @@ var Stats = {
|
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
}); },
|
|
93
|
-
|
|
93
|
+
devicesByType: function (filters) { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
94
|
var axios, result, error_3;
|
|
95
95
|
return __generator(this, function (_a) {
|
|
96
96
|
switch (_a.label) {
|
|
97
97
|
case 0:
|
|
98
98
|
_a.trys.push([0, 2, , 3]);
|
|
99
|
-
__1.EdgeIQAPI.logAction("Getting
|
|
99
|
+
__1.EdgeIQAPI.logAction("Getting devices count by type");
|
|
100
100
|
axios = __1.EdgeIQAPI.getAxios();
|
|
101
|
-
return [4, axios.get(constants_1.Endpoints.
|
|
101
|
+
return [4, axios.get(constants_1.Endpoints.statsDevicesByType, {
|
|
102
|
+
params: (0, filtersParser_1.parseFilters)(filters),
|
|
103
|
+
})];
|
|
102
104
|
case 1:
|
|
103
105
|
result = _a.sent();
|
|
104
106
|
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
@@ -112,5 +114,27 @@ var Stats = {
|
|
|
112
114
|
}
|
|
113
115
|
});
|
|
114
116
|
}); },
|
|
117
|
+
cellUsage: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
+
var axios, result, error_4;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
_a.trys.push([0, 2, , 3]);
|
|
123
|
+
__1.EdgeIQAPI.logAction("Getting cumulative cell usage");
|
|
124
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
125
|
+
return [4, axios.get(constants_1.Endpoints.statsCellUsage)];
|
|
126
|
+
case 1:
|
|
127
|
+
result = _a.sent();
|
|
128
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
129
|
+
case 2:
|
|
130
|
+
error_4 = _a.sent();
|
|
131
|
+
if ((0, helpers_1.isApiError)(error_4)) {
|
|
132
|
+
throw error_4;
|
|
133
|
+
}
|
|
134
|
+
throw error_4;
|
|
135
|
+
case 3: return [2];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}); },
|
|
115
139
|
};
|
|
116
140
|
exports.Stats = Stats;
|
package/dist/testConstants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationInput, Company, CompanyInput, Device, DeviceInput, DiscoveredDeviceInput, DeviceType, DeviceTypeInput, User, UserInput, Integration, Ingestor, IngestorInput, PollableAttribute, PollableAttributeInput, Translator, TranslatorInput, Rule, RuleInput } from '.';
|
|
1
|
+
import { IntegrationInput, Company, CompanyInput, CommandInput, Device, DeviceInput, DiscoveredDeviceInput, DeviceType, DeviceTypeInput, User, UserInput, Integration, Ingestor, IngestorInput, PollableAttribute, PollableAttributeInput, Translator, TranslatorInput, Rule, RuleInput } from '.';
|
|
2
2
|
import { Notification } from './notifications/models';
|
|
3
3
|
export declare const TestAuth: {
|
|
4
4
|
noUser: string;
|
|
@@ -43,4 +43,5 @@ export declare const TestRule: RuleInput;
|
|
|
43
43
|
export declare const TestRule2: RuleInput;
|
|
44
44
|
export declare const NewTestRuleDescription = "EIQSDK Rule Test updated";
|
|
45
45
|
export declare const TestDiscoveredDevice: DiscoveredDeviceInput;
|
|
46
|
+
export declare const TestCommand: CommandInput;
|
|
46
47
|
export declare const EmptyNotificationType: Notification;
|
package/dist/testConstants.js
CHANGED
|
@@ -11,7 +11,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.EmptyNotificationType = exports.TestDiscoveredDevice = exports.NewTestRuleDescription = exports.TestRule2 = exports.TestRule = exports.EmptyRule = exports.NewTestTranslatorName = exports.TestTranslator2 = exports.TestTranslator = exports.EmptyTranslator = exports.NewTestPollableAttributeName = exports.TestPollableAttribute2 = exports.TestPollableAttribute = exports.EmptyPollableAttribute = exports.NewTestIngestorName = exports.TestIngestor2 = exports.TestIngestor = exports.EmptyIngestor = exports.NewIntegrationName = exports.TestIntegration2 = exports.TestIntegration = exports.EmptyIntegration = exports.NewTestDeviceTypeName = exports.TestDeviceType2 = exports.TestDeviceType = exports.EmptyDeviceType = exports.NewTestCompanyName = exports.TestCompany2 = exports.TestCompany = exports.EmptyCompany = exports.NewTestUserName = exports.EmptyUser = exports.TestUser2 = exports.TestUser = exports.NewTestDeviceName = exports.EmptyDevice = exports.TestDevice2 = exports.TestDevice = exports.TestDeviceTypeID = exports.TestAuth = void 0;
|
|
14
|
+
exports.EmptyNotificationType = exports.TestCommand = exports.TestDiscoveredDevice = exports.NewTestRuleDescription = exports.TestRule2 = exports.TestRule = exports.EmptyRule = exports.NewTestTranslatorName = exports.TestTranslator2 = exports.TestTranslator = exports.EmptyTranslator = exports.NewTestPollableAttributeName = exports.TestPollableAttribute2 = exports.TestPollableAttribute = exports.EmptyPollableAttribute = exports.NewTestIngestorName = exports.TestIngestor2 = exports.TestIngestor = exports.EmptyIngestor = exports.NewIntegrationName = exports.TestIntegration2 = exports.TestIntegration = exports.EmptyIntegration = exports.NewTestDeviceTypeName = exports.TestDeviceType2 = exports.TestDeviceType = exports.EmptyDeviceType = exports.NewTestCompanyName = exports.TestCompany2 = exports.TestCompany = exports.EmptyCompany = exports.NewTestUserName = exports.EmptyUser = exports.TestUser2 = exports.TestUser = exports.NewTestDeviceName = exports.EmptyDevice = exports.TestDevice2 = exports.TestDevice = exports.TestDeviceTypeID = exports.TestAuth = void 0;
|
|
15
|
+
var _1 = require(".");
|
|
15
16
|
var parentCompanyId = 'whiteprompt_ssi_dev';
|
|
16
17
|
var baseModel = {
|
|
17
18
|
_id: '',
|
|
@@ -218,4 +219,11 @@ exports.TestDiscoveredDevice = {
|
|
|
218
219
|
name: 'Test Discovered Device',
|
|
219
220
|
unique_id: 'test_discovered_device',
|
|
220
221
|
};
|
|
222
|
+
exports.TestCommand = {
|
|
223
|
+
name: 'Test Command',
|
|
224
|
+
sender_type: _1.SenderType.shell_sender,
|
|
225
|
+
sender: {
|
|
226
|
+
command: "echo 'testing'",
|
|
227
|
+
},
|
|
228
|
+
};
|
|
221
229
|
exports.EmptyNotificationType = __assign(__assign({}, baseModel), { message: 'message', rule_id: 'rule_id', device_id: 'device_id' });
|