iotagent-node-lib 2.15.1 → 2.19.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 (448) hide show
  1. package/.github/workflows/ci.yml +17 -1
  2. package/.readthedocs.yml +7 -0
  3. package/CHANGES_NEXT_RELEASE +0 -1
  4. package/README.md +1 -0
  5. package/doc/Contribution.md +60 -1
  6. package/doc/advanced-topics.md +136 -14
  7. package/doc/api.md +38 -22
  8. package/doc/apiary/iotagent.apib +1 -3
  9. package/doc/architecture.md +2 -2
  10. package/doc/config-basic-example.js +0 -1
  11. package/doc/deprecated.md +2 -2
  12. package/doc/development.md +13 -6
  13. package/doc/expressionLanguage.md +519 -277
  14. package/doc/getting-started.md +0 -1
  15. package/doc/howto.md +13 -17
  16. package/doc/installationguide.md +67 -69
  17. package/doc/usermanual.md +48 -16
  18. package/docker/Mosquitto/Dockerfile +4 -9
  19. package/docker/Mosquitto/README.md +2 -0
  20. package/docker/Mosquitto/startMosquitto.sh +18 -1
  21. package/lib/command/commandLine.js +1 -1
  22. package/lib/commonConfig.js +5 -14
  23. package/lib/errors.js +0 -16
  24. package/lib/fiware-iotagent-lib.js +5 -0
  25. package/lib/jexlTranformsMap.js +71 -0
  26. package/lib/model/Command.js +1 -1
  27. package/lib/model/Device.js +5 -2
  28. package/lib/model/Group.js +20 -2
  29. package/lib/model/dbConn.js +7 -1
  30. package/lib/plugins/attributeAlias.js +6 -13
  31. package/lib/plugins/bidirectionalData.js +2 -27
  32. package/lib/plugins/expressionParser.js +41 -17
  33. package/lib/plugins/expressionPlugin.js +21 -27
  34. package/lib/plugins/jexlParser.js +71 -67
  35. package/lib/plugins/multiEntity.js +68 -147
  36. package/lib/plugins/pluginUtils.js +12 -48
  37. package/lib/plugins/timestampProcessPlugin.js +1 -46
  38. package/lib/request-shim.js +111 -0
  39. package/lib/services/common/domain.js +2 -2
  40. package/lib/services/common/genericMiddleware.js +6 -2
  41. package/lib/services/common/iotManagerService.js +1 -1
  42. package/lib/services/common/securityServiceKeystone.js +1 -1
  43. package/lib/services/common/securityServiceOAuth2.js +3 -2
  44. package/lib/services/devices/deviceRegistryMongoDB.js +29 -22
  45. package/lib/services/devices/deviceService.js +56 -33
  46. package/lib/services/devices/devices-NGSI-LD.js +42 -14
  47. package/lib/services/devices/devices-NGSI-mixed.js +3 -3
  48. package/lib/services/devices/devices-NGSI-v2.js +48 -24
  49. package/lib/services/devices/registrationUtils.js +1 -134
  50. package/lib/services/groups/groupRegistryMemory.js +2 -0
  51. package/lib/services/groups/groupRegistryMongoDB.js +58 -76
  52. package/lib/services/groups/groupService.js +1 -1
  53. package/lib/services/ngsi/entities-NGSI-LD.js +205 -124
  54. package/lib/services/ngsi/entities-NGSI-v2.js +142 -32
  55. package/lib/services/ngsi/ngsiService.js +4 -6
  56. package/lib/services/ngsi/ngsiUtils.js +0 -21
  57. package/lib/services/ngsi/subscription-NGSI-LD.js +14 -5
  58. package/lib/services/ngsi/subscriptionService.js +1 -4
  59. package/lib/services/northBound/contextServer-NGSI-LD.js +7 -2
  60. package/lib/services/northBound/contextServer-NGSI-v2.js +25 -13
  61. package/lib/services/northBound/contextServer.js +1 -4
  62. package/lib/services/northBound/contextServerUtils.js +0 -81
  63. package/lib/services/northBound/deviceProvisioningServer.js +36 -9
  64. package/lib/services/northBound/northboundServer.js +2 -0
  65. package/lib/services/northBound/restUtils.js +2 -39
  66. package/lib/templates/updateDevice.json +4 -0
  67. package/lib/templates/updateDeviceLax.json +4 -0
  68. package/package.json +13 -13
  69. package/test/tools/utils.js +2 -0
  70. package/test/unit/examples/deviceProvisioningRequests/provisionAnotherDevice.json +1 -1
  71. package/test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json +1 -1
  72. package/test/unit/examples/deviceProvisioningRequests/provisionDuplicatedDev.json +1 -1
  73. package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -1
  74. package/test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json +1 -1
  75. package/test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json +1 -1
  76. package/test/unit/examples/iotamRequests/registrationEmpty.json +1 -1
  77. package/test/unit/examples/iotamRequests/registrationWithGroups.json +2 -2
  78. package/test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json +2 -2
  79. package/test/unit/examples/iotamRequests/registrationWithStaticGroups.json +2 -2
  80. package/test/unit/expressions/jexlExpression-test.js +119 -0
  81. package/test/unit/general/config-multi-core-test.js +1 -1
  82. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +30 -77
  83. package/test/unit/general/deviceService-test.js +19 -35
  84. package/test/unit/general/loglevel-api_test.js +8 -13
  85. package/test/unit/general/migration-test.js +1 -0
  86. package/test/unit/general/startup-test.js +3 -2
  87. package/test/unit/general/statistics-persistence_test.js +2 -2
  88. package/test/unit/general/statistics-service_test.js +2 -2
  89. package/test/unit/lazyAndCommands/commandRegistry_test.js +18 -18
  90. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +16 -24
  91. package/test/unit/mongodb/mongodb-connectionoptions-test.js +2 -2
  92. package/test/unit/mongodb/mongodb-group-registry-test.js +11 -11
  93. package/test/unit/mongodb/mongodb-registry-test.js +55 -131
  94. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
  95. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
  96. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
  97. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
  98. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
  99. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
  100. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
  101. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
  102. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
  103. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateCommands1.json +1 -1
  104. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent1.json +1 -1
  105. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
  106. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
  107. package/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json +0 -7
  108. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json +0 -7
  109. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -7
  110. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -14
  111. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -14
  112. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json +1 -15
  113. package/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json +0 -7
  114. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +0 -7
  115. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast5.json +0 -7
  116. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin12a.json +7 -0
  117. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin13.json +13 -13
  118. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin16.json +0 -7
  119. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin17.json +0 -7
  120. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +18 -0
  121. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +18 -0
  122. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin31.json +15 -0
  123. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +17 -0
  124. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin33.json +18 -0
  125. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin34.json +17 -0
  126. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +36 -0
  127. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin5.json +0 -7
  128. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +16 -16
  129. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +18 -0
  130. package/test/unit/ngsi-ld/examples/contextRequests/updateContextGeoproperties3.json +0 -7
  131. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
  132. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +6 -6
  133. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +3 -3
  134. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -7
  135. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json +0 -7
  136. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionDeviceStatic.json +0 -7
  137. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionMinimumDevice.json +0 -7
  138. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +20 -17
  139. package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest.json +18 -15
  140. package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest2.json +18 -15
  141. package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +21 -21
  142. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1018 -0
  143. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -2
  144. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +24 -24
  145. package/test/unit/ngsi-ld/general/deviceService-test.js +7 -7
  146. package/test/unit/ngsi-ld/general/https-support-test.js +14 -13
  147. package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +8 -7
  148. package/test/unit/ngsi-ld/general/startup-test.js +2 -1
  149. package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +10 -8
  150. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +11 -12
  151. package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +25 -29
  152. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +16 -15
  153. package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +18 -17
  154. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +13 -12
  155. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +10 -9
  156. package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +3 -3
  157. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +25 -24
  158. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +13 -12
  159. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +27 -26
  160. package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +5 -5
  161. package/test/unit/ngsi-ld/plugins/event-plugin_test.js +3 -3
  162. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +75 -14
  163. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +3 -3
  164. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +54 -53
  165. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +20 -19
  166. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +23 -22
  167. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +58 -70
  168. package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +8 -7
  169. package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +19 -19
  170. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +18 -20
  171. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +43 -49
  172. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +16 -14
  173. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
  174. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
  175. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent3.json +19 -0
  176. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
  177. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent5.json +19 -0
  178. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
  179. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
  180. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
  181. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
  182. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
  183. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
  184. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateCommands1.json +3 -3
  185. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent1.json +3 -3
  186. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
  187. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
  188. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +17 -1
  189. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +5 -1
  190. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -2
  191. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json +6 -0
  192. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin16.json +14 -0
  193. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +14 -0
  194. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin18.json +6 -0
  195. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin19.json +6 -0
  196. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +13 -1
  197. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin20.json +6 -0
  198. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin21.json +6 -0
  199. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin22.json +6 -0
  200. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin23.json +6 -0
  201. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin24.json +6 -0
  202. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin25.json +6 -0
  203. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin26.json +6 -0
  204. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin27.json +6 -0
  205. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin28.json +6 -0
  206. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +22 -0
  207. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +5 -1
  208. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +6 -0
  209. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +18 -0
  210. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +16 -0
  211. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +22 -0
  212. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +12 -0
  213. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +12 -0
  214. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +5 -1
  215. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +5 -1
  216. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +5 -1
  217. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +17 -1
  218. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +5 -1
  219. package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware1.json +10 -0
  220. package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware2.json +10 -0
  221. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +2 -2
  222. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
  223. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +13 -0
  224. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +33 -0
  225. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +33 -0
  226. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +33 -0
  227. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
  228. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +25 -0
  229. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +2 -2
  230. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
  231. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
  232. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
  233. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
  234. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
  235. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +2 -2
  236. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
  237. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -8
  238. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +4 -4
  239. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
  240. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -2
  241. package/test/unit/ngsiv2/examples/contextRequests/updateProvisionDevice.json +20 -0
  242. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +1 -1
  243. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest.json +1 -1
  244. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest2.json +1 -1
  245. package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +93 -60
  246. package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +16 -16
  247. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +548 -164
  248. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +34 -33
  249. package/test/unit/ngsiv2/general/deviceService-test.js +15 -14
  250. package/test/unit/ngsiv2/general/https-support-test.js +14 -13
  251. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +8 -7
  252. package/test/unit/ngsiv2/general/startup-test.js +2 -1
  253. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +9 -7
  254. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +13 -12
  255. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +323 -51
  256. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +22 -20
  257. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +114 -26
  258. package/test/unit/ngsiv2/ngsiService/autocast-test.js +16 -16
  259. package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +39 -38
  260. package/test/unit/{ngsiService → ngsiv2/ngsiService}/queryDeviceInformationInCb-test.js +25 -54
  261. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +5 -5
  262. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +25 -24
  263. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +22 -22
  264. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +27 -26
  265. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +7 -7
  266. package/test/unit/ngsiv2/plugins/event-plugin_test.js +4 -4
  267. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +549 -24
  268. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +4 -4
  269. package/test/unit/{plugins → ngsiv2/plugins}/translation-inPlugins_test.js +25 -25
  270. package/test/unit/{provisioning → ngsiv2/provisioning}/device-group-api-test.js +44 -75
  271. package/test/unit/{provisioning/device-group-utils_test.js → ngsiv2/provisioning/device-group-utils-test.js} +15 -14
  272. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +74 -73
  273. package/test/unit/ngsiv2/provisioning/device-registration_test.js +20 -19
  274. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +30 -29
  275. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +58 -69
  276. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +8 -7
  277. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +19 -19
  278. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +18 -19
  279. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +49 -52
  280. package/test/unit/plugins/capture-configuration-inPlugins_test.js +6 -4
  281. package/test/unit/plugins/capture-provision-inPlugins_test.js +13 -23
  282. package/.nyc_output/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
  283. package/.nyc_output/processinfo/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
  284. package/.nyc_output/processinfo/index.json +0 -1
  285. package/lib/services/devices/devices-NGSI-v1.js +0 -293
  286. package/lib/services/devices/registrationUtils.js_avega +0 -589
  287. package/lib/services/ngsi/entities-NGSI-v1.js +0 -300
  288. package/lib/services/ngsi/subscription-NGSI-v1.js +0 -234
  289. package/lib/services/northBound/contextServer-NGSI-v1.js +0 -526
  290. package/lib/templates/notificationTemplateNgsi1.json +0 -75
  291. package/lib/templates/updateContextNgsi1.json +0 -50
  292. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json +0 -21
  293. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent2.json +0 -21
  294. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json +0 -25
  295. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent4.json +0 -22
  296. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentAttributeUpdates.json +0 -16
  297. package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +0 -21
  298. package/test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json +0 -21
  299. package/test/unit/examples/contextAvailabilityRequests/registerNewDevice2.json +0 -21
  300. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json +0 -25
  301. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +0 -21
  302. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +0 -33
  303. package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +0 -33
  304. package/test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json +0 -22
  305. package/test/unit/examples/contextAvailabilityRequests/unregisterDevice3.json +0 -26
  306. package/test/unit/examples/contextAvailabilityRequests/unregisterProvisionedDevice.json +0 -26
  307. package/test/unit/examples/contextAvailabilityRequests/updateCommands1.json +0 -22
  308. package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json +0 -22
  309. package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent2.json +0 -26
  310. package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent3.json +0 -22
  311. package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json +0 -8
  312. package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json +0 -4
  313. package/test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json +0 -4
  314. package/test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json +0 -4
  315. package/test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json +0 -4
  316. package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Failed.json +0 -8
  317. package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json +0 -4
  318. package/test/unit/examples/contextAvailabilityResponses/updateCommands1Success.json +0 -4
  319. package/test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json +0 -6
  320. package/test/unit/examples/contextProviderResponses/queryInformationResponse.json +0 -22
  321. package/test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json +0 -22
  322. package/test/unit/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json +0 -27
  323. package/test/unit/examples/contextProviderResponses/updateInformationResponse.json +0 -22
  324. package/test/unit/examples/contextProviderResponses/updateInformationResponse2.json +0 -22
  325. package/test/unit/examples/contextRequests/contextSubscriptionRequest.json +0 -20
  326. package/test/unit/examples/contextRequests/contextSubscriptionRequest2.json +0 -20
  327. package/test/unit/examples/contextRequests/createBidirectionalDevice.json +0 -17
  328. package/test/unit/examples/contextRequests/createDatetimeProvisionedDevice.json +0 -17
  329. package/test/unit/examples/contextRequests/createGeopointProvisionedDevice.json +0 -17
  330. package/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json +0 -17
  331. package/test/unit/examples/contextRequests/createProvisionedDevice.json +0 -32
  332. package/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -32
  333. package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json +0 -47
  334. package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -52
  335. package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -52
  336. package/test/unit/examples/contextRequests/createTimeinstantDevice.json +0 -17
  337. package/test/unit/examples/contextRequests/queryContext1.json +0 -13
  338. package/test/unit/examples/contextRequests/queryContext2.json +0 -13
  339. package/test/unit/examples/contextRequests/queryContextAliasPlugin1.json +0 -10
  340. package/test/unit/examples/contextRequests/queryContextCompressTimestamp1.json +0 -13
  341. package/test/unit/examples/contextRequests/updateActiveAttributes.json +0 -11
  342. package/test/unit/examples/contextRequests/updateContext1.json +0 -22
  343. package/test/unit/examples/contextRequests/updateContext2.json +0 -22
  344. package/test/unit/examples/contextRequests/updateContext3.json +0 -17
  345. package/test/unit/examples/contextRequests/updateContext3WithStatic.json +0 -22
  346. package/test/unit/examples/contextRequests/updateContext4.json +0 -22
  347. package/test/unit/examples/contextRequests/updateContext5.json +0 -19
  348. package/test/unit/examples/contextRequests/updateContextAliasPlugin.json +0 -22
  349. package/test/unit/examples/contextRequests/updateContextAliasPlugin2.json +0 -17
  350. package/test/unit/examples/contextRequests/updateContextAppendMode.json +0 -22
  351. package/test/unit/examples/contextRequests/updateContextCommandError.json +0 -22
  352. package/test/unit/examples/contextRequests/updateContextCommandExpired.json +0 -22
  353. package/test/unit/examples/contextRequests/updateContextCommandFinish.json +0 -22
  354. package/test/unit/examples/contextRequests/updateContextCommandStatus.json +0 -17
  355. package/test/unit/examples/contextRequests/updateContextCompressTimestamp1.json +0 -22
  356. package/test/unit/examples/contextRequests/updateContextCompressTimestamp2.json +0 -29
  357. package/test/unit/examples/contextRequests/updateContextExpressionPlugin1.json +0 -17
  358. package/test/unit/examples/contextRequests/updateContextExpressionPlugin2.json +0 -27
  359. package/test/unit/examples/contextRequests/updateContextExpressionPlugin3.json +0 -17
  360. package/test/unit/examples/contextRequests/updateContextExpressionPlugin4.json +0 -17
  361. package/test/unit/examples/contextRequests/updateContextExpressionPlugin5.json +0 -27
  362. package/test/unit/examples/contextRequests/updateContextMiddleware1.json +0 -22
  363. package/test/unit/examples/contextRequests/updateContextMultiEntityPlugin3.json +0 -35
  364. package/test/unit/examples/contextRequests/updateContextMultientityPlugin1.json +0 -30
  365. package/test/unit/examples/contextRequests/updateContextMultientityPlugin2.json +0 -30
  366. package/test/unit/examples/contextRequests/updateContextProcessTimestamp1.json +0 -29
  367. package/test/unit/examples/contextRequests/updateContextStaticAttributes.json +0 -22
  368. package/test/unit/examples/contextRequests/updateContextTimestamp.json +0 -41
  369. package/test/unit/examples/contextRequests/updateContextTimestampOverride.json +0 -22
  370. package/test/unit/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +0 -22
  371. package/test/unit/examples/contextRequests/updateContextTimestampTimezone.json +0 -41
  372. package/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -17
  373. package/test/unit/examples/contextRequests/updateProvisionCommands1.json +0 -27
  374. package/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json +0 -38
  375. package/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json +0 -17
  376. package/test/unit/examples/contextResponses/contextSubscriptionRequest2Success.json +0 -7
  377. package/test/unit/examples/contextResponses/contextSubscriptionRequestSuccess.json +0 -7
  378. package/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json +0 -22
  379. package/test/unit/examples/contextResponses/createDatetimeProvisionedDeviceSuccess.json +0 -22
  380. package/test/unit/examples/contextResponses/createGeopointProvisionedDeviceSuccess.json +0 -22
  381. package/test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json +0 -22
  382. package/test/unit/examples/contextResponses/createTimeinstantSuccess.json +0 -22
  383. package/test/unit/examples/contextResponses/queryContext1Success.json +0 -27
  384. package/test/unit/examples/contextResponses/queryContext2Error.json +0 -7
  385. package/test/unit/examples/contextResponses/queryContext2UnknownError.json +0 -6
  386. package/test/unit/examples/contextResponses/queryContext3Error.json +0 -34
  387. package/test/unit/examples/contextResponses/queryContextAliasPlugin1Success.json +0 -27
  388. package/test/unit/examples/contextResponses/queryContextCompressTimestamp1Success.json +0 -27
  389. package/test/unit/examples/contextResponses/updateActiveAttributesSuccess.json +0 -16
  390. package/test/unit/examples/contextResponses/updateContext1Failed.json +0 -7
  391. package/test/unit/examples/contextResponses/updateContext1Success.json +0 -27
  392. package/test/unit/examples/contextResponses/updateContext2Failed.json +0 -35
  393. package/test/unit/examples/contextResponses/updateContextAliasPlugin2Success.json +0 -27
  394. package/test/unit/examples/contextResponses/updateContextAliasPluginSuccess.json +0 -27
  395. package/test/unit/examples/contextResponses/updateContextCommandFinishSuccess.json +0 -27
  396. package/test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json +0 -22
  397. package/test/unit/examples/contextResponses/updateContextCompressTimestamp1Success.json +0 -27
  398. package/test/unit/examples/contextResponses/updateContextCompressTimestamp2Success.json +0 -34
  399. package/test/unit/examples/contextResponses/updateContextEvents1Success.json +0 -27
  400. package/test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json +0 -22
  401. package/test/unit/examples/contextResponses/updateContextExpressionPlugin2Success.json +0 -22
  402. package/test/unit/examples/contextResponses/updateContextExpressionPlugin3Success.json +0 -22
  403. package/test/unit/examples/contextResponses/updateContextExpressionPlugin5Success.json +0 -32
  404. package/test/unit/examples/contextResponses/updateContextMultientityPlugin1Success.json +0 -40
  405. package/test/unit/examples/contextResponses/updateContextMultientityPlugin2Success.json +0 -40
  406. package/test/unit/examples/contextResponses/updateContextMultientityPlugin3Success.json +0 -40
  407. package/test/unit/examples/contextResponses/updateContextProcessTimestamp1Success.json +0 -27
  408. package/test/unit/examples/contextResponses/updateProvisionActiveAttributes1Success.json +0 -22
  409. package/test/unit/examples/contextResponses/updateProvisionCommands1Success.json +0 -32
  410. package/test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json +0 -22
  411. package/test/unit/examples/subscriptionRequests/bidirectionalNotification.json +0 -24
  412. package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRemove.json +0 -3
  413. package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -22
  414. package/test/unit/examples/subscriptionRequests/errorNotification.json +0 -24
  415. package/test/unit/examples/subscriptionRequests/simpleNotification.json +0 -24
  416. package/test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json +0 -3
  417. package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json +0 -19
  418. package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json +0 -19
  419. package/test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json +0 -6
  420. package/test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json +0 -6
  421. package/test/unit/expressions/expressionBasedTransformations-test.js +0 -328
  422. package/test/unit/expressions/expressionCombinedTransformations-test.js +0 -306
  423. package/test/unit/expressions/jexlBasedTransformations-test.js +0 -334
  424. package/test/unit/general/contextBrokerOAuthSecurityAccess-test.js +0 -902
  425. package/test/unit/general/https-support-test.js +0 -286
  426. package/test/unit/general/iotam-autoregistration-test.js +0 -368
  427. package/test/unit/lazyAndCommands/active-devices-attribute-update-test.js +0 -168
  428. package/test/unit/lazyAndCommands/command-test.js +0 -341
  429. package/test/unit/lazyAndCommands/lazy-devices-test.js +0 -878
  430. package/test/unit/lazyAndCommands/polling-commands-test.js +0 -421
  431. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin20.json +0 -25
  432. package/test/unit/ngsiService/active-devices-test.js +0 -692
  433. package/test/unit/ngsiService/staticAttributes-test.js +0 -148
  434. package/test/unit/ngsiService/subscriptions-test.js +0 -345
  435. package/test/unit/plugins/alias-plugin_test.js +0 -158
  436. package/test/unit/plugins/bidirectional-plugin_test.js +0 -564
  437. package/test/unit/plugins/compress-timestamp-plugin_test.js +0 -257
  438. package/test/unit/plugins/event-plugin_test.js +0 -119
  439. package/test/unit/plugins/multientity-plugin_test.js +0 -248
  440. package/test/unit/plugins/timestamp-processing-plugin_test.js +0 -119
  441. package/test/unit/provisioning/device-provisioning-api_test.js +0 -748
  442. package/test/unit/provisioning/device-registration_test.js +0 -432
  443. package/test/unit/provisioning/device-update-registration_test.js +0 -326
  444. package/test/unit/provisioning/listProvisionedDevices-test.js +0 -488
  445. package/test/unit/provisioning/provisionDeviceMultientity-test.js +0 -123
  446. package/test/unit/provisioning/removeProvisionedDevice-test.js +0 -244
  447. package/test/unit/provisioning/singleConfigurationMode-test.js +0 -346
  448. package/test/unit/provisioning/updateProvisionedDevices-test.js +0 -436
