@edgeiq/edgeiq-api-js 1.2.0 → 1.2.3
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__/notifications.test.d.ts +1 -0
- package/dist/__tests__/notifications.test.js +72 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/discoveredDevices/index.js +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/notifications/index.d.ts +8 -0
- package/dist/notifications/index.js +124 -0
- package/dist/notifications/models.d.ts +19 -0
- package/dist/notifications/models.js +2 -0
- package/dist/testConstants.d.ts +2 -0
- package/dist/testConstants.js +2 -1
- package/dist/users/index.d.ts +2 -0
- package/dist/users/index.js +48 -0
- package/package.json +1 -1
|
@@ -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 notifications_1 = require("../notifications");
|
|
42
|
+
var testConstants_1 = require("../testConstants");
|
|
43
|
+
describe('Device Types', 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 notifications', 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, notifications_1.Notifications.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/constants.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare const getAttachMessage: (model: string, action: string, baseModel
|
|
|
53
53
|
export declare const BaseEndpoints: {
|
|
54
54
|
auth: string;
|
|
55
55
|
bulkResponse: string;
|
|
56
|
+
notification: string;
|
|
56
57
|
command: string;
|
|
57
58
|
company: string;
|
|
58
59
|
deviceConfig: string;
|
|
@@ -89,6 +90,7 @@ export declare const Endpoints: {
|
|
|
89
90
|
passwordResetRequest: string;
|
|
90
91
|
passwordReset: string;
|
|
91
92
|
bulkResponse: string;
|
|
93
|
+
notification: string;
|
|
92
94
|
command: string;
|
|
93
95
|
company: string;
|
|
94
96
|
deviceConfig: string;
|
package/dist/constants.js
CHANGED
|
@@ -69,6 +69,7 @@ exports.getAttachMessage = getAttachMessage;
|
|
|
69
69
|
exports.BaseEndpoints = {
|
|
70
70
|
auth: 'user',
|
|
71
71
|
bulkResponse: 'bulk_responses',
|
|
72
|
+
notification: 'notifications',
|
|
72
73
|
command: 'commands',
|
|
73
74
|
company: 'companies',
|
|
74
75
|
deviceConfig: 'device_configs',
|
|
@@ -105,6 +106,7 @@ exports.Endpoints = {
|
|
|
105
106
|
passwordResetRequest: exports.BaseEndpoints.auth + "/password_reset_request",
|
|
106
107
|
passwordReset: exports.BaseEndpoints.auth + "/password_reset",
|
|
107
108
|
bulkResponse: "" + exports.BaseEndpoints.bulkResponse,
|
|
109
|
+
notification: "" + exports.BaseEndpoints.notification,
|
|
108
110
|
command: "" + exports.BaseEndpoints.command,
|
|
109
111
|
company: "" + exports.BaseEndpoints.company,
|
|
110
112
|
deviceConfig: "" + exports.BaseEndpoints.deviceConfig,
|
|
@@ -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
|
@@ -15,6 +15,7 @@ export { EscrowDevices } from './escrowDevices';
|
|
|
15
15
|
export { GatewayCommands } from './gatewayCommands';
|
|
16
16
|
export { Ingestors } from './ingestors';
|
|
17
17
|
export { Integrations } from './integrations';
|
|
18
|
+
export { Notifications } from './notifications';
|
|
18
19
|
export { PollableAttributes } from './pollableAttributes';
|
|
19
20
|
export { Regions } from './regions';
|
|
20
21
|
export { Reports } from './reports';
|
|
@@ -43,6 +44,7 @@ export * from './escrowDevices/models';
|
|
|
43
44
|
export * from './gatewayCommands/models';
|
|
44
45
|
export * from './ingestors/models';
|
|
45
46
|
export * from './integrations/models';
|
|
47
|
+
export * from './notifications/models';
|
|
46
48
|
export * from './pollableAttributes/models';
|
|
47
49
|
export * from './reports/models';
|
|
48
50
|
export * from './regions/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.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.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");
|
|
@@ -45,6 +45,8 @@ var ingestors_1 = require("./ingestors");
|
|
|
45
45
|
Object.defineProperty(exports, "Ingestors", { enumerable: true, get: function () { return ingestors_1.Ingestors; } });
|
|
46
46
|
var integrations_1 = require("./integrations");
|
|
47
47
|
Object.defineProperty(exports, "Integrations", { enumerable: true, get: function () { return integrations_1.Integrations; } });
|
|
48
|
+
var notifications_1 = require("./notifications");
|
|
49
|
+
Object.defineProperty(exports, "Notifications", { enumerable: true, get: function () { return notifications_1.Notifications; } });
|
|
48
50
|
var pollableAttributes_1 = require("./pollableAttributes");
|
|
49
51
|
Object.defineProperty(exports, "PollableAttributes", { enumerable: true, get: function () { return pollableAttributes_1.PollableAttributes; } });
|
|
50
52
|
var regions_1 = require("./regions");
|
|
@@ -85,6 +87,7 @@ __exportStar(require("./escrowDevices/models"), exports);
|
|
|
85
87
|
__exportStar(require("./gatewayCommands/models"), exports);
|
|
86
88
|
__exportStar(require("./ingestors/models"), exports);
|
|
87
89
|
__exportStar(require("./integrations/models"), exports);
|
|
90
|
+
__exportStar(require("./notifications/models"), exports);
|
|
88
91
|
__exportStar(require("./pollableAttributes/models"), exports);
|
|
89
92
|
__exportStar(require("./reports/models"), exports);
|
|
90
93
|
__exportStar(require("./regions/models"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PaginationFilter } from '../models';
|
|
2
|
+
import { Notification, NotificationsFilters, PaginatedNotifications } from './models';
|
|
3
|
+
interface NotificationsInterface {
|
|
4
|
+
list(filters?: NotificationsFilters, pagination?: PaginationFilter): Promise<PaginatedNotifications>;
|
|
5
|
+
getOneById(id: string): Promise<Notification>;
|
|
6
|
+
}
|
|
7
|
+
export declare const Notifications: NotificationsInterface;
|
|
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.Notifications = 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.Notifications = (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 notification 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.notification, {
|
|
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 notification with id: " + id);
|
|
107
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
108
|
+
return [4, axios.get(constants_1.Endpoints.notification + "/" + 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 NotificationInput {
|
|
3
|
+
message: string;
|
|
4
|
+
device_id: string;
|
|
5
|
+
rule_id: string;
|
|
6
|
+
device_config_id?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Notification extends NotificationInput, Base {
|
|
9
|
+
}
|
|
10
|
+
export interface NotificationsFilters extends Filters {
|
|
11
|
+
device_id?: Filter;
|
|
12
|
+
device_config_id?: Filter;
|
|
13
|
+
message?: Filter;
|
|
14
|
+
rule_id?: Filter;
|
|
15
|
+
}
|
|
16
|
+
export interface PaginatedNotifications {
|
|
17
|
+
resources: Notification[];
|
|
18
|
+
pagination: Pagination;
|
|
19
|
+
}
|
package/dist/testConstants.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IntegrationInput, Company, CompanyInput, Device, DeviceInput, DiscoveredDeviceInput, DeviceType, DeviceTypeInput, User, UserInput, Integration, Ingestor, IngestorInput, PollableAttribute, PollableAttributeInput, Translator, TranslatorInput, Rule, RuleInput } from '.';
|
|
2
|
+
import { Notification } from './notifications/models';
|
|
2
3
|
export declare const TestAuth: {
|
|
3
4
|
noUser: string;
|
|
4
5
|
username: string;
|
|
@@ -42,3 +43,4 @@ export declare const TestRule: RuleInput;
|
|
|
42
43
|
export declare const TestRule2: RuleInput;
|
|
43
44
|
export declare const NewTestRuleDescription = "EIQSDK Rule Test updated";
|
|
44
45
|
export declare const TestDiscoveredDevice: DiscoveredDeviceInput;
|
|
46
|
+
export declare const EmptyNotificationType: Notification;
|
package/dist/testConstants.js
CHANGED
|
@@ -11,7 +11,7 @@ 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.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.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
15
|
var parentCompanyId = 'whiteprompt_ssi_dev';
|
|
16
16
|
var baseModel = {
|
|
17
17
|
_id: '',
|
|
@@ -218,3 +218,4 @@ exports.TestDiscoveredDevice = {
|
|
|
218
218
|
name: 'Test Discovered Device',
|
|
219
219
|
unique_id: 'test_discovered_device',
|
|
220
220
|
};
|
|
221
|
+
exports.EmptyNotificationType = __assign(__assign({}, baseModel), { message: 'message', rule_id: 'rule_id', device_id: 'device_id' });
|
package/dist/users/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ interface UsersInterface extends BaseModelInterface<User, UserInput, UsersFilter
|
|
|
5
5
|
update(user: User): Promise<User>;
|
|
6
6
|
getOneByEmail(email: string): Promise<User>;
|
|
7
7
|
deleteMultiple(ids: string[]): Promise<BulkActionResponse>;
|
|
8
|
+
addCompanyId(companyId: string, userId: string): Promise<string>;
|
|
9
|
+
removeCompanyId(companyId: string, userId: string): Promise<string>;
|
|
8
10
|
}
|
|
9
11
|
export declare const Users: UsersInterface;
|
|
10
12
|
export {};
|
package/dist/users/index.js
CHANGED
|
@@ -248,5 +248,53 @@ exports.Users = (function (_super) {
|
|
|
248
248
|
});
|
|
249
249
|
});
|
|
250
250
|
};
|
|
251
|
+
class_1.addCompanyId = function (companyId, userId) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
var axios, 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("Adding company id " + companyId + " to user " + userId);
|
|
259
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
260
|
+
return [4, axios.put(constants_1.Endpoints.user + "/" + userId + "/company_ids/" + companyId)];
|
|
261
|
+
case 1:
|
|
262
|
+
_a.sent();
|
|
263
|
+
return [2, 'Success'];
|
|
264
|
+
case 2:
|
|
265
|
+
error_8 = _a.sent();
|
|
266
|
+
if ((0, helpers_1.isApiError)(error_8)) {
|
|
267
|
+
throw error_8;
|
|
268
|
+
}
|
|
269
|
+
throw error_8;
|
|
270
|
+
case 3: return [2];
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
class_1.removeCompanyId = function (companyId, userId) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var axios, error_9;
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0:
|
|
281
|
+
_a.trys.push([0, 2, , 3]);
|
|
282
|
+
this.logAction("Removing company id " + companyId + " from user " + userId);
|
|
283
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
284
|
+
return [4, axios.delete(constants_1.Endpoints.user + "/" + userId + "/company_ids/" + companyId)];
|
|
285
|
+
case 1:
|
|
286
|
+
_a.sent();
|
|
287
|
+
return [2, 'Success'];
|
|
288
|
+
case 2:
|
|
289
|
+
error_9 = _a.sent();
|
|
290
|
+
if ((0, helpers_1.isApiError)(error_9)) {
|
|
291
|
+
throw error_9;
|
|
292
|
+
}
|
|
293
|
+
throw error_9;
|
|
294
|
+
case 3: return [2];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
};
|
|
251
299
|
return class_1;
|
|
252
300
|
}(ModelClass_1.BaseModelClass));
|