iotagent-node-lib 4.1.0 → 4.2.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/.readthedocs.yml CHANGED
@@ -3,7 +3,11 @@ version: 2
3
3
  mkdocs:
4
4
  configuration: mkdocs.yml
5
5
 
6
+ build:
7
+ os: ubuntu-22.04
8
+ tools:
9
+ python: "3.8"
10
+
6
11
  python:
7
- version: 3.8
8
12
  install:
9
13
  - requirements: doc/requirements.txt
@@ -1 +0,0 @@
1
-
package/doc/api.md CHANGED
@@ -955,6 +955,28 @@ The IOTA processes the entity attributes looking for a `TimeInstant` attribute.
955
955
  adds a `TimeInstant` attribute as metadata for every other attribute in the same request. With NGSI-LD, the Standard
956
956
  `observedAt` property-of-a-property is used instead.
957
957
 
958
+ If a `TimeInstant` arrives as measure but not follows [ISO_8601](https://en.wikipedia.org/wiki/ISO_8601) then measure
959
+ is refused.
960
+
961
+ Depending on the `timestamp` configuration and if the measure contains a
962
+ value named `TimeInstant` with a correct value, the IoTA behaviour is described
963
+ in the following table:
964
+
965
+ `timestamp` value | measure contains `TimeInstant` | Behaviour
966
+ -- | -- | --
967
+ true | Yes | TimeInstant and metadata updated with measure value
968
+ true | No | TimeInstant and metadata updated with server timestamp
969
+ false | Yes | TimeInstant and metadata updated with measure value
970
+ false | No | TimeInstant and metadata updated with server timestamp
971
+ Not defined | Yes | TimeInstant and metadata updated with measure value
972
+ Not defined | No | TimeInstant and metadata updated with server timestamp
973
+
974
+ The `timestamp` value used is:
975
+
976
+ * The one defined at device level
977
+ * The one defined at group level (if not defined at device level)
978
+ * The one defined at [IoTA configuration level](admin.md#timestamp) / `IOTA_TIMESTAMP` env var (if not defined at group level or device level)
979
+
958
980
  ## Overriding global Context Broker host
959
981
 
960
982
  **cbHost**: Context Broker host URL. This option can be used to override the global CB configuration for specific types
@@ -963,8 +985,7 @@ of devices.
963
985
  ## Multitenancy, FIWARE Service and FIWARE ServicePath
964
986
 
965
987
  Every operation in the API require the `fiware-service` and `fiware-servicepath` to be defined; the operations are
966
- performed in the scope of those headers. For the list case, the special wildcard servicepath can be specified, `/*`. In
967
- this case, the operation applies to all the subservices of the service given by the `fiware-service` header.
988
+ performed in the scope of those headers.
968
989
 
969
990
  ## Secured access to the Context Broker
970
991
 
@@ -1202,7 +1223,7 @@ Config group is represented by a JSON object with the following fields:
1202
1223
  | `subservice` | | string | | Subservice of the devices of this type. |
1203
1224
  | `resource` | | string | | string representing the Southbound resource that will be used to assign a type to a device (e.g.: pathname in the southbound port). |
1204
1225
  | `apikey` | | string | | API Key string. |
1205
- | `timestamp` | ✓ | bool | | Optional flag about whether or not to add the `TimeInstant` attribute to the device entity created, as well as a `TimeInstant` metadata to each attribute, with the current timestamp. With NGSI-LD, the Standard `observedAt` property-of-a-property is created instead. |
1226
+ | `timestamp` | ✓ | bool | | Optional flag about whether or not to add the `TimeInstant` attribute to the device entity created, as well as a `TimeInstant` metadata to each attribute, with the current server timestamp or provided `TimeInstant` as measure when follows ISO 8601 format (see [timestamp processing](#timestamp-processing) section for aditional detail). With NGSI-LD, the Standard `observedAt` property-of-a-property is created instead. |
1206
1227
  | `entity_type` | | string | | name of the Entity `type` to assign to the group. |
1207
1228
  | `trust` | ✓ | string | | trust token to use for secured access to the Context Broker for this type of devices (optional; only needed for secured scenarios). |
1208
1229
  | `cbHost` | ✓ | string | | Context Broker connection information. This options can be used to override the global ones for specific types of devices. |
@@ -1226,9 +1247,8 @@ The following actions are available under the config group endpoint:
1226
1247
 
1227
1248
  #### Retrieve config groups `GET /iot/services`
1228
1249
 
1229
- List all the config groups for the given `fiware-service` and `fiware-servicepath`. If the `fiware-servicepath` header
1230
- has the wildcard expression, `/*`, all the config groups for that `fiware-service` are returned. The config groups that
1231
- match the `fiware-servicepath` are returned in any other case.
1250
+ List all the config groups for the given `fiware-service` and `fiware-servicepath`. The config groups that match the
1251
+ `fiware-servicepath` are returned in any other case.
1232
1252
 
1233
1253
  _**Request headers**_
1234
1254
 
@@ -1427,7 +1447,7 @@ the API resource fields and the same fields in the database model.
1427
1447
  | `entity_name` | | `string` | | Name of the entity representing the device in the Context Broker |
1428
1448
  | `entity_type` | | `string` | | Type of the entity in the Context Broker |
1429
1449
  | `timezone` | ✓ | `string` | | Timezone of the device if that has any |
1430
- | `timestamp` | ✓ | `string` | | Flag about whether or not to add the `TimeInstant` attribute to the device entity created, as well as a `TimeInstant` metadata to each attribute, with the current timestamp. With NGSI-LD, the Standard `observedAt` property-of-a-property is created instead. |
1450
+ | `timestamp` | ✓ | `string` | | Flag about whether or not to add the `TimeInstant` attribute to the device entity created, as well as a `TimeInstant` metadata to each attribute, with the current server timestamp or provided `TimeInstant` as measure when follows ISO 8601 format (see [timestamp processing](#timestamp-processing) section for aditional detail). With NGSI-LD, the Standard `observedAt` property-of-a-property is created instead. |
1431
1451
  | `apikey` | ✓ | `string` | | Apikey key string to use instead of group apikey |
1432
1452
  | `endpoint` | ✓ | `string` | | Endpoint where the device is going to receive commands, if any. |
1433
1453
  | `protocol` | ✓ | `string` | | Pame of the device protocol, for its use with an IoT Manager |
@@ -1,4 +1,4 @@
1
- mkdocs==1.2.3
1
+ mkdocs==1.2.4
2
2
  Pygments==2.15.0
3
3
  Markdown==3.3.4
4
- jinja2==3.0.0
4
+ jinja2==3.1.3
package/lib/constants.js CHANGED
@@ -61,6 +61,7 @@ module.exports = {
61
61
  NGSI_LD_TENANT_HEADER: 'NGSILD-Tenant',
62
62
  NGSI_LD_PATH_HEADER: 'NGSILD-Path',
63
63
  NGSI_LD_NULL: 'urn:ngsi-ld:null',
64
+ MEASURE: 'measure_',
64
65
  //FIXME: check Keystone support this in lowercase, then change
65
66
  AUTH_HEADER: 'X-Auth-Token',
66
67
  X_FORWARDED_FOR_HEADER: 'x-forwarded-for',
@@ -83,7 +84,7 @@ module.exports = {
83
84
  MONGO_ALARM: 'MONGO-ALARM',
84
85
  ORION_ALARM: 'ORION-ALARM',
85
86
  IOTAM_ALARM: 'IOTAM-ALARM',
86
-
87
+
87
88
  ATTRIBUTE_DEFAULT,
88
89
  DATETIME_DEFAULT,
89
90
 
@@ -282,6 +282,12 @@ function sendUpdateValueNgsi2(entityName, measures, typeInformation, token, call
282
282
  callback(new errors.TypeNotFound(null, entityName));
283
283
  return;
284
284
  }
285
+ //Rename all measures with matches with id and type to measure_id and measure_type
286
+ for (let measure of measures) {
287
+ if (measure.name === 'id' || measure.name === 'type') {
288
+ measure.name = constants.MEASURE + measure.name;
289
+ }
290
+ }
285
291
 
286
292
  //Make a copy of measures in an plain object: plainMeasures
287
293
  plainMeasures = reduceAttrToPlainObject(measures);
@@ -541,7 +547,6 @@ function sendUpdateValueNgsi2(entityName, measures, typeInformation, token, call
541
547
  //extract attributes
542
548
  let isEmpty = true;
543
549
  for (let attr of entities[ename][etype]) {
544
- //Handling id/type measures, skip, hit & explicit (condition)
545
550
  if (
546
551
  attr.name !== 'id' &&
547
552
  attr.name !== 'type' &&
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "iotagent-node-lib",
3
3
  "license": "AGPL-3.0-only",
4
4
  "description": "IoT Agent library to interface with NGSI Context Broker",
5
- "version": "4.1.0",
5
+ "version": "4.2.0",
6
6
  "homepage": "https://github.com/telefonicaid/iotagent-node-lib",
7
7
  "keywords": [
8
8
  "fiware",
@@ -932,6 +932,14 @@ describe('NGSI-v2 - Active attributes test', function () {
932
932
  meas: {
933
933
  value: 'measIoTA',
934
934
  type: 'String'
935
+ },
936
+ measure_id: {
937
+ type: 'text',
938
+ value: 'idIoTA'
939
+ },
940
+ measure_type: {
941
+ type: 'text',
942
+ value: 'typeIoTA'
935
943
  }
936
944
  })
937
945
  .reply(204);
@@ -1026,6 +1034,14 @@ describe('NGSI-v2 - Active attributes test', function () {
1026
1034
  meas: {
1027
1035
  value: 'measIoTA',
1028
1036
  type: 'String'
1037
+ },
1038
+ measure_id: {
1039
+ value: 'idIoTA',
1040
+ type: 'text'
1041
+ },
1042
+ measure_type: {
1043
+ value: 'typeIoTA',
1044
+ type: 'text'
1029
1045
  }
1030
1046
  })
1031
1047
  .reply(204);