@edgeiq/edgeiq-api-js 1.3.22 → 1.3.25

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.
@@ -0,0 +1,7 @@
1
+ import { CommandExecution, CommandExecutionsStatus } from './models';
2
+ interface CommandExecutionsInterface {
3
+ get(): Promise<CommandExecution[]>;
4
+ getStatuses(id: string): Promise<CommandExecutionsStatus[]>;
5
+ }
6
+ export declare const CommandExecutions: CommandExecutionsInterface;
7
+ export {};
@@ -0,0 +1,112 @@
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.CommandExecutions = void 0;
55
+ var constants_1 = require("../constants");
56
+ var ModelClass_1 = require("../core/ModelClass");
57
+ var helpers_1 = require("../helpers");
58
+ var core_1 = require("../core");
59
+ exports.CommandExecutions = (function (_super) {
60
+ __extends(class_1, _super);
61
+ function class_1() {
62
+ return _super !== null && _super.apply(this, arguments) || this;
63
+ }
64
+ class_1.get = function () {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var axios, result, error_1;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0:
70
+ _a.trys.push([0, 2, , 3]);
71
+ axios = core_1.EdgeIQAPI.getAxios();
72
+ return [4, axios.get("" + constants_1.Endpoints.commandExecution)];
73
+ case 1:
74
+ result = _a.sent();
75
+ return [2, result === null || result === void 0 ? void 0 : result.data];
76
+ case 2:
77
+ error_1 = _a.sent();
78
+ if ((0, helpers_1.isApiError)(error_1)) {
79
+ throw error_1;
80
+ }
81
+ throw error_1;
82
+ case 3: return [2];
83
+ }
84
+ });
85
+ });
86
+ };
87
+ class_1.getStatuses = function (id) {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var axios, result, error_2;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ _a.trys.push([0, 2, , 3]);
94
+ this.logAction("Getting statuses attached to command executions with id " + id);
95
+ axios = core_1.EdgeIQAPI.getAxios();
96
+ return [4, axios.get(constants_1.Endpoints.commandExecution + "/" + id + "/command_execution_statuses")];
97
+ case 1:
98
+ result = _a.sent();
99
+ return [2, result === null || result === void 0 ? void 0 : result.data];
100
+ case 2:
101
+ error_2 = _a.sent();
102
+ if ((0, helpers_1.isApiError)(error_2)) {
103
+ throw error_2;
104
+ }
105
+ throw error_2;
106
+ case 3: return [2];
107
+ }
108
+ });
109
+ });
110
+ };
111
+ return class_1;
112
+ }(ModelClass_1.BaseModelClass));
@@ -0,0 +1,21 @@
1
+ import { Base, Filter, Filters, Pagination } from '../models';
2
+ export interface CommandExecutionsInput {
3
+ commandId: string;
4
+ execution_statuses: CommandExecutionsStatus[];
5
+ }
6
+ export declare type CommandExecutionStatus = 'initiated' | 'info' | 'success' | 'error';
7
+ export interface CommandExecutionsStatus extends Base {
8
+ execution_id: string;
9
+ status: CommandExecutionStatus;
10
+ message?: string;
11
+ }
12
+ export interface CommandExecution extends CommandExecutionsInput, Base {
13
+ }
14
+ export interface CommandExecutionsFilters extends Filters {
15
+ command_id?: Filter;
16
+ status?: Filter;
17
+ }
18
+ export interface PaginatedCommandExecutions {
19
+ commandExecutions: CommandExecution[];
20
+ pagination: Pagination;
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,7 @@
1
1
  import { BaseModelInterface } from '../core/ModelClass';
2
- import { BulkActionResponse } from '../models';
2
+ import { BulkActionResponse, PaginationFilter } from '../models';
3
3
  import { Command, CommandInput, CommandsFilters, PaginatedCommands } from './models';
4
+ import { CommandExecutionsFilters, PaginatedCommandExecutions } from '../commandExecutions/models';
4
5
  interface CommandsInterface extends BaseModelInterface<Command, CommandInput, CommandsFilters, PaginatedCommands> {
5
6
  update(command: Command): Promise<Command>;
6
7
  deleteMultiple(ids: string[]): Promise<BulkActionResponse>;
@@ -14,6 +15,7 @@ interface CommandsInterface extends BaseModelInterface<Command, CommandInput, Co
14
15
  type: string;
15
16
  };
16
17
  }): Promise<string>;
18
+ getCommandExecutions(id: string, filters: CommandExecutionsFilters, pagination: PaginationFilter): Promise<PaginatedCommandExecutions>;
17
19
  }
18
20
  export declare const Commands: CommandsInterface;
19
21
  export {};
@@ -340,5 +340,39 @@ exports.Commands = (function (_super) {
340
340
  });
