iotagent-node-lib 2.17.0 → 2.20.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 -2
- package/.nyc_output/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +1 -0
- package/.nyc_output/processinfo/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGES_NEXT_RELEASE +1 -0
- package/README.md +3 -54
- package/doc/advanced-topics.md +121 -85
- package/doc/api.md +52 -52
- package/doc/development.md +13 -6
- package/doc/expressionLanguage.md +514 -312
- package/doc/installationguide.md +66 -64
- package/doc/usermanual.md +48 -16
- package/docker/Mosquitto/Dockerfile +1 -0
- package/docker/Mosquitto/README.md +1 -0
- package/docker/Mosquitto/startMosquitto.sh +9 -4
- package/lib/commonConfig.js +1 -14
- package/lib/errors.js +0 -16
- package/lib/fiware-iotagent-lib.js +4 -2
- package/lib/jexlTranformsMap.js +13 -2
- package/lib/model/Device.js +4 -1
- package/lib/model/Group.js +19 -1
- package/lib/plugins/attributeAlias.js +6 -13
- package/lib/plugins/bidirectionalData.js +1 -21
- package/lib/plugins/expressionParser.js +7 -6
- package/lib/plugins/expressionPlugin.js +11 -25
- package/lib/plugins/jexlParser.js +8 -4
- package/lib/plugins/multiEntity.js +54 -145
- 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 +6 -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 +2 -0
- package/lib/services/devices/deviceService.js +2 -5
- package/lib/services/devices/devices-NGSI-LD.js +1 -1
- package/lib/services/devices/devices-NGSI-v2.js +4 -8
- package/lib/services/devices/registrationUtils.js +1 -134
- package/lib/services/ngsi/entities-NGSI-LD.js +205 -124
- package/lib/services/ngsi/entities-NGSI-v2.js +109 -15
- package/lib/services/ngsi/ngsiService.js +4 -6
- package/lib/services/ngsi/ngsiUtils.js +0 -36
- 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 +24 -12
- package/lib/services/northBound/contextServer.js +1 -4
- package/lib/services/northBound/contextServerUtils.js +0 -81
- package/lib/services/northBound/deviceProvisioningServer.js +31 -7
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/northBound/restUtils.js +1 -38
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +10 -16
- package/test/tools/utils.js +2 -0
- package/test/unit/examples/groupProvisioningRequests/multipleGroupsCreation.json +1 -1
- package/test/unit/expressions/jexlExpression-test.js +44 -5
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +19 -66
- package/test/unit/general/deviceService-test.js +11 -27
- package/test/unit/general/loglevel-api_test.js +6 -11
- package/test/unit/general/startup-test.js +2 -1
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +8 -16
- package/test/unit/mongodb/mongodb-group-registry-test.js +1 -1
- package/test/unit/mongodb/mongodb-registry-test.js +38 -114
- 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/expressions/jexlBasedTransformations-test.js +1018 -0
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
- package/test/unit/ngsi-ld/general/deviceService-test.js +1 -1
- package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsi-ld/general/startup-test.js +1 -0
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +2 -6
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +1 -0
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +61 -0
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +42 -54
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +3 -5
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +12 -18
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +3 -1
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent3.json +19 -0
- package/test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent5.json +19 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +22 -0
- 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/updateContextMiddleware1.json +10 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMiddleware2.json +10 -0
- 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/updateContextMultientityTimestampPlugin1.json +6 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +3 -3
- package/test/unit/{examples → ngsiv2/examples}/contextRequests/updateProvisionDevice.json +0 -0
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +37 -4
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +598 -0
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +3 -2
- package/test/unit/ngsiv2/general/deviceService-test.js +9 -8
- package/test/unit/ngsiv2/general/https-support-test.js +2 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsiv2/general/startup-test.js +1 -0
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +287 -15
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +3 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +88 -0
- package/test/unit/{ngsiService → ngsiv2/ngsiService}/queryDeviceInformationInCb-test.js +20 -49
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +526 -0
- package/test/unit/{plugins → ngsiv2/plugins}/translation-inPlugins_test.js +21 -21
- package/test/unit/{provisioning → ngsiv2/provisioning}/device-group-api-test.js +19 -50
- package/test/unit/{provisioning/device-group-utils_test.js → ngsiv2/provisioning/device-group-utils-test.js} +5 -4
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -3
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +42 -53
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +3 -4
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +14 -20
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +3 -1
- package/test/unit/plugins/capture-provision-inPlugins_test.js +8 -18
- package/.eslintcache +0 -1
- package/.nyc_output/dca24ca1-851e-490c-9d34-8d13b3330297.json +0 -1
- package/.nyc_output/processinfo/dca24ca1-851e-490c-9d34-8d13b3330297.json +0 -1
- package/bin/agentConsole.js +0 -257
- package/bin/iotAgentTester.js +0 -44
- package/lib/command/commandLine.js +0 -918
- package/lib/command/migration.js +0 -176
- package/lib/services/devices/devices-NGSI-v1.js +0 -310
- package/lib/services/ngsi/entities-NGSI-v1.js +0 -299
- 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 -26
- 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 -32
- 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/updateContextExpressionPlugin10.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/updateContextExpressionPlugin6.json +0 -17
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin7.json +0 -27
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin8.json +0 -22
- package/test/unit/examples/contextRequests/updateContextExpressionPlugin9.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 -42
- 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/general/migration-test.js +0 -256
- 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/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
|
|
|
@@ -241,8 +242,8 @@ used for the same purpose. For instance:
|
|
|
241
242
|
- **singleConfigurationMode**: enables the Single Configuration mode for backwards compatibility (see description in
|
|
242
243
|
the Overview). Default to false.
|
|
243
244
|
- **timestamp**: if this flag is activated:
|
|
244
|
-
- For NGSI-v2, the IoT Agent will add a `TimeInstant` metadata attribute to all the attributes updated from
|
|
245
|
-
|
|
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
|
|
246
247
|
- With NGSI-LD, the standard `observedAt` property-of-a-property is created instead.
|
|
247
248
|
- **defaultResource**: default string to use as resource for the registration of new Configurations (if no resource is
|
|
248
249
|
provided).
|
|
@@ -273,10 +274,11 @@ used for the same purpose. For instance:
|
|
|
273
274
|
NGSILD-Path has not yet been included in the NGSI-LD standard (it has been proposed for the next update of the
|
|
274
275
|
standard, but the final decision has yet been confirmed), take into account it could change
|
|
275
276
|
- **explicitAttrs**: if this flag is activated, only provisioned attributes will be processed to Context Broker. This
|
|
276
|
-
flag is overwritten by `explicitAttrs` flag in group or device 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.
|
|
277
279
|
- **defaultEntityNameConjunction**: the default conjunction string used to compose a default `entity_name` when is not
|
|
278
|
-
provided at device provisioning time; in that case `entity_name` is composed by `type` + `:` + `device_id`.
|
|
279
|
-
|
|
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.
|
|
280
282
|
- **relaxTemplateValidation**: if this flag is activated, `objectId` attributes for incoming devices are not
|
|
281
283
|
validated, and may exceptionally include characters (such as semi-colons) which are
|
|
282
284
|
[forbidden](https://fiware-orion.readthedocs.io/en/master/user/forbidden_characters/index.html) according to the
|
|
@@ -291,61 +293,61 @@ with container-based technologies, like Docker, Heroku, etc...
|
|
|
291
293
|
The following table shows the accepted environment variables, as well as the configuration parameter the variable
|
|
292
294
|
overrides.
|
|
293
295
|
|
|
294
|
-
| Environment variable
|
|
295
|
-
|
|
|
296
|
-
| IOTA_CB_URL
|
|
297
|
-
| IOTA_CB_HOST
|
|
298
|
-
| IOTA_CB_PORT
|
|
299
|
-
| IOTA_CB_NGSI_VERSION
|
|
300
|
-
| IOTA_NORTH_HOST
|
|
301
|
-
| IOTA_NORTH_PORT
|
|
302
|
-
| IOTA_PROVIDER_URL
|
|
303
|
-
| IOTA_AUTH_ENABLED
|
|
304
|
-
| IOTA_AUTH_TYPE
|
|
305
|
-
| IOTA_AUTH_HEADER
|
|
306
|
-
| IOTA_AUTH_URL
|
|
307
|
-
| IOTA_AUTH_HOST
|
|
308
|
-
| IOTA_AUTH_PORT
|
|
309
|
-
| IOTA_AUTH_USER
|
|
310
|
-
| IOTA_AUTH_PASSWORD
|
|
311
|
-
| IOTA_AUTH_CLIENT_ID
|
|
312
|
-
| IOTA_AUTH_CLIENT_SECRET
|
|
313
|
-
| IOTA_AUTH_TOKEN_PATH
|
|
314
|
-
| IOTA_AUTH_PERMANENT_TOKEN
|
|
315
|
-
| IOTA_REGISTRY_TYPE
|
|
316
|
-
| IOTA_LOG_LEVEL
|
|
317
|
-
| IOTA_TIMESTAMP
|
|
318
|
-
| IOTA_IOTAM_URL
|
|
319
|
-
| IOTA_IOTAM_HOST
|
|
320
|
-
| IOTA_IOTAM_PORT
|
|
321
|
-
| IOTA_IOTAM_PATH
|
|
322
|
-
| IOTA_IOTAM_AGENTPATH
|
|
323
|
-
| IOTA_IOTAM_PROTOCOL
|
|
324
|
-
| IOTA_IOTAM_DESCRIPTION
|
|
325
|
-
| IOTA_MONGO_HOST
|
|
326
|
-
| IOTA_MONGO_PORT
|
|
327
|
-
| IOTA_MONGO_DB
|
|
328
|
-
| IOTA_MONGO_REPLICASET
|
|
329
|
-
| IOTA_MONGO_USER
|
|
330
|
-
| IOTA_MONGO_PASSWORD
|
|
331
|
-
| IOTA_MONGO_AUTH_SOURCE
|
|
332
|
-
| IOTA_MONGO_RETRIES
|
|
333
|
-
| IOTA_MONGO_RETRY_TIME
|
|
334
|
-
| IOTA_MONGO_SSL
|
|
335
|
-
| IOTA_MONGO_EXTRAARGS
|
|
336
|
-
| IOTA_SINGLE_MODE
|
|
337
|
-
| IOTA_APPEND_MODE
|
|
338
|
-
| IOTA_POLLING_EXPIRATION
|
|
339
|
-
| IOTA_POLLING_DAEMON_FREQ
|
|
340
|
-
| IOTA_AUTOCAST
|
|
341
|
-
| IOTA_MULTI_CORE
|
|
342
|
-
| IOTA_JSON_LD_CONTEXT
|
|
343
|
-
| IOTA_FALLBACK_TENANT
|
|
344
|
-
| IOTA_FALLBACK_PATH
|
|
345
|
-
| IOTA_DEFAULT_EXPRESSION_LANGUAGE
|
|
346
|
-
| IOTA_EXPLICIT_ATTRS
|
|
347
|
-
| IOTA_DEFAULT_ENTITY_NAME_CONJUNCTION | `defaultEntityNameConjunction`
|
|
348
|
-
| 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` |
|
|
349
351
|
|
|
350
352
|
Note:
|
|
351
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
|
|
@@ -9,6 +9,7 @@ RUN yum update -y && yum install -y wget \
|
|
|
9
9
|
&& yum install -y epel-release \
|
|
10
10
|
&& yum update -y epel-release \
|
|
11
11
|
&& yum install -y mosquitto \
|
|
12
|
+
&& cp /etc/mosquitto/mosquitto.conf /etc/mosquitto/mosquitto.conf.orig \
|
|
12
13
|
&& chmod 755 /bin/startMosquitto.sh \
|
|
13
14
|
&& mkdir /var/log/mosquitto \
|
|
14
15
|
&& chown mosquitto:mosquitto /var/log/mosquitto \
|
|
@@ -2,6 +2,7 @@ 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
|
|
5
6
|
- 1.5.0 uses mosquitto-1.6.10-1.el7.x86_64
|
|
6
7
|
- 1.4.0 uses mosquitto-1.6.10-1.el7.x86_64
|
|
7
8
|
- 1.3.0 uses mosquitto-1.6.8-1.el7.x86_64
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
if [ "${CONGIF_FROM_ENV}" = true ] ; then
|
|
4
|
-
|
|
5
|
-
sed -i '$ i acl_file /etc/mosquitto/aclfile\npassword_file /etc/mosquitto/pwfile' /etc/mosquitto/mosquitto.conf
|
|
4
|
+
cp /etc/mosquitto/mosquitto.conf.orig /etc/mosquitto/mosquitto.conf
|
|
6
5
|
echo "log_timestamp true" >> /etc/mosquitto/mosquitto.conf
|
|
7
6
|
echo "log_timestamp_format %Y-%m-%dT%H:%M:%S" >> /etc/mosquitto/mosquitto.conf
|
|
8
7
|
echo 'listener 9001' >> /etc/mosquitto/mosquitto.conf
|
|
9
8
|
echo 'protocol websockets' >> /etc/mosquitto/mosquitto.conf
|
|
10
9
|
echo 'listener 1883' >> /etc/mosquitto/mosquitto.conf
|
|
11
10
|
echo 'protocol mqtt' >> /etc/mosquitto/mosquitto.conf
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
14
19
|
fi
|
|
15
20
|
|
|
16
21
|
/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
|
package/lib/commonConfig.js
CHANGED
|
@@ -525,19 +525,7 @@ function ngsiVersion() {
|
|
|
525
525
|
return 'unknown';
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
|
|
529
|
-
* It checks if the configuration file states a non-legacy format,
|
|
530
|
-
* either v2, LD or mixed.
|
|
531
|
-
*
|
|
532
|
-
* @return {boolean} Result of the checking
|
|
533
|
-
*/
|
|
534
|
-
function isCurrentNgsi() {
|
|
535
|
-
if (config.contextBroker && config.contextBroker.ngsiVersion) {
|
|
536
|
-
const version = config.contextBroker.ngsiVersion.toLowerCase();
|
|
537
|
-
return version === 'v2' || version === 'ld' || version === 'mixed';
|
|
538
|
-
}
|
|
539
|
-
return false;
|
|
540
|
-
}
|
|
528
|
+
|
|
541
529
|
/**
|
|
542
530
|
* It checks if a combination of typeInformation or common Config is LD
|
|
543
531
|
*
|
|
@@ -566,7 +554,6 @@ exports.setCommandRegistry = setCommandRegistry;
|
|
|
566
554
|
exports.getCommandRegistry = getCommandRegistry;
|
|
567
555
|
exports.ngsiVersion = ngsiVersion;
|
|
568
556
|
exports.checkNgsiLD = checkNgsiLD;
|
|
569
|
-
exports.isCurrentNgsi = isCurrentNgsi;
|
|
570
557
|
exports.setSecurityService = setSecurityService;
|
|
571
558
|
exports.getSecurityService = getSecurityService;
|
|
572
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');
|
|
@@ -325,6 +326,7 @@ exports.setDataQueryHandler = contextServer.setQueryHandler;
|
|
|
325
326
|
exports.setConfigurationHandler = contextServer.setConfigurationHandler;
|
|
326
327
|
exports.setRemoveConfigurationHandler = contextServer.setRemoveConfigurationHandler;
|
|
327
328
|
exports.setProvisioningHandler = contextServer.setProvisioningHandler;
|
|
329
|
+
exports.setUpdatingHandler = contextServer.setUpdatingHandler;
|
|
328
330
|
exports.setRemoveDeviceHandler = contextServer.setRemoveDeviceHandler;
|
|
329
331
|
exports.setNotificationHandler = contextServer.setNotificationHandler;
|
|
330
332
|
exports.addUpdateMiddleware = ngsi.addUpdateMiddleware;
|
|
@@ -349,11 +351,10 @@ exports.ensureSouthboundDomain = domainUtils.ensureSouthboundDomain;
|
|
|
349
351
|
exports.finishSouthBoundTransaction = domainUtils.finishSouthBoundTransaction;
|
|
350
352
|
exports.requestDomain = domainUtils.requestDomain;
|
|
351
353
|
exports.regenerateTransid = domainUtils.regenerateTransid;
|
|
354
|
+
exports.fillService = domainUtils.fillService;
|
|
352
355
|
|
|
353
356
|
exports.middlewares = middlewares;
|
|
354
357
|
|
|
355
|
-
exports.commandLine = require('./command/commandLine');
|
|
356
|
-
|
|
357
358
|
exports.dataPlugins = {
|
|
358
359
|
compressTimestamp: require('./plugins/compressTimestamp'),
|
|
359
360
|
attributeAlias: require('./plugins/attributeAlias'),
|
|
@@ -371,3 +372,4 @@ exports.constants = constants;
|
|
|
371
372
|
exports.logModule = logger;
|
|
372
373
|
exports.configModule = config;
|
|
373
374
|
exports.startServer = startServer;
|
|
375
|
+
exports.request = request;
|
package/lib/jexlTranformsMap.js
CHANGED
|
@@ -40,6 +40,7 @@ const map = {
|
|
|
40
40
|
parseint: (val) => parseInt(val),
|
|
41
41
|
parsefloat: (val) => parseFloat(val),
|
|
42
42
|
toisodate: (val) => new Date(val).toISOString(),
|
|
43
|
+
timeoffset: (isostr) => new Date(isostr).getTimezoneOffset(),
|
|
43
44
|
tostring: (val) => val.toString(),
|
|
44
45
|
urlencode: (val) => encodeURI(val),
|
|
45
46
|
urldecode: (val) => decodeURI(val),
|
|
@@ -53,8 +54,18 @@ const map = {
|
|
|
53
54
|
choices[
|
|
54
55
|
values.reduce((acc, curr, i) => (acc === 0 || acc ? acc : val <= curr ? (acc = i) : (acc = null)), null)
|
|
55
56
|
],
|
|
56
|
-
bitwisemask: (i, mask, op) =>
|
|
57
|
-
op === '&' ? parseInt(i) & mask : op === '|' ? parseInt(i) | mask : op === '^' ? parseInt(i) ^ mask : i
|
|
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
|
+
}
|
|
58
69
|
};
|
|
59
70
|
|
|
60
71
|
exports.map = map;
|
package/lib/model/Device.js
CHANGED
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
const mongoose = require('mongoose');
|
|
25
25
|
const Schema = mongoose.Schema;
|
|
26
|
+
const Group = require('./Group');
|
|
27
|
+
|
|
28
|
+
mongoose.Schema.Types.ExplicitAttrsType = Group.ExplicitAttrsType;
|
|
26
29
|
|
|
27
30
|
const Device = new Schema({
|
|
28
31
|
id: String,
|
|
@@ -49,7 +52,7 @@ const Device = new Schema({
|
|
|
49
52
|
internalAttributes: Object,
|
|
50
53
|
autoprovision: Boolean,
|
|
51
54
|
expressionLanguage: String,
|
|
52
|
-
explicitAttrs:
|
|
55
|
+
explicitAttrs: Group.ExplicitAttrsType,
|
|
53
56
|
ngsiVersion: String
|
|
54
57
|
});
|
|
55
58
|
|
package/lib/model/Group.js
CHANGED
|
@@ -24,6 +24,23 @@
|
|
|
24
24
|
const mongoose = require('mongoose');
|
|
25
25
|
const Schema = mongoose.Schema;
|
|
26
26
|
|
|
27
|
+
class ExplicitAttrsType extends mongoose.SchemaType {
|
|
28
|
+
constructor(key, options) {
|
|
29
|
+
super(key, options, 'ExplicitAttrsType');
|
|
30
|
+
}
|
|
31
|
+
// `cast()` takes a parameter that can be anything. You need to
|
|
32
|
+
// validate the provided `val` and throw a `CastError` if you
|
|
33
|
+
// can't convert it.
|
|
34
|
+
cast(val) {
|
|
35
|
+
if (!(typeof val === 'boolean' || typeof val === 'string')) {
|
|
36
|
+
throw new Error('ExplicitAttrsType: ' + val + ' is not Boolean or String');
|
|
37
|
+
}
|
|
38
|
+
return val;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
mongoose.Schema.Types.ExplicitAttrsType = ExplicitAttrsType;
|
|
43
|
+
|
|
27
44
|
const Group = new Schema({
|
|
28
45
|
url: String,
|
|
29
46
|
resource: String,
|
|
@@ -43,7 +60,7 @@ const Group = new Schema({
|
|
|
43
60
|
internalAttributes: Array,
|
|
44
61
|
autoprovision: Boolean,
|
|
45
62
|
expressionLanguage: String,
|
|
46
|
-
explicitAttrs:
|
|
63
|
+
explicitAttrs: ExplicitAttrsType,
|
|
47
64
|
defaultEntityNameConjunction: String,
|
|
48
65
|
ngsiVersion: String
|
|
49
66
|
});
|
|
@@ -55,3 +72,4 @@ function load(db) {
|
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
module.exports.load = load;
|
|
75
|
+
module.exports.ExplicitAttrsType = ExplicitAttrsType;
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
* Modified by: Daniel Calvo - ATOS Research & Innovation
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
const config = require('../commonConfig');
|
|
27
26
|
const utils = require('./pluginUtils');
|
|
28
27
|
/* eslint-disable no-unused-vars */
|
|
29
28
|
const logger = require('logops');
|
|
@@ -73,10 +72,7 @@ function extractAllMappings(typeInformation) {
|
|
|
73
72
|
function applyAlias(mappings) {
|
|
74
73
|
return function aliasApplier(attribute) {
|
|
75
74
|
if (mappings.direct[attribute.name]) {
|
|
76
|
-
|
|
77
|
-
/*jshint camelcase: false */
|
|
78
|
-
attribute.object_id = attribute.name; // inverse not usefull due to collision
|
|
79
|
-
}
|
|
75
|
+
attribute.object_id = attribute.name;
|
|
80
76
|
attribute.metadata = mappings.metadata[attribute.name];
|
|
81
77
|
attribute.type = mappings.types[attribute.name];
|
|
82
78
|
attribute.name = mappings.direct[attribute.name];
|
|
@@ -93,14 +89,11 @@ function applyAlias(mappings) {
|
|
|
93
89
|
*/
|
|
94
90
|
function updateAttribute(entity, typeInformation, callback) {
|
|
95
91
|
const mappings = extractAllMappings(typeInformation);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} else {
|
|
102
|
-
entity.contextElements[0].attributes = entity.contextElements[0].attributes.map(applyAlias(mappings));
|
|
103
|
-
}
|
|
92
|
+
|
|
93
|
+
let attsArray = utils.extractAttributesArrayFromNgsi2Entity(entity);
|
|
94
|
+
attsArray = attsArray.map(applyAlias(mappings));
|
|
95
|
+
entity = utils.createNgsi2Entity(entity.id, entity.type, attsArray, true);
|
|
96
|
+
ngsiUtils.castJsonNativeAttributes(entity);
|
|
104
97
|
|
|
105
98
|
callback(null, entity, typeInformation);
|
|
106
99
|
}
|
|
@@ -33,7 +33,6 @@ const deviceService = require('../services/devices/deviceService');
|
|
|
33
33
|
const context = {
|
|
34
34
|
op: 'IoTAgentNGSI.BidirectionalPlugin'
|
|
35
35
|
};
|
|
36
|
-
const config = require('../commonConfig');
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* Extract a list of all the bidirectional attributes (those containing reverse expressions) from a device object.
|
|
@@ -98,21 +97,6 @@ function extractVariables(item) {
|
|
|
98
97
|
* @param {Array} attributeList List of active attributes for subscription.
|
|
99
98
|
*/
|
|
100
99
|
function sendSubscriptions(device, attributeList, callback) {
|
|
101
|
-
function sendSingleSubscriptionNgsi1(item, innerCb) {
|
|
102
|
-
const variables = extractVariables(item);
|
|
103
|
-
|
|
104
|
-
subscriptions.subscribe(device, [item.name], variables, function handleSubscription(error, subId) {
|
|
105
|
-
if (error) {
|
|
106
|
-
innerCb(error);
|
|
107
|
-
} else {
|
|
108
|
-
innerCb(null, {
|
|
109
|
-
id: subId,
|
|
110
|
-
triggers: [item.name]
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
100
|
function sendSingleSubscriptionNgsi2(item, innerCb) {
|
|
117
101
|
const variables = extractVariables(item);
|
|
118
102
|
|
|
@@ -130,11 +114,7 @@ function sendSubscriptions(device, attributeList, callback) {
|
|
|
130
114
|
|
|
131
115
|
logger.debug(context, 'Sending bidirectionality subscriptions for device [%s]', device.id);
|
|
132
116
|
|
|
133
|
-
|
|
134
|
-
async.map(attributeList, sendSingleSubscriptionNgsi2, callback);
|
|
135
|
-
} else {
|
|
136
|
-
async.map(attributeList, sendSingleSubscriptionNgsi1, callback);
|
|
137
|
-
}
|
|
117
|
+
async.map(attributeList, sendSingleSubscriptionNgsi2, callback);
|
|
138
118
|
}
|
|
139
119
|
|
|
140
120
|
/**
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
const Parser = require('jison').Parser;
|
|
29
29
|
const errors = require('../errors');
|
|
30
30
|
const logger = require('logops');
|
|
31
|
-
const
|
|
31
|
+
const fillService = require('../services/common/domain').fillService;
|
|
32
32
|
const _ = require('underscore');
|
|
33
|
-
|
|
33
|
+
let logContext = {
|
|
34
34
|
op: 'IoTAgentNGSI.Expression'
|
|
35
35
|
};
|
|
36
36
|
const grammar = {
|
|
37
37
|
lex: {
|
|
38
38
|
rules: [
|
|
39
39
|
['\\s+', '/* skip whitespace */'],
|
|
40
|
-
['@[a-zA-Z0-
|
|
40
|
+
['@[a-zA-Z0-9_]+\\b', 'return "VARIABLE";'],
|
|
41
41
|
['[0-9]+(?:\\.[0-9]+)?\\b', 'return "NUMBER";'],
|
|
42
42
|
['\\*', 'return "*";'],
|
|
43
43
|
['\\/', 'return "/";'],
|
|
@@ -157,6 +157,7 @@ function processExpression(context) {
|
|
|
157
157
|
|
|
158
158
|
/* eslint-disable-next-line no-unused-vars */
|
|
159
159
|
function applyExpression(expression, context, typeInformation) {
|
|
160
|
+
logContext = fillService(logContext, typeInformation);
|
|
160
161
|
const expressionList = expression.match(/\$\{.*?\}/g) || [];
|
|
161
162
|
const substitutions = expressionList.map(processExpression(context));
|
|
162
163
|
let expressionResult = expression;
|
|
@@ -192,7 +193,7 @@ function expressionApplier(context, typeInformation) {
|
|
|
192
193
|
};
|
|
193
194
|
|
|
194
195
|
/*jshint camelcase: false */
|
|
195
|
-
if (
|
|
196
|
+
if (attribute.object_id) {
|
|
196
197
|
newAttribute.object_id = attribute.object_id;
|
|
197
198
|
}
|
|
198
199
|
|
|
@@ -215,14 +216,14 @@ function expressionApplier(context, typeInformation) {
|
|
|
215
216
|
function contextAvailable(expression, context) {
|
|
216
217
|
let error;
|
|
217
218
|
try {
|
|
218
|
-
const variablesList = expression.match(/@[a-zA-Z0-
|
|
219
|
+
const variablesList = expression.match(/@[a-zA-Z0-9_]+/g) || [];
|
|
219
220
|
const variables = variablesList.map(function (item) {
|
|
220
221
|
return item.substr(1);
|
|
221
222
|
});
|
|
222
223
|
const keys = Object.keys(context);
|
|
223
224
|
let validContext = _.difference(variables, keys).length === 0;
|
|
224
225
|
if (!validContext) {
|
|
225
|
-
logger.
|
|
226
|
+
logger.info(
|
|
226
227
|
logContext,
|
|
227
228
|
'For expression "[%s]" context "[%j]" does not have element to match',
|
|
228
229
|
expression,
|