iotagent-node-lib 4.8.0 → 4.10.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 +10 -9
  2. package/.nyc_output/e4b1fe20-197e-4221-9f8d-6db65ff234b2.json +1 -0
  3. package/.nyc_output/processinfo/e4b1fe20-197e-4221-9f8d-6db65ff234b2.json +1 -0
  4. package/.nyc_output/processinfo/index.json +1 -0
  5. package/Changelog +791 -0
  6. package/config.js +2 -1
  7. package/doc/admin.md +20 -4
  8. package/doc/api.md +34 -4
  9. package/doc/devel/northboundinteractions.md +200 -112
  10. package/lib/commonConfig.js +16 -3
  11. package/lib/model/Device.js +3 -1
  12. package/lib/model/Group.js +2 -1
  13. package/lib/services/common/domain.js +4 -3
  14. package/lib/services/common/iotManagerService.js +2 -1
  15. package/lib/services/devices/deviceRegistryMongoDB.js +5 -1
  16. package/lib/services/devices/deviceService.js +17 -1
  17. package/lib/services/devices/devices-NGSI-LD.js +4 -4
  18. package/lib/services/devices/devices-NGSI-mixed.js +16 -0
  19. package/lib/services/devices/devices-NGSI-v2.js +123 -10
  20. package/lib/services/devices/registrationUtils.js +97 -30
  21. package/lib/services/groups/groupRegistryMongoDB.js +2 -1
  22. package/lib/services/ngsi/entities-NGSI-LD.js +69 -13
  23. package/lib/services/ngsi/ngsiService.js +3 -1
  24. package/lib/services/ngsi/subscription-NGSI-LD.js +2 -2
  25. package/lib/services/ngsi/subscription-NGSI-mixed.js +3 -3
  26. package/lib/services/ngsi/subscription-NGSI-v2.js +20 -6
  27. package/lib/services/ngsi/subscriptionService.js +2 -2
  28. package/lib/services/northBound/contextServer-NGSI-LD.js +5 -3
  29. package/lib/services/northBound/deviceProvisioningServer.js +6 -3
  30. package/lib/services/northBound/northboundServer.js +1 -1
  31. package/lib/services/northBound/restUtils.js +6 -2
  32. package/lib/templates/updateDevice.json +12 -0
  33. package/lib/templates/updateDeviceLax.json +4 -0
  34. package/package.json +2 -2
  35. package/test/functional/config-test.js +1 -1
  36. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -2
  37. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -1
  38. package/test/unit/ngsi-ld/examples/contextRequests/createDatetimeProvisionedDevice.json +1 -4
  39. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json +3 -12
  40. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceMultientity.json +3 -12
  41. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic.json +6 -24
  42. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +1 -4
  43. package/test/unit/ngsi-ld/examples/contextRequests/updateContext1.json +1 -4
  44. package/test/unit/ngsi-ld/examples/contextRequests/updateContext3WithStatic.json +1 -4
  45. package/test/unit/ngsi-ld/examples/contextRequests/updateContext4.json +1 -4
  46. package/test/unit/ngsi-ld/examples/contextRequests/updateContext5.json +1 -4
  47. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +1 -4
  48. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
  49. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +4 -2
  50. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin9.json +1 -4
  51. package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandError.json +3 -9
  52. package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandExpired.json +13 -19
  53. package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandFinish.json +13 -19
  54. package/test/unit/ngsi-ld/examples/contextRequests/updateContextCommandStatus1.json +4 -9
  55. package/test/unit/ngsi-ld/examples/contextRequests/updateContextCompressTimestamp1.json +1 -4
  56. package/test/unit/ngsi-ld/examples/contextRequests/updateContextCompressTimestamp2.json +1 -4
  57. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +1 -4
  58. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin2.json +2 -8
  59. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +1 -4
  60. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4.json +2 -8
  61. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +3 -12
  62. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin6.json +3 -5
  63. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +1 -4
  64. package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +1 -4
  65. package/test/unit/ngsi-ld/examples/contextRequests/updateContextJsonProperty.json +13 -0
  66. package/test/unit/ngsi-ld/examples/contextRequests/updateContextListProperty.json +14 -0
  67. package/test/unit/ngsi-ld/examples/contextRequests/updateContextListRelationship.json +14 -0
  68. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin1.json +2 -8
  69. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin2.json +2 -8
  70. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin3.json +3 -8
  71. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin4.json +1 -4
  72. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +2 -8
  73. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +2 -8
  74. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +2 -8
  75. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -4
  76. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -4
  77. package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -8
  78. package/test/unit/ngsi-ld/examples/contextRequests/updateContextRelationship.json +11 -0
  79. package/test/unit/ngsi-ld/examples/contextRequests/updateContextValueType1.json +51 -0
  80. package/test/unit/ngsi-ld/examples/contextRequests/updateContextValueType2.json +65 -0
  81. package/test/unit/ngsi-ld/examples/contextRequests/updateContextVocabProperty.json +11 -0
  82. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionCommands1.json +2 -8
  83. package/test/unit/ngsi-ld/examples/contextRequests/updateProvisionDeviceStatic.json +1 -4
  84. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
  85. package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
  86. package/test/unit/ngsi-ld/general/startup-test.js +3 -0
  87. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +1 -1
  88. package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +71 -1
  89. package/test/unit/ngsi-ld/ngsiService/attributeTypes-test.js +293 -0
  90. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +6 -6
  91. package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +0 -10
  92. package/test/unit/ngsi-ld/ngsiService/value-types-test.js +221 -0
  93. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands.json +24 -0
  94. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands2.json +24 -0
  95. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands3.json +24 -0
  96. package/test/unit/ngsiv2/examples/contextAvailabilityRequests/subscribeIoTAgentCommands4.json +24 -0
  97. package/test/unit/ngsiv2/examples/contextRequests/updateEntity.json +5 -0
  98. package/test/unit/ngsiv2/examples/contextRequests/updateEntity2.json +5 -0
  99. package/test/unit/ngsiv2/examples/contextRequests/updateEntity2b.json +7 -0
  100. package/test/unit/ngsiv2/examples/contextRequests/updateEntity3.json +5 -0
  101. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest.json +4 -2
  102. package/test/unit/ngsiv2/examples/subscriptionRequests/simpleSubscriptionRequest2.json +4 -2
  103. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
  104. package/test/unit/ngsiv2/general/https-support-test.js +1 -1
  105. package/test/unit/ngsiv2/lazyAndCommands/command-test.js +245 -2
  106. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast1.json +0 -11
  107. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast10.json +0 -14
  108. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast2.json +0 -11
  109. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast3.json +0 -11
  110. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast4.json +0 -11
  111. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast5.json +0 -7
  112. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast6.json +0 -17
  113. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast7.json +0 -19
  114. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast8.json +0 -14
  115. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAutocast9.json +0 -14
  116. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -109
  117. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +0 -8
  118. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +0 -8
  119. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +0 -8
  120. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +0 -8
  121. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +0 -8
  122. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +0 -8
  123. package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +0 -8
  124. /package/test/unit/ngsi-ld/examples/contextRequests/{updateContextLanguageProperties1.json → updateContextLanguageProperty.json} +0 -0