341
341
  });
342
342
  };
343
+ class_1.getCommandExecutions = function (id, filters, pagination) {
344
+ var _a, _b, _c, _d;
345
+ return __awaiter(this, void 0, void 0, function () {
346
+ var axios, result, error_12;
347
+ return __generator(this, function (_e) {
348
+ switch (_e.label) {
349
+ case 0:
350
+ _e.trys.push([0, 2, , 3]);
351
+ this.logAction("Getting command executions attached to command with id " + id + ".\n And pagination " + (pagination !== null && pagination !== void 0 ? pagination : '{}'));
352
+ axios = __1.EdgeIQAPI.getAxios();
353
+ return [4, axios.get(constants_1.Endpoints.command + "/" + id + "/command_executions", {
354
+ params: (0, filtersParser_1.parseFilters)(filters, pagination),
355
+ })];
356
+ case 1:
357
+ result = _e.sent();
358
+ return [2, {
359
+ commandExecutions: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
360
+ pagination: {
361
+ page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
362
+ itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
363
+ total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
364
+ },
365
+ }];
366
+ case 2:
367
+ error_12 = _e.sent();
368
+ if ((0, helpers_1.isApiError)(error_12)) {
369
+ throw error_12;
370
+ }
371
+ throw error_12;
372
+ case 3: return [2];
373
+ }
374
+ });
375
+ });
376
+ };
343
377
  return class_1;
344
378
  }(ModelClass_1.BaseModelClass));
@@ -55,6 +55,7 @@ export declare const BaseEndpoints: {
55
55
  bulkResponse: string;
56
56
  notification: string;
57
57
  command: string;
58
+ commandExecution: string;
58
59
  company: string;
59
60
  deviceConfig: string;
60
61
  deviceError: string;
@@ -98,6 +99,7 @@ export declare const Endpoints: {
98
99
  notification: string;
99
100
  file: string;
100
101
  command: string;
102
+ commandExecution: string;
101
103
  company: string;
102
104
  deviceConfig: string;
103
105
  deviceError: string;
package/dist/constants.js CHANGED
@@ -71,6 +71,7 @@ exports.BaseEndpoints = {
71
71
  bulkResponse: 'bulk_responses',
72
72
  notification: 'notifications',
73
73
  command: 'commands',
74
+ commandExecution: 'commandExecutions',
74
75
  company: 'companies',
75
76
  deviceConfig: 'device_configs',
76
77
  deviceError: 'device_errors',
@@ -114,6 +115,7 @@ exports.Endpoints = {
114
115
  notification: "" + exports.BaseEndpoints.notification,
115
116
  file: "" + exports.BaseEndpoints.file,
116
117
  command: "" + exports.BaseEndpoints.command,
118
+ commandExecution: "" + exports.BaseEndpoints.commandExecution,
117
119
  company: "" + exports.BaseEndpoints.company,
118
120
  deviceConfig: "" + exports.BaseEndpoints.deviceConfig,
119
121
  deviceError: "" + exports.BaseEndpoints.deviceError,
@@ -6,6 +6,7 @@ import { BulkActionResponse } from '../models';
6
6
  import { Lwm2mObjectLinks } from '../lwm2m/models';
7
7
  import { DeviceFile } from '../deviceFiles/models';
8
8
  import { DevicesFilters, Device, DeviceInput, PaginatedDevices } from './models';
9
+ import { CommandExecution } from '../commandExecutions/models';
9
10
  interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, DevicesFilters, PaginatedDevices> {
10
11
  bulkCreate(uniqueIds: string[], deviceTypeId: string, namePrefix: string): Promise<BulkActionResponse>;
11
12
  update(device: Device): Promise<Device>;
@@ -27,6 +28,7 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
27
28
  processGatewayCommand(deviceId: string, gatewayCommandRequest: GatewayCommandRequest): Promise<GatewayCommand>;
28
29
  bulkExecuteGatewayCommand(ids: string[], gatewayCommandRequest: GatewayCommandRequest): Promise<BulkActionResponse>;
29
30
  getFiles(id: string): Promise<DeviceFile[]>;
31
+ getCommandExecutions(id: string): Promise<CommandExecution[]>;
30
32
  }
31
33
  export declare const Devices: DevicesInterface;
32
34
  export {};
@@ -684,5 +684,29 @@ exports.Devices = (function (_super) {
684
684
  });
685
685
  });
686
686
  };
687
+ class_1.getCommandExecutions = function (id) {
688
+ return __awaiter(this, void 0, void 0, function () {
689
+ var axios, result, error_25;
690
+ return __generator(this, function (_a) {
691
+ switch (_a.label) {
692
+ case 0:
693
+ _a.trys.push([0, 2, , 3]);
694
+ this.logAction("Getting command executions attached to device with id " + id);
695
+ axios = __1.EdgeIQAPI.getAxios();
696
+ return [4, axios.get(constants_1.Endpoints.command + "/" + id + "/command_executions")];
697
+ case 1:
698
+ result = _a.sent();
699
+ return [2, result === null || result === void 0 ? void 0 : result.data];
700
+ case 2:
701
+ error_25 = _a.sent();
702
+ if ((0, helpers_1.isApiError)(error_25)) {
703
+ throw error_25;
704
+ }
705
+ throw error_25;
706
+ case 3: return [2];
707
+ }
708
+ });
709
+ });
710
+ };
687
711
  return class_1;
688
712
  }(ModelClass_1.BaseModelClass));
