iotagent-node-lib 3.3.0 → 3.4.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 (79) hide show
  1. package/README.md +10 -11
  2. package/doc/README.md +16 -0
  3. package/doc/admin.md +565 -0
  4. package/doc/api.md +9 -5
  5. package/doc/deprecated.md +16 -14
  6. package/doc/{architecture.md → devel/architecture.md} +3 -3
  7. package/doc/{Contribution.md → devel/contribution-guidelines.md} +43 -35
  8. package/doc/devel/development.md +1879 -0
  9. package/doc/{northboundinteractions.md → devel/northboundinteractions.md} +18 -33
  10. package/doc/index.md +3 -5
  11. package/docker/Mosquitto/README.md +1 -0
  12. package/lib/commonConfig.js +0 -5
  13. package/lib/fiware-iotagent-lib.js +1 -1
  14. package/lib/jexlTranformsMap.js +2 -1
  15. package/lib/request-shim.js +2 -2
  16. package/lib/services/commands/commandService.js +1 -1
  17. package/lib/services/common/genericMiddleware.js +1 -1
  18. package/lib/services/devices/deviceRegistryMemory.js +2 -2
  19. package/lib/services/devices/deviceRegistryMongoDB.js +22 -9
  20. package/lib/services/devices/deviceService.js +36 -30
  21. package/lib/services/devices/devices-NGSI-LD.js +14 -2
  22. package/lib/services/devices/devices-NGSI-mixed.js +0 -2
  23. package/lib/services/devices/devices-NGSI-v2.js +22 -100
  24. package/lib/services/groups/groupService.js +1 -1
  25. package/lib/services/ngsi/entities-NGSI-v2.js +11 -25
  26. package/lib/services/northBound/deviceProvisioningServer.js +14 -5
  27. package/mkdocs.yml +6 -11
  28. package/package.json +3 -3
  29. package/scripts/legacy_expression_tool/README.md +56 -38
  30. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -2
  31. package/test/unit/mongodb/mongodb-registry-test.js +1 -1
  32. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +66 -65
  33. package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
  34. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +8 -7
  35. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +12 -11
  36. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +41 -39
  37. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +122 -122
  38. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +28 -28
  39. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +18 -17
  40. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +7 -7
  41. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +8 -7
  42. package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +2 -0
  43. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +0 -12
  44. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +0 -4
  45. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +1 -5
  46. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +0 -12
  47. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +0 -12
  48. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +0 -4
  49. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +0 -10
  50. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +0 -4
  51. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +0 -4
  52. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +0 -4
  53. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +0 -12
  54. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +0 -4
  55. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +1 -5
  56. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +13 -12
  57. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
  58. package/test/unit/ngsiv2/general/https-support-test.js +1 -1
  59. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -8
  60. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +10 -10
  61. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +8 -103
  62. package/test/unit/ngsiv2/provisioning/device-registration_test.js +8 -6
  63. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -1
  64. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -1
  65. package/.nyc_output/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
  66. package/.nyc_output/processinfo/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
  67. package/.nyc_output/processinfo/index.json +0 -1
  68. package/doc/config-basic-example.js +0 -20
  69. package/doc/development.md +0 -285
  70. package/doc/howto.md +0 -641
  71. package/doc/installationguide.md +0 -365
  72. package/doc/operations.md +0 -127
  73. package/doc/usermanual.md +0 -900
  74. package/lib/plugins/bidirectionalData.js +0 -356
  75. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +0 -697
  76. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -536
  77. /package/doc/{NorthboundInteractions.postman_collection → devel/NorthboundInteractions.postman_collection} +0 -0
  78. /package/doc/{echo.js → devel/echo.js} +0 -0
  79. /package/doc/{finalResult.js → devel/finalResult.js} +0 -0
