iotagent-node-lib 4.5.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/.github/workflows/ci.yml +0 -1
  2. package/Changelog +12 -0
  3. package/README.md +67 -272
  4. package/config.js +3 -1
  5. package/doc/README.md +1 -1
  6. package/doc/admin.md +40 -18
  7. package/doc/api.md +532 -136
  8. package/doc/deprecated.md +4 -0
  9. package/doc/devel/architecture.md +5 -135
  10. package/doc/devel/development.md +224 -12
  11. package/doc/getting-started.md +114 -53
  12. package/doc/requirements.txt +1 -1
  13. package/doc/roadmap.md +5 -5
  14. package/docker/Mosquitto/Dockerfile +2 -2
  15. package/docker/Mosquitto/README.md +14 -11
  16. package/lib/commonConfig.js +21 -2
  17. package/lib/constants.js +3 -0
  18. package/lib/fiware-iotagent-lib.js +12 -15
  19. package/lib/jexlTranformsMap.js +3 -1
  20. package/lib/model/Command.js +2 -2
  21. package/lib/model/Device.js +7 -3
  22. package/lib/model/Group.js +5 -3
  23. package/lib/model/dbConn.js +53 -115
  24. package/lib/services/commands/commandRegistryMongoDB.js +115 -75
  25. package/lib/services/common/alarmManagement.js +3 -0
  26. package/lib/services/common/iotManagerService.js +3 -1
  27. package/lib/services/devices/deviceRegistryMemory.js +36 -0
  28. package/lib/services/devices/deviceRegistryMongoDB.js +160 -87
  29. package/lib/services/devices/deviceService.js +33 -3
  30. package/lib/services/devices/devices-NGSI-v2.js +6 -1
  31. package/lib/services/groups/groupRegistryMongoDB.js +120 -83
  32. package/lib/services/groups/groupService.js +1 -1
  33. package/lib/services/ngsi/entities-NGSI-LD.js +320 -570
  34. package/lib/services/ngsi/entities-NGSI-v2.js +51 -3
  35. package/lib/services/ngsi/ngsiService.js +34 -1
  36. package/lib/services/northBound/deviceGroupAdministrationServer.js +42 -6
  37. package/lib/services/northBound/deviceProvisioningServer.js +12 -4
  38. package/lib/services/northBound/northboundServer.js +2 -0
  39. package/lib/services/stats/statsRegistry.js +128 -101
  40. package/lib/templates/createDevice.json +0 -24
  41. package/lib/templates/createDeviceLax.json +0 -23
  42. package/lib/templates/deviceGroup.json +1 -25
  43. package/lib/templates/updateDevice.json +12 -24
  44. package/lib/templates/updateDeviceLax.json +12 -23
  45. package/package.json +5 -5
  46. package/scripts/legacy_expression_tool/README.md +0 -1
  47. package/test/functional/README.md +22 -17
  48. package/test/functional/config-test.js +3 -2
  49. package/test/functional/functional-tests-runner.js +9 -4
  50. package/test/functional/functional-tests.js +4 -4
  51. package/test/functional/testCases.js +245 -4
  52. package/test/functional/testUtils.js +2 -2
  53. package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -13
  54. package/test/unit/examples/groupProvisioningRequests/multipleConfigGroupsCreation.json +44 -0
  55. package/test/unit/examples/groupProvisioningRequests/provisionDuplicateConfigGroup.json +35 -0
  56. package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroup.json +36 -0
  57. package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroupAlternate.json +36 -0
  58. package/test/unit/examples/groupProvisioningRequests/provisionFullGroup.json +1 -0
  59. package/test/unit/general/config-multi-core-test.js +1 -2
  60. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +5 -4
  61. package/test/unit/general/deviceService-test.js +106 -3
  62. package/test/unit/general/statistics-service_test.js +1 -74
  63. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +6 -5
  64. package/test/unit/mongodb/mongodb-configGroup-registry-test.js +452 -0
  65. package/test/unit/mongodb/mongodb-connectionoptions-test.js +9 -42
  66. package/test/unit/mongodb/mongodb-group-registry-test.js +34 -33
  67. package/test/unit/mongodb/mongodb-service-registry-test.js +477 -0
  68. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +4 -4
  69. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin2.json +22 -22
  70. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +4 -4
  71. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +14 -15
  72. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin1.json +23 -23
  73. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +0 -5
  74. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin4.json +11 -16
  75. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +23 -28
  76. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +8 -13
  77. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
  78. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +24 -29
  79. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +12 -17
  80. package/test/unit/ngsi-ld/examples/contextRequests/updateContextStaticLinkedAttributes.json +12 -10
  81. package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -104
  82. package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +1 -2
  83. package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +4 -5
  84. package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +0 -4
  85. package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +8 -5
  86. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +42 -41
  87. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +11 -10
  88. package/test/unit/ngsiv2/general/deviceService-test.js +98 -4
  89. package/test/unit/ngsiv2/general/https-support-test.js +1 -1
  90. package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +195 -0
  91. package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +4 -3
  92. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +6 -5
  93. package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +17 -16
  94. package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +10 -18
  95. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +21 -20
  96. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +8 -7
  97. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +12 -11
  98. package/test/unit/ngsiv2/plugins/custom-plugin_test.js +3 -2
  99. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +28 -27
  100. package/test/unit/ngsiv2/provisioning/device-group-api-test.js +265 -4
  101. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +12 -11
  102. package/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js +1190 -0
  103. package/test/unit/ngsiv2/provisioning/device-registration_test.js +5 -4
  104. package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +6 -9
  105. package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -1
  106. package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +5 -4
  107. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +8 -7
  108. package/test/unit/statsRegistry/openmetrics-test.js +167 -0
  109. package/lib/templates/queryContext.json +0 -25
  110. package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +0 -35
  111. package/test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json +0 -17
  112. package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +0 -31
  113. package/test/unit/general/statistics-persistence_test.js +0 -121
  114. package/test/unit/ngsi-ld/examples/contextRequests/createBidirectionalDevice.json +0 -17
  115. package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +0 -12
  116. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
  117. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithDatasetId.json +0 -21
  118. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -17
  119. package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -23
  120. package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +0 -132
  121. package/test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json +0 -8
  122. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
  123. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -19
  124. package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -24