@@ -25,7 +25,6 @@ config = {
25
25
  service: "openiot",
26
26
  subservice: "/",
27
27
  providerUrl: "http://iot-agent:4041",
28
- deviceRegistrationDuration: "P1M",
29
28
  defaultType: "Thing",
30
29
  };
31
30
  ```
package/doc/howto.md CHANGED
@@ -315,8 +315,8 @@ var iotAgentLib = require("iotagent-node-lib"),
315
315
  #### QueryContext implementation
316
316
 
317
317
  The main step to complete in order to implement the Lazy attributes mechanism in the IoT Agent is to provide handlers
318
- for the context provisioning requests. At this point, we should provide two handlers: the `updateContext` and the
319
- `queryContext` handlers. To do so, we must first define the handlers themselves:
318
+ for the context provisioning requests. At this point, we should provide two handlers: the `/v2/op/update` and the
319
+ `/v2/op/query` handlers. To do so, we must first define the handlers themselves:
320
320
 
321
321
  ```javascript
322
322
  function queryContextHandler(id, type, service, subservice, attributes, callback) {
@@ -338,7 +338,7 @@ function queryContextHandler(id, type, service, subservice, attributes, callback
338
338
  }
339
339
  ```
340
340
 
341
- The `queryContext` handler is called whenever a `queryContext` request arrives at the North port of the IoT Agent. It is
341
+ The queryContext handler is called whenever a `/v2/op/query` request arrives at the North port of the IoT Agent. It is
342
342
  invoked once for each entity requested, passing the entity ID and Type as the parameters, as well as a list of the
343
343
  attributes that are requested. In our case, the handler uses this parameters to compose a request to the device. Once
344
344
  the results of the device are returned, the values are returned to the caller, in the NGSI attribute format.
@@ -395,7 +395,7 @@ function updateContextHandler(id, type, service, subservice, attributes, callbac
395
395
  }
396
396
  ```
397
397
 
398
- The updateContext handler deals with the modification requests that arrive at the North Port of the IoT Agent. It is
398
+ The updateContext handler deals with the modification requests that arrive at the North Port of the IoT Agent via `/v2/op/update`. It is
399
399
  invoked once for each entity requested (note that a single request can contain multiple entity updates), with the same
400
400
  parameters used in the queryContext handler. The only difference is the value of the attributes array, now containing a
401
401
  list of attribute objects, each containing name, type and value. The handler must also make use of the callback to
@@ -491,35 +491,31 @@ Postman-Token: 993ac66b-72da-9e96-ab46-779677a5896a
491
491
  }
