opengate-js 14.0.0 → 14.2.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.
Files changed (48) hide show
  1. package/bower.json +1 -1
  2. package/dist/{opengate-api-bower-14.0.0.js → opengate-api-bower-14.2.0.js} +26 -21
  3. package/dist/opengate-api-bower-14.2.0.js.map +1 -0
  4. package/dist/{opengate-api-bower-14.0.0.min.js → opengate-api-bower-14.2.0.min.js} +2 -2
  5. package/dist/{opengate-api-bower-14.0.0.min.js.map → opengate-api-bower-14.2.0.min.js.map} +1 -1
  6. package/dist/src/operations/OperationActions.js +2 -0
  7. package/dist/src/operations/OperationActions.js.map +1 -1
  8. package/dist/src/operations/catalog/BaseOperationBuilder.js +14 -11
  9. package/dist/src/operations/catalog/BaseOperationBuilder.js.map +1 -1
  10. package/dist/src/searching/StaticSearch.js +4 -4
  11. package/dist/src/searching/StaticSearch.js.map +1 -1
  12. package/docs/ast/source/operations/OperationActions.js.json +8300 -7782
  13. package/docs/ast/source/operations/catalog/BaseOperationBuilder.js.json +10013 -9786
  14. package/docs/ast/source/searching/StaticSearch.js.json +18177 -18127
  15. package/docs/class/src/operations/OperationActions.js~OperationActions.html +2 -2
  16. package/docs/class/src/operations/catalog/BaseOperationBuilder.js~BaseOperationBuilder.html +22 -15
  17. package/docs/coverage.json +1 -1
  18. package/docs/dump.json +1971 -1915
  19. package/docs/file/src/operations/OperationActions.js.html +2 -0
  20. package/docs/file/src/operations/catalog/BaseOperationBuilder.js.html +12 -11
  21. package/docs/file/src/searching/StaticSearch.js.html +4 -4
  22. package/docs/package.json +1 -1
  23. package/docs/source.html +240 -240
  24. package/features/features/provision/operations/actions_execution.feature +105 -52
  25. package/features/features/provision/operations/execute_operations.feature +152 -112
  26. package/features/features/provision/operations/execute_periodic_operations.feature +115 -64
  27. package/features/features/provision/operations/find_execution.feature +49 -11
  28. package/features/features/provision/operations/find_executions.feature +51 -11
  29. package/features/features/provision/operations/find_periodic_execution.feature +48 -11
  30. package/features/features/provision/operations/setting_up_period-each_operation.feature +88 -23
  31. package/features/features/provision/operations/update_periodic_operation.feature +88 -46
  32. package/features/features/provision/users/update_password.feature +0 -1
  33. package/features/features/provision/users/update_user.feature +0 -1
  34. package/features/features/searching/operations/searching_executions.feature +47 -7
  35. package/features/features/searching/operations/searching_periodic_operations.feature +51 -10
  36. package/features/step_definitions/given_step_definitions.js +12 -5
  37. package/features/step_definitions/then_step_definitions.js +44 -35
  38. package/features/step_definitions/when_step_definitions.js +16 -10
  39. package/features/support/create_provision_model.js +6 -0
  40. package/features/support/find_model.js +4 -0
  41. package/features/support/utils_model.js +26 -20
  42. package/features/support/world.js +2 -2
  43. package/package.json +1 -1
  44. package/src/operations/OperationActions.js +2 -0
  45. package/src/operations/catalog/BaseOperationBuilder.js +12 -11
  46. package/src/searching/StaticSearch.js +4 -4
  47. package/yarn-error.log +7437 -0
  48. package/dist/opengate-api-bower-14.0.0.js.map +0 -1
