@edgeiq/edgeiq-api-js 1.0.4 → 1.1.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.
@@ -73,6 +73,7 @@ export declare const BaseEndpoints: {
73
73
  rule: string;
74
74
  secret: string;
75
75
  softwareUpdate: string;
76
+ stats: string;
76
77
  systemCommand: string;
77
78
  systemCommandJob: string;
78
79
  translator: string;
@@ -105,6 +106,9 @@ export declare const Endpoints: {
105
106
  rule: string;
106
107
  secret: string;
107
108
  softwareUpdate: string;
109
+ statsDevicesByHeartbeat: string;
110
+ statsDevicesByType: string;
111
+ statsCellUsage: string;
108
112
  systemCommand: string;
109
113
  systemCommandJob: string;
110
114
  translator: string;
package/dist/constants.js CHANGED
@@ -89,6 +89,7 @@ exports.BaseEndpoints = {
89
89
  rule: 'rules',
90
90
  secret: 'secrets',
91
91
  softwareUpdate: 'software_updates',
92
+ stats: 'stats',
92
93
  systemCommand: 'system_commands',
93
94
  systemCommandJob: 'system_command_jobs',
94
95
  translator: 'translators',
@@ -121,6 +122,9 @@ exports.Endpoints = {
121
122
  rule: "" + exports.BaseEndpoints.rule,
122
123
  secret: "" + exports.BaseEndpoints.secret,
123
124
  softwareUpdate: "" + exports.BaseEndpoints.softwareUpdate,
125
+ statsDevicesByHeartbeat: exports.BaseEndpoints.stats + "/devices/count_by_heartbeat_status",
126
+ statsDevicesByType: exports.BaseEndpoints.stats + "/devices/count_by_type",
127
+ statsCellUsage: exports.BaseEndpoints.stats + "/cumulative_cell_usage",
124
128
  systemCommand: "" + exports.BaseEndpoints.systemCommand,
125
129
  systemCommandJob: "" + exports.BaseEndpoints.systemCommandJob,
126
130
  translator: "" + exports.BaseEndpoints.translator,
@@ -11,6 +11,7 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
11
11
  detachIngestor(id: string, ingestorId: string): Promise<string>;
12
12
  getIngestors(id: string): Promise<Ingestor[]>;
13
13
  attachRule(id: string, ruleId: string): Promise<string>;
14
+ bulkAttachRules(id: string, rulesIds: string[]): Promise<BulkActionResponse>;
14
15
  detachRule(id: string, ruleId: string): Promise<string>;
15
16
  getRules(id: string): Promise<Rule[]>;
16
17
  }
@@ -379,9 +379,35 @@ exports.Devices = (function (_super) {
379
379
  });
380
380
  });
381
381
  };