package/doc/api.md CHANGED
@@ -56,7 +56,7 @@
56
56
  - [Miscellaneous API](#miscellaneous-api)
57
57
  - [Log operations](#log-operations)
58
58
  - [Modify Loglevel `PUT /admin/log`](#modify-loglevel-put-adminlog)
59
- - [Retrieve log level `PUT /admin/log`](#retrieve-log-level-put-adminlog)
59
+ - [Retrieve log level `GET /admin/log`](#retrieve-log-level-get-adminlog)
60
60
  - [About operations](#about-operations)
61
61
  - [List IoTA Information `GET /iot/about`](#list-iota-information-get-iotabout)
62
62
 
@@ -183,7 +183,7 @@ All of them have the same syntax, a list of objects with the following attribute
183
183
  - **type** (mandatory): name of the type of the attribute in the target entity.
184
184
  - **metadata** (optional): additional static metadata for the attribute in the target entity. (e.g. `unitCode`)
185
185
 
186
- Some transformation plugins also allow the use of the following optional fields:
186
+ Some advanced features also allow the use of the following optional fields:
187
187
 
188
188
  - **expression**: indicates that the value of the target attribute will not be the plain value or the measurement, but
189
189
  an expression based on a combination of the reported values. See the
@@ -674,6 +674,10 @@ will check which ones contain expressions whose variables are present in the rec
674
674
  whose variables are covered, their expressions will be executed with the received values, and their values updated in
675
675
  the Context Broker.
676
676
 
677
+ If as a result of apply expression `undefined` or `null` value is obtained then any of them will not progress to entity
678
+ attribute. Have into acount that some numeric operations results (like nonexistent \* 2) are a kind of null with a
679
+ number type but NaN value, which will also not progress to entity attribute.
680
+
677
681
  E.g.: if a device with the following provisioning information is created in the IoT Agent:
678
682
 
679
683
  ```json
@@ -751,7 +755,7 @@ following to CB:
751
755
 
752
756
  ### Multientity measurement transformation support (`object_id`)
753
757
 
754
- To allow support for measurement transformation in combination with multi entity plugin, where the same attribute is
758
+ To allow support for measurement transformation in combination with multi entity feature, where the same attribute is
755
759
  generated for different entities out of different incoming attribute values (i.e. `object_id`), we introduced support
756
760
  for `object_id` in the expression context.
757
761
 
@@ -845,7 +849,7 @@ it in queries (and viceversa, receive the extended one in queries and return it
845
849
 
846
850
  ## Timestamp Processing
847
851
 
848
- The IOTA processes the entity attributes looking for a `TimeInstant` attribute. If one is found, for NGSI v2, the plugin
852
+ The IOTA processes the entity attributes looking for a `TimeInstant` attribute. If one is found, for NGSI v2, then it
849
853
  adds a `TimeInstant` attribute as metadata for every other attribute in the same request. With NGSI-LD, the Standard
850
854
  `observedAt` property-of-a-property is used instead.
851
855
 
@@ -1609,7 +1613,7 @@ _**Response code**_
1609
1613
  - `200` `OK` if successful.
1610
1614
  - `500` `SERVER ERROR` if there was any error not contemplated above.
1611
1615
 
1612
- #### Retrieve log level `PUT /admin/log`
1616
+ #### Retrieve log level `GET /admin/log`
1613
1617
 
1614
1618
  _**Response code**_
1615
1619
 
package/doc/deprecated.md CHANGED
@@ -21,9 +21,10 @@ A list of deprecated features and the version in which they were deprecated foll
21
21
  - Support to NGSI-LD v1.3 in iotagent-node-lib 2.25.0 (finally removed in 2.26.0)
22
22
  - Support groups (provision) statically defined by configuration
23
23
  - Support to in-memory registry (i.e.`deviceRegistry.type=memory`)
24
+ - eventType configuration (finally removed in 3.0.0)
24
25
  - Support to legacy expressions (finally removed in 3.2.0)
25
- - Bidirectinal pluging (to be removed in 3.4.0)
26
- - appendMode (to be removed in 3.4.0)
26
+ - Bidirectinal pluging (finally removed in 3.4.0)
27
+ - appendMode configuration (`IOTA_APPEND_MODE` env var) (finally removed in 3.4.0)
27
28
 
28
29
  The use of Node.js v14 is highly recommended.
29
30
 
@@ -43,15 +44,16 @@ information in the case you want to use old versions:
43
44
 
44
45
  The following table provides information about the last iotagent-node-lib version supporting currently removed features:
45
46
 
46
- | **Removed feature** | **Last iotagent-node-lib version supporting feature** | **That version release date** |
47
- | ---------------------- | ----------------------------------------------------- | ----------------------------- |
48
- | NGSI v1 API | 2.17.0 | August 30th, 2021 |
49
- | Support to Node.js v4 | 2.8.1 | December 19th, 2018 |
50
- | Support to Node.js v6 | 2.9.0 | May 22nd, 2019 |
51
- | Support to Node.js v8 | 2.12.0 | April 7th, 2020 |
52
- | Support to Node.js v10 | 2.15.0 | February 18th, 2021 |
53
- | Support to Node.js v12 | 2.24.0 | September 2nd, 2022 |
54
- | Support to NGSI-LD 1.3 | 2.25.0 | January 24th, 2023 |
55
- | Support to Legacy Expressions | 3.1.0 | April 25th, 2023 |
56
- | bidirrectional plugin | 3.3.0 | August 24th, 2023 |
57
- | appendMode | 3.3.0 | August 24th, 2023 |
47
+ | **Removed feature** | **Last iotagent-node-lib version supporting feature** | **That version release date** |
48
+ | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------- |
49
+ | NGSI v1 API | 2.17.0 | August 30th, 2021 |
50
+ | Support to Node.js v4 | 2.8.1 | December 19th, 2018 |
51
+ | Support to Node.js v6 | 2.9.0 | May 22nd, 2019 |
52
+ | Support to Node.js v8 | 2.12.0 | April 7th, 2020 |
53
+ | Support to Node.js v10 | 2.15.0 | February 18th, 2021 |
54
+ | Support to Node.js v12 | 2.24.0 | September 2nd, 2022 |
55
+ | Support to NGSI-LD 1.3 | 2.25.0 | January 24th, 2023 |
56
+ | eventType configuration | 2.26.0 | March 15th, 2023 |
57
+ | Support to Legacy Expressions | 3.1.0 | April 25th, 2023 |
58
+ | bidirectional plugin | 3.3.0 | August 24th, 2023 |
59
+ | appendMode configuration (`IOTA_APPEND_MODE` env var) | 3.3.0 | August 24th, 2023 |
@@ -1,6 +1,6 @@
1
1
  ## Architecture
2
2
 
3
- The following section defines the archtecture and message flow which is common to all IoT Agents which use the library.
3
+ The following section defines the architecture and message flow which is common to all IoT Agents which use the library.
4
4
 
5
5
  ### Device to NGSI Mapping
6
6
 
@@ -32,7 +32,7 @@ basis preprovisioning the devices). Device measures can have three different beh
32
32
  The following sequence diagram shows the different NGSI interactions an IoT Agent makes with the Context Broker,
33
33
  explained in the following subsections (using the example of a OMA Lightweight M2M device).
34
34
 
35
- ![General ](./img/ngsiInteractions.png "NGSI Interactions")
35
+ ![General ](../img/ngsiInteractions.png 'NGSI Interactions')
36
36
 
37
37
  Be aware that the IoT Agents are only required to support NGSI10 operations `updateContext` and `queryContext` in their
38
38
  standard formats (currently in JSON format; XML deprecated) but will not answer to NGSI9 operations (or NGSI convenience
@@ -254,7 +254,7 @@ the concrete IoT Agent implementations will be to map between the native device
254
254
  The following figure offers a graphical example of how a COAP IoT Agent work, ordered from the registration of the
255
255
  device to a command update to the device.
256
256
 
257
- ![General ](./img/iotAgentLib.png "Architecture Overview")
257
+ ![General ](../img/iotAgentLib.png 'Architecture Overview')
258
258
 
259
259
  ### The `TimeInstant` element
260
260
 
@@ -4,21 +4,22 @@
4
4
 
5
5
  Before we get started, here are a few things we expect from you (and that you should expect from others):
6
6
 
7
- * Be kind and thoughtful in your conversations around this project. We all come from different backgrounds and
8
- projects, which means we likely have different perspectives on "how open source is done." Try to listen to others
9
- rather than convince them that your way is correct.
10
- * Please ensure that your contribution passes all tests. If there are test failures, you will need to address them
11
- before we can merge your contribution.
12
- * When adding content, please consider if it is widely valuable. Please don't add references or links to things you or
13
- your employer have created as others will do so if they appreciate it.
14
- * When reporting a vulnerability on the software, please, put in contact with IoT Agent Node Lib repository maintainers in order to discuss it
15
- in a private way.
7
+ - Be kind and thoughtful in your conversations around this project. We all come from different backgrounds and
8
+ projects, which means we likely have different perspectives on "how open source is done." Try to listen to others
9
+ rather than convince them that your way is correct.
10
+ - Please ensure that your contribution passes all tests. If there are test failures, you will need to address them
11
+ before we can merge your contribution.
12
+ - When adding content, please consider if it is widely valuable. Please don't add references or links to things you or
13
+ your employer have created as others will do so if they appreciate it.
14
+ - When reporting a vulnerability on the software, please, put in contact with IoT Agent Node Lib repository
15
+ maintainers in order to discuss it in a private way.
16
16
 
17
17
  ## How to contribute
18
18
 
19
- If you'd like to contribute, start by searching through the [issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
20
- [pull requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) to see whether someone else has raised a similar idea or
21
- question.
19
+ If you'd like to contribute, start by searching through the
20
+ [issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
21
+ [pull requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) to see whether someone else has raised a
22
+ similar idea or question.
22
23
 
23
24
  If you don't see your idea listed, and you think it fits into the goals of this guide, do one of the following:
24
25
 
@@ -28,36 +29,43 @@ If you don't see your idea listed, and you think it fits into the goals of this
28
29
 
29
30
  ### Pull Request protocol
30
31
 
31
- As explained in ([FIWARE Contribution Requirements](https://fiware-requirements.readthedocs.io/en/latest))
32
- contributions are done using a pull request (PR). The detailed "protocol" used in such PR is described below:
33
-
34
- * Direct commits to master branch (even single-line modifications) are not allowed. Every modification has to come as a PR
35
- * In case the PR is implementing/fixing a numbered issue, the issue number has to be referenced in the body of the PR at creation time
36
- * Anybody is welcome to provide comments to the PR (either direct comments or using the review feature offered by GitHub)
37
- * Use *code line comments* instead of *general comments*, for traceability reasons (see comments lifecycle below)
38
- * Comments lifecycle
39
- * Comment is created, initiating a *comment thread*
40
- * New comments can be added as responses to the original one, starting a discussion
41
- * After discussion, the comment thread ends in one of the following ways:
42
- * `Fixed in <commit hash>` in case the discussion involves a fix in the PR branch (which commit hash is
43
- included as reference)
44
- * `NTC`, if finally nothing needs to be done (NTC = Nothing To Change)
45
- * PR can be merged when the following conditions are met:
46
- * All comment threads are closed
47
- * All the participants in the discussion have provided a `LGTM` general comment (LGTM = Looks good to me)
48
- * Self-merging is not allowed (except in rare and justified circumstances)
32
+ As explained in ([FIWARE Contribution Requirements](https://fiware-requirements.readthedocs.io/en/latest)) contributions
33
+ are done using a pull request (PR). The detailed "protocol" used in such PR is described below:
34
+
35
+ - Direct commits to master branch (even single-line modifications) are not allowed. Every modification has to come as
36
+ a PR
37
+ - In case the PR is implementing/fixing a numbered issue, the issue number has to be referenced in the body of the PR
38
+ at creation time
39
+ - Anybody is welcome to provide comments to the PR (either direct comments or using the review feature offered by
40
+ GitHub)
41
+ - Use _code line comments_ instead of _general comments_, for traceability reasons (see comments lifecycle below)
42
+ - Comments lifecycle
43
+ - Comment is created, initiating a _comment thread_
44
+ - New comments can be added as responses to the original one, starting a discussion
45
+ - After discussion, the comment thread ends in one of the following ways:
46
+ - `Fixed in <commit hash>` in case the discussion involves a fix in the PR branch (which commit hash is
47
+ included as reference)
48
+ - `NTC`, if finally nothing needs to be done (NTC = Nothing To Change)
49
+ - PR can be merged when the following conditions are met:
50
+ - All comment threads are closed
51
+ - All the participants in the discussion have provided a `LGTM` general comment (LGTM = Looks good to me)
52
+ - Self-merging is not allowed (except in rare and justified circumstances)
49
53
 
50
54
  Some additional remarks to take into account when contributing with new PRs:
51
55
 
52
- * PR must include not only code contributions, but their corresponding pieces of documentation (new or modifications to existing one) and tests
53
- * PR modifications must pass full regression based on existing test (unit, functional, memory, e2e) in addition to whichever new test added due to the new functionality
54
- * PR should be of an appropriated size that makes review achievable. Too large PRs could be closed with a "please, redo the work in smaller pieces" without any further discussing
56
+ - PR must include not only code contributions, but their corresponding pieces of documentation (new or modifications
57
+ to existing one) and tests
58
+ - PR modifications must pass full regression based on existing test (unit, functional, memory, e2e) in addition to
59
+ whichever new test added due to the new functionality
60
+ - PR should be of an appropriated size that makes review achievable. Too large PRs could be closed with a "please,
61
+ redo the work in smaller pieces" without any further discussing
55
62
 
56
63
  ## Community
57
64
 
58
65
  Discussions about the Open Source Guides take place on this repository's
59
- [Issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and [Pull Requests](https://github.com/telefonicaid/iotagent-node-lib/pulls)
60
- sections. Anybody is welcome to join these conversations.
66
+ [Issues](https://github.com/telefonicaid/iotagent-node-lib/issues) and
67
+ [Pull Requests](https://github.com/telefonicaid/iotagent-node-lib/pulls) sections. Anybody is welcome to join these
68
+ conversations.
61
69
 
62
70
  Wherever possible, do not take these conversations to private channels, including contacting the maintainers directly.
63
71