@edgeiq/edgeiq-api-js 1.0.3 → 1.1.2

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,10 +122,13 @@ 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,
127
- userType: "" + exports.BaseEndpoints.report,
131
+ userType: "" + exports.BaseEndpoints.userType,
128
132
  user: "" + exports.BaseEndpoints.user,
129
133
  };
130
134
  exports.MethodsActions = {
@@ -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;
@@ -13,12 +13,16 @@ var parseFilters = function (filters, pagination) {
13
13
  if (filter) {
14
14
  if (!Array.isArray(filter)) {
15
15
  if (filter.operator) {
16
- result[key + "_" + filter.operator] = filter.value;
16
+ result[key + "_" + filter.operator] = Array.isArray(filter.value)
17
+ ? filter.value.toString()
18
+ : filter.value;
17
19
  }
18
20
  else {
19
21
  for (var subKey in filter) {
20
22
  if (Object.prototype.hasOwnProperty.call(filter, subKey)) {
21
- result[key + "_" + subKey + "_" + filter.operator] = filter.value;
23
+ result[key + "_" + subKey + "_" + filter.operator] = Array.isArray(filter.value)
24
+ ? filter.value.toString()
25
+ : filter.value;
22
26
  }
23
27
  }
24
28
  }
@@ -27,7 +31,9 @@ var parseFilters = function (filters, pagination) {
27
31
  filter.forEach(function (subFilter) {
28
32
  if (subFilter.key) {
29
33
  result[subFilter.key + "_" + subFilter.operator] =
30
- subFilter.value;
34
+ Array.isArray(subFilter.value)
35
+ ? subFilter.value.toString()
36
+ : subFilter.value;
31
37
  }
32
38
  });
33
39
  }
@@ -38,6 +44,9 @@ var parseFilters = function (filters, pagination) {
38
44
  result['page'] = (pagination === null || pagination === void 0 ? void 0 : pagination.page) || constants_1.DefaultPagination.page;
39
45
  result['per_page'] =
40
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
+ }
41
50
  return result;
42
51
  };
43
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.3",
3
+ "version": "1.1.2",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",