492
492
  ```
493
493
 
494
- 2. Execute a queryContext or updateContext against one of the entity attributes (use a NGSI client of curl command).
494
+ 2. Execute a `/v2/op/query` or `/v2/op/update` against one of the entity attributes (use a NGSI client of curl command).
495
495
 
496
496
  ```text
497
- POST /v1/queryContext HTTP/1.1
497
+ POST /v2/op/query HTTP/1.1
498
498
  Host: localhost:1026
499
499
  Content-Type: application/json
500
500
  Accept: application/json
501
501
  Fiware-Service: howtoserv
502
502
  Fiware-ServicePath: /test
503
503
  Cache-Control: no-cache
504
- Postman-Token: 1dc568a1-5588-059c-fa9b-ff217a7d7aa2
505
504
 
506
505
  {
507
- "entities": [
508
- {
509
- "isPattern": "true",
510
- "id": ".*",
511
- "type": "BasicULSensor"
512
- }
513
- ],
514
- "attributes" : [
515
- "l"]
506
+ entities: [
507
+ {
508
+ id: 'Light:light1'
509
+ }
510
+ ],
511
+ attrs: ['dimming']
516
512
  }
517
513
  ```
518
514
 
519
515
  3. Check the received request in the nc console is the expected one.
520
516
 
521
517
  4. (In case you use netcat). Answer the request with an appropriate HTTP response and check the result of the
522
- `queryContext` or `updateContext` request is the expected one. An example of HTTP response, for a query to the `t`
518
+ `/v2/op/query` or `/v2/op/update` request is the expected one. An example of HTTP response, for a query to the `t`
523
519
  and `l` attributes would be:
524
520
 
525
521
  ```text
