@edgeiq/edgeiq-api-js 1.3.25 → 1.3.26
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__/auth.test.js +1 -1
- package/dist/__tests__/command.test.js +22 -11
- package/dist/__tests__/companies.test.js +2 -2
- package/dist/__tests__/deviceErrors.test.js +2 -2
- package/dist/__tests__/deviceTypes.test.js +2 -2
- package/dist/__tests__/devices.test.js +35 -7
- package/dist/__tests__/discoveredDevice.test.js +32 -3
- package/dist/__tests__/files.test.d.ts +1 -0
- package/dist/__tests__/files.test.js +162 -0
- package/dist/__tests__/ingestors.test.js +30 -4
- package/dist/__tests__/integrations.test.js +2 -2
- package/dist/__tests__/notifications.test.js +2 -2
- package/dist/__tests__/pollableAttributes.test.js +2 -2
- package/dist/__tests__/rules.test.js +2 -2
- package/dist/__tests__/translators.test.js +2 -2
- package/dist/__tests__/users.test.js +2 -2
- package/dist/deviceTypes/models.d.ts +1 -0
- package/dist/devices/index.d.ts +2 -4
- package/dist/files/index.d.ts +11 -0
- package/dist/files/index.js +278 -0
- package/dist/files/models.d.ts +20 -0
- package/dist/files/models.js +2 -0
- package/dist/gatewayCommands/models.d.ts +3 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -4
- package/dist/testConstants.d.ts +5 -2
- package/dist/testConstants.js +18 -11
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@ var constants_1 = require("../constants");
|
|
|
42
42
|
var helpers_1 = require("../helpers");
|
|
43
43
|
var testConstants_1 = require("../testConstants");
|
|
44
44
|
describe('Authentication', function () {
|
|
45
|
-
__1.EdgeIQAPI.init();
|
|
45
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
46
46
|
it('Wrong user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
47
|
var error_1;
|
|
48
48
|
return __generator(this, function (_a) {
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -42,7 +53,7 @@ var constants_1 = require("../constants");
|
|
|
42
53
|
var helpers_1 = require("../helpers");
|
|
43
54
|
var testConstants_1 = require("../testConstants");
|
|
44
55
|
describe('Commands', function () {
|
|
45
|
-
__1.EdgeIQAPI.init();
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
46
57
|
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
58
|
var result;
|
|
48
59
|
return __generator(this, function (_a) {
|
|
@@ -57,25 +68,25 @@ describe('Commands', function () {
|
|
|
57
68
|
}); });
|
|
58
69
|
var targetDevice;
|
|
59
70
|
var targetDeviceType;
|
|
60
|
-
it('Given a device and device
|
|
61
|
-
var
|
|
71
|
+
it('Given a device type and a device', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var deviceTypeOptions, dtresult, deviceOptions, dresult;
|
|
62
73
|
return __generator(this, function (_a) {
|
|
63
74
|
switch (_a.label) {
|
|
64
75
|
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
76
|
deviceTypeOptions = JSON.parse(JSON.stringify(testConstants_1.TestDeviceType));
|
|
73
77
|
deviceTypeOptions.name = 'js_sdk_command_test_device_type';
|
|
74
78
|
return [4, __1.DeviceTypes.create(testConstants_1.TestDeviceType)];
|
|
75
|
-
case
|
|
79
|
+
case 1:
|
|
76
80
|
dtresult = _a.sent();
|
|
77
81
|
expect(dtresult._id).not.toBeNull();
|
|
78
82
|
targetDeviceType = dtresult;
|
|
83
|
+
deviceOptions = JSON.parse(JSON.stringify(__assign(__assign({}, testConstants_1.TestDevice), { device_type_id: targetDeviceType._id })));
|
|
84
|
+
deviceOptions.unique_id = 'js_sdk_command_test_device';
|
|
85
|
+
return [4, __1.Devices.create(deviceOptions)];
|
|
86
|
+
case 2:
|
|
87
|
+
dresult = _a.sent();
|
|
88
|
+
expect(dresult._id).not.toBeNull();
|
|
89
|
+
targetDevice = dresult;
|
|
79
90
|
return [2];
|
|
80
91
|
}
|
|
81
92
|
});
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Companies', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
@@ -41,8 +41,8 @@ var __2 = require("..");
|
|
|
41
41
|
var deviceErrors_1 = require("../deviceErrors");
|
|
42
42
|
var testConstants_1 = require("../testConstants");
|
|
43
43
|
describe('deviceErrors', function () {
|
|
44
|
-
__1.EdgeIQAPI.init();
|
|
45
|
-
it('
|
|
44
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
45
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
46
|
var result;
|
|
47
47
|
return __generator(this, function (_a) {
|
|
48
48
|
switch (_a.label) {
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Device Types', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
@@ -48,17 +48,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
var __1 = require("..");
|
|
51
|
-
var __2 = require("..");
|
|
52
51
|
var constants_1 = require("../constants");
|
|
53
52
|
var helpers_1 = require("../helpers");
|
|
54
53
|
var testConstants_1 = require("../testConstants");
|
|
55
54
|
describe('Devices', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
55
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
56
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
57
|
var result;
|
|
59
58
|
return __generator(this, function (_a) {
|
|
60
59
|
switch (_a.label) {
|
|
61
|
-
case 0: return [4,
|
|
60
|
+
case 0: return [4, __1.Authentication.login(testConstants_1.TestAuth.username, testConstants_1.TestAuth.pass)];
|
|
62
61
|
case 1:
|
|
63
62
|
result = _a.sent();
|
|
64
63
|
expect(result.session_token).not.toBeNull();
|
|
@@ -66,13 +65,30 @@ describe('Devices', function () {
|
|
|
66
65
|
}
|
|
67
66
|
});
|
|
68
67
|
}); });
|
|
68
|
+
var targetDeviceType;
|
|
69
|
+
it('Given a device type', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
+
var deviceTypeOptions, dtresult;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
deviceTypeOptions = JSON.parse(JSON.stringify(testConstants_1.TestDeviceType));
|
|
75
|
+
deviceTypeOptions.name = 'js_sdk_discovered_device_test_device_type';
|
|
76
|
+
return [4, __1.DeviceTypes.create(testConstants_1.TestDeviceType)];
|
|
77
|
+
case 1:
|
|
78
|
+
dtresult = _a.sent();
|
|
79
|
+
expect(dtresult._id).not.toBeNull();
|
|
80
|
+
targetDeviceType = dtresult;
|
|
81
|
+
return [2];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); });
|
|
69
85
|
var device = testConstants_1.EmptyDevice;
|
|
70
86
|
var device2 = testConstants_1.EmptyDevice;
|
|
71
87
|
it('Creates a device', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
88
|
var result;
|
|
73
89
|
return __generator(this, function (_a) {
|
|
74
90
|
switch (_a.label) {
|
|
75
|
-
case 0: return [4, __1.Devices.create(testConstants_1.TestDevice)];
|
|
91
|
+
case 0: return [4, __1.Devices.create(__assign(__assign({}, testConstants_1.TestDevice), { device_type_id: targetDeviceType._id }))];
|
|
76
92
|
case 1:
|
|
77
93
|
result = _a.sent();
|
|
78
94
|
expect(result._id).not.toBeNull();
|
|
@@ -88,7 +104,7 @@ describe('Devices', function () {
|
|
|
88
104
|
switch (_a.label) {
|
|
89
105
|
case 0:
|
|
90
106
|
_a.trys.push([0, 2, , 3]);
|
|
91
|
-
return [4, __1.Devices.create(testConstants_1.TestDevice)];
|
|
107
|
+
return [4, __1.Devices.create(__assign(__assign({}, testConstants_1.TestDevice), { device_type_id: targetDeviceType._id }))];
|
|
92
108
|
case 1:
|
|
93
109
|
_a.sent();
|
|
94
110
|
return [3, 3];
|
|
@@ -106,7 +122,7 @@ describe('Devices', function () {
|
|
|
106
122
|
var result;
|
|
107
123
|
return __generator(this, function (_a) {
|
|
108
124
|
switch (_a.label) {
|
|
109
|
-
case 0: return [4, __1.Devices.create(testConstants_1.TestDevice2)];
|
|
125
|
+
case 0: return [4, __1.Devices.create(__assign(__assign({}, testConstants_1.TestDevice2), { device_type_id: targetDeviceType._id }))];
|
|
110
126
|
case 1:
|
|
111
127
|
result = _a.sent();
|
|
112
128
|
expect(result._id).not.toBeNull();
|
|
@@ -201,4 +217,16 @@ describe('Devices', function () {
|
|
|
201
217
|
}
|
|
202
218
|
});
|
|
203
219
|
}); });
|
|
220
|
+
it('cleans up', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
221
|
+
var dtresult;
|
|
222
|
+
return __generator(this, function (_a) {
|
|
223
|
+
switch (_a.label) {
|
|
224
|
+
case 0: return [4, __1.DeviceTypes.delete(targetDeviceType._id)];
|
|
225
|
+
case 1:
|
|
226
|
+
dtresult = _a.sent();
|
|
227
|
+
expect(dtresult).toBe((0, helpers_1.getReturnDeleteMessage)('device type'));
|
|
228
|
+
return [2];
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}); });
|
|
204
232
|
});
|
|
@@ -42,8 +42,8 @@ var constants_1 = require("../constants");
|
|
|
42
42
|
var helpers_1 = require("../helpers");
|
|
43
43
|
var testConstants_1 = require("../testConstants");
|
|
44
44
|
describe('Devices', function () {
|
|
45
|
-
__1.EdgeIQAPI.init();
|
|
46
|
-
it('
|
|
45
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
46
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
47
|
var result;
|
|
48
48
|
return __generator(this, function (_a) {
|
|
49
49
|
switch (_a.label) {
|
|
@@ -55,6 +55,23 @@ describe('Devices', function () {
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
}); });
|
|
58
|
+
var targetDeviceType;
|
|
59
|
+
it('Given a device type', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
+
var deviceTypeOptions, dtresult;
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
deviceTypeOptions = JSON.parse(JSON.stringify(testConstants_1.TestDeviceType));
|
|
65
|
+
deviceTypeOptions.name = 'js_sdk_discovered_device_test_device_type';
|
|
66
|
+
return [4, __1.DeviceTypes.create(testConstants_1.TestDeviceType)];
|
|
67
|
+
case 1:
|
|
68
|
+
dtresult = _a.sent();
|
|
69
|
+
expect(dtresult._id).not.toBeNull();
|
|
70
|
+
targetDeviceType = dtresult;
|
|
71
|
+
return [2];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}); });
|
|
58
75
|
var discoveredDevice;
|
|
59
76
|
var device;
|
|
60
77
|
it('Creates a discovered device', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -77,7 +94,7 @@ describe('Devices', function () {
|
|
|
77
94
|
switch (_a.label) {
|
|
78
95
|
case 0:
|
|
79
96
|
if (!discoveredDevice._id) return [3, 2];
|
|
80
|
-
return [4, __1.DiscoveredDevices.promote(discoveredDevice,
|
|
97
|
+
return [4, __1.DiscoveredDevices.promote(discoveredDevice, targetDeviceType._id)];
|
|
81
98
|
case 1:
|
|
82
99
|
result = _a.sent();
|
|
83
100
|
device = result;
|
|
@@ -123,4 +140,16 @@ describe('Devices', function () {
|
|
|
123
140
|
}
|
|
124
141
|
});
|
|
125
142
|
}); });
|
|
143
|
+
it('cleans up', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
144
|
+
var dtresult;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0: return [4, __1.DeviceTypes.delete(targetDeviceType._id)];
|
|
148
|
+
case 1:
|
|
149
|
+
dtresult = _a.sent();
|
|
150
|
+
expect(dtresult).toBe((0, helpers_1.getReturnDeleteMessage)('device type'));
|
|
151
|
+
return [2];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}); });
|
|
126
155
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var __1 = require("..");
|
|
51
|
+
var __2 = require("..");
|
|
52
|
+
var constants_1 = require("../constants");
|
|
53
|
+
var helpers_1 = require("../helpers");
|
|
54
|
+
var testConstants_1 = require("../testConstants");
|
|
55
|
+
describe('EIQFiles', function () {
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var result;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0: return [4, __2.Authentication.login(testConstants_1.TestAuth.username, testConstants_1.TestAuth.pass)];
|
|
62
|
+
case 1:
|
|
63
|
+
result = _a.sent();
|
|
64
|
+
expect(result.session_token).not.toBeNull();
|
|
65
|
+
return [2];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}); });
|
|
69
|
+
var targetDevice;
|
|
70
|
+
var targetDeviceType;
|
|
71
|
+
it('Given a device type and a device', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var deviceTypeOptions, dtresult, deviceOptions, dresult;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
deviceTypeOptions = JSON.parse(JSON.stringify(testConstants_1.TestDeviceType));
|
|
77
|
+
deviceTypeOptions.name = 'js_sdk_file_test_device_type';
|
|
78
|
+
return [4, __1.DeviceTypes.create(testConstants_1.TestDeviceType)];
|
|
79
|
+
case 1:
|
|
80
|
+
dtresult = _a.sent();
|
|
81
|
+
expect(dtresult._id).not.toBeNull();
|
|
82
|
+
targetDeviceType = dtresult;
|
|
83
|
+
deviceOptions = JSON.parse(JSON.stringify(__assign(__assign({}, testConstants_1.TestDevice), { device_type_id: targetDeviceType._id })));
|
|
84
|
+
deviceOptions.unique_id = 'js_sdk_file_test_device';
|
|
85
|
+
return [4, __1.Devices.create(deviceOptions)];
|
|
86
|
+
case 2:
|
|
87
|
+
dresult = _a.sent();
|
|
88
|
+
expect(dresult._id).not.toBeNull();
|
|
89
|
+
targetDevice = dresult;
|
|
90
|
+
return [2];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}); });
|
|
94
|
+
var createdFile;
|
|
95
|
+
it('Creates a file object', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
+
var result;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0: return [4, __1.EIQFiles.create(testConstants_1.TestFile)];
|
|
100
|
+
case 1:
|
|
101
|
+
result = _a.sent();
|
|
102
|
+
expect(result._id).not.toBeNull();
|
|
103
|
+
expect(result.name).toBe(testConstants_1.TestFile.name);
|
|
104
|
+
createdFile = result;
|
|
105
|
+
return [2];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}); });
|
|
109
|
+
it('Lists files', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
110
|
+
var filters, result, firstFile;
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
switch (_a.label) {
|
|
113
|
+
case 0:
|
|
114
|
+
filters = {
|
|
115
|
+
name: {
|
|
116
|
+
operator: 'eq',
|
|
117
|
+
value: testConstants_1.TestFile.name,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
return [4, __1.EIQFiles.list(filters)];
|
|
121
|
+
case 1:
|
|
122
|
+
result = _a.sent();
|
|
123
|
+
firstFile = result.files[0];
|
|
124
|
+
expect(firstFile === null || firstFile === void 0 ? void 0 : firstFile.name).toEqual(testConstants_1.TestFile.name);
|
|
125
|
+
expect(result.files).toBeDefined();
|
|
126
|
+
expect(result.files).toBeInstanceOf(Array);
|
|
127
|
+
expect(result.files).toHaveLength(1);
|
|
128
|
+
expect(result.pagination.page).toBe(constants_1.DefaultPagination.page);
|
|
129
|
+
expect(result.pagination.itemsPerPage).toBe(constants_1.DefaultPagination.itemsPerPage);
|
|
130
|
+
return [2];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}); });
|
|
134
|
+
it('Deletes a file', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
135
|
+
var result;
|
|
136
|
+
return __generator(this, function (_a) {
|
|
137
|
+
switch (_a.label) {
|
|
138
|
+
case 0: return [4, __1.EIQFiles.delete(createdFile.id)];
|
|
139
|
+
case 1:
|
|
140
|
+
result = _a.sent();
|
|
141
|
+
expect(result).toBe((0, helpers_1.getReturnDeleteMessage)('file'));
|
|
142
|
+
return [2];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); });
|
|
146
|
+
it('cleans up', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
|
+
var dresult, dtresult;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0: return [4, __1.Devices.delete(targetDevice._id)];
|
|
151
|
+
case 1:
|
|
152
|
+
dresult = _a.sent();
|
|
153
|
+
return [4, __1.DeviceTypes.delete(targetDeviceType._id)];
|
|
154
|
+
case 2:
|
|
155
|
+
dtresult = _a.sent();
|
|
156
|
+
expect(dresult).toBe((0, helpers_1.getReturnDeleteMessage)('device'));
|
|
157
|
+
expect(dtresult).toBe((0, helpers_1.getReturnDeleteMessage)('device type'));
|
|
158
|
+
return [2];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}); });
|
|
162
|
+
});
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Ingestors', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
@@ -66,13 +66,27 @@ describe('Ingestors', function () {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
}); });
|
|
69
|
+
var translator;
|
|
70
|
+
it('Given a translator', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
+
var result;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0: return [4, __1.Translators.create(testConstants_1.TestTranslator)];
|
|
75
|
+
case 1:
|
|
76
|
+
result = _a.sent();
|
|
77
|
+
expect(result._id).not.toBeNull();
|
|
78
|
+
translator = result;
|
|
79
|
+
return [2];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}); });
|
|
69
83
|
var ingestor = testConstants_1.EmptyIngestor;
|
|
70
84
|
var ingestor2 = testConstants_1.EmptyIngestor;
|
|
71
85
|
it('Creates a ingestor', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
86
|
var result;
|
|
73
87
|
return __generator(this, function (_a) {
|
|
74
88
|
switch (_a.label) {
|
|
75
|
-
case 0: return [4, __1.Ingestors.create(testConstants_1.TestIngestor)];
|
|
89
|
+
case 0: return [4, __1.Ingestors.create(__assign(__assign({}, testConstants_1.TestIngestor), { translator_id: translator._id }))];
|
|
76
90
|
case 1:
|
|
77
91
|
result = _a.sent();
|
|
78
92
|
expect(result._id).not.toBeNull();
|
|
@@ -86,7 +100,7 @@ describe('Ingestors', function () {
|
|
|
86
100
|
var result;
|
|
87
101
|
return __generator(this, function (_a) {
|
|
88
102
|
switch (_a.label) {
|
|
89
|
-
case 0: return [4, __1.Ingestors.create(testConstants_1.TestIngestor2)];
|
|
103
|
+
case 0: return [4, __1.Ingestors.create(__assign(__assign({}, testConstants_1.TestIngestor2), { translator_id: translator._id }))];
|
|
90
104
|
case 1:
|
|
91
105
|
result = _a.sent();
|
|
92
106
|
expect(result._id).not.toBeNull();
|
|
@@ -169,4 +183,16 @@ describe('Ingestors', function () {
|
|
|
169
183
|
}
|
|
170
184
|
});
|
|
171
185
|
}); });
|
|
186
|
+
it('cleans up', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
+
var dresult;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0: return [4, __1.Translators.delete(translator._id)];
|
|
191
|
+
case 1:
|
|
192
|
+
dresult = _a.sent();
|
|
193
|
+
expect(dresult).toBe((0, helpers_1.getReturnDeleteMessage)('translator'));
|
|
194
|
+
return [2];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); });
|
|
172
198
|
});
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Integrations', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
@@ -41,8 +41,8 @@ var __2 = require("..");
|
|
|
41
41
|
var notifications_1 = require("../notifications");
|
|
42
42
|
var testConstants_1 = require("../testConstants");
|
|
43
43
|
describe('Device Types', function () {
|
|
44
|
-
__1.EdgeIQAPI.init();
|
|
45
|
-
it('
|
|
44
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
45
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
46
|
var result;
|
|
47
47
|
return __generator(this, function (_a) {
|
|
48
48
|
switch (_a.label) {
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Pollable Attributes', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Rules', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Translators', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
@@ -53,8 +53,8 @@ var constants_1 = require("../constants");
|
|
|
53
53
|
var helpers_1 = require("../helpers");
|
|
54
54
|
var testConstants_1 = require("../testConstants");
|
|
55
55
|
describe('Users', function () {
|
|
56
|
-
__1.EdgeIQAPI.init();
|
|
57
|
-
it('
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
58
|
var result;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
package/dist/devices/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Ingestor, Rule, Command } from '..';
|
|
1
|
+
import { Ingestor, Rule, Command, Log, EIQFile } from '..';
|
|
2
2
|
import { BaseModelInterface } from '../core/ModelClass';
|
|
3
|
-
import { Log } from '../log/models';
|
|
4
3
|
import { GatewayCommand, GatewayCommandRequest } from '../gatewayCommands/models';
|
|
5
4
|
import { BulkActionResponse } from '../models';
|
|
6
5
|
import { Lwm2mObjectLinks } from '../lwm2m/models';
|
|
7
|
-
import { DeviceFile } from '../deviceFiles/models';
|
|
8
6
|
import { DevicesFilters, Device, DeviceInput, PaginatedDevices } from './models';
|
|
9
7
|
import { CommandExecution } from '../commandExecutions/models';
|
|
10
8
|
interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, DevicesFilters, PaginatedDevices> {
|
|
@@ -27,7 +25,7 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
|
|
|
27
25
|
deviceLwm2mObjetLinks(id: string): Promise<Lwm2mObjectLinks[]>;
|
|
28
26
|
processGatewayCommand(deviceId: string, gatewayCommandRequest: GatewayCommandRequest): Promise<GatewayCommand>;
|
|
29
27
|
bulkExecuteGatewayCommand(ids: string[], gatewayCommandRequest: GatewayCommandRequest): Promise<BulkActionResponse>;
|
|
30
|
-
getFiles(id: string): Promise<
|
|
28
|
+
getFiles(id: string): Promise<EIQFile[]>;
|
|
31
29
|
getCommandExecutions(id: string): Promise<CommandExecution[]>;
|
|
32
30
|
}
|
|
33
31
|
export declare const Devices: DevicesInterface;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseModelInterface } from '../core/ModelClass';
|
|
2
|
+
import { BulkActionResponse } from '../models';
|
|
3
|
+
import { FilesFilters, EIQFile, FileInput, PaginatedFiles } from './models';
|
|
4
|
+
interface FilesInterface extends BaseModelInterface<EIQFile, FileInput, FilesFilters, PaginatedFiles> {
|
|
5
|
+
update(file: EIQFile): Promise<EIQFile>;
|
|
6
|
+
deleteMultiple(ids: string[]): Promise<BulkActionResponse>;
|
|
7
|
+
uploadFile(id: string, file: File): Promise<EIQFile>;
|
|
8
|
+
downloadFile(id: string): Promise<File>;
|
|
9
|
+
}
|
|
10
|
+
export declare const EIQFiles: FilesInterface;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,278 @@
|
|
|
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.EIQFiles = 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.EIQFiles = (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 (file) {
|
|
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 file with unique ID: " + file);
|
|
73
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
74
|
+
data = JSON.stringify(file);
|
|
75
|
+
return [4, axios.post(constants_1.Endpoints.file, 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 (file) {
|
|
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 file with ID: " + file._id);
|
|
98
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
99
|
+
data = JSON.stringify(file);
|
|
100
|
+
return [4, axios.put(constants_1.Endpoints.file + "/" + file._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 files 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.file, {
|
|
126
|
+
params: (0, filtersParser_1.parseFilters)(filters, pagination),
|
|
127
|
+
})];
|
|
128
|
+
case 1:
|
|
129
|
+
result = _e.sent();
|
|
130
|
+
return [2, {
|
|
131
|
+
files: (_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 file with id: " + id);
|
|
157
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
158
|
+
return [4, axios.get(constants_1.Endpoints.file + "/" + 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 file with id " + id);
|
|
181
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
182
|
+
return [4, axios.delete(constants_1.Endpoints.file + "/" + id)];
|
|
183
|
+
case 1:
|
|
184
|
+
_a.sent();
|
|
185
|
+
return [2, (0, helpers_1.getReturnDeleteMessage)('file')];
|
|
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.uploadFile = function (id, file) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var axios, form, 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("Uploading file to device");
|
|
205
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
206
|
+
form = new FormData();
|
|
207
|
+
form.append('file', file);
|
|
208
|
+
return [4, axios.post(constants_1.Endpoints.file + "/" + id, form, {
|
|
209
|
+
headers: {
|
|
210
|
+
'Content-Type': 'multipart/form-data',
|
|
211
|
+
},
|
|
212
|
+
})];
|
|
213
|
+
case 1:
|
|
214
|
+
result = _a.sent();
|
|
215
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
216
|
+
case 2:
|
|
217
|
+
error_6 = _a.sent();
|
|
218
|
+
if ((0, helpers_1.isApiError)(error_6)) {
|
|
219
|
+
throw error_6;
|
|
220
|
+
}
|
|
221
|
+
throw error_6;
|
|
222
|
+
case 3: return [2];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
class_1.downloadFile = function (id) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
+
var axios, result, error_7;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
_a.trys.push([0, 2, , 3]);
|
|
234
|
+
this.logAction("Downloading file with id: " + id);
|
|
235
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
236
|
+
return [4, axios.get(constants_1.Endpoints.file + "/" + id + "/download")];
|
|
237
|
+
case 1:
|
|
238
|
+
result = _a.sent();
|
|
239
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
240
|
+
case 2:
|
|
241
|
+
error_7 = _a.sent();
|
|
242
|
+
if ((0, helpers_1.isApiError)(error_7)) {
|
|
243
|
+
throw error_7;
|
|
244
|
+
}
|
|
245
|
+
throw error_7;
|
|
246
|
+
case 3: return [2];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
class_1.deleteMultiple = function (ids) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
var axios, result, error_8;
|
|
254
|
+
return __generator(this, function (_a) {
|
|
255
|
+
switch (_a.label) {
|
|
256
|
+
case 0:
|
|
257
|
+
_a.trys.push([0, 2, , 3]);
|
|
258
|
+
this.logAction("Deleting files with id " + ids.join(', '));
|
|
259
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
260
|
+
return [4, axios.delete(constants_1.Endpoints.file + "/bulk", {
|
|
261
|
+
data: { ids: ids },
|
|
262
|
+
})];
|
|
263
|
+
case 1:
|
|
264
|
+
result = _a.sent();
|
|
265
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
266
|
+
case 2:
|
|
267
|
+
error_8 = _a.sent();
|
|
268
|
+
if ((0, helpers_1.isApiError)(error_8)) {
|
|
269
|
+
throw error_8;
|
|
270
|
+
}
|
|
271
|
+
throw error_8;
|
|
272
|
+
case 3: return [2];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
return class_1;
|
|
278
|
+
}(ModelClass_1.BaseModelClass));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Base, Filter, Filters, Pagination } from '../models';
|
|
2
|
+
export interface FileInput {
|
|
3
|
+
name: string;
|
|
4
|
+
mime_type: string;
|
|
5
|
+
company_id: string;
|
|
6
|
+
device_id?: string;
|
|
7
|
+
metadata?: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface EIQFile extends FileInput, Base {
|
|
10
|
+
id: string;
|
|
11
|
+
size: number;
|
|
12
|
+
}
|
|
13
|
+
export interface FilesFilters extends Filters {
|
|
14
|
+
unique_id?: Filter;
|
|
15
|
+
website?: Filter;
|
|
16
|
+
}
|
|
17
|
+
export interface PaginatedFiles {
|
|
18
|
+
files: EIQFile[];
|
|
19
|
+
pagination: Pagination;
|
|
20
|
+
}
|
|
@@ -28,6 +28,9 @@ export interface GatewayCommandRequest {
|
|
|
28
28
|
export interface Lwm2mRequest extends GatewayCommandRequest {
|
|
29
29
|
type: CommandType;
|
|
30
30
|
endpoint: string;
|
|
31
|
+
value?: string;
|
|
32
|
+
file_path?: string;
|
|
33
|
+
file?: string;
|
|
31
34
|
}
|
|
32
35
|
export interface AmagCardHolder {
|
|
33
36
|
first_name?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,11 +8,11 @@ export { DeviceConfigs } from './deviceConfigs';
|
|
|
8
8
|
export { DeviceLocationObservations } from './deviceLocationObservations';
|
|
9
9
|
export { Devices } from './devices';
|
|
10
10
|
export { DeviceErrors } from './deviceErrors';
|
|
11
|
-
export { DeviceFiles } from './deviceFiles';
|
|
12
11
|
export { DeviceTemplates } from './deviceTemplates';
|
|
13
12
|
export { DeviceTransferRequests } from './deviceTransferRequests';
|
|
14
13
|
export { DeviceTypes } from './deviceTypes';
|
|
15
14
|
export { DiscoveredDevices } from './discoveredDevices';
|
|
15
|
+
export { EIQFiles } from './files';
|
|
16
16
|
export { DownstreamSystems } from './downstreamSystems';
|
|
17
17
|
export { EscrowDevices } from './escrowDevices';
|
|
18
18
|
export { GatewayCommands } from './gatewayCommands';
|
|
@@ -40,7 +40,6 @@ export * from './commandExecutions/models';
|
|
|
40
40
|
export * from './deviceConfigs/models';
|
|
41
41
|
export * from './deviceLocationObservations/models';
|
|
42
42
|
export * from './devices/models';
|
|
43
|
-
export * from './deviceFiles/models';
|
|
44
43
|
export * from './discoveredDevices/models';
|
|
45
44
|
export * from './deviceErrors/models';
|
|
46
45
|
export * from './deviceTemplates/models';
|
|
@@ -48,10 +47,12 @@ export * from './deviceTransferRequests/models';
|
|
|
48
47
|
export * from './deviceTypes/models';
|
|
49
48
|
export * from './downstreamSystems/models';
|
|
50
49
|
export * from './escrowDevices/models';
|
|
50
|
+
export * from './files/models';
|
|
51
51
|
export * from './gatewayCommands/models';
|
|
52
52
|
export * from './ingestors/models';
|
|
53
53
|
export * from './integrations/models';
|
|
54
54
|
export * from './lwm2m/models';
|
|
55
|
+
export * from './log/models';
|
|
55
56
|
export * from './notifications/models';
|
|
56
57
|
export * from './pollableAttributes/models';
|
|
57
58
|
export * from './reports/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.LWM2M = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.
|
|
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.LWM2M = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.EIQFiles = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.DeviceErrors = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.CommandExecutions = 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");
|
|
@@ -31,8 +31,6 @@ var devices_1 = require("./devices");
|
|
|
31
31
|
Object.defineProperty(exports, "Devices", { enumerable: true, get: function () { return devices_1.Devices; } });
|
|
32
32
|
var deviceErrors_1 = require("./deviceErrors");
|
|
33
33
|
Object.defineProperty(exports, "DeviceErrors", { enumerable: true, get: function () { return deviceErrors_1.DeviceErrors; } });
|
|
34
|
-
var deviceFiles_1 = require("./deviceFiles");
|
|
35
|
-
Object.defineProperty(exports, "DeviceFiles", { enumerable: true, get: function () { return deviceFiles_1.DeviceFiles; } });
|
|
36
34
|
var deviceTemplates_1 = require("./deviceTemplates");
|
|
37
35
|
Object.defineProperty(exports, "DeviceTemplates", { enumerable: true, get: function () { return deviceTemplates_1.DeviceTemplates; } });
|
|
38
36
|
var deviceTransferRequests_1 = require("./deviceTransferRequests");
|
|
@@ -41,6 +39,8 @@ var deviceTypes_1 = require("./deviceTypes");
|
|
|
41
39
|
Object.defineProperty(exports, "DeviceTypes", { enumerable: true, get: function () { return deviceTypes_1.DeviceTypes; } });
|
|
42
40
|
var discoveredDevices_1 = require("./discoveredDevices");
|
|
43
41
|
Object.defineProperty(exports, "DiscoveredDevices", { enumerable: true, get: function () { return discoveredDevices_1.DiscoveredDevices; } });
|
|
42
|
+
var files_1 = require("./files");
|
|
43
|
+
Object.defineProperty(exports, "EIQFiles", { enumerable: true, get: function () { return files_1.EIQFiles; } });
|
|
44
44
|
var downstreamSystems_1 = require("./downstreamSystems");
|
|
45
45
|
Object.defineProperty(exports, "DownstreamSystems", { enumerable: true, get: function () { return downstreamSystems_1.DownstreamSystems; } });
|
|
46
46
|
var escrowDevices_1 = require("./escrowDevices");
|
|
@@ -87,7 +87,6 @@ __exportStar(require("./commandExecutions/models"), exports);
|
|
|
87
87
|
__exportStar(require("./deviceConfigs/models"), exports);
|
|
88
88
|
__exportStar(require("./deviceLocationObservations/models"), exports);
|
|
89
89
|
__exportStar(require("./devices/models"), exports);
|
|
90
|
-
__exportStar(require("./deviceFiles/models"), exports);
|
|
91
90
|
__exportStar(require("./discoveredDevices/models"), exports);
|
|
92
91
|
__exportStar(require("./deviceErrors/models"), exports);
|
|
93
92
|
__exportStar(require("./deviceTemplates/models"), exports);
|
|
@@ -95,10 +94,12 @@ __exportStar(require("./deviceTransferRequests/models"), exports);
|
|
|
95
94
|
__exportStar(require("./deviceTypes/models"), exports);
|
|
96
95
|
__exportStar(require("./downstreamSystems/models"), exports);
|
|
97
96
|
__exportStar(require("./escrowDevices/models"), exports);
|
|
97
|
+
__exportStar(require("./files/models"), exports);
|
|
98
98
|
__exportStar(require("./gatewayCommands/models"), exports);
|
|
99
99
|
__exportStar(require("./ingestors/models"), exports);
|
|
100
100
|
__exportStar(require("./integrations/models"), exports);
|
|
101
101
|
__exportStar(require("./lwm2m/models"), exports);
|
|
102
|
+
__exportStar(require("./log/models"), exports);
|
|
102
103
|
__exportStar(require("./notifications/models"), exports);
|
|
103
104
|
__exportStar(require("./pollableAttributes/models"), exports);
|
|
104
105
|
__exportStar(require("./reports/models"), exports);
|
package/dist/testConstants.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { IntegrationInput, Company, CompanyInput, CommandInput, 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, FileInput } from '.';
|
|
2
2
|
import { Notification } from './notifications/models';
|
|
3
|
+
export declare const stageURL: {
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
3
6
|
export declare const TestAuth: {
|
|
4
7
|
noUser: string;
|
|
5
8
|
username: string;
|
|
6
9
|
pass: string;
|
|
7
10
|
};
|
|
8
|
-
export declare const TestDeviceTypeID = "610aaa4abc72d700011b872d";
|
|
9
11
|
export declare const TestDevice: DeviceInput;
|
|
10
12
|
export declare const TestDevice2: DeviceInput;
|
|
11
13
|
export declare const EmptyDevice: Device;
|
|
@@ -45,3 +47,4 @@ export declare const NewTestRuleDescription = "EIQSDK Rule Test updated";
|
|
|
45
47
|
export declare const TestDiscoveredDevice: DiscoveredDeviceInput;
|
|
46
48
|
export declare const TestCommand: CommandInput;
|
|
47
49
|
export declare const EmptyNotificationType: Notification;
|
|
50
|
+
export declare const TestFile: FileInput;
|
package/dist/testConstants.js
CHANGED
|
@@ -11,9 +11,12 @@ 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.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.
|
|
14
|
+
exports.TestFile = 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.TestAuth = exports.stageURL = void 0;
|
|
15
15
|
var _1 = require(".");
|
|
16
|
-
|
|
16
|
+
exports.stageURL = {
|
|
17
|
+
url: 'https://api.stage.edgeiq.io/api/v1/platform/',
|
|
18
|
+
};
|
|
19
|
+
var parentCompanyId = '30_qa_company';
|
|
17
20
|
var baseModel = {
|
|
18
21
|
_id: '',
|
|
19
22
|
company_id: '',
|
|
@@ -24,17 +27,16 @@ var baseModel = {
|
|
|
24
27
|
};
|
|
25
28
|
exports.TestAuth = {
|
|
26
29
|
noUser: 'NO_USER_VALUE',
|
|
27
|
-
username: 'akhil.asaad+
|
|
28
|
-
pass: '
|
|
30
|
+
username: 'akhil.asaad+30qa@edgeiq.io',
|
|
31
|
+
pass: 'p@ssw0rd',
|
|
29
32
|
};
|
|
30
|
-
exports.TestDeviceTypeID = '610aaa4abc72d700011b872d';
|
|
31
33
|
exports.TestDevice = {
|
|
32
|
-
device_type_id:
|
|
34
|
+
device_type_id: '',
|
|
33
35
|
name: 'EdgeIQAPI Test Device',
|
|
34
|
-
unique_id: '
|
|
36
|
+
unique_id: 'api_js_test_device',
|
|
35
37
|
company_id: parentCompanyId,
|
|
36
38
|
};
|
|
37
|
-
exports.TestDevice2 = __assign(__assign({}, exports.TestDevice), { name: 'EdgeIQAPI Test Device 2', unique_id: '
|
|
39
|
+
exports.TestDevice2 = __assign(__assign({}, exports.TestDevice), { name: 'EdgeIQAPI Test Device 2', unique_id: 'api_js_test_device_2' });
|
|
38
40
|
exports.EmptyDevice = __assign(__assign({}, baseModel), { unique_id: '', device_type_id: '', name: '' });
|
|
39
41
|
exports.NewTestDeviceName = 'Updated Test Device name';
|
|
40
42
|
exports.TestUser = {
|
|
@@ -42,7 +44,7 @@ exports.TestUser = {
|
|
|
42
44
|
email: 'akhil.edgeiq.api.user@user.com',
|
|
43
45
|
first_name: 'API User',
|
|
44
46
|
last_name: 'Test user',
|
|
45
|
-
user_type_id: '
|
|
47
|
+
user_type_id: '5fc672507048be0001f045bd',
|
|
46
48
|
password: 'Test123!',
|
|
47
49
|
password_confirmation: 'Test123!',
|
|
48
50
|
};
|
|
@@ -177,7 +179,7 @@ exports.TestIngestor = {
|
|
|
177
179
|
type: 'cloud',
|
|
178
180
|
listener_type: 'cloud',
|
|
179
181
|
handler_type: 'passthrough',
|
|
180
|
-
translator_id: '
|
|
182
|
+
translator_id: '',
|
|
181
183
|
listener: {
|
|
182
184
|
version: '1',
|
|
183
185
|
params: {
|
|
@@ -213,7 +215,7 @@ exports.TestIngestor2 = {
|
|
|
213
215
|
type: 'edge',
|
|
214
216
|
listener_type: 'shell_polling',
|
|
215
217
|
handler_type: 'fixed',
|
|
216
|
-
translator_id: '
|
|
218
|
+
translator_id: '',
|
|
217
219
|
listener: {
|
|
218
220
|
version: '1',
|
|
219
221
|
params: {
|
|
@@ -310,3 +312,8 @@ exports.TestCommand = {
|
|
|
310
312
|
},
|
|
311
313
|
};
|
|
312
314
|
exports.EmptyNotificationType = __assign(__assign({}, baseModel), { message: 'message', rule_id: 'rule_id', device_id: 'device_id' });
|
|
315
|
+
exports.TestFile = {
|
|
316
|
+
company_id: parentCompanyId,
|
|
317
|
+
mime_type: 'text/plain',
|
|
318
|
+
name: 'Test File',
|
|
319
|
+
};
|