iotagent-node-lib 4.4.0 → 4.6.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/README.md +67 -272
- package/config.js +2 -1
- package/doc/README.md +1 -1
- package/doc/admin.md +19 -22
- package/doc/api.md +621 -155
- package/doc/deprecated.md +4 -0
- package/doc/devel/architecture.md +5 -135
- package/doc/devel/development.md +224 -12
- package/doc/getting-started.md +114 -53
- package/doc/requirements.txt +1 -1
- package/doc/roadmap.md +5 -5
- package/docker/Mosquitto/Dockerfile +2 -2
- package/docker/Mosquitto/README.md +14 -11
- package/lib/commonConfig.js +7 -1
- package/lib/constants.js +3 -0
- package/lib/fiware-iotagent-lib.js +12 -15
- package/lib/jexlTranformsMap.js +3 -1
- package/lib/model/dbConn.js +1 -4
- package/lib/services/common/alarmManagement.js +3 -0
- package/lib/services/devices/deviceRegistryMemory.js +1 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +2 -2
- package/lib/services/devices/deviceService.js +4 -3
- package/lib/services/devices/devices-NGSI-LD.js +5 -5
- package/lib/services/devices/devices-NGSI-mixed.js +3 -3
- package/lib/services/devices/devices-NGSI-v2.js +5 -5
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +321 -571
- package/lib/services/ngsi/entities-NGSI-v2.js +348 -281
- package/lib/services/ngsi/ngsiService.js +3 -1
- package/lib/services/ngsi/subscription-NGSI-LD.js +2 -2
- package/lib/services/ngsi/subscription-NGSI-v2.js +2 -2
- package/lib/services/northBound/deviceGroupAdministrationServer.js +42 -6
- package/lib/services/northBound/deviceProvisioningServer.js +5 -5
- package/lib/services/northBound/northboundServer.js +4 -2
- package/lib/services/stats/statsRegistry.js +128 -101
- package/lib/templates/createDevice.json +0 -24
- package/lib/templates/createDeviceLax.json +0 -23
- package/lib/templates/deviceGroup.json +1 -25
- package/lib/templates/updateDevice.json +0 -24
- package/lib/templates/updateDeviceLax.json +0 -23
- package/package.json +2 -2
- package/scripts/legacy_expression_tool/README.md +0 -1
- package/test/functional/README.md +75 -47
- package/test/functional/functional-tests-runner.js +9 -4
- package/test/functional/functional-tests.js +4 -4
- package/test/functional/testCases.js +1251 -257
- package/test/functional/testUtils.js +53 -20
- package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -13
- package/test/unit/examples/deviceProvisioningRequests/updateProvisionDeviceWithApikey.json +4 -0
- package/test/unit/examples/groupProvisioningRequests/multipleConfigGroupsCreation.json +44 -0
- package/test/unit/examples/groupProvisioningRequests/provisionDuplicateConfigGroup.json +35 -0
- package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroup.json +36 -0
- package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroupAlternate.json +36 -0
- package/test/unit/general/deviceService-test.js +102 -0
- package/test/unit/general/statistics-service_test.js +1 -74
- package/test/unit/mongodb/mongodb-configGroup-registry-test.js +452 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +2 -3
- package/test/unit/mongodb/mongodb-group-registry-test.js +34 -33
- package/test/unit/mongodb/mongodb-service-registry-test.js +477 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin2.json +22 -22
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +14 -15
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin1.json +23 -23
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin4.json +11 -16
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +23 -28
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +8 -13
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +24 -29
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +12 -17
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextStaticLinkedAttributes.json +12 -10
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +0 -102
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +4 -5
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +5 -5
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +0 -4
- package/test/unit/ngsiv2/general/deviceService-test.js +94 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +195 -0
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +259 -0
- package/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js +1189 -0
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +6 -6
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +0 -4
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +35 -0
- package/test/unit/statsRegistry/openmetrics-test.js +167 -0
- package/lib/templates/queryContext.json +0 -25
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +0 -35
- package/test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json +0 -17
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +0 -31
- package/test/unit/general/statistics-persistence_test.js +0 -121
- package/test/unit/ngsi-ld/examples/contextRequests/createBidirectionalDevice.json +0 -17
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +0 -12
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithDatasetId.json +0 -21
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -17
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -23
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +0 -132
- package/test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json +0 -8
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -19
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -24
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Telefonica Investigación y Desarrollo, S.A.U
|
|
3
|
-
*
|
|
4
|
-
* This file is part of fiware-iotagent-lib
|
|
5
|
-
*
|
|
6
|
-
* fiware-iotagent-lib is free software: you can redistribute it and/or
|
|
7
|
-
* modify it under the terms of the GNU Affero General Public License as
|
|
8
|
-
* published by the Free Software Foundation, either version 3 of the License,
|
|
9
|
-
* or (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* fiware-iotagent-lib is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
14
|
-
* See the GNU Affero General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU Affero General Public
|
|
17
|
-
* License along with fiware-iotagent-lib.
|
|
18
|
-
* If not, see http://www.gnu.org/licenses/.
|
|
19
|
-
*
|
|
20
|
-
* For those usages not covered by the GNU Affero General Public License
|
|
21
|
-
* please contact with::daniel.moranjimenez@telefonica.com
|
|
22
|
-
*
|
|
23
|
-
* Modified by: Jason Fox - FIWARE Foundation
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
|
|
27
|
-
const utils = require('../../../tools/utils');
|
|
28
|
-
const should = require('should');
|
|
29
|
-
const logger = require('logops');
|
|
30
|
-
const nock = require('nock');
|
|
31
|
-
const moment = require('moment');
|
|
32
|
-
let contextBrokerMock;
|
|
33
|
-
const iotAgentConfig = {
|
|
34
|
-
contextBroker: {
|
|
35
|
-
host: '192.168.1.1',
|
|
36
|
-
port: '1026',
|
|
37
|
-
ngsiVersion: 'ld',
|
|
38
|
-
jsonLdContext: 'http://context.json-ld'
|
|
39
|
-
},
|
|
40
|
-
server: {
|
|
41
|
-
port: 4041,
|
|
42
|
-
host: 'localhost'
|
|
43
|
-
},
|
|
44
|
-
types: {
|
|
45
|
-
Light: {
|
|
46
|
-
commands: [],
|
|
47
|
-
type: 'Light',
|
|
48
|
-
lazy: [
|
|
49
|
-
{
|
|
50
|
-
name: 'temperature',
|
|
51
|
-
type: 'centigrades'
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
active: [
|
|
55
|
-
{
|
|
56
|
-
name: 'pressure',
|
|
57
|
-
type: 'Hgmm'
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
service: 'smartgondor',
|
|
63
|
-
subservice: 'gardens',
|
|
64
|
-
providerUrl: 'http://smartgondor.com'
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
describe('NGSI-LD - Timestamp processing plugin', function () {
|
|
68
|
-
beforeEach(function (done) {
|
|
69
|
-
logger.setLevel('FATAL');
|
|
70
|
-
|
|
71
|
-
iotAgentLib.activate(iotAgentConfig, function () {
|
|
72
|
-
iotAgentLib.clearAll(function () {
|
|
73
|
-
done();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
afterEach(function (done) {
|
|
79
|
-
iotAgentLib.clearAll(function () {
|
|
80
|
-
iotAgentLib.deactivate(done);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe('When an update comes with a timestamp through the plugin', function () {
|
|
84
|
-
const values = [
|
|
85
|
-
{
|
|
86
|
-
name: 'state',
|
|
87
|
-
type: 'Boolean',
|
|
88
|
-
value: true
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: 'TimeInstant',
|
|
92
|
-
type: 'DateTime',
|
|
93
|
-
value: '2016-05-30T16:25:22.304Z'
|
|
94
|
-
}
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
beforeEach(function () {
|
|
98
|
-
nock.cleanAll();
|
|
99
|
-
|
|
100
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
101
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
102
|
-
.post('/ngsi-ld/v1/entityOperations/upsert/?options=update', function (body) {
|
|
103
|
-
const expectedBody = utils.readExampleFile(
|
|
104
|
-
'./test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json'
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// Note that TimeInstant fields are not included in the json used by this mock as they are dynamic
|
|
108
|
-
// fields. The following code just checks that TimeInstant fields are present.
|
|
109
|
-
if (!body[0].state.observedAt) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const timeInstantAtt = body[0].state.observedAt;
|
|
114
|
-
if (moment(timeInstantAtt, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid) {
|
|
115
|
-
delete body[0].state.observedAt;
|
|
116
|
-
delete expectedBody[0].state.observedAt;
|
|
117
|
-
return JSON.stringify(body) === JSON.stringify(expectedBody);
|
|
118
|
-
}
|
|
119
|
-
return false;
|
|
120
|
-
})
|
|
121
|
-
.reply(204);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should return an entity with all its timestamps expanded to have separators', function (done) {
|
|
125
|
-
iotAgentLib.update('light1', 'Light', '', values, function (error) {
|
|
126
|
-
should.not.exist(error);
|
|
127
|
-
contextBrokerMock.done();
|
|
128
|
-
done();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
});
|
package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"subscriptionId": "51c0ac9ed714fb3b37d7d5a8",
|
|
3
|
-
"data": [
|
|
4
|
-
{
|
|
5
|
-
"location": {
|
|
6
|
-
"type": "geo:point",
|
|
7
|
-
"value": "12.4, -9.6",
|
|
8
|
-
"metadata": {
|
|
9
|
-
"qos": {
|
|
10
|
-
"type": "Number",
|
|
11
|
-
"value": 1
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"type": "TheLightType",
|
|
16
|
-
"id": "TheFirstLight"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"subject":{
|
|
3
|
-
"entities": [
|
|
4
|
-
{
|
|
5
|
-
"id": "TheFirstLight",
|
|
6
|
-
"type": "TheLightType"
|
|
7
|
-
}
|
|
8
|
-
],
|
|
9
|
-
"condition":{
|
|
10
|
-
"attrs":[
|
|
11
|
-
"location"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"notification":{
|
|
16
|
-
"http":{
|
|
17
|
-
"url":"http://smartgondor.com/notify"
|
|
18
|
-
},
|
|
19
|
-
"attrs":[
|
|
20
|
-
"location"
|
|
21
|
-
],
|
|
22
|
-
"attrsFormat": "normalized"
|
|
23
|
-
}
|
|
24
|
-
}
|