@@ -56,9 +56,10 @@ allowing the computer to interpret the rest of the data with more clarity and de
56
56
  }
57
57
  ```
58
58
 
59
- Under mixed mode, **NGSI v2** payloads are used for context broker communications by default, but this payload may also be switched
60
- to **NGSI LD** at service group or device provisioning time using the `ngsiVersion` field in the provisioning API.
61
- The `ngsiVersion` field switch may be added at either group or device level, with the device level overriding the group setting.
59
+ Under mixed mode, **NGSI v2** payloads are used for context broker communications by default, but this payload may also
60
+ be switched to **NGSI LD** at service group or device provisioning time using the `ngsiVersion` field in the
61
+ provisioning API. The `ngsiVersion` field switch may be added at either group or device level, with the device level
62
+ overriding the group setting.
62
63
 
63
64
  - **server**: configuration used to create the Context Server (port where the IoT Agent will be listening as a Context
64
65
  Provider and base root to prefix all the paths). The `port` attribute is required. If no `baseRoot` attribute is
@@ -159,7 +160,7 @@ used for the same purpose. For instance:
159
160
 
160
161
  ```javascript
161
162
  {
162
- type: "mongodb";
163
+ type: 'mongodb';
163
164
  }
164
165
  ```
165
166
 
@@ -230,10 +231,6 @@ used for the same purpose. For instance:
230
231
  - **providerUrl**: URL to send in the Context Provider registration requests. Should represent the external IP of the
231
232
  deployed IoT Agent (the IP where the Context Broker will redirect the NGSI requests). E.g.:
232
233
  'http://192.168.56.1:4041'.
233
- - **deviceRegistrationDuration**: duration of the registrations as Context Providers and the subscriptions done by
234
- bidirectional plugin, in [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601) standard format. E.g.: 'P1M'. Only used
235
- if agent is configured in NGSI v1 mode. In NGSI v2 mode the setting is ignored (registrations and subscriptions are
236
- non-expirable and the IOTA manages its removal explicitely).
237
234
  - **iotaVersion**: indicates the version of the IoTA that will be displayed in the about method (it should be filled
238
235
  automatically by each IoTA).
239
236
  - **appendMode**: if this flag is activated, the update requests to the Context Broker will be performed always with
@@ -245,8 +242,8 @@ used for the same purpose. For instance:
245
242
  - **singleConfigurationMode**: enables the Single Configuration mode for backwards compatibility (see description in
246
243
  the Overview). Default to false.
247
244
  - **timestamp**: if this flag is activated:
248
- - For NGSIv1/NGSIv2, the IoT Agent will add a `TimeInstant` metadata attribute to all the attributes updated from
249
- device information. This flag is overwritten by `timestamp` flag in group or device
245
+ - For NGSI-v2, the IoT Agent will add a `TimeInstant` metadata attribute to all the attributes updated from device
246
+ information. This flag is overwritten by `timestamp` flag in group or device
250
247
  - With NGSI-LD, the standard `observedAt` property-of-a-property is created instead.
251
248
  - **defaultResource**: default string to use as resource for the registration of new Configurations (if no resource is
252
249
  provided).
@@ -277,10 +274,11 @@ used for the same purpose. For instance:
277
274
  NGSILD-Path has not yet been included in the NGSI-LD standard (it has been proposed for the next update of the
278
275
  standard, but the final decision has yet been confirmed), take into account it could change
279
276
  - **explicitAttrs**: if this flag is activated, only provisioned attributes will be processed to Context Broker. This
280
- flag is overwritten by `explicitAttrs` flag in group or device provision.
281
- - **defaultEntityNameConjunction**: the default conjunction string used to compose a default `entity_name` when is not
282
- provided at device provisioning time; in that case `entity_name` is composed by `type` + `:` + `device_id`.
283
- Default value is `:`. This value is overwritten by `defaultEntityNameConjunction` in group provision.
277
+ flag is overwritten by `explicitAttrs` flag in group or device provision. Additionally `explicitAttrs` can be used
278
+ to define which meassures defined in JSON/JEXL array will be propagated to NGSI interface.
279
+ - **defaultEntityNameConjunction**: the default conjunction string used to compose a default `entity_name` when is not
280
+ provided at device provisioning time; in that case `entity_name` is composed by `type` + `:` + `device_id`. Default
281
+ value is `:`. This value is overwritten by `defaultEntityNameConjunction` in group provision.
284
282
  - **relaxTemplateValidation**: if this flag is activated, `objectId` attributes for incoming devices are not
285
283
  validated, and may exceptionally include characters (such as semi-colons) which are
286
284
  [forbidden](https://fiware-orion.readthedocs.io/en/master/user/forbidden_characters/index.html) according to the
@@ -295,61 +293,61 @@ with container-based technologies, like Docker, Heroku, etc...
295
293
  The following table shows the accepted environment variables, as well as the configuration parameter the variable
296
294
  overrides.
297
295
 
298
- | Environment variable | Configuration attribute |
299
- | :------------------------------- | :------------------------------ |
300
- | IOTA_CB_URL | `contextBroker.url` |
301
- | IOTA_CB_HOST | `contextBroker.host` |
302
- | IOTA_CB_PORT | `contextBroker.port` |
303
- | IOTA_CB_NGSI_VERSION | `contextBroker.ngsiVersion` |
304
- | IOTA_NORTH_HOST | `server.host` |
305
- | IOTA_NORTH_PORT | `server.port` |
306
- | IOTA_PROVIDER_URL | `providerUrl` |
307
- | IOTA_AUTH_ENABLED | `authentication.enabled` |
308
- | IOTA_AUTH_TYPE | `authentication.type` |
309
- | IOTA_AUTH_HEADER | `authentication.header` |
310
- | IOTA_AUTH_URL | `authentication.url` |
311
- | IOTA_AUTH_HOST | `authentication.host` |
312
- | IOTA_AUTH_PORT | `authentication.port` |
313
- | IOTA_AUTH_USER | `authentication.user` |
314
- | IOTA_AUTH_PASSWORD | `authentication.password` |
315
- | IOTA_AUTH_CLIENT_ID | `authentication.clientId` |
316
- | IOTA_AUTH_CLIENT_SECRET | `authentication.clientSecret` |
317
- | IOTA_AUTH_TOKEN_PATH | `authentication.tokenPath` |
318
- | IOTA_AUTH_PERMANENT_TOKEN | `authentication.permanentToken` |
319
- | IOTA_REGISTRY_TYPE | `deviceRegistry.type` |
320
- | IOTA_LOG_LEVEL | `logLevel` |
321
- | IOTA_TIMESTAMP | `timestamp` |
322
- | IOTA_IOTAM_URL | `iotManager.url` |
323
- | IOTA_IOTAM_HOST | `iotManager.host` |
324
- | IOTA_IOTAM_PORT | `iotManager.port` |
325
- | IOTA_IOTAM_PATH | `iotManager.path` |
326
- | IOTA_IOTAM_AGENTPATH | `iotManager.agentPath` |
327
- | IOTA_IOTAM_PROTOCOL | `iotManager.protocol` |
328
- | IOTA_IOTAM_DESCRIPTION | `iotManager.description` |
329
- | IOTA_MONGO_HOST | `mongodb.host` |
330
- | IOTA_MONGO_PORT | `mongodb.port` |
331
- | IOTA_MONGO_DB | `mongodb.db` |
332
- | IOTA_MONGO_REPLICASET | `mongodb.replicaSet` |
333
- | IOTA_MONGO_USER | `mongodb.user` |
334
- | IOTA_MONGO_PASSWORD | `mongodb.password` |
335
- | IOTA_MONGO_AUTH_SOURCE | `mongodb.authSource` |
336
- | IOTA_MONGO_RETRIES | `mongodb.retries` |
337
- | IOTA_MONGO_RETRY_TIME | `mongodb.retryTime` |
338
- | IOTA_MONGO_SSL | `mongodb.ssl` |
339
- | IOTA_MONGO_EXTRAARGS | `mongodb.extraArgs` |
340
- | IOTA_SINGLE_MODE | `singleConfigurationMode` |
341
- | IOTA_APPEND_MODE | `appendMode` |
342
- | IOTA_POLLING_EXPIRATION | `pollingExpiration` |
343
- | IOTA_POLLING_DAEMON_FREQ | `pollingDaemonFrequency` |
344
- | IOTA_AUTOCAST | `autocast` |
345
- | IOTA_MULTI_CORE | `multiCore` |
346
- | IOTA_JSON_LD_CONTEXT | `jsonLdContext` |
347
- | IOTA_FALLBACK_TENANT | `fallbackTenant` |
348
- | IOTA_FALLBACK_PATH | `fallbackPath` |
349
- | IOTA_DEFAULT_EXPRESSION_LANGUAGE | `defaultExpressionLanguage` |
350
- | IOTA_EXPLICIT_ATTRS | `explicitAttrs` |
351
- | IOTA_DEFAULT_ENTITY_NAME_CONJUNCTION | `defaultEntityNameConjunction` |
352
- | IOTA_RELAX_TEMPLATE_VALIDATION | `relaxTemplateValidation` |
296
+ | Environment variable | Configuration attribute |
297
+ | :----------------------------------- | :------------------------------ |
298
+ | IOTA_CB_URL | `contextBroker.url` |
299
+ | IOTA_CB_HOST | `contextBroker.host` |
300
+ | IOTA_CB_PORT | `contextBroker.port` |
301
+ | IOTA_CB_NGSI_VERSION | `contextBroker.ngsiVersion` |
302
+ | IOTA_NORTH_HOST | `server.host` |
303
+ | IOTA_NORTH_PORT | `server.port` |
304
+ | IOTA_PROVIDER_URL | `providerUrl` |
305
+ | IOTA_AUTH_ENABLED | `authentication.enabled` |
306
+ | IOTA_AUTH_TYPE | `authentication.type` |
307
+ | IOTA_AUTH_HEADER | `authentication.header` |
308
+ | IOTA_AUTH_URL | `authentication.url` |
309
+ | IOTA_AUTH_HOST | `authentication.host` |
310
+ | IOTA_AUTH_PORT | `authentication.port` |
311
+ | IOTA_AUTH_USER | `authentication.user` |
312
+ | IOTA_AUTH_PASSWORD | `authentication.password` |
313
+ | IOTA_AUTH_CLIENT_ID | `authentication.clientId` |
314
+ | IOTA_AUTH_CLIENT_SECRET | `authentication.clientSecret` |
315
+ | IOTA_AUTH_TOKEN_PATH | `authentication.tokenPath` |
316
+ | IOTA_AUTH_PERMANENT_TOKEN | `authentication.permanentToken` |
317
+ | IOTA_REGISTRY_TYPE | `deviceRegistry.type` |
318
+ | IOTA_LOG_LEVEL | `logLevel` |
319
+ | IOTA_TIMESTAMP | `timestamp` |
320
+ | IOTA_IOTAM_URL | `iotManager.url` |
321
+ | IOTA_IOTAM_HOST | `iotManager.host` |
322
+ | IOTA_IOTAM_PORT | `iotManager.port` |
323
+ | IOTA_IOTAM_PATH | `iotManager.path` |
324
+ | IOTA_IOTAM_AGENTPATH | `iotManager.agentPath` |
325
+ | IOTA_IOTAM_PROTOCOL | `iotManager.protocol` |
326
+ | IOTA_IOTAM_DESCRIPTION | `iotManager.description` |
327
+ | IOTA_MONGO_HOST | `mongodb.host` |
328
+ | IOTA_MONGO_PORT | `mongodb.port` |
329
+ | IOTA_MONGO_DB | `mongodb.db` |
330
+ | IOTA_MONGO_REPLICASET | `mongodb.replicaSet` |
331
+ | IOTA_MONGO_USER | `mongodb.user` |
332
+ | IOTA_MONGO_PASSWORD | `mongodb.password` |
333
+ | IOTA_MONGO_AUTH_SOURCE | `mongodb.authSource` |
334
+ | IOTA_MONGO_RETRIES | `mongodb.retries` |
335
+ | IOTA_MONGO_RETRY_TIME | `mongodb.retryTime` |
336
+ | IOTA_MONGO_SSL | `mongodb.ssl` |
337
+ | IOTA_MONGO_EXTRAARGS | `mongodb.extraArgs` |
338
+ | IOTA_SINGLE_MODE | `singleConfigurationMode` |
339
+ | IOTA_APPEND_MODE | `appendMode` |
340
+ | IOTA_POLLING_EXPIRATION | `pollingExpiration` |
341
+ | IOTA_POLLING_DAEMON_FREQ | `pollingDaemonFrequency` |
342
+ | IOTA_AUTOCAST | `autocast` |
343
+ | IOTA_MULTI_CORE | `multiCore` |
344
+ | IOTA_JSON_LD_CONTEXT | `jsonLdContext` |
345
+ | IOTA_FALLBACK_TENANT | `fallbackTenant` |
346
+ | IOTA_FALLBACK_PATH | `fallbackPath` |
347
+ | IOTA_DEFAULT_EXPRESSION_LANGUAGE | `defaultExpressionLanguage` |
348
+ | IOTA_EXPLICIT_ATTRS | `explicitAttrs` |
349
+ | IOTA_DEFAULT_ENTITY_NAME_CONJUNCTION | `defaultEntityNameConjunction` |
350
+ | IOTA_RELAX_TEMPLATE_VALIDATION | `relaxTemplateValidation` |
353
351
 
354
352
  Note:
355
353
 
package/doc/usermanual.md CHANGED
@@ -25,7 +25,7 @@ More values will be added in the future to the library. The applications using t
25
25
  Registry just by using the following function:
26
26
 
27
27
  ```javascript