package/dist/index.d.ts CHANGED
@@ -3,10 +3,12 @@ export { Authentication } from './auth';
3
3
  export { BulkResponses } from './bulkResponses';
4
4
  export { Commands } from './commands';
5
5
  export { Companies } from './companies';
6
+ export { CommandExecutions } from './commandExecutions';
6
7
  export { DeviceConfigs } from './deviceConfigs';
7
8
  export { DeviceLocationObservations } from './deviceLocationObservations';
8
9
  export { Devices } from './devices';
9
10
  export { DeviceErrors } from './deviceErrors';
11
+ export { DeviceFiles } from './deviceFiles';
10
12
  export { DeviceTemplates } from './deviceTemplates';
11
13
  export { DeviceTransferRequests } from './deviceTransferRequests';
12
14
  export { DeviceTypes } from './deviceTypes';
@@ -34,9 +36,11 @@ export * from './models';
34
36
  export * from './bulkResponses/models';
35
37
  export * from './commands/models';
36
38
  export * from './companies/models';
39
+ export * from './commandExecutions/models';
37
40
  export * from './deviceConfigs/models';
38
41
  export * from './deviceLocationObservations/models';
39
42
  export * from './devices/models';
43
+ export * from './deviceFiles/models';
40
44
  export * from './discoveredDevices/models';
41
45
  export * from './deviceErrors/models';
42
46
  export * from './deviceTemplates/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.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.DeviceErrors = 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.LWM2M = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.DeviceFiles = 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");
@@ -21,6 +21,8 @@ var commands_1 = require("./commands");
21
21
  Object.defineProperty(exports, "Commands", { enumerable: true, get: function () { return commands_1.Commands; } });
22
22
  var companies_1 = require("./companies");
23
23
  Object.defineProperty(exports, "Companies", { enumerable: true, get: function () { return companies_1.Companies; } });
24
+ var commandExecutions_1 = require("./commandExecutions");
25
+ Object.defineProperty(exports, "CommandExecutions", { enumerable: true, get: function () { return commandExecutions_1.CommandExecutions; } });
24
26
  var deviceConfigs_1 = require("./deviceConfigs");
25
27
  Object.defineProperty(exports, "DeviceConfigs", { enumerable: true, get: function () { return deviceConfigs_1.DeviceConfigs; } });
26
28
  var deviceLocationObservations_1 = require("./deviceLocationObservations");
@@ -29,6 +31,8 @@ var devices_1 = require("./devices");
29
31
  Object.defineProperty(exports, "Devices", { enumerable: true, get: function () { return devices_1.Devices; } });
30
32
  var deviceErrors_1 = require("./deviceErrors");
31
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; } });
32
36
  var deviceTemplates_1 = require("./deviceTemplates");
33
37
  Object.defineProperty(exports, "DeviceTemplates", { enumerable: true, get: function () { return deviceTemplates_1.DeviceTemplates; } });
34
38
  var deviceTransferRequests_1 = require("./deviceTransferRequests");
@@ -79,9 +83,11 @@ __exportStar(require("./models"), exports);
79
83
  __exportStar(require("./bulkResponses/models"), exports);
80
84
  __exportStar(require("./commands/models"), exports);
81
85
  __exportStar(require("./companies/models"), exports);
86
+ __exportStar(require("./commandExecutions/models"), exports);
82
87
  __exportStar(require("./deviceConfigs/models"), exports);
83
88
  __exportStar(require("./deviceLocationObservations/models"), exports);
84
89
  __exportStar(require("./devices/models"), exports);
90
+ __exportStar(require("./deviceFiles/models"), exports);
85
91
  __exportStar(require("./discoveredDevices/models"), exports);
86
92
  __exportStar(require("./deviceErrors/models"), exports);
87
93
  __exportStar(require("./deviceTemplates/models"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeiq/edgeiq-api-js",
3
- "version": "1.3.22",
3
+ "version": "1.3.25",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",