iotagent-node-lib 2.25.0 → 2.26.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 (33) hide show
  1. package/CHANGES_NEXT_RELEASE +0 -1
  2. package/config.js +6 -1
  3. package/doc/deprecated.md +4 -1
  4. package/doc/howto.md +8 -0
  5. package/doc/installationguide.md +18 -0
  6. package/doc/usermanual.md +77 -0
  7. package/lib/commonConfig.js +15 -1
  8. package/lib/constants.js +1 -0
  9. package/lib/fiware-iotagent-lib.js +1 -0
  10. package/lib/services/devices/deviceService.js +1 -0
  11. package/lib/services/devices/registrationUtils.js +21 -1
  12. package/lib/services/northBound/contextServer-NGSI-LD.js +221 -38
  13. package/lib/services/northBound/contextServer.js +14 -1
  14. package/lib/services/northBound/northboundServer.js +1 -0
  15. package/package.json +1 -1
  16. package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -1
  17. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent1.json +24 -14
  18. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent2.json +25 -15
  19. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent4.json +15 -5
  20. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgentCommands.json +9 -1
  21. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgentCommandsAndLazy.json +32 -0
  22. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice.json +12 -1
  23. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDevice2.json +9 -1
  24. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup.json +12 -1
  25. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup2.json +12 -1
  26. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerProvisionedDeviceWithGroup3.json +9 -1
  27. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateCommands1.json +10 -2
  28. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent1.json +11 -1
  29. package/test/unit/ngsi-ld/examples/contextAvailabilityRequests/updateIoTAgent2.json +12 -1
  30. package/test/unit/ngsi-ld/general/startup-test.js +17 -2
  31. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +1 -12
  32. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +249 -0
  33. package/test/unit/ngsi-ld/ngsiService/unsupported-endpoints-test.js +171 -0
@@ -1,18 +1,28 @@
1
1
  {
2
- "@context": "http://context.json-ld",
3
- "endpoint": "http://smartgondor.com",
4
- "information": [
2
+ "type": "ContextSourceRegistration",
3
+ "information": [
4
+ {
5
+ "entities": [
5
6
  {
6
- "entities": [
7
- {
8
- "id": "urn:ngsi-ld:Light:light1",
9
- "type": "Light"
10
- }
11
- ],
12
- "properties": [
13
- "temperature"
14
- ]
7
+ "type": "Light",
8
+ "id": "urn:ngsi-ld:Light:light1"
15
9
  }
16
- ],
17
- "type": "ContextSourceRegistration"
10
+ ],
11
+ "propertyNames": [
12
+ "temperature"
13
+ ]
14
+ }
15
+ ],
16
+ "mode": "exclusive",
17
+ "operations": [
18
+ "retrieveOps"
19
+ ],
20
+ "endpoint": "http://smartgondor.com",
21
+ "contextSourceInfo": [
22
+ {
23
+ "key": "jsonldContext",
24
+ "value": "http://context.json-ld"
25
+ }
26
+ ],
27
+ "@context": "http://context.json-ld"
18
28
  }
@@ -1,18 +1,28 @@
1
1
  {
2
- "type": "ContextSourceRegistration",
3
- "information": [
4
- {
5
- "entities": [
2
+ "type": "ContextSourceRegistration",
3
+ "information": [
6
4
  {
7
- "type": "Motion",
8
- "id": "urn:ngsi-ld:Motion:motion1"
5
+ "entities": [
6
+ {
7
+ "type": "Motion",
8
+ "id": "urn:ngsi-ld:Motion:motion1"
9
+ }
10
+ ],
11
+ "propertyNames": [
12
+ "moving"
13
+ ]
9
14
  }
10
- ],
11
- "properties": [
12
- "moving"
13
- ]
14
- }
15
- ],
16
- "endpoint": "http://smartgondor.com",
17
- "@context": "http://context.json-ld"
18
- }
15
+ ],
16
+ "mode": "exclusive",
17
+ "operations": [
18
+ "retrieveOps"
19
+ ],
20
+ "endpoint": "http://smartgondor.com",
21
+ "contextSourceInfo":[
22
+ {
23
+ "key": "jsonldContext",
24
+ "value": "http://context.json-ld"
25
+ }
26
+ ],
27
+ "@context": "http://context.json-ld"
28
+ }
@@ -4,15 +4,25 @@
4
4
  {
5
5
  "entities": [
6
6
  {
7
- "type": "RobotPre",
8
- "id": "urn:ngsi-ld:RobotPre:TestRobotPre"
7
+ "type": "Light",
8
+ "id": "urn:ngsi-ld:Light:light1"
9
9
  }
10
10
  ],
11
- "properties": [
12
- "moving"
11
+ "propertyNames": [
12
+ "temperature"
13
13
  ]
14
14
  }
15
15
  ],