28
- iotagentLib.statsRegistry.add("statName", statIncrementalValue, callback);
28
+ iotagentLib.statsRegistry.add('statName', statIncrementalValue, callback);
29
29
  ```
30
30
 
31
31
  The first time this function is invoked, it will add the new stat to the registry. Subsequent calls will add the value
@@ -80,7 +80,7 @@ In order to use the library, add the following dependency to your package.json f
80
80
  In order to use this library, first you must require it:
81
81
 
82
82
  ```javascript
83
- var iotagentLib = require("iotagent-node-lib");
83
+ var iotagentLib = require('iotagent-node-lib');
84
84
  ```
85
85
 
86
86
  The library supports four groups of features, one for each direction of the communication: client-to-server and
@@ -265,16 +265,16 @@ Once all the updates have taken place, the callback must be invoked with the upd
265
265
 
266
266
  ```javascript
267
267
  callback(null, {
268
- type: "TheType",
268
+ type: 'TheType',
269
269
  isPattern: false,
270
- id: "EntityID",
270
+ id: 'EntityID',
271
271
  attributes: [
272
272
  {
273
- name: "lumniscence",
274
- type: "Lumens",
275
- value: "432",
276
- },
277
- ],
273
+ name: 'lumniscence',
274
+ type: 'Lumens',
275
+ value: '432'
276
+ }
277
+ ]
278
278
  });