@@ -49,7 +49,8 @@ const iotAgentConfig = {
49
49
  service: 'smartgondor',
50
50
  subservice: 'gardens',
51
51
  providerUrl: 'http://smartgondor.com',
52
- explicitAttrs: false
52
+ explicitAttrs: false,
53
+ useCBflowControl: true
53
54
  };
54
55
 
55
56
  describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
@@ -74,7 +75,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
74
75
  contextBrokerMock
75
76
  .matchHeader('fiware-service', 'smartgondor')
76
77
  .matchHeader('fiware-servicepath', '/gardens')
77
- .post('/v2/entities?options=upsert')
78
+ .post('/v2/entities?options=upsert,flowControl')
78
79
  .reply(204);
79
80
 
80
81
  iotAgentLib.clearAll(done);
@@ -419,7 +420,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
419
420
  .matchHeader('fiware-service', 'smartgondor')
420
421
  .matchHeader('fiware-servicepath', '/gardens')
421
422
  .post(
422
- '/v2/entities?options=upsert',
423
+ '/v2/entities?options=upsert,flowControl',
423
424
  utils.readExampleFile(
424
425
  './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json'
425
426
  )
@@ -491,7 +492,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
491
492
  .matchHeader('fiware-service', 'smartgondor')
492
493
  .matchHeader('fiware-servicepath', '/gardens')
493
494
  .post(
494
- '/v2/entities?options=upsert',
495
+ '/v2/entities?options=upsert,flowControl',
495
496
  utils.readExampleFile(
496
497
  './test/unit/ngsiv2/examples/' +
497
498
  'contextRequests/createStaticAttributesProvisionDevice.json'
@@ -557,7 +558,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
557
558
  .matchHeader('fiware-service', 'smartgondor')
558
559
  .matchHeader('fiware-servicepath', '/gardens')
559
560
  .post(
560
- '/v2/entities?options=upsert',
561
+ '/v2/entities?options=upsert,flowControl',
561
562
  utils.readExampleFile(
562
563
  './test/unit/ngsiv2/examples/' +
563
564
  'contextRequests/createStaticAttributesProvisionDevice.json'
@@ -631,7 +632,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
631
632
  .matchHeader('fiware-service', 'smartgondor')
632
633
  .matchHeader('fiware-servicepath', '/gardens')
633
634
  .post(
634
- '/v2/entities?options=upsert',
635
+ '/v2/entities?options=upsert,flowControl',
635
636
  utils.readExampleFile(
636
637
  './test/unit/ngsiv2/examples/' +
637
638
  'contextRequests/createStaticAttributesProvisionDevice2.json'
@@ -700,7 +701,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
700
701
  .matchHeader('fiware-service', 'smartgondor')
701
702
  .matchHeader('fiware-servicepath', '/gardens')
702
703
  .post(
703
- '/v2/entities?options=upsert',
704
+ '/v2/entities?options=upsert,flowControl',
704
705
  utils.readExampleFile(
705
706
  './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice4.json'
706
707
  )
@@ -772,7 +773,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
772
773
  .matchHeader('fiware-service', 'smartgondor')
773
774
  .matchHeader('fiware-servicepath', '/gardens')
774
775
  .post(
775
- '/v2/entities?options=upsert',
776
+ '/v2/entities?options=upsert,flowControl',
776
777
  utils.readExampleFile(
777
778
  './test/unit/ngsiv2/examples/' +
778
779
  'contextRequests/createStaticAttributesProvisionDevice3.json'
@@ -977,7 +978,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
977
978
  nock.cleanAll();
978
979
  contextBrokerMock = nock('http://192.168.1.1:1026')
979
980
  .post(
980
- '/v2/entities?options=upsert',
981
+ '/v2/entities?options=upsert,flowControl',
981
982
  utils.readExampleFile(
982
983
  './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json'
983
984
  )
@@ -986,7 +987,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
986
987
 
987
988
  contextBrokerMock
988
989
  .post(
989
- '/v2/entities?options=upsert',
990
+ '/v2/entities?options=upsert,flowControl',
990
991
  utils.readExampleFile(
991
992
  './test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json'
992
993
  )
@@ -1137,7 +1138,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
1137
1138
  contextBrokerMock
1138
1139
  .matchHeader('fiware-service', 'smartgondor')
1139
1140
  .matchHeader('fiware-servicepath', '/gardens')
1140
- .post('/v2/entities?options=upsert')
1141
+ .post('/v2/entities?options=upsert,flowControl')
1141
1142
  .reply(204);
1142
1143
 
1143
1144
  done();