382
+ class_1.bulkAttachRules = function (id, rulesIds) {
383
+ return __awaiter(this, void 0, void 0, function () {
384
+ var axios, result, error_13;
385
+ return __generator(this, function (_a) {
386
+ switch (_a.label) {
387
+ case 0:
388
+ _a.trys.push([0, 2, , 3]);
389
+ this.logAction("Attaching " + rulesIds.length + " rules with to device with id " + id);
390
+ axios = __1.EdgeIQAPI.getAxios();
391
+ return [4, axios.post(constants_1.Endpoints.device + "/" + id + "/rules/bulk", {
392
+ data: { ids: rulesIds },
393
+ })];
394
+ case 1:
395
+ result = _a.sent();
396
+ return [2, result === null || result === void 0 ? void 0 : result.data];
397
+ case 2:
398
+ error_13 = _a.sent();
399
+ if ((0, helpers_1.isApiError)(error_13)) {
400
+ throw error_13;
401
+ }
402
+ throw error_13;
403
+ case 3: return [2];
404
+ }
405
+ });
406
+ });
407
+ };
382
408
  class_1.detachRule = function (id, ruleId) {
383
409
  return __awaiter(this, void 0, void 0, function () {
384
- var axios, error_13;
410
+ var axios, error_14;
385
411
  return __generator(this, function (_a) {
386
412
  switch (_a.label) {
387
413
  case 0:
@@ -393,11 +419,11 @@ exports.Devices = (function (_super) {
393
419
  _a.sent();
394
420
  return [2, (0, constants_1.getAttachMessage)('Rule', 'detach', 'device')];
395
421
  case 2:
396
- error_13 = _a.sent();
397
- if ((0, helpers_1.isApiError)(error_13)) {
398
- throw error_13;
422
+ error_14 = _a.sent();
423
+ if ((0, helpers_1.isApiError)(error_14)) {
424
+ throw error_14;
399
425
  }
400
- throw error_13;
426
+ throw error_14;
401
427
  case 3: return [2];
402
428
  }
403
429
  });
@@ -405,7 +431,7 @@ exports.Devices = (function (_super) {
405
431
  };
406
432
  class_1.getRules = function (id) {
407
433
  return __awaiter(this, void 0, void 0, function () {
408
- var axios, result, error_14;
434
+ var axios, result, error_15;
409
435
  return __generator(this, function (_a) {
410
436
  switch (_a.label) {
411
437
  case 0:
@@ -417,11 +443,11 @@ exports.Devices = (function (_super) {
417
443
  result = _a.sent();
418
444
  return [2, result === null || result === void 0 ? void 0 : result.data];
419
445
  case 2:
420
- error_14 = _a.sent();
421
- if ((0, helpers_1.isApiError)(error_14)) {
422
- throw error_14;
446
+ error_15 = _a.sent();
447
+ if ((0, helpers_1.isApiError)(error_15)) {
448
+ throw error_15;
423
449
  }
424
- throw error_14;
450
+ throw error_15;
425
451
  case 3: return [2];
426
452
  }
427
453
  });
@@ -8,7 +8,7 @@ export interface LogConfig {
8
8
  forward_level?: string;
9
9
  forward_frequency_limit?: number;
10
10
  }
11
- export interface GeoJsonGeometry {
11
+ export interface Geometry {
12
12
  type: string;
13
13
  coordinates: number[];
14
14
  }
@@ -20,13 +20,14 @@ export interface GeoJsonProperties {
20
20
  }
21
21
  export interface GeoJson {
22
22
  type: string;
23
- geometry: GeoJsonGeometry;
23
+ geometry: Geometry;
24
24
  properties: GeoJsonProperties;
25
25
  }
26
26
  export interface DeviceInput {
27
27
  name: string;
28
28
  unique_id: string;
29
29
  company_id: string;
30
+ serial?: string;
30
31
  device_type_id: string;
31
32
  last_report_id?: string;
32
33
  last_location_observation_id?: string;
@@ -44,6 +44,9 @@ var parseFilters = function (filters, pagination) {
44
44
  result['page'] = (pagination === null || pagination === void 0 ? void 0 : pagination.page) || constants_1.DefaultPagination.page;
45
45
  result['per_page'] =
46
46
  (pagination === null || pagination === void 0 ? void 0 : pagination.itemsPerPage) || constants_1.DefaultPagination.itemsPerPage;
47
+ if (pagination === null || pagination === void 0 ? void 0 : pagination.order_by) {
48
+ result['order_by'] = pagination === null || pagination === void 0 ? void 0 : pagination.order_by;
49
+ }
47
50
  return result;
48
51
  };
49
52
  exports.parseFilters = parseFilters;
package/dist/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export { SystemCommandJobs } from './systemCommandJobs';
25
25
  export { Translators } from './translators';
26
26
  export { Users } from './users';
27
27
  export { UserTypes } from './userTypes';
28
+ export * from './models';
28
29
  export * from './bulkResponses/models';
29
30
  export * from './commands/models';
30
31
  export * from './companies/models';
package/dist/index.js CHANGED
@@ -65,6 +65,7 @@ var users_1 = require("./users");
65
65
  Object.defineProperty(exports, "Users", { enumerable: true, get: function () { return users_1.Users; } });
66
66
  var userTypes_1 = require("./userTypes");
67
67
  Object.defineProperty(exports, "UserTypes", { enumerable: true, get: function () { return userTypes_1.UserTypes; } });
68
+ __exportStar(require("./models"), exports);
68
69
  __exportStar(require("./bulkResponses/models"), exports);
69
70
  __exportStar(require("./commands/models"), exports);
70
71
  __exportStar(require("./companies/models"), exports);
package/dist/models.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface Pagination {
9
9
  export interface PaginationFilter {
10
10
  page: number;
11
11
  itemsPerPage: number;
12
+ order_by?: string;
12
13
  }
13
14
  export interface Filter {
14
15
  operator: 'eq' | 'ne' | 'like' | 'gt' | 'gte' | 'lt' | 'lte' | 'between' | 'in' | 'nin' | 'incany' | 'incall';
@@ -0,0 +1,7 @@
1
+ import { CumulativeCellUsage, DevicesCountByHeartbeat, DevicesCountByType } from './models';
2
+ declare const Stats: {
3
+ devicesByHeartbeat: () => Promise<DevicesCountByHeartbeat>;
4
+ devicesByType: () => Promise<DevicesCountByType>;
5
+ cellUsage: () => Promise<CumulativeCellUsage>;
6
+ };
7
+ export { Stats };
@@ -0,0 +1,111 @@
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
+ exports.Stats = void 0;
40
+ var __1 = require("..");
41
+ var constants_1 = require("../constants");
42
+ var helpers_1 = require("../helpers");
43
+ var Stats = {
44
+ devicesByHeartbeat: function () { return __awaiter(void 0, void 0, void 0, function () {
45
+ var axios, result, error_1;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ _a.trys.push([0, 2, , 3]);
50
+ __1.EdgeIQAPI.logAction("Getting devices count by heartbeat status");
51
+ axios = __1.EdgeIQAPI.getAxios();
52
+ return [4, axios.get(constants_1.Endpoints.statsDevicesByHeartbeat)];
53
+ case 1:
54
+ result = _a.sent();
55
+ return [2, result === null || result === void 0 ? void 0 : result.data];
56
+ case 2:
57
+ error_1 = _a.sent();
58
+ if ((0, helpers_1.isApiError)(error_1)) {
59
+ throw error_1;
60
+ }
61
+ throw error_1;
62
+ case 3: return [2];
63
+ }
64
+ });
65
+ }); },
66
+ devicesByType: function () { return __awaiter(void 0, void 0, void 0, function () {
67
+ var axios, result, error_2;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0:
71
+ _a.trys.push([0, 2, , 3]);
72
+ __1.EdgeIQAPI.logAction("Getting devices count by type");
73
+ axios = __1.EdgeIQAPI.getAxios();
74
+ return [4, axios.get(constants_1.Endpoints.statsDevicesByType)];
75
+ case 1:
76
+ result = _a.sent();
77
+ return [2, result === null || result === void 0 ? void 0 : result.data];
78
+ case 2:
79
+ error_2 = _a.sent();
80
+ if ((0, helpers_1.isApiError)(error_2)) {
81
+ throw error_2;
82
+ }
83
+ throw error_2;
84
+ case 3: return [2];
85
+ }
86
+ });
87
+ }); },
88
+ cellUsage: function () { return __awaiter(void 0, void 0, void 0, function () {
89
+ var axios, result, error_3;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ _a.trys.push([0, 2, , 3]);
94
+ __1.EdgeIQAPI.logAction("Getting cumulative cell usage");
95
+ axios = __1.EdgeIQAPI.getAxios();
96
+ return [4, axios.get(constants_1.Endpoints.statsCellUsage)];
97
+ case 1:
98
+ result = _a.sent();
99
+ return [2, result === null || result === void 0 ? void 0 : result.data];
100
+ case 2:
101
+ error_3 = _a.sent();
102
+ if ((0, helpers_1.isApiError)(error_3)) {
103
+ throw error_3;
104
+ }
105
+ throw error_3;
106
+ case 3: return [2];
107
+ }
108
+ });
109
+ }); },
110
+ };
111
+ exports.Stats = Stats;
@@ -0,0 +1,27 @@
1
+ export interface DevicesCountByHeartbeat {
2
+ online: number;
3
+ offline: number;
4
+ idle: number;
5
+ never_reported: number;
6
+ }
7
+ interface CountByType {
8
+ count: number;
9
+ name: string;
10
+ }
11
+ export interface DevicesCountByType {
12
+ cloud_native: {
13
+ [key: string]: CountByType;
14
+ };
15
+ gateway: {
16
+ [key: string]: CountByType;
17
+ };
18
+ }
19
+ export interface CumulativeCellUsage {
20
+ day: number;
21
+ last: number;
22
+ month: number;
23
+ total: number;
24
+ week: number;
25
+ year: number;
26
+ }
27
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeiq/edgeiq-api-js",
3
- "version": "1.0.4",
3
+ "version": "1.1.3",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",