@edgeiq/edgeiq-api-js 1.6.21 → 1.7.0

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.
@@ -68,6 +68,90 @@ describe('Companies', function () {
68
68
  }); });
69
69
  var company = testConstants_1.EmptyCompany;
70
70
  var company2 = testConstants_1.EmptyCompany;
71
+ it('Throws a bad request error if the post request doesnt provide name', function () { return __awaiter(void 0, void 0, void 0, function () {
72
+ var error_1;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ _a.trys.push([0, 2, , 3]);
77
+ return [4, __1.Companies.create(__assign(__assign({}, testConstants_1.TestCompany), { name: '' }))];
78
+ case 1:
79
+ _a.sent();
80
+ return [3, 3];
81
+ case 2:
82
+ error_1 = _a.sent();
83
+ expect(error_1).toStrictEqual({
84
+ message: "'name' field required",
85
+ name: 'Unable to validate resource',
86
+ });
87
+ return [3, 3];
88
+ case 3: return [2];
89
+ }
90
+ });
91
+ }); });
92
+ it('Throws a bad request error if the post request doesnt provide a valid id ', function () { return __awaiter(void 0, void 0, void 0, function () {
93
+ var error_2;
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0:
97
+ _a.trys.push([0, 2, , 3]);
98
+ return [4, __1.Companies.create(__assign(__assign({}, testConstants_1.TestCompany), { _id: '' }))];
99
+ case 1:
100
+ _a.sent();
101
+ return [3, 3];
102
+ case 2:
103
+ error_2 = _a.sent();
104
+ expect(error_2).toStrictEqual({
105
+ message: 'Account not found',
106
+ name: 'Unable to create resource',
107
+ });
108
+ return [3, 3];
109
+ case 3: return [2];
110
+ }
111
+ });
112
+ }); });
113
+ it('Throws a bad request error if the post request name attribute is too long ', function () { return __awaiter(void 0, void 0, void 0, function () {
114
+ var error_3;
115
+ return __generator(this, function (_a) {
116
+ switch (_a.label) {
117
+ case 0:
118
+ _a.trys.push([0, 2, , 3]);
119
+ return [4, __1.Companies.create(__assign(__assign({}, testConstants_1.TestCompany), { name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, \n sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, \n quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \n Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \n Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }))];
120
+ case 1:
121
+ _a.sent();
122
+ return [3, 3];
123
+ case 2:
124
+ error_3 = _a.sent();
125
+ expect(error_3).toStrictEqual({
126
+ message: 'Account name is too long',
127
+ name: 'Unable to create resource',
128
+ });
129
+ return [3, 3];
130
+ case 3: return [2];
131
+ }
132
+ });
133
+ }); });
134
+ it('Throws Not Found if request a nonexistent record with an id', function () { return __awaiter(void 0, void 0, void 0, function () {
135
+ var error_4;
136
+ return __generator(this, function (_a) {
137
+ switch (_a.label) {
138
+ case 0:
139
+ _a.trys.push([0, 2, , 3]);
140
+ return [4, __1.Companies.getOneById('ThisDefinitelyRecordIdDoesntExists')];
141
+ case 1:
142
+ _a.sent();
143
+ return [3, 3];
144
+ case 2:
145
+ error_4 = _a.sent();
146
+ expect(error_4).toStrictEqual({
147
+ message: 'not found',
148
+ name: 'loading',
149
+ });
150
+ return [3, 3];
151
+ case 3: return [2];
152
+ }
153
+ });
154
+ }); });
71
155
  it('Creates a company', function () { return __awaiter(void 0, void 0, void 0, function () {
72
156
  var result;
73
157
  return __generator(this, function (_a) {
@@ -83,7 +167,7 @@ describe('Companies', function () {
83
167
  });
84
168
  }); });
85
169
  it('Company already exists', function () { return __awaiter(void 0, void 0, void 0, function () {
86
- var error_1;
170
+ var error_5;
87
171
  return __generator(this, function (_a) {
88
172
  switch (_a.label) {
89
173
  case 0:
@@ -93,9 +177,9 @@ describe('Companies', function () {
93
177
  _a.sent();
94
178
  return [3, 3];
95
179
  case 2:
96
- error_1 = _a.sent();
97
- if ((0, helpers_1.isApiError)(error_1)) {
98
- expect(error_1.message).toBe(constants_1.ResponseErrorsMessages.uniqueConstraint('companies'));
180
+ error_5 = _a.sent();
181
+ if ((0, helpers_1.isApiError)(error_5)) {
182
+ expect(error_5.message).toBe(constants_1.ResponseErrorsMessages.uniqueConstraint('account'));
99
183
  }
100
184
  return [3, 3];
101
185
  case 3: return [2];
@@ -1,8 +1,7 @@
1
- import { BaseModelInterface } from '../core/ModelClass';
2
- import { CommandExecution, CommandExecutionsStatus, CommandExecutionInput, CommandExecutionsFilters, PaginatedCommandExecutions } from './models';
3
- interface CommandExecutionsInterface extends BaseModelInterface<CommandExecution, CommandExecutionInput, CommandExecutionsFilters, PaginatedCommandExecutions> {
4
- getStatuses(id: string): Promise<CommandExecutionsStatus[]>;
1
+ import { PaginationFilter } from '../models';
2
+ import { CommandExecutionsFilters, PaginatedCommandExecutions } from './models';
3
+ declare const CommandExecutions: {
4
+ list(filters?: CommandExecutionsFilters | undefined, pagination?: PaginationFilter | undefined): Promise<PaginatedCommandExecutions>;
5
5
  getCommandExecutionsOutput(id: string): Promise<string>;
6
- }
7
- export declare const CommandExecutions: CommandExecutionsInterface;
8
- export {};
6
+ };
7
+ export { CommandExecutions };
@@ -1,19 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -53,44 +38,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
53
38
  Object.defineProperty(exports, "__esModule", { value: true });
54
39
  exports.CommandExecutions = void 0;
55
40
  var constants_1 = require("../constants");
56
- var ModelClass_1 = require("../core/ModelClass");
57
41
  var filtersParser_1 = require("../filtersParser");
58
42
  var helpers_1 = require("../helpers");
59
43
  var core_1 = require("../core");
60
- exports.CommandExecutions = (function (_super) {
61
- __extends(class_1, _super);
62
- function class_1() {
63
- return _super !== null && _super.apply(this, arguments) || this;
64
- }
65
- class_1.create = function (commandExecutionRequest) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- var axios, data, result, error_1;
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
70
- case 0:
71
- _a.trys.push([0, 2, , 3]);
72
- this.logAction("Creating command execution with unique ID: " + commandExecutionRequest);
73
- axios = core_1.EdgeIQAPI.getAxios();
74
- data = JSON.stringify(commandExecutionRequest);
75
- return [4, axios.post(constants_1.Endpoints.commandExecution, data)];
76
- case 1:
77
- result = _a.sent();
78
- return [2, result === null || result === void 0 ? void 0 : result.data];
79
- case 2:
80
- error_1 = _a.sent();
81
- if ((0, helpers_1.isApiError)(error_1)) {
82
- throw error_1;
83
- }
84
- throw error_1;
85
- case 3: return [2];
86
- }
87
- });
88
- });
89
- };
90
- class_1.list = function (filters, pagination) {
44
+ var CommandExecutions = {
45
+ list: function (filters, pagination) {
91
46
  var _a, _b, _c, _d;
92
47
  return __awaiter(this, void 0, void 0, function () {
93
- var axios, result, error_2;
48
+ var axios, result, error_1;
94
49
  return __generator(this, function (_e) {
95
50
  switch (_e.label) {
96
51
  case 0:
@@ -110,111 +65,38 @@ exports.CommandExecutions = (function (_super) {
110
65
  },
111
66
  }];
112
67
  case 2:
113
- error_2 = _e.sent();
114
- if ((0, helpers_1.isApiError)(error_2)) {
115
- throw error_2;
116
- }
117
- throw error_2;
118
- case 3: return [2];
119
- }
120
- });
121
- });
122
- };
123
- class_1.getOneById = function (id) {
124
- return __awaiter(this, void 0, void 0, function () {
125
- var axios, result, error_3;
126
- return __generator(this, function (_a) {
127
- switch (_a.label) {
128
- case 0:
129
- _a.trys.push([0, 2, , 3]);
130
- this.logAction("Getting command execution request with id: " + id);
131
- axios = core_1.EdgeIQAPI.getAxios();
132
- return [4, axios.get(constants_1.Endpoints.commandExecution + "/" + id)];
133
- case 1:
134
- result = _a.sent();
135
- return [2, result === null || result === void 0 ? void 0 : result.data];
136
- case 2:
137
- error_3 = _a.sent();
138
- if ((0, helpers_1.isApiError)(error_3)) {
139
- throw error_3;
140
- }
141
- throw error_3;
142
- case 3: return [2];
143
- }
144
- });
145
- });
146
- };
147
- class_1.delete = function (id) {
148
- return __awaiter(this, void 0, void 0, function () {
149
- var axios, error_4;
150
- return __generator(this, function (_a) {
151
- switch (_a.label) {
152
- case 0:
153
- _a.trys.push([0, 2, , 3]);
154
- this.logAction("Deleting command execution request with id " + id);
155
- axios = core_1.EdgeIQAPI.getAxios();
156
- return [4, axios.delete(constants_1.Endpoints.commandExecution + "/" + id)];
157
- case 1:
158
- _a.sent();
159
- return [2, (0, helpers_1.getReturnDeleteMessage)('command execution request')];
160
- case 2:
161
- error_4 = _a.sent();
162
- if ((0, helpers_1.isApiError)(error_4)) {
163
- throw error_4;
164
- }
165
- throw error_4;
166
- case 3: return [2];
167
- }
168
- });
169
- });
170
- };
171
- class_1.getStatuses = function (id) {
172
- return __awaiter(this, void 0, void 0, function () {
173
- var axios, result, error_5;
174
- return __generator(this, function (_a) {
175
- switch (_a.label) {
176
- case 0:
177
- _a.trys.push([0, 2, , 3]);
178
- this.logAction("Getting statuses attached to command executions with id " + id);
179
- axios = core_1.EdgeIQAPI.getAxios();
180
- return [4, axios.get(constants_1.Endpoints.commandExecution + "/" + id + "/command_execution_statuses")];
181
- case 1:
182
- result = _a.sent();
183
- return [2, result === null || result === void 0 ? void 0 : result.data];
184
- case 2:
185
- error_5 = _a.sent();
186
- if ((0, helpers_1.isApiError)(error_5)) {
187
- throw error_5;
68
+ error_1 = _e.sent();
69
+ if ((0, helpers_1.isApiError)(error_1)) {
70
+ throw error_1;
188
71
  }
189
- throw error_5;
72
+ throw error_1;
190
73
  case 3: return [2];
191
74
  }
192
75
  });
193
76
  });
194
- };
195
- class_1.getCommandExecutionsOutput = function (id) {
77
+ },
78
+ getCommandExecutionsOutput: function (id) {
196
79
  return __awaiter(this, void 0, void 0, function () {
197
- var axios, result, error_6;
80
+ var axios, result, error_2;
198
81
  return __generator(this, function (_a) {
199
82
  switch (_a.label) {
200
83
  case 0:
201
84
  _a.trys.push([0, 2, , 3]);
202
- this.logAction("Getting command executions output for id " + id);
203
85
  axios = core_1.EdgeIQAPI.getAxios();
204
86
  return [4, axios.get(constants_1.Endpoints.commandExecution + "/" + id + "/output")];
205
87
  case 1:
206
88
  result = _a.sent();
207
89
  return [2, result === null || result === void 0 ? void 0 : result.data];
208
90
  case 2:
209
- error_6 = _a.sent();
210
- if ((0, helpers_1.isApiError)(error_6)) {
211
- throw error_6;
91
+ error_2 = _a.sent();
92
+ if ((0, helpers_1.isApiError)(error_2)) {
93
+ throw error_2;
212
94
  }
213
- throw error_6;
95
+ throw error_2;
214
96
  case 3: return [2];
215
97
  }
216
98
  });
217
99
  });
218
- };
219
- return class_1;
220
- }(ModelClass_1.BaseModelClass));
100
+ },
101
+ };
102
+ exports.CommandExecutions = CommandExecutions;
@@ -1,20 +1,10 @@
1
- import { Base, Filter, Filters, Pagination } from '../models';
2
- export interface CommandExecutionInput {
1
+ import { Base, Execution, Filter, Filters, Pagination } from '../models';
2
+ export interface CommandExecution extends Base {
3
3
  command_id: string;
4
4
  device_id: string;
5
- execution_statuses: CommandExecutionsStatus[];
5
+ execution_statuses: Execution[];
6
6
  generate_child_command_executions?: boolean;
7
7
  }
8
- export declare type CommandExecutionStatus = 'initiated' | 'info' | 'success' | 'error';
9
- export interface CommandExecutionRequest extends CommandExecutionInput, Base {
10
- }
11
- export interface CommandExecutionsStatus extends Base {
12
- execution_id: string;
13
- status: CommandExecutionStatus;
14
- message?: string;
15
- }
16
- export interface CommandExecution extends CommandExecutionInput, Base {
17
- }
18
8
  export interface CommandExecutionsFilters extends Filters {
19
9
  command_id?: Filter;
20
10
  device_id?: Filter;
@@ -79,6 +79,7 @@ exports.Companies = (function (_super) {
79
79
  case 2:
80
80
  error_1 = _a.sent();
81
81
  if ((0, helpers_1.isApiError)(error_1)) {
82
+ error_1.message = (0, helpers_1.parseResourceError)(error_1.message, 'account');
82
83
  throw error_1;
83
84
  }
84
85
  throw error_1;
@@ -252,7 +252,7 @@ exports.Configurations = (function (_super) {
252
252
  _a.trys.push([0, 2, , 3]);
253
253
  this.logAction("Removing a relation between configuration with id: " + id + " and command with id " + commandId);
254
254
  axios = core_1.EdgeIQAPI.getAxios();
255
- return [4, axios.delete(constants_1.Endpoints.configuration + "/" + id + "/commands/" + commandId)];
255
+ return [4, axios.delete(constants_1.Endpoints.command + "/" + commandId + "/configurations/" + id)];
256
256
  case 1:
257
257
  _a.sent();
258
258
  return [2, (0, constants_1.getAttachMessage)('Command', 'detach', 'configuration')];
@@ -39,10 +39,12 @@ export declare const ResponseErrorsMessages: {
39
39
  deviceCharacters: string;
40
40
  emailUsed: (email: string) => string;
41
41
  uniqueConstraint: (model: string) => string;
42
+ nullIdConstraint: (model: string) => string;
42
43
  unEditableIntegration: (type: string) => string;
43
44
  integrationMissinValues: (type: string, values: string[]) => string;
44
45
  unexpected: string;
45
46
  invalidTokenExpiration: string;
47
+ tooLong: string;
46
48
  };
47
49
  export declare const ErrorParts: {
48
50
  deviceExists: string;
@@ -93,8 +95,10 @@ export declare const BaseEndpoints: {
93
95
  userType: string;
94
96
  user: string;
95
97
  logs: string;
98
+ workflows: string;
96
99
  workflowActions: string;
97
100
  workflowDefinitions: string;
101
+ workflowExecutions: string;
98
102
  };
99
103
  export declare const Endpoints: {
100
104
  me: string;
@@ -145,8 +149,10 @@ export declare const Endpoints: {
145
149
  translator: string;
146
150
  userType: string;
147
151
  user: string;
152
+ workflows: string;
148
153
  workflowAction: string;
149
154
  workflowDefinition: string;
155
+ workflowExecutions: string;
150
156
  };
151
157
  export declare const MethodsActions: {
152
158
  post: string;
package/dist/constants.js CHANGED
@@ -43,11 +43,14 @@ exports.ResponseErrorsMessages = {
43
43
  },
44
44
  deviceCharacters: 'A unique ID can only contain lower case letters, numbers or special characters -, : or _',
45
45
  emailUsed: function (email) {
46
- return "A user with email '" + email + "' already exists";
46
+ return "A User with email '" + email + "' already exists";
47
47
  },
48
48
  uniqueConstraint: function (model) {
49
49
  return "A " + model + " with the same key already exists";
50
50
  },
51
+ nullIdConstraint: function (model) {
52
+ return model.charAt(0).toLocaleUpperCase() + model.slice(1) + " not found";
53
+ },
51
54
  unEditableIntegration: function (type) {
52
55
  return "Intregration of type " + type + " cannot be edited";
53
56
  },
@@ -56,6 +59,7 @@ exports.ResponseErrorsMessages = {
56
59
  },
57
60
  unexpected: 'Unexpected error has ocurred',
58
61
  invalidTokenExpiration: 'Invalid session token expiration. Session token expiration must be greater than 0 and less than one week.',
62
+ tooLong: 'Account name is too long',
59
63
  };
60
64
  exports.ErrorParts = {
61
65
  deviceExists: 'A Device with unique id',
@@ -109,8 +113,10 @@ exports.BaseEndpoints = {
109
113
  userType: 'user_types',
110
114
  user: 'users',
111
115
  logs: 'logs',
116
+ workflows: 'workflows',
112
117
  workflowActions: 'workflow_actions',
113
118
  workflowDefinitions: 'workflow_definitions',
119
+ workflowExecutions: 'workflow_executions',
114
120
  };
115
121
  exports.Endpoints = {
116
122
  me: 'me',
@@ -161,8 +167,10 @@ exports.Endpoints = {
161
167
  translator: "" + exports.BaseEndpoints.translator,
162
168
  userType: "" + exports.BaseEndpoints.userType,
163
169
  user: "" + exports.BaseEndpoints.user,
170
+ workflows: "" + exports.BaseEndpoints.workflows,
164
171
  workflowAction: "" + exports.BaseEndpoints.workflowActions,
165
172
  workflowDefinition: "" + exports.BaseEndpoints.workflowDefinitions,
173
+ workflowExecutions: "" + exports.BaseEndpoints.workflowExecutions,
166
174
  };
167
175
  exports.MethodsActions = {
168
176
  post: 'creating',
package/dist/helpers.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  declare const getReturnDeleteMessage: (model: string) => string;
2
2
  declare const isApiError: (error: unknown) => error is Error;
3
- export { getReturnDeleteMessage, isApiError };
3
+ declare const parseResourceError: (msg: string, model: string) => string;
4
+ export { getReturnDeleteMessage, isApiError, parseResourceError };
package/dist/helpers.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isApiError = exports.getReturnDeleteMessage = void 0;
3
+ exports.parseResourceError = exports.isApiError = exports.getReturnDeleteMessage = void 0;
4
+ var constants_1 = require("./constants");
4
5
  var getReturnDeleteMessage = function (model) {
5
6
  return "The " + model + " has been deleted.";
6
7
  };
@@ -9,3 +10,20 @@ var isApiError = function (error) {
9
10
  return error.message !== undefined;
10
11
  };
11
12
  exports.isApiError = isApiError;
13
+ var parseResourceError = function (msg, model) {
14
+ var tooLong = constants_1.ResponseErrorsMessages.tooLong, uniqueConstraint = constants_1.ResponseErrorsMessages.uniqueConstraint, nullIdConstraint = constants_1.ResponseErrorsMessages.nullIdConstraint;
15
+ var keywords = [
16
+ ['too long', tooLong],
17
+ ['exists', uniqueConstraint(model)],
18
+ ['not-null constraint', nullIdConstraint(model)],
19
+ ];
20
+ for (var _i = 0, keywords_1 = keywords; _i < keywords_1.length; _i++) {
21
+ var keyword = keywords_1[_i];
22
+ var key = keyword[0], message = keyword[1];
23
+ if (msg.search(key) > 0) {
24
+ return message;
25
+ }
26
+ }
27
+ return msg;
28
+ };
29
+ exports.parseResourceError = parseResourceError;
package/dist/index.d.ts CHANGED
@@ -36,8 +36,10 @@ export { Translators } from './translators';
36
36
  export { Users } from './users';
37
37
  export { UserTypes } from './userTypes';
38
38
  export { ScheduledJobs } from './scheduledJobs';
39
+ export { Workflows } from './workflows';
39
40
  export { WorkflowDefinitions } from './workflowDefinitions';
40
41
  export { WorkflowActions } from './workflowActions';
42
+ export { WorkflowExecutions } from './workflowExecutions';
41
43
  export * from './models';
42
44
  export * from './bulkResponses/models';
43
45
  export * from './commands/models';
@@ -76,5 +78,7 @@ export * from './translators/models';
76
78
  export * from './users/models';
77
79
  export * from './userTypes/models';
78
80
  export * from './scheduledJobs/models';
81
+ export * from './workflows/models';
79
82
  export * from './workflowDefinitions/models';
80
83
  export * from './workflowActions/models';
84
+ export * from './workflowExecutions/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.WorkflowActions = exports.WorkflowDefinitions = exports.ScheduledJobs = exports.UserTypes = exports.Users = exports.Translators = exports.SystemCommandJobs = exports.SystemCommands = exports.Stats = exports.SoftwareUpdates = exports.SettingApplicationRecords = exports.Settings = 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.EIQFiles = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.DeviceErrors = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.Configurations = exports.CommandExecutions = exports.Companies = exports.Commands = exports.BulkResponses = exports.Authentication = exports.EdgeIQAPI = void 0;
13
+ exports.WorkflowExecutions = exports.WorkflowActions = exports.WorkflowDefinitions = exports.Workflows = exports.ScheduledJobs = exports.UserTypes = exports.Users = exports.Translators = exports.SystemCommandJobs = exports.SystemCommands = exports.Stats = exports.SoftwareUpdates = exports.SettingApplicationRecords = exports.Settings = 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.EIQFiles = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.DeviceErrors = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.Configurations = 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");
@@ -87,10 +87,14 @@ var userTypes_1 = require("./userTypes");
87
87
  Object.defineProperty(exports, "UserTypes", { enumerable: true, get: function () { return userTypes_1.UserTypes; } });
88
88
  var scheduledJobs_1 = require("./scheduledJobs");
89
89
  Object.defineProperty(exports, "ScheduledJobs", { enumerable: true, get: function () { return scheduledJobs_1.ScheduledJobs; } });
90
+ var workflows_1 = require("./workflows");
91
+ Object.defineProperty(exports, "Workflows", { enumerable: true, get: function () { return workflows_1.Workflows; } });
90
92
  var workflowDefinitions_1 = require("./workflowDefinitions");
91
93
  Object.defineProperty(exports, "WorkflowDefinitions", { enumerable: true, get: function () { return workflowDefinitions_1.WorkflowDefinitions; } });
92
94
  var workflowActions_1 = require("./workflowActions");
93
95
  Object.defineProperty(exports, "WorkflowActions", { enumerable: true, get: function () { return workflowActions_1.WorkflowActions; } });
96
+ var workflowExecutions_1 = require("./workflowExecutions");
97
+ Object.defineProperty(exports, "WorkflowExecutions", { enumerable: true, get: function () { return workflowExecutions_1.WorkflowExecutions; } });
94
98
  __exportStar(require("./models"), exports);
95
99
  __exportStar(require("./bulkResponses/models"), exports);
96
100
  __exportStar(require("./commands/models"), exports);
@@ -129,5 +133,7 @@ __exportStar(require("./translators/models"), exports);
129
133
  __exportStar(require("./users/models"), exports);
130
134
  __exportStar(require("./userTypes/models"), exports);
131
135
  __exportStar(require("./scheduledJobs/models"), exports);
136
+ __exportStar(require("./workflows/models"), exports);
132
137
  __exportStar(require("./workflowDefinitions/models"), exports);
133
138
  __exportStar(require("./workflowActions/models"), exports);
139
+ __exportStar(require("./workflowExecutions/models"), exports);
package/dist/models.d.ts CHANGED
@@ -16,6 +16,7 @@ export interface Filter {
16
16
  value: string | number | boolean | string[] | number[];
17
17
  key?: string;
18
18
  }
19
+ export declare type ExecutionStatus = 'initiated' | 'info' | 'success' | 'error';
19
20
  export interface Filters {
20
21
  _id?: Filter;
21
22
  company_id?: Filter;
@@ -69,3 +70,8 @@ export interface AwsThingGroup {
69
70
  arn: string;
70
71
  name: string;
71
72
  }
73
+ export interface Execution extends Base {
74
+ execution_id: string;
75
+ status: ExecutionStatus;
76
+ message?: string;
77
+ }
@@ -145,7 +145,7 @@ exports.EmptyIntegration = __assign(__assign({}, baseModel), { name: '', archety
145
145
  exports.TestIntegration = {
146
146
  archetype: 'device',
147
147
  company_id: parentCompanyId,
148
- name: 'EIQSDK Integration Test',
148
+ name: 'EIQSDK Integration Mock',
149
149
  type: 'azure_device_integrations',
150
150
  iot_hub_hostname: 'test_hostname',
151
151
  shared_access_key: 'test_access_key',
@@ -154,7 +154,7 @@ exports.TestIntegration = {
154
154
  exports.TestIntegration2 = {
155
155
  archetype: 'device',
156
156
  company_id: parentCompanyId,
157
- name: 'EIQSDK Integration Test 2',
157
+ name: 'EIQSDK Integration Mock 2',
158
158
  type: 'twilio_rule_action_integrations',
159
159
  sid: 'test_sid',
160
160
  token: 'test_token',
@@ -163,7 +163,7 @@ exports.TestIntegration2 = {
163
163
  exports.TestIntegration3 = {
164
164
  archetype: 'device',
165
165
  company_id: parentCompanyId,
166
- name: 'EIQSDK Integration Test',
166
+ name: 'EIQSDK Integration Mock 3',
167
167
  type: 'aws_device_integrations',
168
168
  region: 'us-east-1',
169
169
  greengrass_core_install_url: 'https://d2s8p88vqu9w66.cloudfront.net/releases/greengrass-nucleus-latest.zip',
@@ -0,0 +1,6 @@
1
+ import { PaginationFilter } from '../models';
2
+ import { WorkflowExecutionsFilters, PaginatedWorkflowExecutions } from './models';
3
+ declare const WorkflowExecutions: {
4
+ list(filters?: WorkflowExecutionsFilters | undefined, pagination?: PaginationFilter | undefined): Promise<PaginatedWorkflowExecutions>;
5
+ };
6
+ export { WorkflowExecutions };
@@ -0,0 +1,79 @@
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.WorkflowExecutions = void 0;
40
+ var constants_1 = require("../constants");
41
+ var filtersParser_1 = require("../filtersParser");
42
+ var helpers_1 = require("../helpers");
43
+ var core_1 = require("../core");
44
+ var WorkflowExecutions = {
45
+ list: function (filters, pagination) {
46
+ var _a, _b, _c, _d;
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ var axios, result, error_1;
49
+ return __generator(this, function (_e) {
50
+ switch (_e.label) {
51
+ case 0:
52
+ _e.trys.push([0, 2, , 3]);
53
+ axios = core_1.EdgeIQAPI.getAxios();
54
+ return [4, axios.get("" + constants_1.Endpoints.workflowExecutions, {
55
+ params: (0, filtersParser_1.parseFilters)(filters, pagination),
56
+ })];
57
+ case 1:
58
+ result = _e.sent();
59
+ return [2, {
60
+ workflowExecutions: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
61
+ pagination: {
62
+ page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
63
+ itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
64
+ total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
65
+ },
66
+ }];
67
+ case 2:
68
+ error_1 = _e.sent();
69
+ if ((0, helpers_1.isApiError)(error_1)) {
70
+ throw error_1;
71
+ }
72
+ throw error_1;
73
+ case 3: return [2];
74
+ }
75
+ });
76
+ });
77
+ },
78
+ };
79
+ exports.WorkflowExecutions = WorkflowExecutions;
@@ -0,0 +1,14 @@
1
+ import { Base, Execution, Filter, Filters, Pagination } from '../models';
2
+ export interface WorkflowExecution extends Base {
3
+ workflow_id: string;
4
+ workflow_instance_id: string;
5
+ execution_statuses: Execution[];
6
+ }
7
+ export interface WorkflowExecutionsFilters extends Filters {
8
+ workflow_id?: Filter;
9
+ device_id?: Filter;
10
+ }
11
+ export interface PaginatedWorkflowExecutions {
12
+ workflowExecutions: WorkflowExecution[];
13
+ pagination: Pagination;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { PaginationFilter } from '../models';
2
+ import { WorkflowFilters, PaginatedWorkflows, Workflow } from './models';
3
+ declare const Workflows: {
4
+ list(filters?: WorkflowFilters | undefined, pagination?: PaginationFilter | undefined): Promise<PaginatedWorkflows>;
5
+ getOneById(id: string): Promise<Workflow>;
6
+ };
7
+ export { Workflows };
@@ -0,0 +1,102 @@
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.Workflows = void 0;
40
+ var __1 = require("..");
41
+ var constants_1 = require("../constants");
42
+ var filtersParser_1 = require("../filtersParser");
43
+ var helpers_1 = require("../helpers");
44
+ var Workflows = {
45
+ list: function (filters, pagination) {
46
+ var _a, _b, _c, _d;
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ var axios, result, error_1;
49
+ return __generator(this, function (_e) {
50
+ switch (_e.label) {
51
+ case 0:
52
+ _e.trys.push([0, 2, , 3]);
53
+ axios = __1.EdgeIQAPI.getAxios();
54
+ return [4, axios.get(constants_1.Endpoints.workflows, {
55
+ params: (0, filtersParser_1.parseFilters)(filters, pagination),
56
+ })];
57
+ case 1:
58
+ result = _e.sent();
59
+ return [2, {
60
+ workflows: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
61
+ pagination: {
62
+ page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
63
+ itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
64
+ total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
65
+ },
66
+ }];
67
+ case 2:
68
+ error_1 = _e.sent();
69
+ if ((0, helpers_1.isApiError)(error_1)) {
70
+ throw error_1;
71
+ }
72
+ throw error_1;
73
+ case 3: return [2];
74
+ }
75
+ });
76
+ });
77
+ },
78
+ getOneById: function (id) {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var axios, result, error_2;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0:
84
+ _a.trys.push([0, 2, , 3]);
85
+ axios = __1.EdgeIQAPI.getAxios();
86
+ return [4, axios.get(constants_1.Endpoints.workflows + "/" + id)];
87
+ case 1:
88
+ result = _a.sent();
89
+ return [2, result === null || result === void 0 ? void 0 : result.data];
90
+ case 2:
91
+ error_2 = _a.sent();
92
+ if ((0, helpers_1.isApiError)(error_2)) {
93
+ throw error_2;
94
+ }
95
+ throw error_2;
96
+ case 3: return [2];
97
+ }
98
+ });
99
+ });
100
+ },
101
+ };
102
+ exports.Workflows = Workflows;
@@ -0,0 +1,14 @@
1
+ import { Base, Filter, Filters, Pagination } from '../models';
2
+ export interface Workflow extends Base {
3
+ name: string;
4
+ workflow_url: string;
5
+ current_status: string;
6
+ }
7
+ export interface WorkflowFilters extends Filters {
8
+ name?: Filter;
9
+ current_status?: Filter;
10
+ }
11
+ export interface PaginatedWorkflows {
12
+ workflows: Workflow[];
13
+ pagination: Pagination;
14
+ }
@@ -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.6.21",
3
+ "version": "1.7.0",
4
4
  "author": "EdgeIQ",
5
5
  "license": "ISC",
6
6
  "description": "This project presents EdgeIQ API SDK.",
@@ -27,6 +27,7 @@
27
27
  "prepublishOnly": "npm run lint",
28
28
  "preversion": "npm run lint",
29
29
  "test": "jest --config jestconfig.json --runInBand --detectOpenHandles",
30
+ "test:watch": "jest --config jestconfig.json --watch --detectOpenHandles",
30
31
  "version": "npm run format && git add -A src"
31
32
  },
32
33
  "dependencies": {