16
+ "mode": "exclusive",
17
+ "operations": [
18
+ "retrieveOps"
19
+ ],
16
20
  "endpoint": "http://smartgondor.com",
21
+ "contextSourceInfo": [
22
+ {
23
+ "key": "jsonldContext",
24
+ "value": "http://context.json-ld"
25
+ }
26
+ ],
17
27
  "@context": "http://context.json-ld"
18
- }
28
+ }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,11 +15,13 @@
9
15
  "type": "Robot"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "position",
14
20
  "orientation"
15
21
  ]
16
22
  }
17
23
  ],
24
+ "mode": "exclusive",
25
+ "operations" :["updateOps"],
18
26
  "type": "ContextSourceRegistration"
19
27
  }
@@ -0,0 +1,32 @@
1
+ {
2
+ "type": "ContextSourceRegistration",
3
+ "information": [
4
+ {
5
+ "entities": [
6
+ {
7
+ "type": "Robot",
8
+ "id": "urn:ngsi-ld:Robot:r2d2"
9
+ }
10
+ ],
11
+ "propertyNames": [
12
+ "batteryLevel",
13
+ "position",
14
+ "orientation"
15
+ ]
16
+ }
17
+ ],
18
+ "mode": "exclusive",
19
+ "operations": [
20
+ "retrieveOps",
21
+ "updateOps",
22
+ "mergeEntity"
23
+ ],
24
+ "endpoint": "http://smartgondor.com",
25
+ "contextSourceInfo": [
26
+ {
27
+ "key": "jsonldContext",
28
+ "value": "http://context.json-ld"
29
+ }
30
+ ],
31
+ "@context": "http://context.json-ld"
32
+ }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,11 +15,16 @@
9
15
  "type": "TheLightType"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "luminance",
14
20
  "commandAttr"
15
21
  ]
16
22
  }
17
23
  ],
24
+ "mode": "exclusive",
25
+ "operations": [
26
+ "retrieveOps",
27
+ "updateOps"
28
+ ],
18
29
  "type": "ContextSourceRegistration"
19
30
  }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,10 +15,12 @@
9
15
  "type": "TheLightType"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "luminance"
14
20
  ]
15
21
  }
16
22
  ],
23
+ "mode": "exclusive",
24
+ "operations" :["retrieveOps"],
17
25
  "type": "ContextSourceRegistration"
18
26
  }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,7 +15,7 @@
9
15
  "type": "TheLightType"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "luminance",
14
20
  "luminescence",
15
21
  "commandAttr",
@@ -17,5 +23,10 @@
17
23
  ]
18
24
  }
19
25
  ],
26
+ "mode": "exclusive",
27
+ "operations": [
28
+ "retrieveOps",
29
+ "updateOps"
30
+ ],
20
31
  "type": "ContextSourceRegistration"
21
32
  }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,7 +15,7 @@
9
15
  "type": "SensorMachine"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "luminance",
14
20
  "luminescence",
15
21
  "commandAttr",
@@ -17,5 +23,10 @@
17
23
  ]
18
24
  }
19
25
  ],
26
+ "mode": "exclusive",
27
+ "operations" : [
28
+ "retrieveOps",
29
+ "updateOps"
30
+ ],
20
31
  "type": "ContextSourceRegistration"
21
32
  }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,10 +15,12 @@
9
15
  "type": "Light"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "temperature"
14
20
  ]
15
21
  }
16
22
  ],
23
+ "mode": "exclusive",
24
+ "operations" :["retrieveOps"],
17
25
  "type": "ContextSourceRegistration"
18
26
  }
@@ -1,5 +1,11 @@
1
1
  {
2
2
  "type":"ContextSourceRegistration",
3
+ "contextSourceInfo":[
4
+ {
5
+ "key": "jsonldContext",
6
+ "value": "http://context.json-ld"
7
+ }
8
+ ],
3
9
  "information":[
4
10
  {
5
11
  "entities":[
@@ -8,11 +14,13 @@
8
14
  "id":"urn:ngsi-ld:Light:light1"
9
15
  }
10
16
  ],
11
- "properties":[
17
+ "propertyNames":[
12
18
  "move"
13
19
  ]
14
20
  }
15
21
  ],
22
+ "mode": "exclusive",
23
+ "operations":["updateOps"],
16
24
  "endpoint":"http://smartgondor.com",
17
25
  "@context": "http://context.json-ld"
18
- }
26
+ }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,10 +15,14 @@
9
15
  "type": "Light"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "pressure"