@@ -75,7 +75,7 @@ Then(/^throws an error\. the error message explain that a parameter with name "(
75
75
 
76
76
  Then(/^response error code sould be: (\d+)$/, function (statusCode, callback) {
77
77
  // Write code here that turns the phrase above into concrete actions
78
- var response = this.responseData;
78
+ var response = this.responseData || this.error;
79
79
  if (typeof response.response !== "undefined") {
80
80
  response = response.response;
81
81
  }
@@ -123,15 +123,15 @@ Then(/^response must have attached an entity list with "([^"]*)" type defined by
123
123
 
124
124
 
125
125
 
126
- Then(/^response specific error code sould be: (\d+)$/, function (statusCode, callback) {
126
+ Then('response specific error code sould be: {string}', function (statusCode, callback) {
127
127
  // Write code here that turns the phrase above into concrete actions
128
- var response = this.responseData;
128
+ var response = this.responseData || this.error;
129
129
  if (typeof response.response !== "undefined") {
130
130
  response = response.response;
131
131
  }
132
132
 
133
133
  for (var i = 0; i < response.data.errors.length; i++) {
134
- this.expect(response.data.errors[i].code).to.equal(parseInt(statusCode));
134
+ this.expect(response.data.errors[i].code).to.equal(statusCode);
135
135
  }
136
136
  callback();
137
137
  });
@@ -145,24 +145,23 @@ Then(/^response contains a parameter "([^"]*)" as name and "([^"]*)" as value$/,
145
145
  if (this.responseData.data)
146
146
  data = this.responseData.data;
147
147
  var parameters = data.request.parameters;
148
- var parameterNames = parameters.map(function (item) {
149
- return item.name;
150
- });
151
- var isDuplicate = parameterNames.some(function (item, idx) {
152
- return parameterNames.indexOf(item) != idx;
153
- });
154
- this.expect(isDuplicate).to.be.false;
155
-
156
-
157
- var parameter = parameters.find(function (param) {
158
- return param.name == this;
159
- }, paramName);
160
- this.expect(parameter).to.be.an('object');
148
+
149
+ this.expect(parameters[paramName]).to.equal(paramValue);
161
150
 
151
+ callback();
152
+ });
162
153
 
163
- for (var key in parameter.value) {
164
- this.expect(parameter.value[key] == paramValue).to.be.true;
154
+ Then('response contains a parameter {string} as name and {string} as json value', function (paramName, paramValue, callback) {
155
+ // Write code here that turns the phrase above into concrete actions
156
+ if (this.responseData.response) {
157
+ this.expect(this.responseData.response.statusCode).to.equal(201);
165
158
  }
159
+ var data;
160
+ if (this.responseData.data)
161
+ data = this.responseData.data;
162
+ var parameters = data.request.parameters;
163
+ this.expect(JSON.stringify(parameters[paramName])).to.equal(paramValue);
164
+
166
165
  callback();
167
166
  });
168
167
 
@@ -285,7 +284,7 @@ Then(/^I can see into the post data a every month pattern at day (\d+) and month
285
284
  });
286
285
 
287
286
  Then(/^I can see into the post data a job timeout by (\d+) minutes$/, function (minutes, callback) {
288
- var milliseconds = eval(minutes) * 60 * 1000;
287
+ var milliseconds = (eval(minutes) * 60 * 1000) - 1000;
289
288
  var stop = this.build._postObj.task.job.request.schedule.stop;
290
289
  this.expect(stop).to.be.an('object');
291
290
  var jobTimeout = stop.delayed;
@@ -313,23 +312,33 @@ Then(/^I can see into the post data a start date as "([^"]*)"$/, function (when,
313
312
  Then(/^throws an error equal to "([^"]*)"$/, function (errorMessage, callback) {
314
313
  this.expect(this.error).to.exist;
315
314
  var errorText;
316
- if (this.error.constructor == Array) {
317
- this.expect(this.error).to.have.lengthOf(1);
318
- errorText = this.error[0].description || this.error[0].message || this.error[0];
319
- } else {
320
- if (this.error.message) {
321
- errorText = this.error.message;
322
- } else if (this.error.data) {
323
- errorText = this.error.data;
324
- if (errorText.errors) {
325
- errorText = errorText.errors[0].message;
315
+ var _errorText;
316
+ switch (this.error.constructor) {
317
+ case Array:
318
+ this.expect(this.error).to.have.lengthOf(1);
319
+ errorText = this.error[0].description || this.error[0].message || this.error[0];
320
+ break;
321
+ case Error:
322
+ errorText = this.error.message
323
+ break;
324
+ case String:
325
+ errorText = JSON.parse(this.error)
326
+ //NO BREAK!!!!!
327
+ case Object:
328
+ _errorText = errorText || this.error
329
+ if (_errorText.message) {
330
+ errorText = _errorText.message;
331
+ } else if (_errorText.data) {
332
+ errorText = _errorText.data;
333
+ if (errorText.errors) {
334
+ errorText = errorText.errors[0].message;
335
+ }
336
+ } else {
337
+ errorText = _errorText;
326
338
  }
327
- } else {
328
- errorText = this.error;
329
- }
330
-
339
+ break;
331
340
  }
332
-
341
+
333
342
  this.expect(errorText).to.equal(errorMessage);
334
343
 
335
344
  callback();
@@ -6,9 +6,7 @@ var {
6
6
  Given
7
7
  } = require('cucumber');
8
8
 
9
- When(/^I want "([^"]*)"( (\d*) minutes| for this url "([^"]*)" for)? (a|of a) operation$/, function (action, nothing, minutes, data, exclude) {
10
- var _this = this;
11
-
9
+ function executeActionOperation (action, minutes, data, _this){
12
10
  function digestResponseData(response) {
13
11
  //console.log('digestResponseData', response)
14
12
  //Guardamos el identificador anterior por si hiciera falta para el siguiente paso
@@ -34,7 +32,7 @@ When(/^I want "([^"]*)"( (\d*) minutes| for this url "([^"]*)" for)? (a|of a) op
34
32
  if (location && !_this.responseData.location) {
35
33
  _this.responseData.location = location;
36
34
  }
37
- this.error = undefined;
35
+ _this.error = undefined;
38
36
  }
39
37
 
40
38
  function digestErrorData(response) {
@@ -91,13 +89,21 @@ When(/^I want "([^"]*)"( (\d*) minutes| for this url "([^"]*)" for)? (a|of a) op
91
89
  default:
92
90
  throw new Error("Not exists action " + action);
93
91
  }
94
- var util = this.util[findMethod];
95
- return util.call(this.util, (data || (minutes * 1))).then(digestResponseData).catch(digestErrorData);
92
+ var util = _this.util[findMethod];
93
+ return util.call(_this.util, (data || (minutes * 1))).then(digestResponseData).catch(digestErrorData);
96
94
  } catch (err) {
97
95
  console.error('ERROR: ', err)
98
- this.error = err;
96
+ _this.error = err;
99
97
  throw new Error(JSON.stringify(err));
100
98
  }
99
+ }
100
+
101
+ When(/^I want "([^"]*)"( (\d*) minutes| for this url "([^"]*)" for) operation$/, function (action, minutes) {
102
+ return executeActionOperation(action, minutes, undefined, this)
103
+ });
104
+
105
+ When(/^I want "([^"]*)" (a|of a) operation$/, function (action, nothing) {
106
+ return executeActionOperation(action, undefined, undefined, this)
101
107
  });
102
108
 
103
109
  When(/^I try to find an operation for its id of periodicity and save its id$/, function () {
@@ -115,7 +121,7 @@ When(/^I try to find an operation for its id of periodicity and save its id$/, f
115
121
  }
116
122
 
117
123
  function digestErrorData(error) {
118
- console.error('digestErrorData', err)
124
+ console.error('digestErrorData', error)
119
125
  _this.error = error;
120
126
  _this.responseData = error;
121
127
 
@@ -194,8 +200,8 @@ When(/^I build it with filter by operation's id$/, function (callback) {
194
200
 
195
201
  try {
196
202
  var data;
197
- if (this.responseData.statusCode)
198
- data = this.responseData.statusCode;
203
+ if (this.responseData.data)
204
+ data = this.responseData.data;
199
205
  else if (this.responseData[1])
200
206
  data = this.responseData[1];
201
207
  var jobId = data.id;
@@ -18,6 +18,12 @@ module.exports = {
18
18
  },
19
19
  setters: function (setter) {
20
20
  return {
21
+ 'operation type': {
22
+ 'name': "withName",
23
+ 'title': "withTitle",
24
+ 'description': "withDescription",
25
+ 'fromCatalog': "fromCatalog"
26
+ },
21
27
  'user': {
22
28
  'email': 'withEmail',
23
29
  'password': 'withPassword',
@@ -118,6 +118,10 @@ module.exports = {
118
118
  'organization name': 'name',
119
119
  'periodic operation type': 'job.request.name',
120
120
  'periodic schedule': 'schedule',
121
+ 'periodic schedule - repeating': 'schedule.repeating',
122
+ 'periodic schedule - repeating - weekly': 'schedule.repeating.pattern.weekly',
123
+ 'periodic schedule - repeating - monthly': 'schedule.repeating.pattern.monthly',
124
+ 'periodic schedule - repeating - yearly': 'schedule.repeating.pattern.yearly',
121
125
  'periodic status': 'status',
122
126
  'user email': 'email',
123
127
  'rule configuration name': 'name',
@@ -89,8 +89,11 @@ module.exports = {
89
89
  "devices search": function(ogapi) {
90
90
  return ogapi.devicesSearchBuilder();
91
91
  },
92
- "devices builder": function(ogapi, param1) {
93
- return ogapi.entityBuilder.devicesBuilder(param1);
92
+ "operation type": function(ogapi, param){
93
+ return ogapi.operationTypeBuilder(param);
94
+ },
95
+ "devices builder": function(ogapi, param) {
96
+ return ogapi.entityBuilder.devicesBuilder(param);
94
97
  },
95
98
  "subscribers search": function(ogapi) {
96
99
  return ogapi.subscribersSearchBuilder();
@@ -143,11 +146,11 @@ module.exports = {
143
146
  "softwares search": function(ogapi) {
144
147
  return ogapi.softwaresSearchBuilder();
145
148
  },
146
- "subscriptions builder": function(ogapi, param1) {
147
- return ogapi.entityBuilder.subscriptionsBuilder(param1);
149
+ "subscriptions builder": function(ogapi, param) {
150
+ return ogapi.entityBuilder.subscriptionsBuilder(param);
148
151
  },
149
- "subscribers builder": function(ogapi, param1) {
150
- return ogapi.entityBuilder.subscribersBuilder(param1);
152
+ "subscribers builder": function(ogapi, param) {
153
+ return ogapi.entityBuilder.subscribersBuilder(param);
151
154
  },
152
155
  "user finder": function(ogapi) {
153
156
  return ogapi.newUserFinder();
@@ -266,6 +269,9 @@ module.exports = {
266
269
  "executions search": function() {
267
270
  return ogapi.executionsSearchBuilder();
268
271
  },
272
+ "executions history search": function() {
273
+ return ogapi.executionsHistorySearchBuilder();
274
+ },
269
275
  "periodic operations search": function() {
270
276
  return ogapi.tasksSearchBuilder();
271
277
  },
@@ -296,20 +302,20 @@ module.exports = {
296
302
  "entities search": function() {
297
303
  return ogapi.entitiesSearchBuilder();
298
304
  },
299
- "csv bulk builder": function(ogapi, param1, param2) {
300
- return ogapi.entityBuilder.newCsvBulkBuilder(param1, param2);
305
+ "csv bulk builder": function(ogapi, param, param2) {
306
+ return ogapi.entityBuilder.newCsvBulkBuilder(param, param2);
301
307
  },
302
- "bulk execution builder": function(ogapi, param1, param2){
303
- return ogapi.bulkExecutionBuilder(param1, param2);
308
+ "bulk execution builder": function(ogapi, param, param2){
309
+ return ogapi.bulkExecutionBuilder(param, param2);
304
310
  },
305
- "json bulk builder": function(ogapi, param1, param2) {
306
- return ogapi.entityBuilder.newJsonBulkBuilder(param1, param2);
311
+ "json bulk builder": function(ogapi, param, param2) {
312
+ return ogapi.entityBuilder.newJsonBulkBuilder(param, param2);
307
313
  },
308
- "json flattened bulk builder": function(ogapi, param1, param2) {
309
- return ogapi.entityBuilder.newJsonFlattenedBulkBuilder(param1, param2);
314
+ "json flattened bulk builder": function(ogapi, param, param2) {
315
+ return ogapi.entityBuilder.newJsonFlattenedBulkBuilder(param, param2);
310
316
  },
311
- "csv bulk async builder": function(ogapi, param1, param2) {
312
- return ogapi.entityBuilder.newCsvBulkBuilder(param1, param2, null, null, true);
317
+ "csv bulk async builder": function(ogapi, param, param2) {
318
+ return ogapi.entityBuilder.newCsvBulkBuilder(param, param2, null, null, true);
313
319
  },
314
320
  "bulks search": function(ogapi) {
315
321
  return ogapi.bulkSearchBuilder();
@@ -317,14 +323,14 @@ module.exports = {
317
323
  "bulk executions search": function(ogapi) {
318
324
  return ogapi.bulkExecutionSearchBuilder();
319
325
  },
320
- "asset builder": function(ogapi, param1) {
321
- return ogapi.entityBuilder.assetsBuilder(param1);
326
+ "asset builder": function(ogapi, param) {
327
+ return ogapi.entityBuilder.assetsBuilder(param);
322
328
  },
323
329
  "asset search": function(ogapi) {
324
330
  return ogapi.assetsSearchBuilder();
325
331
  },
326
- "tickets builder": function(ogapi, param1) {
327
- return ogapi.entityBuilder.ticketsBuilder(param1);
332
+ "tickets builder": function(ogapi, param) {
333
+ return ogapi.entityBuilder.ticketsBuilder(param);
328
334
  },
329
335
  "ticket search": function(ogapi) {
330
336
  return ogapi.ticketsSearchBuilder();
@@ -17,8 +17,8 @@ function World() {
17
17
  this.test_url_north = process.env.API_NORTH_INTERNAL || 'https://odmux01.amplia.int';
18
18
  this.test_url_south = process.env.API_SOUTH_INTERNAL || 'https://odmux01.amplia.int/south';
19
19
  //this.apikey = process.env.API_KEY || 'YOUR_API_KEY';
20
- this.YOUR_EMAIL = process.env.YOUR_EMAIL || 'root@amplia.es';
21
- this.YOUR_PASSWORD = process.env.YOUR_PASSWORD || 'defaultRoot12.';
20
+ this.YOUR_EMAIL = process.env.YOUR_EMAIL || 'monica.fernandez@amplia.es';
21
+ this.YOUR_PASSWORD = process.env.YOUR_PASSWORD || 'ampliaM2M@Opengate';
22
22
  this.guerrillaApi = 'https://api.guerrillamail.com/ajax.php'
23
23
  chai.use(chai_as_promised);
24
24
  this.expect = chai.expect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opengate-js",
3
- "version": "14.0.0",
3
+ "version": "14.2.0",
4
4
  "description": "",
5
5
  "main": "dist/opengate-api-npm.js",
6
6
  "repository": {
@@ -151,6 +151,7 @@ export default class OperationActions {
151
151
  }
152
152
  }
153
153
  };
154
+ this._key = "job";
154
155
  return this._readAndUpdate(config, true);
155
156
  }
156
157
 
@@ -178,6 +179,7 @@ export default class OperationActions {
178
179
  }
179
180
  }
180
181
  };
182
+ this._key = "job";
181
183
  return this._readAndUpdate(config);
182
184
  }
183
185
 
@@ -300,21 +300,22 @@ export default class BaseOperationBuilder {
300
300
  /**
301
301
  * Set a timeout of job.
302
302
  * @example
303
- * ogapi.operations.builderFactory.newXXXBuilder().withJobTimeout(3)
304
- * @param {number} minutes - if null then parameter will be removed into builder
305
- * @throws {Error} throw error when minutes is not typeof number
303
+ * ogapi.operations.builderFactory.newXXXBuilder().withJobTimeout(180)
304
+ * @param {!number} milliseconds - if null then parameter will be removed into builder
305
+ * @param {string} format - Can be 'milliseconds' || 'ms' ,'seconds' || 's', 'mintutes' || 'm', 'hours' || 'h', 'days' || 'd', 'weeks' || 'w', 'months' || 'M'
306
+ * @throws {Error} throw error when milliseconds is not typeof number
306
307
  * @return {BaseOperationBuilder}
307
308
  */
308
- withJobTimeout(minutes) {
309
- if (minutes === null) {
309
+ withJobTimeout(milliseconds, format = "milliseconds") {
310
+ if (milliseconds === null) {
310
311
  delete this._build.schedule.stop;
311
312
  return this;
312
313
  }
313
- if (typeof minutes !== "number") {
314
- throw new Error("Parameter minutes must be a number");
314
+ if (typeof milliseconds !== "number") {
315
+ throw new Error("Parameter milliseconds must be a number");
315
316
  }
316
317
  this._build.schedule.stop = {
317
- delayed: moment.duration(minutes, 'minutes').asMilliseconds()
318
+ delayed: moment.duration(milliseconds, format).asMilliseconds()
318
319
  };
319
320
  return this;
320
321
  }
@@ -479,9 +480,9 @@ export default class BaseOperationBuilder {
479
480
  errors.push("You can not execute an operation with a job timeout greater than the repetition period.");
480
481
  }
481
482
  } else {
482
- jobTimeout = moment.duration(maxJobTimeout, 'milliseconds').asMinutes() - 1;
483
- console.info("Not specified the job timeout. By default, timeout will be " + jobTimeout + " minutes");
484
- this.withJobTimeout(jobTimeout);
483
+ jobTimeout = moment.duration(maxJobTimeout, 'milliseconds').asSeconds() - 1;
484
+ console.info("Not specified the job timeout. By default, timeout will be " + jobTimeout + " seconds");
485
+ this.withJobTimeout(jobTimeout, 'seconds');
485
486
  }
486
487
 
487
488
  }
@@ -517,12 +517,12 @@ export default class StaticSearch extends Search {
517
517
  'optional': ['IMEI', 'HARDWARE', 'SOFTWARE']
518
518
  },
519
519
  'SUBSCRIPTION': {
520
- 'mandatory': ['generatedEntityKey'],
521
- 'optional': ['administrativeState', 'subscriptionName', 'description', 'IMSI', 'ADDRESS', 'HOME_OPERATOR', 'REGISTER_OPERATOR', 'LOCATION']
520
+ 'mandatory': [],
521
+ 'optional': ['generatedEntityKey', 'administrativeState', 'subscriptionName', 'description', 'IMSI', 'ADDRESS', 'HOME_OPERATOR', 'REGISTER_OPERATOR', 'LOCATION']
522
522
  },
523
523
  'SUBSCRIBER': {
524
- 'mandatory': ['generatedEntityKey'],
525
- 'optional': ['administrativeState', 'subscriberName', 'description', 'ICC']
524
+ 'mandatory': [],
525
+ 'optional': ['generatedEntityKey', 'administrativeState', 'subscriberName', 'description', 'ICC']
526
526
  }
527
527
  },
528
528
  'PLC': {