@edgeiq/edgeiq-api-js 1.4.3 → 1.4.5

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.
@@ -34,6 +34,7 @@ export interface BulkResponse extends Base {
34
34
  total: number;
35
35
  command_id?: string;
36
36
  bulk_response_statuses: (BulkResponseStatus | undefined)[];
37
+ generate_child_command_executions: boolean;
37
38
  }
38
39
  export interface BulkResponsesFilters extends Filters {
39
40
  type?: Filter;
@@ -3,6 +3,7 @@ export interface CommandExecutionInput {
3
3
  command_id: string;
4
4
  device_id: string;
5
5
  execution_statuses: CommandExecutionsStatus[];
6
+ generate_child_command_executions?: boolean;
6
7
  }
7
8
  export declare type CommandExecutionStatus = 'initiated' | 'info' | 'success' | 'error';
8
9
  export interface CommandExecutionRequest extends CommandExecutionInput, Base {
@@ -23,11 +23,10 @@ export interface CommandInput {
23
23
  options?: {
24
24
  [key: string]: unknown;
25
25
  };
26
- payload?: {
27
- [key: string]: unknown;
28
- };
26
+ payload?: string;
29
27
  translator_id?: string;
30
28
  save_command_output?: boolean;
29
+ generate_child_command_executions?: boolean;
31
30
  }
32
31
  export interface Command extends CommandInput, Base {
33
32
  }
@@ -24,7 +24,8 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
24
24
  requestLogs(id: string): Promise<GatewayCommand>;
25
25
  deviceLwm2mObjetLinks(id: string): Promise<Lwm2mObjectLinks[]>;
26
26
  processGatewayCommand(deviceId: string, gatewayCommandRequest: GatewayCommandRequest): Promise<GatewayCommand>;
27
- bulkExecuteGatewayCommand(ids: string[], gatewayCommandRequest: GatewayCommandRequest): Promise<BulkActionResponse>;
27
+ bulkExecuteGatewayCommand(ids: string[], gatewayCommandRequest: GatewayCommandRequest, generateChildCommandExecutions?: boolean): Promise<BulkActionResponse>;
28
+ bulkExecuteCommand(ids: string[], command: Command, generateChildCommandExecutions?: boolean): Promise<BulkActionResponse>;
28
29
  getFiles(id: string): Promise<EIQFile[]>;
29
30
  getCommandExecutions(id: string, filters: CommandExecutionsFilters, pagination: PaginationFilter): Promise<PaginatedCommandExecutions>;
30
31
  }
@@ -644,7 +644,7 @@ exports.Devices = (function (_super) {
644
644
  });
645
645
  });
646
646
  };