14
20
  ]
15
21
  }
16
22
  ],
23
+ "mode": "exclusive",
24
+ "operations": [
25
+ "retrieveOps"
26
+ ],
17
27
  "type": "ContextSourceRegistration"
18
28
  }
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "@context": "http://context.json-ld",
3
3
  "endpoint": "http://smartgondor.com",
4
+ "contextSourceInfo":[
5
+ {
6
+ "key": "jsonldContext",
7
+ "value": "http://context.json-ld"
8
+ }
9
+ ],
4
10
  "information": [
5
11
  {
6
12
  "entities": [
@@ -9,11 +15,16 @@
9
15
  "type": "TheLightType"
10
16
  }
11
17
  ],
12
- "properties": [
18
+ "propertyNames": [
13
19
  "luminance",
14
20
  "commandAttr"
15
21
  ]
16
22
  }
17
23
  ],
24
+ "mode": "exclusive",
25
+ "operations" : [
26
+ "retrieveOps",
27
+ "updateOps"
28
+ ],
18
29
  "type": "ContextSourceRegistration"
19
30
  }
@@ -66,7 +66,7 @@ describe('NGSI-LD - Startup tests', function () {
66
66
  beforeEach(function () {
67
67
  process.env.IOTA_CB_HOST = 'cbhost';
68
68
  process.env.IOTA_CB_PORT = '1111';
69
- process.env.IOTA_CB_NGSI_VERSION = 'v2';
69
+ process.env.IOTA_CB_NGSI_VERSION = 'ld';
70
70
  process.env.IOTA_NORTH_HOST = 'localhost';
71
71
  process.env.IOTA_NORTH_PORT = '2222';
72
72
  process.env.IOTA_PROVIDER_URL = 'provider:3333';
@@ -83,6 +83,11 @@ describe('NGSI-LD - Startup tests', function () {
83
83
  process.env.IOTA_MONGO_DB = 'themongodb';
84
84
  process.env.IOTA_MONGO_REPLICASET = 'customReplica';
85
85
  process.env.IOTA_DEFAULT_RESOURCE = '/iot/custom';
86
+ process.env.IOTA_JSON_LD_CONTEXT = 'http://context.jsonld';
87
+ process.env.IOTA_FALLBACK_TENANT = 'openiot';
88
+ process.env.IOTA_FALLBACK_PATH = 'smartgondor';
89
+ process.env.IOTA_LD_SUPPORT_NULL = 'false';
90
+ process.env.IOTA_LD_SUPPORT_DATASET_ID = 'false';
86
91
 
87
92
  nock.cleanAll();
88
93
 
@@ -114,6 +119,11 @@ describe('NGSI-LD - Startup tests', function () {
114
119
  delete process.env.IOTA_MONGO_DB;
115
120
  delete process.env.IOTA_MONGO_REPLICASET;
116
121
  delete process.env.IOTA_DEFAULT_RESOURCE;
122
+ delete process.env.IOTA_JSON_LD_CONTEXT;
123
+ delete process.env.IOTA_FALLBACK_TENANT;
124
+ delete process.env.IOTA_FALLBACK_PATH;
125
+ delete process.env.IOTA_LD_SUPPORT_NULL;
126
+ delete process.env.IOTA_LD_SUPPORT_DATASET_ID;
117
127
  });
118
128
 
119
129
  afterEach(function (done) {
@@ -123,7 +133,12 @@ describe('NGSI-LD - Startup tests', function () {
123
133
  it('should load the correct configuration parameters', function (done) {
124
134
  iotAgentLib.activate(iotAgentConfig, function (error) {
125
135
  config.getConfig().contextBroker.url.should.equal('http://cbhost:1111');
126
- config.getConfig().contextBroker.ngsiVersion.should.equal('v2');
136
+ config.getConfig().contextBroker.ngsiVersion.should.equal('ld');
137
+ config.getConfig().contextBroker.jsonLdContext.should.equal('http://context.jsonld');
138
+ config.getConfig().contextBroker.fallbackTenant.should.equal( 'openiot');
139
+ config.getConfig().contextBroker.fallbackPath.should.equal('smartgondor');
140
+ config.getConfig().server.ldSupport.null.should.equal(false);
141
+ config.getConfig().server.ldSupport.datasetId.should.equal(false);
127
142
  config.getConfig().server.host.should.equal('localhost');
128
143
  config.getConfig().server.port.should.equal('2222');
129
144
  config.getConfig().providerUrl.should.equal('provider:3333');
@@ -184,7 +184,6 @@ describe('NGSI-LD - Command functionalities', function () {
184
184
  };
185
185
 
186
186
  beforeEach(function (done) {
187
- logger.setLevel('ERROR');
188
187
  iotAgentLib.register(device3, function (error) {
189
188
  done();
190
189
  });
@@ -287,7 +286,6 @@ describe('NGSI-LD - Command functionalities', function () {
287
286
  };
288
287
 
289
288
  beforeEach(function (done) {
290
- logger.setLevel('ERROR');
291
289
  iotAgentLib.register(device3, function (error) {
292
290
  done();
293
291
  });
@@ -368,7 +366,7 @@ describe('NGSI-LD - Command functionalities', function () {
368
366
  describe('When a sequential command with datasetId updates via PATCH /attrs/attr-name arrives to the IoT Agent', function () {
369
367
  const options = {
370
368
  url: 'http://localhost:' + iotAgentConfig.server.port + '/ngsi-ld/v1/entities/urn:ngsi-ld:Robot:r2d2/attrs',
371
- method: 'PUT',
369
+ method: 'PATCH',
372
370
  json: {
373
371
  position: [
374
372
  {
@@ -390,7 +388,6 @@ describe('NGSI-LD - Command functionalities', function () {
390
388
  };
391
389
 
392
390
  beforeEach(function (done) {
393
- logger.setLevel('ERROR');
394
391
  iotAgentLib.register(device3, function (error) {
395
392
  done();
396
393
  });
@@ -496,7 +493,6 @@ describe('NGSI-LD - Command functionalities', function () {
496
493
  };
497
494
 
498
495
  beforeEach(function (done) {
499
- logger.setLevel('ERROR');
500
496
  iotAgentLib.register(device3, function (error) {
501
497
  done();
502
498
  });
@@ -594,7 +590,6 @@ describe('NGSI-LD - Command functionalities', function () {
594
590
  };
595
591
 
596
592
  beforeEach(function (done) {
597
- logger.setLevel('ERROR');
598
593
  iotAgentLib.register(device3, function (error) {
599
594
  done();
600
595
  });
@@ -691,7 +686,6 @@ describe('NGSI-LD - Command functionalities', function () {
691
686
  };
692
687
 
693
688
  beforeEach(function (done) {
694
- logger.setLevel('ERROR');
695
689
  iotAgentLib.register(device3, function (error) {
696
690
  done();
697
691
  });
@@ -794,7 +788,6 @@ describe('NGSI-LD - Command functionalities', function () {
794
788
  };
795
789
 
796
790
  beforeEach(function (done) {
797
- logger.setLevel('ERROR');
798
791
  iotAgentLib.register(device3, function (error) {
799
792
  done();
800
793
  });
@@ -902,7 +895,6 @@ describe('NGSI-LD - Command functionalities', function () {
902
895
  };
903
896
 
904
897
  beforeEach(function (done) {
905
- logger.setLevel('ERROR');
906
898
  iotAgentLib.register(device3, function (error) {
907
899
  done();
908
900
  });
@@ -1006,7 +998,6 @@ describe('NGSI-LD - Command functionalities', function () {
1006
998
  };
1007
999
 
1008
1000
  beforeEach(function (done) {
1009
- logger.setLevel('ERROR');
1010
1001
  iotAgentLib.register(device3, function (error) {
1011
1002
  done();
1012
1003
  });
@@ -1104,7 +1095,6 @@ describe('NGSI-LD - Command functionalities', function () {
1104
1095
  };
1105
1096
 
1106
1097
  beforeEach(function (done) {
1107
- logger.setLevel('ERROR');
1108
1098
  iotAgentLib.register(device3, function (error) {
1109
1099
  done();
1110
1100
  });
@@ -1246,7 +1236,6 @@ describe('NGSI-LD - Command functionalities', function () {
1246
1236
  };
1247
1237
 
1248
1238
  beforeEach(function (done) {
1249
- logger.setLevel('ERROR');
1250
1239
  iotAgentLib.register(device3, function (error) {
1251
1240
  done();
1252
1241
  });