iotagent-node-lib 4.0.0 → 4.0.1
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.
package/lib/errors.js
CHANGED
|
@@ -229,9 +229,9 @@ class BadAnswer {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
class BadTimestamp {
|
|
232
|
-
constructor(payload) {
|
|
232
|
+
constructor(payload, entityName) {
|
|
233
233
|
this.name = 'BAD_TIMESTAMP';
|
|
234
|
-
this.message = 'Invalid ISO8601 timestamp [' + payload + ']';
|
|
234
|
+
this.message = 'Invalid ISO8601 timestamp [' + payload + '] in [' + entityName + ']';
|
|
235
235
|
this.code = 400;
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -1015,7 +1015,7 @@ function sendUpdateValueNgsiLD(entityName, attributes, typeInformation, token, c
|
|
|
1015
1015
|
} else if (!utils.IsValidTimestampedNgsi2(payload[n])) {
|
|
1016
1016
|
// legacy check needed?
|
|
1017
1017
|
logger.error(context, 'Invalid timestamp:%s', JSON.stringify(payload[0]));
|
|
1018
|
-
callback(new errors.BadTimestamp(payload));
|
|
1018
|
+
callback(new errors.BadTimestamp(payload, entityName));
|
|
1019
1019
|
return;
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
@@ -311,7 +311,7 @@ function sendUpdateValueNgsi2(entityName, measures, typeInformation, token, call
|
|
|
311
311
|
if (moment(plainMeasures[constants.TIMESTAMP_ATTRIBUTE], moment.ISO_8601, true).isValid()) {
|
|
312
312
|
timestamp.value = plainMeasures[constants.TIMESTAMP_ATTRIBUTE];
|
|
313
313
|
} else {
|
|
314
|
-
callback(new errors.BadTimestamp(
|
|
314
|
+
callback(new errors.BadTimestamp(plainMeasures[constants.TIMESTAMP_ATTRIBUTE], entityName));
|
|
315
315
|
}
|
|
316
316
|
} else if (!typeInformation.timezone) {
|
|
317
317
|
timestamp.value = new Date().toISOString();
|
|
@@ -387,10 +387,11 @@ function sendUpdateValueNgsi2(entityName, measures, typeInformation, token, call
|
|
|
387
387
|
typeof currentAttr.entity_name == 'string'
|
|
388
388
|
) {
|
|
389
389
|
try {
|
|
390
|
-
logger.debug(
|
|
390
|
+
logger.debug(
|
|
391
|
+
context,
|
|
391
392
|
'Evaluating attribute: %j, for entity_name(exp):%j, with ctxt: %j',
|
|
392
|
-
currentAttr.name,
|
|
393
|
-
currentAttr.entity_name,
|
|
393
|
+
currentAttr.name,
|
|
394
|
+
currentAttr.entity_name,
|
|
394
395
|
jexlctxt
|
|
395
396
|
);
|
|
396
397
|
attrEntityName = jexlParser.applyExpression(currentAttr.entity_name, jexlctxt, typeInformation);
|
|
@@ -451,10 +452,11 @@ function sendUpdateValueNgsi2(entityName, measures, typeInformation, token, call
|
|
|
451
452
|
} catch (e) {
|
|
452
453
|
valueExpression = null;
|
|
453
454
|
}
|
|
454
|
-
logger.debug(
|
|
455
|
-
|
|
455
|
+
logger.debug(
|
|
456
|
+
context,
|
|
457
|
+
'Evaluated attr: %j, with expression: %j, and ctxt: %j resulting: %j',
|
|
456
458
|
currentAttr.name,
|
|
457
|
-
currentAttr.expression,
|
|
459
|
+
currentAttr.expression,
|
|
458
460
|
jexlctxt,
|
|
459
461
|
valueExpression
|
|
460
462
|
);
|
|
@@ -564,7 +566,7 @@ function sendUpdateValueNgsi2(entityName, measures, typeInformation, token, call
|
|
|
564
566
|
}
|
|
565
567
|
}
|
|
566
568
|
}
|
|
567
|
-
|
|
569
|
+
|
|
568
570
|
let url = '/v2/op/update';
|
|
569
571
|
let options = NGSIUtils.createRequestObject(url, typeInformation, token);
|
|
570
572
|
options.json = payload;
|
|
@@ -607,15 +609,9 @@ function sendUpdateValueNgsi2(entityName, measures, typeInformation, token, call
|
|
|
607
609
|
} // else: keep current options object created for a batch update
|
|
608
610
|
|
|
609
611
|
//Send the NGSI request
|
|
610
|
-
logger.debug(context,
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
);
|
|
614
|
-
logger.debug(context,
|
|
615
|
-
'Using the following NGSI v2 request: %j',
|
|
616
|
-
options
|
|
617
|
-
);
|
|
618
|
-
|
|
612
|
+
logger.debug(context, 'Updating device value in the Context Broker at: %j', options.url);
|
|
613
|
+
logger.debug(context, 'Using the following NGSI v2 request: %j', options);
|
|
614
|
+
|
|
619
615
|
request(
|
|
620
616
|
options,
|
|
621
617
|
generateNGSI2OperationHandler('update', entityName, typeInformation, token, options, callback)
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "iotagent-node-lib",
|
|
3
3
|
"license": "AGPL-3.0-only",
|
|
4
4
|
"description": "IoT Agent library to interface with NGSI Context Broker",
|
|
5
|
-
"version": "4.0.
|
|
5
|
+
"version": "4.0.1",
|
|
6
6
|
"homepage": "https://github.com/telefonicaid/iotagent-node-lib",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"fiware",
|
package/CHANGES_NEXT_RELEASE
DELETED
|
File without changes
|