647
- class_1.bulkExecuteGatewayCommand = function (ids, gatewayCommandRequest) {
647
+ class_1.bulkExecuteGatewayCommand = function (ids, gatewayCommandRequest, generateChildCommandExecutions) {
648
648
  return __awaiter(this, void 0, void 0, function () {
649
649
  var axios, result, error_23;
650
650
  return __generator(this, function (_a) {
@@ -653,7 +653,7 @@ exports.Devices = (function (_super) {
653
653
  _a.trys.push([0, 2, , 3]);
654
654
  this.logAction("Execute " + gatewayCommandRequest.command_type + " command on devices with IDs: " + ids);
655
655
  axios = __1.EdgeIQAPI.getAxios();
656
- return [4, axios.post(constants_1.Endpoints.device + "/bulk/gateway_command", __assign(__assign({}, gatewayCommandRequest), { ids: ids }))];
656
+ return [4, axios.post(constants_1.Endpoints.device + "/bulk/gateway_command", __assign(__assign({}, gatewayCommandRequest), { generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false, ids: ids }))];
657
657
  case 1:
658
658
  result = _a.sent();
659
659
  return [2, result === null || result === void 0 ? void 0 : result.data];
@@ -668,16 +668,20 @@ exports.Devices = (function (_super) {
668
668
  });
669
669
  });
670
670
  };
671
- class_1.getFiles = function (id) {
671
+ class_1.bulkExecuteCommand = function (ids, command, generateChildCommandExecutions) {
672
672
  return __awaiter(this, void 0, void 0, function () {
673
673
  var axios, result, error_24;
674
674
  return __generator(this, function (_a) {
675
675
  switch (_a.label) {
676
676
  case 0:
677
677
  _a.trys.push([0, 2, , 3]);
678
- this.logAction("Getting files attached to device with id " + id);
678
+ this.logAction("Execute command with ID: " + command._id + " on devices with IDs: " + ids);
679
679
  axios = __1.EdgeIQAPI.getAxios();
680
- return [4, axios.get(constants_1.Endpoints.device + "/" + id + "/files")];
680
+ return [4, axios.post(constants_1.Endpoints.device + "/bulk/commands/" + command._id + "/execute", {
681
+ command: command,
682
+ ids: ids,
683
+ generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false,
684
+ })];
681
685
  case 1:
682
686
  result = _a.sent();
683
687
  return [2, result === null || result === void 0 ? void 0 : result.data];
@@ -692,10 +696,34 @@ exports.Devices = (function (_super) {
692
696
  });
693
697
  });
694
698
  };
699
+ class_1.getFiles = function (id) {
700
+ return __awaiter(this, void 0, void 0, function () {
701
+ var axios, result, error_25;
702
+ return __generator(this, function (_a) {
703
+ switch (_a.label) {
704
+ case 0:
705
+ _a.trys.push([0, 2, , 3]);
706
+ this.logAction("Getting files attached to device with id " + id);
707
+ axios = __1.EdgeIQAPI.getAxios();
708
+ return [4, axios.get(constants_1.Endpoints.device + "/" + id + "/files")];
709
+ case 1:
710
+ result = _a.sent();
711
+ return [2, result === null || result === void 0 ? void 0 : result.data];
712
+ case 2:
713
+ error_25 = _a.sent();
714
+ if ((0, helpers_1.isApiError)(error_25)) {
715
+ throw error_25;
716
+ }
717
+ throw error_25;
718
+ case 3: return [2];
719
+ }
720
+ });
721
+ });
722
+ };
695
723
  class_1.getCommandExecutions = function (id, filters, pagination) {
696
724
  var _a, _b, _c, _d;
697
725
  return __awaiter(this, void 0, void 0, function () {
698
- var axios, result, error_25;
726
+ var axios, result, error_26;
699
727
  return __generator(this, function (_e) {
700
728
  switch (_e.label) {
701
729
  case 0:
@@ -716,11 +744,11 @@ exports.Devices = (function (_super) {
716
744
  },
717
745
  }];
718
746
  case 2:
719
- error_25 = _e.sent();
720
- if ((0, helpers_1.isApiError)(error_25)) {
721
- throw error_25;
747
+ error_26 = _e.sent();
748
+ if ((0, helpers_1.isApiError)(error_26)) {
749
+ throw error_26;
722
750
  }
723
- throw error_25;
751
+ throw error_26;
724
752
  case 3: return [2];
725
753
  }
726
754
  });
@@ -120,6 +120,7 @@ export interface DevicesFilters extends Filters {
120
120
  metadata?: {
121
121
  [key: string]: Filter;
122
122
  };
123
+ parent_device_id?: Filter;
123
124
  }
124
125
  export interface PaginatedDevices {
125
126
  devices: Device[];
@@ -359,6 +359,7 @@ export interface BulkRequest {
359
359
  bulk_response_id: string;
360
360
  context?: WorkflowContext;
361
361
  definition_id: string;
362
+ generate_child_command_executions?: boolean;
362
363
  }
363
364
  export interface BulkSingleResponse {
364
365
  status?: number;
@@ -379,6 +380,7 @@ export interface BulkResponse {
379
380
  type: string;
380
381
  total: number;
381
382
  bulk_response_statuses: (BulkResponseStatus | undefined)[];
383
+ generate_child_command_executions?: boolean;
382
384
  }
383
385
  export interface BulkResponseStatus {
384
386
  status_code?: number;
@@ -411,6 +413,7 @@ export interface Command {
411
413
  [key: string]: unknown;
412
414
  };
413
415
  translator_id: string;
416
+ generate_child_command_executions: boolean;
414
417
  }
415
418
  export interface CommandWithDeviceID {
416
419
  device_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeiq/edgeiq-api-js",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",