@@ -1,11 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "id": "urn:ngsi-ld:Light:light1",
5
- "pressure": {
6
- "type": "Property",
7
- "value": 23
8
- },
9
- "type": "Light"
10
- }
11
- ]
@@ -1,14 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "date": {
5
- "type": "Property",
6
- "value": {
7
- "@type": "Date",
8
- "@value": "2016-04-30"
9
- }
10
- },
11
- "id": "urn:ngsi-ld:Light:light1",
12
- "type": "Light"
13
- }
14
- ]
@@ -1,11 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "id": "urn:ngsi-ld:Light:light1",
5
- "temperature": {
6
- "type": "Property",
7
- "value": 14.4
8
- },
9
- "type": "Light"
10
- }
11
- ]
@@ -1,11 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "id": "urn:ngsi-ld:Light:light1",
5
- "status": {
6
- "type": "Property",
7
- "value": true
8
- },
9
- "type": "Light"
10
- }
11
- ]
@@ -1,11 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "id": "urn:ngsi-ld:Light:light1",
5
- "status": {
6
- "type": "Property",
7
- "value": false
8
- },
9
- "type": "Light"
10
- }
11
- ]
@@ -1,7 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "id": "urn:ngsi-ld:Light:light1",
5
- "type": "Light"
6
- }
7
- ]
@@ -1,17 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "id": "urn:ngsi-ld:Light:light1",
5
- "tags": {
6
- "type": "Property",
7
- "value": {
8
- "@type": "Array",
9
- "@value": [
10
- "iot",
11
- "device"
12
- ]
13
- }
14
- },
15
- "type": "Light"
16
- }
17
- ]
@@ -1,19 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "configuration": {
5
- "type": "Property",
6
- "value": {
7
- "@type": "Object",
8
- "@value": {
9
- "firmware": {
10
- "hash": "cf23df2207d99a74fbe169e3eba035e633b65d94",
11
- "version": "1.1.0"
12
- }
13
- }
14
- }
15
- },
16
- "id": "urn:ngsi-ld:Light:light1",
17
- "type": "Light"
18
- }
19
- ]
@@ -1,14 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "time": {
5
- "type": "Property",
6
- "value": {
7
- "@type": "Time",
8
- "@value": "14:59:46"
9
- }
10
- },
11
- "id": "urn:ngsi-ld:Light:light1",
12
- "type": "Light"
13
- }
14
- ]
@@ -1,14 +0,0 @@
1
- [
2
- {
3
- "@context": "http://context.json-ld",
4
- "dateTime": {
5
- "type": "Property",
6
- "value": {
7
- "@type": "DateTime",
8
- "@value": "2016-04-30T00:00:00.000Z"
9
- }
10
- },
11
- "id": "urn:ngsi-ld:Light:light1",
12
- "type": "Light"
13
- }
14
- ]
@@ -1,109 +0,0 @@
1
- /*
2
- * Copyright 2022 Telefonica Investigación y Desarrollo, S.A.U
3
- *
4
- * This file is part of fiware-iotagent-lib
5
- *
6
- * fiware-iotagent-lib is free software: you can redistribute it and/or
7
- * modify it under the terms of the GNU Affero General Public License as
8
- * published by the Free Software Foundation, either version 3 of the License,
9
- * or (at your option) any later version.
10
- *
11
- * fiware-iotagent-lib is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
- * See the GNU Affero General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Affero General Public
17
- * License along with fiware-iotagent-lib.
18
- * If not, see http://www.gnu.org/licenses/.
19
- *
20
- * For those usages not covered by the GNU Affero General Public License
21
- * please contact with::[contacto@tid.es]
22
- *
23
- * Modified by: Daniel Calvo - ATOS Research & Innovation
24
- */
25
-
26
- /* eslint-disable no-unused-vars */
27
-
28
- const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
29
- const utils = require('../../../tools/utils');
30
- const request = utils.request;
31
- const should = require('should');
32
- const logger = require('logops');
33
- const nock = require('nock');
34
- let contextBrokerMock;
35
- const iotAgentConfig = {
36
- contextBroker: {
37
- host: '192.168.1.1',
38
- port: '1026',
39
- ngsiVersion: 'ld',
40
- jsonLdContext: 'http://context.json-ld'
41
- },
42
- server: {
43
- port: 4041,
44
- host: 'localhost'
45
- },
46
- types: {
47
- Light: {
48
- commands: [],
49
- type: 'Light',
50
- active: [
51
- {
52
- name: 'name',
53
- type: 'LanguageProperty'
54
- }
55
- ]
56
- }
57
- },
58
- service: 'smartgondor',
59
- subservice: 'gardens',
60
- providerUrl: 'http://smartgondor.com'
61
- };
62
-
63
- describe('NGSI-LD - LanguageProperty test', function () {
64
- beforeEach(function () {
65
- logger.setLevel('FATAL');
66
- });
67
-
68
- afterEach(function (done) {
69
- iotAgentLib.deactivate(done);
70
- });
71
-
72
- describe('When the IoT Agent receives new exonym from a device name with LanguageProperty type and a JSON object', function () {
73
- const values = [
74
- {
75
- name: 'name',
76
- type: 'LanguageProperty',
77
- value: {
78
- el: 'Κωνσταντινούπολις',
79
- en: 'Constantinople',
80
- tr: 'İstanbul'
81
- }
82
- }
83
- ];
84
-
85
- beforeEach(function (done) {
86
- nock.cleanAll();
87
-
88
- contextBrokerMock = nock('http://192.168.1.1:1026')
89
- .matchHeader('fiware-service', 'smartgondor')
90
- .post(
91
- '/ngsi-ld/v1/entityOperations/upsert/?options=update',
92
- utils.readExampleFile(
93
- './test/unit/ngsi-ld/examples/contextRequests/updateContextLanguageProperties1.json'
94
- )
95
- )
96
- .reply(204);
97
-
98
- iotAgentLib.activate(iotAgentConfig, done);
99
- });
100
-
101
- it('should change the value of the corresponding attribute in the context broker', function (done) {
102
- iotAgentLib.update('light1', 'Light', '', values, function (error) {
103
- should.not.exist(error);
104
- contextBrokerMock.done();
105
- done();
106
- });
107
- });
108
- });
109
- });
@@ -1,8 +0,0 @@
1
- {
2
- "id":"light1",
3
- "type":"Light",
4
- "pressure":{
5
- "value": 23,
6
- "type": "Number"
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "id":"light1",
3
- "type":"Light",
4
- "temperature":{
5
- "value": 14.4,
6
- "type": "Number"
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "id":"light1",
3
- "type":"Light",
4
- "status": {
5
- "type": "Boolean",
6
- "value": true
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "id":"light1",
3
- "type":"Light",
4
- "status": {
5
- "type": "Boolean",
6
- "value": false
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "id":"light1",
3
- "type":"Light",
4
- "keep_alive": {
5
- "type": "None",
6
- "value": null
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "id":"light1",
3
- "type":"Light",
4
- "tags": {
5
- "type": "Array",
6
- "value": ["iot","device"]
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "id":"light1",
3
- "type":"Light",
4
- "configuration": {
5
- "type": "Object",
6
- "value": {"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}
7
- }
8
- }