279
279
  ```
280
280
 
@@ -303,16 +303,16 @@ The callback must be invoked with the updated Context Element, using the informa
303
303
 
304
304
  ```javascript
305
305
  callback(null, {
306
- type: "TheType",
306
+ type: 'TheType',
307
307
  isPattern: false,
308
- id: "EntityID",
308
+ id: 'EntityID',
309
309
  attributes: [
310
310
  {
311
- name: "lumniscence",
312
- type: "Lumens",
313
- value: "432",
314
- },
315
- ],
311
+ name: 'lumniscence',
312
+ type: 'Lumens',
313
+ value: '432'
314
+ }
315
+ ]
316
316
  });
317
317
  ```
318
318
 
@@ -686,6 +686,38 @@ unexpectedly dead, a new process is created automatically to keep always the max
686
686
  - iotAgent: The IoT Agent Objects, used to start the agent.
687
687
  - callback: The callback function.
688
688
 
689
+ ##### iotagentLib.request()
690
+
691
+ ###### Signature
692
+
693
+ ```javascript
694
+ function request(options, callback)
695
+ ```
696
+
697
+ ###### Description
698
+
699
+ Make a direct HTTP request using the underlying request library (currently [got](https://github.com/sindresorhus/got)),
700
+ this is useful when creating agents which use an HTTP transport for their southbound commands, and removes the need for
701
+ the custom IoT Agent to import its own additional request library
702
+
703
+ ###### Params
704
+
705
+ - options: definition of the request (see
706
+ [got options](https://github.com/sindresorhus/got/blob/main/documentation/2-options.md) for more details). The
707
+ following attributes are currently exposed.
708
+ - `method` - HTTP Method
709
+ - `searchParams` - query string params
710
+ - `qs` - alias for query string params
711
+ - `headers`
712
+ - `responseType` - either `text` or `json`. `json` is the default
713
+ - `json` - a supplied JSON object as the request body
714
+ - `body` - any ASCII text as the request body. It takes precedence over `json` if both are provided at the same
715
+ time (not recommended).
716
+ - `url` - the request URL
717
+ - `uri` - alternative alias for the request URL.
718
+ - callback: The callback currently returns an `error` Object, the `response` and `body`. The `body` is parsed to a
719
+ JSON object if the `responseType` is JSON.
720
+
689
721
  #### Generic middlewares
690
722
 
691
723
  This collection of utility middlewares is aimed to be used to north of the IoT Agent Library, as well as in other
@@ -3,24 +3,19 @@ FROM centos:7.9.2009
3
3
  COPY aclfile /root/
4
4
  COPY startMosquitto.sh /bin
5
5
 
6
+ ENV CONGIF_FROM_ENV true
7
+
6
8
  RUN yum update -y && yum install -y wget \
7
9
  && yum install -y epel-release \
8
10
  && yum update -y epel-release \
9
11
  && yum install -y mosquitto \
12
+ && cp /etc/mosquitto/mosquitto.conf /etc/mosquitto/mosquitto.conf.orig \
10
13
  && chmod 755 /bin/startMosquitto.sh \
11
14
  && mkdir /var/log/mosquitto \
12
15
  && chown mosquitto:mosquitto /var/log/mosquitto \
13
- && touch /etc/mosquitto/pwfile \
14
- && sed -i '$ i acl_file /etc/mosquitto/aclfile\npassword_file /etc/mosquitto/pwfile' /etc/mosquitto/mosquitto.conf \
15
- && echo "log_timestamp true" >> /etc/mosquitto/mosquitto.conf \
16
- && echo "log_timestamp_format %Y-%m-%dT%H:%M:%S" >> /etc/mosquitto/mosquitto.conf \
17
- && echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf \
18
- && echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf \
19
- && echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf \
20
- && echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf \
21
- && mv /root/aclfile /etc/mosquitto/aclfile \
22
16
  && yum clean all
23
17
 
18
+
24
19
  EXPOSE 1883
25
20
  EXPOSE 9001
26
21
 
@@ -2,6 +2,8 @@ Thi directory containts the Dockerfile (and associated files) for a container of
2
2
  This container is provide as a help for users to test with MQTT, but it is just an auxiliary material in this repository.
3
3
 
4
4
  The following releases matches with eclipse-mosquitto version:
5
+ - 1.6.0 uses mosquitto-1.6.10-1.el7.x86_64
6
+ - 1.5.0 uses mosquitto-1.6.10-1.el7.x86_64
5
7
  - 1.4.0 uses mosquitto-1.6.10-1.el7.x86_64
6
8
  - 1.3.0 uses mosquitto-1.6.8-1.el7.x86_64
7
9
  - 1.2.0 uses mosquitto-1.6.7-1.el7.x86_64
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- mosquitto_passwd -b /etc/mosquitto/pwfile iota ${IOTA_PASS}
3
+ if [ "${CONGIF_FROM_ENV}" = true ] ; then
4
+ cp /etc/mosquitto/mosquitto.conf.orig /etc/mosquitto/mosquitto.conf
5
+ echo "log_timestamp true" >> /etc/mosquitto/mosquitto.conf
6
+ echo "log_timestamp_format %Y-%m-%dT%H:%M:%S" >> /etc/mosquitto/mosquitto.conf
7
+ echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf
8
+ echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf
9
+ echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf
10
+ echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf
11
+ if ! [ -z "${IOTA_PASS}" ] ; then
12
+ # Only if IOTA_PASS is set and not empty MQTT user/pass authentication is used
13
+ touch /etc/mosquitto/pwfile
14
+ sed -i '$ i acl_file /etc/mosquitto/aclfile\npassword_file /etc/mosquitto/pwfile' /etc/mosquitto/mosquitto.conf
15
+ cp -f /root/aclfile /etc/mosquitto/aclfile
16
+ sed -i 's/user iota/user '${IOTA_USER}'/g' /etc/mosquitto/aclfile
17
+ mosquitto_passwd -b /etc/mosquitto/pwfile ${IOTA_USER} ${IOTA_PASS}
18
+ fi
19
+ fi
20
+
4
21
  /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
@@ -25,7 +25,7 @@ const fs = require('fs');
25
25
  const clUtils = require('command-shell-lib');
26
26
  const migrationLib = require('./migration');
27
27
  const constants = require('../constants');
28
- const request = require('request');
28
+ const request = require('../request-shim');
29
29
  const async = require('async');
30
30
  const mu = require('mu2');
31
31
  let config;
@@ -243,6 +243,10 @@ function processEnvironmentVariables() {
243
243
  config.contextBroker.jsonLdContext = process.env.IOTA_JSON_LD_CONTEXT.split(',').map((ctx) => ctx.trim());
244
244
  }
245
245
 
246
+ if (Array.isArray(config.contextBroker.jsonLdContext) && config.contextBroker.jsonLdContext.length === 1){
247
+ config.contextBroker.jsonLdContext = config.contextBroker.jsonLdContext[0];
248
+ }
249
+
246
250
  config.contextBroker.fallbackTenant =
247
251
  process.env.IOTA_FALLBACK_TENANT || config.contextBroker.service || 'iotagent';
248
252
  config.contextBroker.fallbackPath = process.env.IOTA_FALLBACK_PATH || config.contextBroker.subservice || '/';
@@ -521,19 +525,7 @@ function ngsiVersion() {
521
525
  return 'unknown';
522
526
  }
523
527
 
524
- /**
525
- * It checks if the configuration file states a non-legacy format,
526
- * either v2, LD or mixed.
527
- *
528
- * @return {boolean} Result of the checking
529
- */
530
- function isCurrentNgsi() {
531
- if (config.contextBroker && config.contextBroker.ngsiVersion) {
532
- const version = config.contextBroker.ngsiVersion.toLowerCase();
533
- return version === 'v2' || version === 'ld' || version === 'mixed';
534
- }
535
- return false;
536
- }
528
+
537
529
  /**
538
530
  * It checks if a combination of typeInformation or common Config is LD
539
531
  *
@@ -562,7 +554,6 @@ exports.setCommandRegistry = setCommandRegistry;
562
554
  exports.getCommandRegistry = getCommandRegistry;
563
555
  exports.ngsiVersion = ngsiVersion;
564
556
  exports.checkNgsiLD = checkNgsiLD;
565
- exports.isCurrentNgsi = isCurrentNgsi;
566
557
  exports.setSecurityService = setSecurityService;
567
558
  exports.getSecurityService = getSecurityService;
568
559
  exports.getSecretData = getSecretData;
package/lib/errors.js CHANGED
@@ -96,13 +96,6 @@ class DeviceNotFound {
96
96
  this.code = 404;
97
97
  }
98
98
  }
99
- class AttributeNotFound {
100
- constructor() {
101
- this.name = 'ATTRIBUTE_NOT_FOUND';
102
- this.message = 'Some of the attributes does not exist';
103
- this.code = 404;
104
- }
105
- }
106
99
  class DuplicateDeviceId {
107
100
  constructor(id) {
108
101
  this.name = 'DUPLICATE_DEVICE_ID';
@@ -190,13 +183,6 @@ class MissingConfigParams {
190
183
  this.code = 400;
191
184
  }
192
185
  }
193
- class NotificationError {
194
- constructor(code) {
195
- this.name = 'NOTIFICATION_ERROR';
196
- this.message = 'Incoming notification with non-200 status code: ' + code;
197
- this.code = 400;
198
- }
199
- }
200
186
  class DeviceGroupNotFound {
201
187
  constructor(fields, values) {
202
188
  this.name = 'DEVICE_GROUP_NOT_FOUND';
@@ -269,7 +255,6 @@ module.exports = {
269
255
  TypeNotFound,
270
256
  MissingAttributes,
271
257
  DeviceNotFound,
272
- AttributeNotFound,
273
258
  DuplicateDeviceId,
274
259
  DuplicateGroup,
275
260
  SecurityInformationMissing,
@@ -282,7 +267,6 @@ module.exports = {
282
267
  WrongSyntax,
283
268
  CommandNotFound,
284
269
  MissingConfigParams,
285
- NotificationError,
286
270
  DeviceGroupNotFound,
287
271
  GroupNotFound,
288
272
  WrongExpressionType,
@@ -37,6 +37,7 @@ const iotManager = require('./services/common/iotManagerService');
37
37
  const contextServer = require('./services/northBound/northboundServer');
38
38
  const errors = require('./errors');
39
39
  const constants = require('./constants');
40
+ const request = require('./request-shim');
40
41
  const logger = require('logops');
41
42
  const config = require('./commonConfig');
42
43
  const cluster = require('cluster');
@@ -317,6 +318,7 @@ exports.getDevicesByAttribute = deviceService.getDevicesByAttribute;
317
318
  exports.mergeDeviceWithConfiguration = deviceService.mergeDeviceWithConfiguration;
318
319
  exports.retrieveDevice = deviceService.retrieveDevice;
319
320
  exports.getConfiguration = groupConfig.get;
321
+ exports.getConfigurationSilently = groupConfig.getSilently;
320
322
  exports.findConfiguration = groupConfig.find;
321
323
  exports.setDataUpdateHandler = contextServer.setUpdateHandler;
322
324
  exports.setCommandHandler = contextServer.setCommandHandler;
@@ -324,6 +326,7 @@ exports.setDataQueryHandler = contextServer.setQueryHandler;
324
326
  exports.setConfigurationHandler = contextServer.setConfigurationHandler;
325
327
  exports.setRemoveConfigurationHandler = contextServer.setRemoveConfigurationHandler;
326
328
  exports.setProvisioningHandler = contextServer.setProvisioningHandler;
329
+ exports.setUpdatingHandler = contextServer.setUpdatingHandler;
327
330
  exports.setRemoveDeviceHandler = contextServer.setRemoveDeviceHandler;
328
331
  exports.setNotificationHandler = contextServer.setNotificationHandler;
329
332
  exports.addUpdateMiddleware = ngsi.addUpdateMiddleware;
@@ -348,6 +351,7 @@ exports.ensureSouthboundDomain = domainUtils.ensureSouthboundDomain;
348
351
  exports.finishSouthBoundTransaction = domainUtils.finishSouthBoundTransaction;
349
352
  exports.requestDomain = domainUtils.requestDomain;
350
353
  exports.regenerateTransid = domainUtils.regenerateTransid;
354
+ exports.fillService = domainUtils.fillService;
351
355
 
352
356
  exports.middlewares = middlewares;
353
357
 
@@ -370,3 +374,4 @@ exports.constants = constants;
370
374
  exports.logModule = logger;
371
375
  exports.configModule = config;
372
376
  exports.startServer = startServer;
377
+ exports.request = request;
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
3
+ *
4
+ * This file is part of fiware-iotagent-lib
5
+ *
6
+ * fiware-iotagent-lib is free software: you can redistribute it and/or
7
+ * modify it under the terms of the GNU Affero General Public License as
8
+ * published by the Free Software Foundation, either version 3 of the License,
9
+ * or (at your option) any later version.
10
+ *
11
+ * fiware-iotagent-lib is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
+ * See the GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public
17
+ * License along with fiware-iotagent-lib.
18
+ * If not, see http://www.gnu.org/licenses/.
19
+ *
20
+ * For those usages not covered by the GNU Affero General Public License
21
+ * please contact with::daniel.moranjimenez@telefonica.com
22
+ *
23
+ */
24
+
25
+ /*This file is intended to contain the whole transformartion map defining
26
+ JEXL avaliable transformations*/
27
+
28
+ const map = {
29
+ jsonparse: (str) => JSON.parse(str),
30
+ jsonstringify: (obj) => JSON.stringify(obj),
31
+ indexOf: (val, char) => String(val).indexOf(char),
32
+ length: (val) => String(val).length,
33
+ trim: (val) => String(val).trim(),
34
+ substr: (val, int1, int2) => String(val).substr(int1, int2),
35
+ addreduce: (arr) => arr.reduce((i, v) => i + v),
36
+ lengtharray: (arr) => arr.length,
37
+ typeof: (val) => typeof val,
38
+ isarray: (arr) => Array.isArray(arr),
39
+ isnan: (val) => isNaN(val),
40
+ parseint: (val) => parseInt(val),
41
+ parsefloat: (val) => parseFloat(val),
42
+ toisodate: (val) => new Date(val).toISOString(),
43
+ timeoffset: (isostr) => new Date(isostr).getTimezoneOffset(),
44
+ tostring: (val) => val.toString(),
45
+ urlencode: (val) => encodeURI(val),
46
+ urldecode: (val) => decodeURI(val),
47
+ replacestr: (str, from, to) => str.replace(from, to),
48
+ replaceregexp: (str, reg, to) => str.replace(new RegExp(reg), to),
49
+ replaceallstr: (str, from, to) => str.replaceAll(from, to),
50
+ replaceallregexp: (str, reg, to) => str.replaceAll(new RegExp(reg, 'g'), to),
51
+ split: (str, ch) => str.split(ch),
52
+ mapper: (val, values, choices) => choices[values.findIndex((target) => target === val)],
53
+ thmapper: (val, values, choices) =>
54
+ choices[
55
+ values.reduce((acc, curr, i) => (acc === 0 || acc ? acc : val <= curr ? (acc = i) : (acc = null)), null)
56
+ ],
57
+ bitwisemask: (i, mask, op, shf) =>
58
+ (op === '&' ? parseInt(i) & mask : op === '|' ? parseInt(i) | mask : op === '^' ? parseInt(i) ^ mask : i) >>
59
+ shf,
60
+ slice: (arr, init, end) => arr.slice(init, end),
61
+ addset: (arr, x) => {
62
+ return Array.from(new Set(arr).add(x));
63
+ },
64
+ removeset: (arr, x) => {
65
+ let s = new Set(arr);
66
+ s.delete(x);
67
+ return Array.from(s);
68
+ }
69
+ };
70
+
71
+ exports.map = map;
@@ -29,7 +29,7 @@ const Command = new Schema({
29
29
  type: String,
30
30
  name: String,
31
31
  value: Object,
32
- service: String,
32
+ service: { type: String, lowercase: true },
33
33
  subservice: String,
34
34
  creationDate: { type: Date, default: Date.now }
35
35
  });