{
  "api": "tsf-js-api",
  "docsBaseUrl": "https://documentation.opengate.es/",
  "functions": [
    {
      "examples": [
        {
          "code": "if(data.exists(receivedValues[recVal].value)){\n    newSum = newSum + receivedValues[recVal].value;\n}",
          "language": "javascript"
        }
      ],
      "id": "data.exists",
      "internal": false,
      "kind": "function",
      "name": "exists",
      "namespace": "data",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "value to be checked.",
          "name": "value",
          "type": "any"
        }
      ],
      "returns": {
        "description": "Boolean - Json with result."
      },
      "signature": "data.exists(value)",
      "summary": "Aux method to check if some value has value. If value is undefined or null it will return false.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#dataexistsvalue"
    },
    {
      "examples": [
        {
          "code": "var newValue = data.undefined2null(undefined);\n\nconsole.log(newValue) // null",
          "language": "javascript"
        }
      ],
      "id": "data.undefined2null",
      "internal": false,
      "kind": "function",
      "name": "undefined2null",
      "namespace": "data",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "value to be checked and transformed.",
          "name": "value",
          "type": "any"
        }
      ],
      "returns": {
        "description": "Any - Json with result."
      },
      "signature": "data.undefined2null(value)",
      "summary": "Aux method to replace all undefined fields with null values. Internally used to avoid issues when processing execution result.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#dataundefined2nullvalue"
    },
    {
      "examples": [
        {
          "code": "var newValue = result.ok(5, {\"sum\":30}, {\"count\":6});",
          "language": "javascript"
        }
      ],
      "id": "result.ok",
      "internal": false,
      "kind": "function",
      "name": "ok",
      "namespace": "result",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "value to be used to update column data.",
          "name": "value",
          "type": "any"
        },
        {
          "description": "List of parameters to be used to compound `extra` json. Each parameter must be a Json with unique parameter and value.",
          "name": "extraParams",
          "type": "any"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "result.ok(value, ...extraParams)",
      "summary": "Used to build aggregation function result object",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#resultokvalue-extraparams"
    },
    {
      "examples": [
        {
          "code": "var newValue = result.error(new Error(\"Custom error message\"));",
          "language": "javascript"
        }
      ],
      "id": "result.error",
      "internal": false,
      "kind": "function",
      "name": "error",
      "namespace": "result",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Caught error. It can be Error type or String type",
          "name": "error",
          "type": "any"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "result.error(error)",
      "summary": "Internally used to build aggregation function result object when some execution exception is caught.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#resulterrorerror"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.AVG(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.AVG",
      "internal": false,
      "kind": "function",
      "name": "AVG",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.AVG(receivedValues, currentValue, extra)",
      "summary": "The engine will calculate the arithmetic average of all received values in the configured time bucket. Only available in numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctavgreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.COUNT(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.COUNT",
      "internal": false,
      "kind": "function",
      "name": "COUNT",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.COUNT(receivedValues, currentValue, extra)",
      "summary": "The engine will store the count of total number values received per time bucket.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctcountreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.FIRST(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.FIRST",
      "internal": false,
      "kind": "function",
      "name": "FIRST",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.FIRST(receivedValues, currentValue, extra)",
      "summary": "The engine will store only the first received value per time bucket. The collection engine ignores the following values obtained in the same time bucket.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctfirstreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.GEO_AVG(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.GEO_AVG",
      "internal": false,
      "kind": "function",
      "name": "GEO_AVG",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.GEO_AVG(receivedValues, currentValue, extra)",
      "summary": "The engine will calculate the geometric average of all received values in the configured time bucket. Only available in numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctgeo_avgreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.LAST(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.LAST",
      "internal": false,
      "kind": "function",
      "name": "LAST",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.LAST(receivedValues, currentValue, extra)",
      "summary": "The engine will store only the last received value per time bucket, overwriting the previous ones.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctlastreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.MAX(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.MAX",
      "internal": false,
      "kind": "function",
      "name": "MAX",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.MAX(receivedValues, currentValue, extra)",
      "summary": "The engine will save the maximum value of all received values in the configured time bucket. Only available for numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctmaxreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.MEDIAN(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.MEDIAN",
      "internal": false,
      "kind": "function",
      "name": "MEDIAN",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.MEDIAN(receivedValues, currentValue, extra)",
      "summary": "The engine will calculate the median of all received values in the configured time bucket. Only available in numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctmedianreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.MIN(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.MIN",
      "internal": false,
      "kind": "function",
      "name": "MIN",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.MIN(receivedValues, currentValue, extra)",
      "summary": "The engine will save the minimum value of all received values in the configured time bucket. Only available for numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctminreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.STD_DEVIATION(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.STD_DEVIATION",
      "internal": false,
      "kind": "function",
      "name": "STD_DEVIATION",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.STD_DEVIATION(receivedValues, currentValue, extra)",
      "summary": "The engine will calculate the standard deviation of all received values in the configured time bucket. Only available in numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctstd_deviationreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.SUM(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.SUM",
      "internal": false,
      "kind": "function",
      "name": "SUM",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.SUM(receivedValues, currentValue, extra)",
      "summary": "The engine will save the sum of all received values in the configured time bucket. Only available for numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctsumreceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "var newValue = aggFunct.VARIANCE(receivedValues, currentValue, extra);",
          "language": "javascript"
        }
      ],
      "id": "aggFunct.VARIANCE",
      "internal": false,
      "kind": "function",
      "name": "VARIANCE",
      "namespace": "aggFunct",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Array of objects with new values to be used for final value calculation.",
          "name": "receivedValues",
          "type": "Array"
        },
        {
          "description": "Column's current value.",
          "name": "currentValue",
          "type": "any"
        },
        {
          "description": "JSON with auxiliary parameters for final value calculation.",
          "name": "extra",
          "type": "Object"
        }
      ],
      "returns": {
        "description": "Object - Json with result."
      },
      "signature": "aggFunct.VARIANCE(receivedValues, currentValue, extra)",
      "summary": "The engine will calculate the variance of all received values in the configured time bucket. Only available in numeric values.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#aggfunctvariancereceivedvalues-currentvalue-extra"
    },
    {
      "examples": [
        {
          "code": "log.trace(\"This is a trace message\");",
          "language": "javascript"
        }
      ],
      "id": "log.trace",
      "internal": false,
      "kind": "function",
      "name": "trace",
      "namespace": "log",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "The function takes as parameters a list of elements to be concatenated to generate the string message to be printed.",
          "name": "...msg",
          "type": "any"
        }
      ],
      "signature": "log.trace(...msg)",
      "summary": "Creates *TRACE* level logging messages. It concatenates msg parameters to compound message to be logged.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#logtracemsg"
    },
    {
      "examples": [
        {
          "code": "log.debug(\"This is a debug message\");",
          "language": "javascript"
        }
      ],
      "id": "log.debug",
      "internal": false,
      "kind": "function",
      "name": "debug",
      "namespace": "log",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "The function takes as parameters a list of elements to be concatenated to generate the string message to be printed.",
          "name": "...msg",
          "type": "any"
        }
      ],
      "signature": "log.debug(...msg)",
      "summary": "Creates *DEBUG* level logging messages. It concatenates msg parameters to compound message to be logged.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#logdebugmsg"
    },
    {
      "examples": [
        {
          "code": "log.info(\"This is an info message\");",
          "language": "javascript"
        }
      ],
      "id": "log.info",
      "internal": false,
      "kind": "function",
      "name": "info",
      "namespace": "log",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "The function takes as parameters a list of elements to be concatenated to generate the string message to be printed.",
          "name": "...msg",
          "type": "any"
        }
      ],
      "signature": "log.info(...msg)",
      "summary": "Creates *INFO* level logging messages. It concatenates msg parameters to compound message to be logged.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#loginfomsg"
    },
    {
      "examples": [
        {
          "code": "log.warn(\"This is a warn message\");",
          "language": "javascript"
        }
      ],
      "id": "log.warn",
      "internal": false,
      "kind": "function",
      "name": "warn",
      "namespace": "log",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "The function takes as parameters a list of elements to be concatenated to generate the string message to be printed.",
          "name": "...msg",
          "type": "any"
        }
      ],
      "signature": "log.warn(...msg)",
      "summary": "Creates *WARN* level logging messages. It concatenates msg parameters to compound message to be logged.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#logwarnmsg"
    },
    {
      "examples": [
        {
          "code": "log.error(\"This is an error message\");",
          "language": "javascript"
        }
      ],
      "id": "log.error",
      "internal": false,
      "kind": "function",
      "name": "error",
      "namespace": "log",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "The function takes as parameters a list of elements to be concatenated to generate the string message to be printed.",
          "name": "...msg",
          "type": "any"
        }
      ],
      "signature": "log.error(...msg)",
      "summary": "Creates *ERROR* level logging messages. It concatenates msg parameters to compound message to be logged.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#logerrormsg"
    },
    {
      "examples": [
        {
          "code": "var parsedDate = date.fromString(\"2022-01-01T00:00:00.000Z\");",
          "language": "javascript"
        }
      ],
      "id": "date.fromString",
      "internal": false,
      "kind": "function",
      "name": "fromString",
      "namespace": "date",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Iso string date",
          "name": "stringDate",
          "type": "string"
        }
      ],
      "signature": "date.fromString(stringDate)",
      "summary": "Create Date object from ISO string.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#datefromstringstringdate"
    },
    {
      "examples": [
        {
          "code": "var isoDate = date.toString(new Date());",
          "language": "javascript"
        }
      ],
      "id": "date.toString",
      "internal": false,
      "kind": "function",
      "name": "toString",
      "namespace": "date",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Date object",
          "name": "date",
          "type": "Date"
        }
      ],
      "signature": "date.toString(date)",
      "summary": "Returns iso string representation of Date object.",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#datetostringdate"
    },
    {
      "examples": [
        {
          "code": "var date1 = date.fromString(\"2022-01-01T00:00:00.000Z\");\nvar date2 = date.fromString(\"2022-01-02T00:00:00.000Z\");\nvar result = date.compare(date1, date2);",
          "language": "javascript"
        }
      ],
      "id": "date.compare",
      "internal": false,
      "kind": "function",
      "name": "compare",
      "namespace": "date",
      "page": {
        "title": "JavaScript API",
        "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/",
        "weight": 20
      },
      "params": [
        {
          "description": "Date object",
          "name": "date1",
          "type": "Date"
        },
        {
          "description": "Date object",
          "name": "date2",
          "type": "Date"
        }
      ],
      "signature": "date.compare(date1, date2)",
      "summary": "Compares two dates. These dates can be passed as strings in ISO format or as Date objects. The result is:",
      "url": "api/data_retrieval/time_series/timeseries_functions/aggregation_functions_js_api/#datecomparedate1-date2"
    }
  ],
  "generatedAt": "2026-08-17T11:35:28Z",
  "internal": false,
  "platformVersion": "20.5.1-SNAPSHOT",
  "schemaVersion": "1.0"
}