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.
- package/.github/workflows/ci.yml +17 -1
- package/.readthedocs.yml +7 -0
- package/CHANGES_NEXT_RELEASE +0 -1
- package/README.md +1 -0
- package/doc/Contribution.md +60 -1
- package/doc/advanced-topics.md +136 -14
- package/doc/api.md +38 -22
- package/doc/apiary/iotagent.apib +1 -3
- package/doc/architecture.md +2 -2
- package/doc/config-basic-example.js +0 -1
- package/doc/deprecated.md +2 -2
- package/doc/development.md +13 -6
- package/doc/expressionLanguage.md +519 -277
- package/doc/getting-started.md +0 -1
- package/doc/howto.md +13 -17
- package/doc/installationguide.md +67 -69
- package/doc/usermanual.md +48 -16
- package/docker/Mosquitto/Dockerfile +4 -9
- package/docker/Mosquitto/README.md +2 -0
- package/docker/Mosquitto/startMosquitto.sh +18 -1
- package/lib/command/commandLine.js +1 -1
- package/lib/commonConfig.js +5 -14
- package/lib/errors.js +0 -16
- package/lib/fiware-iotagent-lib.js +5 -0
- package/lib/jexlTranformsMap.js +71 -0
- package/lib/model/Command.js +1 -1
- package/lib/model/Device.js +5 -2
- package/lib/model/Group.js +20 -2
- package/lib/model/dbConn.js +7 -1
- package/lib/plugins/attributeAlias.js +6 -13
- package/lib/plugins/bidirectionalData.js +2 -27
- package/lib/plugins/expressionParser.js +41 -17
- package/lib/plugins/expressionPlugin.js +21 -27
- package/lib/plugins/jexlParser.js +71 -67
- package/lib/plugins/multiEntity.js +68 -147
- package/lib/plugins/pluginUtils.js +12 -48
- package/lib/plugins/timestampProcessPlugin.js +1 -46
- package/lib/request-shim.js +111 -0
- package/lib/services/common/domain.js +2 -2
- package/lib/services/common/genericMiddleware.js +6 -2
- package/lib/services/common/iotManagerService.js +1 -1
- package/lib/services/common/securityServiceKeystone.js +1 -1
- package/lib/services/common/securityServiceOAuth2.js +3 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +29 -22
- package/lib/services/devices/deviceService.js +56 -33
- package/lib/services/devices/devices-NGSI-LD.js +42 -14
- package/lib/services/devices/devices-NGSI-mixed.js +3 -3
- package/lib/services/devices/devices-NGSI-v2.js +48 -24
- package/lib/services/devices/registrationUtils.js +1 -134
- package/lib/services/groups/groupRegistryMemory.js +2 -0
- package/lib/services/groups/groupRegistryMongoDB.js +58 -76
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +205 -124
- package/lib/services/ngsi/entities-NGSI-v2.js +142 -32
- package/lib/services/ngsi/ngsiService.js +4 -6
- package/lib/services/ngsi/ngsiUtils.js +0 -21
- package/lib/services/ngsi/subscription-NGSI-LD.js +14 -5
- package/lib/services/ngsi/subscriptionService.js +1 -4
- package/lib/services/northBound/contextServer-NGSI-LD.js +7 -2
- package/lib/services/northBound/contextServer-NGSI-v2.js +25 -13
- package/lib/services/northBound/contextServer.js +1 -4
- package/lib/services/northBound/contextServerUtils.js +0 -81
- package/lib/services/northBound/deviceProvisioningServer.js +36 -9
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/northBound/restUtils.js +2 -39
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +13 -13
- package/test/tools/utils.js +2 -0
- package/test/unit/examples/deviceProvisioningRequests/provisionAnotherDevice.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionDeviceMissingParameters.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionDuplicatedDev.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -1
- package/test/unit/examples/deviceProvisioningRequests/provisionNewDeviceMalformed1.json +1 -1
- package/test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json +1 -1
- package/test/unit/examples/iotamRequests/registrationEmpty.json +1 -1
- package/test/unit/examples/iotamRequests/registrationWithGroups.json +2 -2
- package/test/unit/examples/iotamRequests/registrationWithGroupsWithoutCB.json +2 -2
- package/test/unit/examples/iotamRequests/registrationWithStaticGroups.json +2 -2
- package/test/unit/expressions/jexlExpression-test.js +119 -0
- package/test/unit/general/config-multi-core-test.js +1 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +30 -77
- package/test/unit/general/deviceService-test.js +19 -35
- package/test/unit/general/loglevel-api_test.js +8 -13
- package/test/unit/general/migration-test.js +1 -0
- package/test/unit/general/startup-test.js +3 -2
- package/test/unit/general/statistics-persistence_test.js +2 -2
- package/test/unit/general/statistics-service_test.js +2 -2
- package/test/unit/lazyAndCommands/commandRegistry_test.js +18 -18
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +16 -24
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +2 -2
- package/test/unit/mongodb/mongodb-group-registry-test.js +11 -11
- package/test/unit/mongodb/mongodb-registry-test.js +55 -131
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateCommands1.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent1.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
- package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
- package/test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -14
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -14
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic3.json +1 -15
- package/test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast5.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin12a.json +7 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin13.json +13 -13
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin16.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin17.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin31.json +15 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin33.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin34.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +36 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin5.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +16 -16
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextGeoproperties3.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +6 -6
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +3 -3
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionDeviceStatic.json +0 -7
- package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionMinimumDevice.json +0 -7
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +20 -17
- package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest.json +18 -15
- package/test/unit/ngsi-ld/examples/subscriptionRequests/simpleSubscriptionRequest2.json +18 -15
- package/test/unit/ngsi-ld/expressions/expressionBasedTransformations-test.js +21 -21
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1018 -0
- package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +2 -2
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +24 -24
- package/test/unit/ngsi-ld/general/deviceService-test.js +7 -7
- package/test/unit/ngsi-ld/general/https-support-test.js +14 -13
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +8 -7
- package/test/unit/ngsi-ld/general/startup-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +10 -8
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +11 -12
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +25 -29
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +16 -15
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +18 -17
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +13 -12
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +10 -9
- package/test/unit/ngsi-ld/ngsiService/staticAttributes-test.js +3 -3
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +25 -24
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +13 -12
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +27 -26
- package/test/unit/ngsi-ld/plugins/compress-timestamp-plugin_test.js +5 -5
- package/test/unit/ngsi-ld/plugins/event-plugin_test.js +3 -3
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +75 -14
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +3 -3
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +54 -53
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +20 -19
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +23 -22
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +58 -70
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +8 -7
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +19 -19
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +18 -20
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +43 -49
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +16 -14
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent3.json +19 -0
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent4.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent5.json +19 -0
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateCommands1.json +3 -3
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent1.json +3 -3
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent2.json +1 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/updateIoTAgent3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +17 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin15.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin16.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin18.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin19.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +13 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin20.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin21.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin22.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin23.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin24.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin25.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin26.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin27.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin28.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +6 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +18 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +16 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin4.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +17 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +5 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware1.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware2.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +13 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +33 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +25 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +8 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -2
- package/test/unit/ngsiv2/examples/contextRequests/updateProvisionDevice.json +20 -0
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +1 -1
- package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest.json +1 -1
- package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest2.json +1 -1
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +93 -60
- package/test/unit/ngsiv2/expressions/expressionCombinedTransformations-test.js +16 -16
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +548 -164
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +34 -33
- package/test/unit/ngsiv2/general/deviceService-test.js +15 -14
- package/test/unit/ngsiv2/general/https-support-test.js +14 -13
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +8 -7
- package/test/unit/ngsiv2/general/startup-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +9 -7
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +13 -12
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +323 -51
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +22 -20
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +114 -26
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +16 -16
- package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +39 -38
- package/test/unit/{ngsiService → ngsiv2/ngsiService}/queryDeviceInformationInCb-test.js +25 -54
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +5 -5
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +25 -24
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +22 -22
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +27 -26
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +7 -7
- package/test/unit/ngsiv2/plugins/event-plugin_test.js +4 -4
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +549 -24
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +4 -4
- package/test/unit/{plugins → ngsiv2/plugins}/translation-inPlugins_test.js +25 -25
- package/test/unit/{provisioning → ngsiv2/provisioning}/device-group-api-test.js +44 -75
- package/test/unit/{provisioning/device-group-utils_test.js → ngsiv2/provisioning/device-group-utils-test.js} +15 -14
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +74 -73
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +20 -19
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +30 -29
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +58 -69
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +8 -7
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +19 -19
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +18 -19
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +49 -52
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +6 -4
- package/test/unit/plugins/capture-provision-inPlugins_test.js +13 -23
- package/.nyc_output/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
- package/.nyc_output/processinfo/016aca19-69bf-4681-9b41-2835c5131681.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/lib/services/devices/devices-NGSI-v1.js +0 -293
- package/lib/services/devices/registrationUtils.js_avega +0 -589
- package/lib/services/ngsi/entities-NGSI-v1.js +0 -300
- package/lib/services/ngsi/subscription-NGSI-v1.js +0 -234
- package/lib/services/northBound/contextServer-NGSI-v1.js +0 -526
- package/lib/templates/notificationTemplateNgsi1.json +0 -75
- package/lib/templates/updateContextNgsi1.json +0 -50
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent1.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent2.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent3.json +0 -25
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgent4.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentAttributeUpdates.json +0 -16
- package/test/unit/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerNewDevice1.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerNewDevice2.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice.json +0 -25
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +0 -21
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +0 -33
- package/test/unit/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +0 -33
- package/test/unit/examples/contextAvailabilityRequests/unregisterDevice1.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/unregisterDevice3.json +0 -26
- package/test/unit/examples/contextAvailabilityRequests/unregisterProvisionedDevice.json +0 -26
- package/test/unit/examples/contextAvailabilityRequests/updateCommands1.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent1.json +0 -22
- package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent2.json +0 -26
- package/test/unit/examples/contextAvailabilityRequests/updateIoTAgent3.json +0 -22
- package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Failed.json +0 -8
- package/test/unit/examples/contextAvailabilityResponses/registerIoTAgent1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/registerNewDevice1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/registerNewDevice2Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/registerProvisionedDeviceSuccess.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Failed.json +0 -8
- package/test/unit/examples/contextAvailabilityResponses/unregisterDevice1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/updateCommands1Success.json +0 -4
- package/test/unit/examples/contextAvailabilityResponses/updateIoTAgent1Success.json +0 -6
- package/test/unit/examples/contextProviderResponses/queryInformationResponse.json +0 -22
- package/test/unit/examples/contextProviderResponses/queryInformationResponseEmptyAttributes.json +0 -22
- package/test/unit/examples/contextProviderResponses/queryInformationStaticAttributesResponse.json +0 -27
- package/test/unit/examples/contextProviderResponses/updateInformationResponse.json +0 -22
- package/test/unit/examples/contextProviderResponses/updateInformationResponse2.json +0 -22
- package/test/unit/examples/contextRequests/contextSubscriptionRequest.json +0 -20
- package/test/unit/examples/contextRequests/contextSubscriptionRequest2.json +0 -20
- package/test/unit/examples/contextRequests/createBidirectionalDevice.json +0 -17
- package/test/unit/examples/contextRequests/createDatetimeProvisionedDevice.json +0 -17
- package/test/unit/examples/contextRequests/createGeopointProvisionedDevice.json +0 -17
- package/test/unit/examples/contextRequests/createMinimumProvisionedDevice.json +0 -17
- package/test/unit/examples/contextRequests/createProvisionedDevice.json +0 -32
- package/test/unit/examples/contextRequests/createProvisionedDeviceMultientity.json +0 -32
- package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroup.json +0 -47
- package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +0 -52
- package/test/unit/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +0 -52
- package/test/unit/examples/contextRequests/createTimeinstantDevice.json +0 -17
- package/test/unit/examples/contextRequests/queryContext1.json +0 -13
- package/test/unit/examples/contextRequests/queryContext2.json +0 -13
- package/test/unit/examples/contextRequests/queryContextAliasPlugin1.json +0 -10
- package/test/unit/examples/contextRequests/queryContextCompressTimestamp1.json +0 -13
- package/test/unit/examples/contextRequests/updateActiveAttributes.json +0 -11
- package/test/unit/examples/contextRequests/updateContext1.json +0 -22
- package/test/unit/examples/contextRequests/updateContext2.json +0 -22
- package/test/unit/examples/contextRequests/updateContext3.json +0 -17
- package/test/unit/examples/contextRequests/updateContext3WithStatic.json +0 -22
- package/test/unit/examples/contextRequests/updateContext4.json +0 -22
- package/test/unit/examples/contextRequests/updateContext5.json +0 -19
- package/test/unit/examples/contextRequests/updateContextAliasPlugin.json +0 -22
- package/test/unit/examples/contextRequests/updateContextAliasPlugin2.json +0 -17
- package/test/unit/examples/contextRequests/updateContextAppendMode.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandError.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandExpired.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandFinish.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCommandStatus.json +0 -17
- package/test/unit/examples/contextRequests/updateContextCompressTimestamp1.json +0 -22
- package/test/unit/examples/contextRequests/updateContextCompressTimestamp2.json +0 -29
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin1.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin2.json +0 -27
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin3.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin4.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin5.json +0 -27
- package/test/unit/examples/contextRequests/updateContextMiddleware1.json +0 -22
- package/test/unit/examples/contextRequests/updateContextMultiEntityPlugin3.json +0 -35
- package/test/unit/examples/contextRequests/updateContextMultientityPlugin1.json +0 -30
- package/test/unit/examples/contextRequests/updateContextMultientityPlugin2.json +0 -30
- package/test/unit/examples/contextRequests/updateContextProcessTimestamp1.json +0 -29
- package/test/unit/examples/contextRequests/updateContextStaticAttributes.json +0 -22
- package/test/unit/examples/contextRequests/updateContextTimestamp.json +0 -41
- package/test/unit/examples/contextRequests/updateContextTimestampOverride.json +0 -22
- package/test/unit/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +0 -22
- package/test/unit/examples/contextRequests/updateContextTimestampTimezone.json +0 -41
- package/test/unit/examples/contextRequests/updateProvisionActiveAttributes1.json +0 -17
- package/test/unit/examples/contextRequests/updateProvisionCommands1.json +0 -27
- package/test/unit/examples/contextRequests/updateProvisionDeviceStatic.json +0 -38
- package/test/unit/examples/contextRequests/updateProvisionMinimumDevice.json +0 -17
- package/test/unit/examples/contextResponses/contextSubscriptionRequest2Success.json +0 -7
- package/test/unit/examples/contextResponses/contextSubscriptionRequestSuccess.json +0 -7
- package/test/unit/examples/contextResponses/createBidirectionalDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createDatetimeProvisionedDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createGeopointProvisionedDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createProvisionedDeviceSuccess.json +0 -22
- package/test/unit/examples/contextResponses/createTimeinstantSuccess.json +0 -22
- package/test/unit/examples/contextResponses/queryContext1Success.json +0 -27
- package/test/unit/examples/contextResponses/queryContext2Error.json +0 -7
- package/test/unit/examples/contextResponses/queryContext2UnknownError.json +0 -6
- package/test/unit/examples/contextResponses/queryContext3Error.json +0 -34
- package/test/unit/examples/contextResponses/queryContextAliasPlugin1Success.json +0 -27
- package/test/unit/examples/contextResponses/queryContextCompressTimestamp1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateActiveAttributesSuccess.json +0 -16
- package/test/unit/examples/contextResponses/updateContext1Failed.json +0 -7
- package/test/unit/examples/contextResponses/updateContext1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContext2Failed.json +0 -35
- package/test/unit/examples/contextResponses/updateContextAliasPlugin2Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContextAliasPluginSuccess.json +0 -27
- package/test/unit/examples/contextResponses/updateContextCommandFinishSuccess.json +0 -27
- package/test/unit/examples/contextResponses/updateContextCommandStatusSuccess.json +0 -22
- package/test/unit/examples/contextResponses/updateContextCompressTimestamp1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContextCompressTimestamp2Success.json +0 -34
- package/test/unit/examples/contextResponses/updateContextEvents1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin1Success.json +0 -22
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin2Success.json +0 -22
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin3Success.json +0 -22
- package/test/unit/examples/contextResponses/updateContextExpressionPlugin5Success.json +0 -32
- package/test/unit/examples/contextResponses/updateContextMultientityPlugin1Success.json +0 -40
- package/test/unit/examples/contextResponses/updateContextMultientityPlugin2Success.json +0 -40
- package/test/unit/examples/contextResponses/updateContextMultientityPlugin3Success.json +0 -40
- package/test/unit/examples/contextResponses/updateContextProcessTimestamp1Success.json +0 -27
- package/test/unit/examples/contextResponses/updateProvisionActiveAttributes1Success.json +0 -22
- package/test/unit/examples/contextResponses/updateProvisionCommands1Success.json +0 -32
- package/test/unit/examples/contextResponses/updateProvisionMinimumDeviceSuccess.json +0 -22
- package/test/unit/examples/subscriptionRequests/bidirectionalNotification.json +0 -24
- package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRemove.json +0 -3
- package/test/unit/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -22
- package/test/unit/examples/subscriptionRequests/errorNotification.json +0 -24
- package/test/unit/examples/subscriptionRequests/simpleNotification.json +0 -24
- package/test/unit/examples/subscriptionRequests/simpleSubscriptionRemove.json +0 -3
- package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest.json +0 -19
- package/test/unit/examples/subscriptionRequests/simpleSubscriptionRequest1.json +0 -19
- package/test/unit/examples/subscriptionResponses/bidirectionalSubscriptionSuccess.json +0 -6
- package/test/unit/examples/subscriptionResponses/simpleSubscriptionSuccess.json +0 -6
- package/test/unit/expressions/expressionBasedTransformations-test.js +0 -328
- package/test/unit/expressions/expressionCombinedTransformations-test.js +0 -306
- package/test/unit/expressions/jexlBasedTransformations-test.js +0 -334
- package/test/unit/general/contextBrokerOAuthSecurityAccess-test.js +0 -902
- package/test/unit/general/https-support-test.js +0 -286
- package/test/unit/general/iotam-autoregistration-test.js +0 -368
- package/test/unit/lazyAndCommands/active-devices-attribute-update-test.js +0 -168
- package/test/unit/lazyAndCommands/command-test.js +0 -341
- package/test/unit/lazyAndCommands/lazy-devices-test.js +0 -878
- package/test/unit/lazyAndCommands/polling-commands-test.js +0 -421
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin20.json +0 -25
- package/test/unit/ngsiService/active-devices-test.js +0 -692
- package/test/unit/ngsiService/staticAttributes-test.js +0 -148
- package/test/unit/ngsiService/subscriptions-test.js +0 -345
- package/test/unit/plugins/alias-plugin_test.js +0 -158
- package/test/unit/plugins/bidirectional-plugin_test.js +0 -564
- package/test/unit/plugins/compress-timestamp-plugin_test.js +0 -257
- package/test/unit/plugins/event-plugin_test.js +0 -119
- package/test/unit/plugins/multientity-plugin_test.js +0 -248
- package/test/unit/plugins/timestamp-processing-plugin_test.js +0 -119
- package/test/unit/provisioning/device-provisioning-api_test.js +0 -748
- package/test/unit/provisioning/device-registration_test.js +0 -432
- package/test/unit/provisioning/device-update-registration_test.js +0 -326
- package/test/unit/provisioning/listProvisionedDevices-test.js +0 -488
- package/test/unit/provisioning/provisionDeviceMultientity-test.js +0 -123
- package/test/unit/provisioning/removeProvisionedDevice-test.js +0 -244
- package/test/unit/provisioning/singleConfigurationMode-test.js +0 -346
- package/test/unit/provisioning/updateProvisionedDevices-test.js +0 -436
package/doc/getting-started.md
CHANGED
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 `
|
|
319
|
-
`
|
|
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
|
|
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
|
|
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
|
|
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 /
|
|
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
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
-
`
|
|
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
|
package/doc/installationguide.md
CHANGED
|
@@ -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
|
|
60
|
-
to **NGSI LD** at service group or device provisioning time using the `ngsiVersion` field in the
|
|
61
|
-
The `ngsiVersion` field switch may be added at either group or device level, with the device level
|
|
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:
|
|
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
|
|
249
|
-
|
|
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
|
299
|
-
|
|
|
300
|
-
| IOTA_CB_URL
|
|
301
|
-
| IOTA_CB_HOST
|
|
302
|
-
| IOTA_CB_PORT
|
|
303
|
-
| IOTA_CB_NGSI_VERSION
|
|
304
|
-
| IOTA_NORTH_HOST
|
|
305
|
-
| IOTA_NORTH_PORT
|
|
306
|
-
| IOTA_PROVIDER_URL
|
|
307
|
-
| IOTA_AUTH_ENABLED
|
|
308
|
-
| IOTA_AUTH_TYPE
|
|
309
|
-
| IOTA_AUTH_HEADER
|
|
310
|
-
| IOTA_AUTH_URL
|
|
311
|
-
| IOTA_AUTH_HOST
|
|
312
|
-
| IOTA_AUTH_PORT
|
|
313
|
-
| IOTA_AUTH_USER
|
|
314
|
-
| IOTA_AUTH_PASSWORD
|
|
315
|
-
| IOTA_AUTH_CLIENT_ID
|
|
316
|
-
| IOTA_AUTH_CLIENT_SECRET
|
|
317
|
-
| IOTA_AUTH_TOKEN_PATH
|
|
318
|
-
| IOTA_AUTH_PERMANENT_TOKEN
|
|
319
|
-
| IOTA_REGISTRY_TYPE
|
|
320
|
-
| IOTA_LOG_LEVEL
|
|
321
|
-
| IOTA_TIMESTAMP
|
|
322
|
-
| IOTA_IOTAM_URL
|
|
323
|
-
| IOTA_IOTAM_HOST
|
|
324
|
-
| IOTA_IOTAM_PORT
|
|
325
|
-
| IOTA_IOTAM_PATH
|
|
326
|
-
| IOTA_IOTAM_AGENTPATH
|
|
327
|
-
| IOTA_IOTAM_PROTOCOL
|
|
328
|
-
| IOTA_IOTAM_DESCRIPTION
|
|
329
|
-
| IOTA_MONGO_HOST
|
|
330
|
-
| IOTA_MONGO_PORT
|
|
331
|
-
| IOTA_MONGO_DB
|
|
332
|
-
| IOTA_MONGO_REPLICASET
|
|
333
|
-
| IOTA_MONGO_USER
|
|
334
|
-
| IOTA_MONGO_PASSWORD
|
|
335
|
-
| IOTA_MONGO_AUTH_SOURCE
|
|
336
|
-
| IOTA_MONGO_RETRIES
|
|
337
|
-
| IOTA_MONGO_RETRY_TIME
|
|
338
|
-
| IOTA_MONGO_SSL
|
|
339
|
-
| IOTA_MONGO_EXTRAARGS
|
|
340
|
-
| IOTA_SINGLE_MODE
|
|
341
|
-
| IOTA_APPEND_MODE
|
|
342
|
-
| IOTA_POLLING_EXPIRATION
|
|
343
|
-
| IOTA_POLLING_DAEMON_FREQ
|
|
344
|
-
| IOTA_AUTOCAST
|
|
345
|
-
| IOTA_MULTI_CORE
|
|
346
|
-
| IOTA_JSON_LD_CONTEXT
|
|
347
|
-
| IOTA_FALLBACK_TENANT
|
|
348
|
-
| IOTA_FALLBACK_PATH
|
|
349
|
-
| IOTA_DEFAULT_EXPRESSION_LANGUAGE
|
|
350
|
-
| IOTA_EXPLICIT_ATTRS
|
|
351
|
-
| IOTA_DEFAULT_ENTITY_NAME_CONJUNCTION | `defaultEntityNameConjunction`
|
|
352
|
-
| IOTA_RELAX_TEMPLATE_VALIDATION
|
|
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(
|
|
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(
|
|
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:
|
|
268
|
+
type: 'TheType',
|
|
269
269
|
isPattern: false,
|
|
270
|
-
id:
|
|
270
|
+
id: 'EntityID',
|
|
271
271
|
attributes: [
|
|
272
272
|
{
|
|
273
|
-
name:
|
|
274
|
-
type:
|
|
275
|
-
value:
|
|
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:
|
|
306
|
+
type: 'TheType',
|
|
307
307
|
isPattern: false,
|
|
308
|
-
id:
|
|
308
|
+
id: 'EntityID',
|
|
309
309
|
attributes: [
|
|
310
310
|
{
|
|
311
|
-
name:
|
|
312
|
-
type:
|
|
313
|
-
value:
|
|
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
|
-
|
|
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;
|
package/lib/commonConfig.js
CHANGED
|
@@ -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;
|
package/lib/model/Command.js
CHANGED