iotagent-node-lib
iotagent-node-lib copied to clipboard
extend autocast feature to control each attribute
autocast feature is performed by
https://github.com/telefonicaid/iotagent-node-lib/blob/9557e7568f28ee5c35116d7213c41a8a25425897/lib/services/ngsi/ngsiUtils.js#L98-L134
It was introduced by https://github.com/dcalvoalonso/iotagent-node-lib/pull/7 in 2.7.0 release of iota-node-lib
Currently is performing casting based on some attribute types (Boolean, Number, None) which is not the best. But instead of that (which is not a best approach) control cast per attribute is proposed:
{
"name": "myNumber",
"type": "MyCustomType",
"autocastType": "Number",
"autocast" : true
}
as was suggested in https://github.com/telefonicaid/iotagent-node-lib/pull/1020#discussion_r621073048
(autocast feature is used by iotagent-ul, but not used by iotagent-json)
As follow up of this issue, the current autocast feature in IOTA-UL (IOTA_AUTOCAST env var and associated config.js setting) should be removed. It makes no sense to keep both system at the same time, it can be confusing for users.
@AlvaroVega I am interested to work in this issue.
As per my understanding , In castJsonNativeAttributes
casting take place on the basis of type.
and we have to extend the castJsonNativeAttributes
or do casting on the basis of ( name, autocastType) attribute too.
Please confirm.
autocast should be done in base of proposed "autocastType" field and "autocast" flag of each attribute, possible in castJsonNativeAttributes or in another new function
@Sunny-NEC thanks for your willingness to work on this issue! Please go ahead and create the pull request with your contribution, so we can evaluate and provide feedback.