@edgeiq/edgeiq-api-js 1.6.9 → 1.6.11

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.
@@ -37,6 +37,9 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
37
37
  getSettings(id: string, configId?: string): Promise<Setting[]>;
38
38
  attachSettings(id: string, settingsId: string): Promise<string>;
39
39
  detachSettings(id: string, settingsId: string): Promise<string>;
40
+ dryRunCommand(id: string, commandId: string, data?: {
41
+ [key: string]: unknown;
42
+ }): Promise<Command>;
40
43
  }
41
44
  export declare const Devices: DevicesInterface;
42
45
  export {};
@@ -901,5 +901,29 @@ exports.Devices = (function (_super) {
901
901
  });
902
902
  });
903
903
  };
904
+ class_1.dryRunCommand = function (id, commandId, data) {
905
+ return __awaiter(this, void 0, void 0, function () {
906
+ var axios, result, error_33;
907
+ return __generator(this, function (_a) {
908
+ switch (_a.label) {
909
+ case 0:
910
+ _a.trys.push([0, 2, , 3]);
911
+ this.logAction("Dry run command " + commandId + " on device " + id);
912
+ axios = __1.EdgeIQAPI.getAxios();
913
+ return [4, axios.post(constants_1.Endpoints.device + "/" + id + "/commands/" + commandId + "/dry-run", data)];
914
+ case 1:
915
+ result = _a.sent();
916
+ return [2, result === null || result === void 0 ? void 0 : result.data];
917
+ case 2:
918
+ error_33 = _a.sent();
919
+ if ((0, helpers_1.isApiError)(error_33)) {
920
+ throw error_33;
921
+ }
922
+ throw error_33;
923
+ case 3: return [2];
924
+ }
925
+ });
926
+ });
927
+ };
904
928
  return class_1;
905
929
  }(ModelClass_1.BaseModelClass));
@@ -4,7 +4,7 @@ import { Device } from '../devices/models';
4
4
  import { DeviceType } from '../deviceTypes/models';
5
5
  interface SettingsInterface extends BaseModelInterface<Setting, SettingInput, SettingFilters, PaginatedSettings> {
6
6
  getOneById(id: string, version?: number): Promise<Setting>;
7
- update(setting: Setting): Promise<Setting>;
7
+ update(setting: Setting, versionUpdate?: boolean): Promise<Setting>;
8
8
  getDevices(id: string): Promise<Device[]>;
9
9
  getDeviceTypes(id: string): Promise<DeviceType[]>;
10
10
  }
@@ -87,27 +87,33 @@ exports.Settings = (function (_super) {
87
87
  });
88
88
  });
89
89
  };
90
- class_1.update = function (setting) {
90
+ class_1.update = function (setting, versionUpdate) {
91
+ if (versionUpdate === void 0) { versionUpdate = false; }
91
92
  return __awaiter(this, void 0, void 0, function () {
92
- var axios, data, result, error_2;
93
+ var axios, data, result_1, result, error_2;
93
94
  return __generator(this, function (_a) {
94
95
  switch (_a.label) {
95
96
  case 0:
96
- _a.trys.push([0, 2, , 3]);
97
+ _a.trys.push([0, 4, , 5]);
97
98
  this.logAction("Updating setting with ID: " + setting._id);
98
99
  axios = __1.EdgeIQAPI.getAxios();
99
100
  data = JSON.stringify(setting);
100
- return [4, axios.put(constants_1.Endpoints.setting + "/" + setting._id, data)];
101
+ if (!!versionUpdate) return [3, 2];
102
+ return [4, axios.put(constants_1.Endpoints.setting + "/" + setting._id + "/versions/" + setting.version, data)];
101
103
  case 1:
104
+ result_1 = _a.sent();
105
+ return [2, result_1 === null || result_1 === void 0 ? void 0 : result_1.data];
106
+ case 2: return [4, axios.post(constants_1.Endpoints.setting + "/" + setting._id + "/versions", data)];
107
+ case 3:
102
108
  result = _a.sent();
103
109
  return [2, result === null || result === void 0 ? void 0 : result.data];
104
- case 2:
110
+ case 4:
105
111
  error_2 = _a.sent();
106
112
  if ((0, helpers_1.isApiError)(error_2)) {
107
113
  throw error_2;
108
114
  }
109
115
  throw error_2;
110
- case 3: return [2];
116
+ case 5: return [2];
111
117
  }
112
118
  });
113
119
  });
@@ -10,6 +10,7 @@ export interface SettingInput {
10
10
  version?: number;
11
11
  }
12
12
  export interface Setting extends SettingInput, Base {
13
+ version: number;
13
14
  }
14
15
  export interface SettingFilters extends Filters {
15
16
  name?: Filter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeiq/edgeiq-api-js",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",