opengate-js 11.9.1 → 11.9.2

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.
@@ -266,6 +266,11 @@ for (var field in IOT_FIELDS) {
266
266
  }
267
267
  }
268
268
 
269
+ const REGEX_PATH_CURRENT = new RegExp("^(.+)._current\\.?(.+)?$")
270
+ const REGEX_PATH_ARRAY = new RegExp("\\[[0-9]+\\]")
271
+ const REGEX_DATASTREAM_VALUE = new RegExp('value\\.?')
272
+
273
+
269
274
  const match_url = {
270
275
  '/jobs': 'JOB',
271
276
  '/tasks': 'TASKS',
@@ -398,7 +403,6 @@ const _getDatamodelFields = function(parent, objSearcher){
398
403
  }
399
404
  });
400
405
  }
401
-
402
406
  if (rtFilter.and.length > 0) {
403
407
  datamodelSearchBuilder.filter(rtFilter);
404
408
  }
@@ -603,24 +607,24 @@ const FIELD_SEARCHER = {
603
607
  //search de la definición de schemas de opengate
604
608
  _this._ogapi.basicTypesSearchBuilder().withPath('$').build().execute().then(function (basicTypes) {
605
609
  const definitions = basicTypes.data.definitions
606
- let query = {selectAll: true}
610
+ objSearcher.selectAll = true
607
611
  if (selectedField) {
608
612
  columns = columns.filter(function (column) { return selectedField === column.name })
609
613
  const column = columns[0]
610
- const datastreamMatch = column.path.match(new RegExp("^(.+)._current\.?(.+)?$"));
611
- const datastream = datastreamMatch[1].replace(new RegExp("\[[0-9]+\]"), "[]")
612
- query = {selectedField: datastream}
614
+ const datastreamMatch = column.path.match(REGEX_PATH_CURRENT);
615
+ const datastream = datastreamMatch[1].replace(REGEX_PATH_ARRAY, "[]")
616
+ objSearcher.selectedField = datastream
613
617
  }
614
- query.organization = organization
615
618
  //recuperamos la defnición de todas las columnas y todos los datastreams
616
- _getDatamodelFields(_this, query).then(function (datamodelFields) {
619
+ _getDatamodelFields(_this, objSearcher).then(function (datamodelFields) {
617
620
  columns.forEach(function (column) {
618
621
  //Expresión regular para recuperar el path del datastream (1) y, si se tratase de un datastream complejo, también el path hasta el dato simple (2).
619
622
  //Datastream simple: provision.device.identifier._current.value, device.communicationModules[0].subscriber.mobile.icc._current.at
620
623
  //Datastream complejo: device.model._current.value.manufacturer, device.location._current.value.position.type
621
- const datastreamMatch = column.path.match(new RegExp("^(.+)._current\.?(.+)?$"));
622
- const datastream = datastreamMatch[1].replace(new RegExp("\[[0-9]+\]"), "[]")
623
- const subdatastream = datastreamMatch[2].replace(new RegExp('value\.?'), '');
624
+ const datastreamMatch = column.path.match(REGEX_PATH_CURRENT);
625
+ //Eliminamos el indice para los modulos de comunicaciones y los arrays para el resto de datastreams
626
+ const datastream = datastreamMatch[1].replace(REGEX_PATH_ARRAY, "[]")
627
+ const subdatastream = datastreamMatch[2].replace(REGEX_DATASTREAM_VALUE, '').replace(REGEX_PATH_ARRAY, '');
624
628
  //Buscamos la definición del datastream en el datamodel
625
629
  const datamodelField = Array.isArray(datamodelFields) ? datamodelFields.find(function (df) {
626
630
  return datastream === df.identifier
package/docs/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opengate-js",
3
- "version": "11.9.1",
3
+ "version": "11.9.2",
4
4
  "description": "",
5
5
  "main": "dist/opengate-api-npm.js",
6
6
  "repository": {