From 4eb8bd51d04028b85b45d2fb1becac19660ad154 Mon Sep 17 00:00:00 2001 From: Aurelien Arino Date: Mon, 30 Jan 2023 02:33:31 -0800 Subject: [PATCH] fix(quantity): add several name length limits (#356) * fix(quantity): add unit name length limit * feat(stringOrTranslations): add back length limit * fix(measurement-filter): add name and desc input limit * fix(webhook): add name len limit * fix(environment): add name len limit * rebase fix * chore(docs): update * fix: remove unwanted breaking change * chore: Documentation updated by github actions * chore: remove abitrary max apiVersion number * fix(measurement-filter): add missing limit on model * chore: Documentation updated by github actions * refactor(string-or-translation): simplify versionning * address feedback * chore: Documentation updated by github actions BREAKING CHANGE: localised entities names are now limited in length --- docs/index.html | 18 ++--- src/models/command-type.ts | 4 +- src/models/device-type.ts | 12 +-- src/models/environment.ts | 2 +- src/models/fields/base-field-configuration.ts | 26 +++--- src/models/measurement-filter.ts | 9 ++- src/models/quantity.ts | 5 +- src/models/string-or-translations.ts | 29 ++++--- src/models/supplier-report-type.ts | 4 +- src/models/supplier-webhook.ts | 2 +- src/models/translations.ts | 50 +++++++++--- src/routes/command-type/add.ts | 2 +- src/routes/command-type/update.ts | 2 +- src/routes/device-type/add.ts | 10 +-- src/routes/device-type/update.ts | 10 +-- src/routes/environment/add.ts | 2 +- src/routes/measurement-filter/add.ts | 9 ++- src/routes/measurement-filter/update.ts | 4 +- src/routes/measurement-threshold/find.ts | 2 +- src/routes/quantity/add.ts | 2 +- src/routes/quantity/update.ts | 2 +- src/routes/supplier-report-type/add.ts | 2 +- src/routes/supplier-report-type/update.ts | 2 +- src/routes/supplier-webhook/add.ts | 2 +- test/string-or-translations.test.ts | 80 ++++++++++++++++++- 25 files changed, 209 insertions(+), 83 deletions(-) diff --git a/docs/index.html b/docs/index.html index e7720d16..3d4e6aeb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2928,7 +2928,7 @@

Headers

identifierFieldKey
string or null

Value from form field with this key will be displayed as device identifier insetad of hashId

Responses

Request samples

Content type
text/json
{
  • "name": "untranslated string",
  • "eventHandler": "string",
  • "fieldConfigurations": [
    ],
  • "pinGroupFieldConfigurations": [
    ],
  • "channels": [
    ],
  • "charts": [
    ],
  • "commandTypeHashIds": [
    ],
  • "identifierFieldKey": "deviceFormFieldKey"
}

Environment

add

Create a monitoring environment

-
Authorizations:
jwt-token
header Parameters
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
required
string

Responses

Authorizations:
jwt-token
header Parameters
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
required
string <= 255 characters

Responses

Request samples

Content type
text/json
{
  • "name": "My monitoring environment"
}

Response samples

Content type
text/json
{
  • "environment": {
    },
  • "environmentRights": [
    ],
  • "userEnvironmentSettings": {
    }
}

delete

Delete a monitoring environment. No user can access it afterwards.

Rights

    @@ -3688,7 +3688,7 @@

    Headers

    • Monitoring environment: REPORTS
    -
Authorizations:
jwt-token
header Parameters
Environment-Hash-Id
required
string
Example: yourAssetEnvironmentHashId
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
required
string
description
required
string
required
string or object
includePinsWithoutReports
boolean
Default: true
reportTypeHashIds
required
Array of strings <= 20 items
gridHashId
string
pinGroupHashIds
Array of strings [ 1 .. 50 ] items
quantityHashIds
required
Array of strings [ 1 .. 64 ] items
fieldKeys
required
Array of strings <= 20 items
pinFieldKeys
Array of strings
edgeFieldKeys
Array of strings

Responses

Authorizations:
jwt-token
header Parameters
Environment-Hash-Id
required
string
Example: yourAssetEnvironmentHashId
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
required
string <= 100 characters
description
required
string <= 255 characters
required
string or object
includePinsWithoutReports
boolean
Default: true
reportTypeHashIds
required
Array of strings <= 20 items
gridHashId
string
pinGroupHashIds
Array of strings [ 1 .. 50 ] items
quantityHashIds
required
Array of strings [ 1 .. 64 ] items
fieldKeys
required
Array of strings <= 20 items
pinFieldKeys
Array of strings
edgeFieldKeys
Array of strings

Responses

Request samples

Content type
text/json
{
  • "name": "North",
  • "description": "Temperatures in the North",
  • "period": "lastMonth",
  • "includePinsWithoutReports": true,
  • "reportTypeHashIds": [
    ],
  • "gridHashId": "string",
  • "pinGroupHashIds": [
    ],
  • "quantityHashIds": [
    ],
  • "fieldKeys": [
    ],
  • "pinFieldKeys": [
    ],
  • "edgeFieldKeys": [
    ]
}

Response samples

Content type
text/json
{
  • "hashId": "k8gh3"
}

find

Search through measurement filters

Rights

    @@ -3737,7 +3737,7 @@

    Headers

    • Monitoring environment: REPORTS
    -
Authorizations:
jwt-token
path Parameters
hashId
required
string
Example: k8gh3
header Parameters
Environment-Hash-Id
required
string
Example: yourAssetEnvironmentHashId
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
string
description
string
string or object
includePinsWithoutReports
boolean
reportTypeHashIds
Array of strings <= 20 items
gridHashId
string
pinGroupHashIds
Array of strings [ 1 .. 50 ] items
quantityHashIds
Array of strings [ 1 .. 64 ] items
fieldKeys
Array of strings <= 20 items
pinFieldKeys
Array of strings
edgeFieldKeys
Array of strings

Responses

Authorizations:
jwt-token
path Parameters
hashId
required
string
Example: k8gh3
header Parameters
Environment-Hash-Id
required
string
Example: yourAssetEnvironmentHashId
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
string <= 100 characters
description
string <= 255 characters
string or object
includePinsWithoutReports
boolean
reportTypeHashIds
Array of strings <= 20 items
gridHashId
string
pinGroupHashIds
Array of strings [ 1 .. 50 ] items
quantityHashIds
Array of strings [ 1 .. 64 ] items
fieldKeys
Array of strings <= 20 items
pinFieldKeys
Array of strings
edgeFieldKeys
Array of strings

Responses

Request samples

Content type
text/json
{
  • "name": "South",
  • "description": "string",
  • "period": "lastMonth",
  • "includePinsWithoutReports": true,
  • "reportTypeHashIds": [
    ],
  • "gridHashId": "string",
  • "pinGroupHashIds": [
    ],
  • "quantityHashIds": [
    ],
  • "fieldKeys": [
    ],
  • "pinFieldKeys": [
    ],
  • "edgeFieldKeys": [
    ]
}

Measurement-threshold

find

Search through measurement thresholds on environment and pin level

Rights

    @@ -4269,7 +4269,7 @@

    Headers

    • Connectivity environment: ENVIRONMENT_ADMIN
    -
Authorizations:
jwt-token
header Parameters
Environment-Hash-Id
required
string
Example: yourAssetEnvironmentHashId
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
required
string
identifier
required
string <= 1000000 characters

A javascript function that returns deviceType and identifier. See the chapter "User defined code"

+
Authorizations:
jwt-token
header Parameters
Environment-Hash-Id
required
string
Example: yourAssetEnvironmentHashId
Api-Version
required
integer
Example: 5
Request Body schema: text/json
name
required
string <= 255 characters
identifier
required
string <= 1000000 characters

A javascript function that returns deviceType and identifier. See the chapter "User defined code"

Responses

Request samples

Content type
text/json
{
  • "name": "My webhook",
  • "identifier": "function (command) {\n return JSON.stringify({\n hashId: command.hashId,\n commandTypeHashId: command.commandTypeHashId,\n startAt: command.startAt,\n endAt: command.endAt,\n settings: command.settings,\n });\n}"
}

Response samples

Content type
text/json
{}

find

Search through webhooks

Rights

@@ -4420,7 +4420,7 @@

Headers

identifierFieldKey
string or null

Chosen field will serve as an identifier for device instead of hashId

{
  • "hashId": "wasd2",
  • "name": "untranslated string",
  • "fieldConfigurations": [
    ],
  • "pinGroupFieldConfigurations": [
    ],
  • "channels": [
    ],
  • "charts": [
    ],
  • "commandTypeHashIds": [
    ],
  • "identifierFieldKey": "fieldKey"
}

edge

hashId
required
string
node1HashId
required
string or null
node2HashId
required
string or null
object or object
name
required
string
fields
required
object

The field configuration is stored in the fieldConfigurations key of the monitoring environment object

level
required
integer
Enum: 0 1 2

0: no serious or critical open issues, 1: one or more serious open issues an no critical open issues, 2: one or more critical open issues

-
mapLayer
required
string
mostRecentMeasurementAt
required
string or null <date-time>
deletedAt
required
string or null <date-time>
{
  • "hashId": "ka08d",
  • "node1HashId": "qp111a",
  • "node2HashId": "qp111a",
  • "geometry": [
    ],
  • "name": "My line",
  • "fields": {
    },
  • "level": 0,
  • "mapLayer": "myLayer",
  • "mostRecentMeasurementAt": null,
  • "deletedAt": null
}

environment

hashId
required
string
name
required
string
required
Array of objects (mapLayer) non-empty
required
object or null

All pin groups and edges in this monitoring environment are contained in the rectangle described by this linestring. If null, no locations (pinGroups) or lines (edges) are present

+
mapLayer
required
string
mostRecentMeasurementAt
required
string or null <date-time>
deletedAt
required
string or null <date-time>
{
  • "hashId": "ka08d",
  • "node1HashId": "qp111a",
  • "node2HashId": "qp111a",
  • "geometry": [
    ],
  • "name": "My line",
  • "fields": {
    },
  • "level": 0,
  • "mapLayer": "myLayer",
  • "mostRecentMeasurementAt": null,
  • "deletedAt": null
}

environment

hashId
required
string
name
required
string <= 255 characters
required
Array of objects (mapLayer) non-empty
required
object or null

All pin groups and edges in this monitoring environment are contained in the rectangle described by this linestring. If null, no locations (pinGroups) or lines (edges) are present

required
object

See the chapter on open fields on how to use this

locale
required
string
Enum: "en" "nl"

Locale code

defaultGraphRange
required
string
measurementsExpirationDays
required
integer [ 1 .. 9999 ]
enforceTwoFactorAuthentication
required
boolean

Determines whether users need to have two factor authentication enabled in order to access this environment.

@@ -4442,7 +4442,7 @@

Headers

reportHashId
required
string
pinHashId
required
string or null
orderOfMagnitude
required
integer [ -128 .. 127 ]

The measured value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

significand
required
integer [ -2147483648 .. 2147483647 ]

The measured value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

performance
integer

-1: not compared to thresholds, 0: within thresholds, 1: outside serious thresholds but inside critical thresholds, 2: outside critical thresholds

-
{
  • "hashId": "po177",
  • "generatedAt": "2019-12-31T15:23Z",
  • "channelIndex": 0,
  • "channelMeasurementIndex": 0,
  • "reportHashId": "qoa978",
  • "pinHashId": "e13d57",
  • "orderOfMagnitude": -3,
  • "significand": -1500,
  • "performance": 0
}

measurementFilter

hashId
required
string
name
required
string
description
required
string
required
string or object
includePinsWithoutReports
required
boolean
createdAt
required
string <date-time>
updatedAt
required
string <date-time>
deletedAt
string or null <date-time>
{
  • "hashId": "k8gh3",
  • "name": "North",
  • "description": "Temperatures in the North",
  • "period": "lastMonth",
  • "includePinsWithoutReports": true,
  • "createdAt": "2019-12-31T15:23Z",
  • "updatedAt": "2019-12-31T15:23Z",
  • "deletedAt": "2019-08-24T14:15:22Z"
}

measurementThreshold

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

+
{
  • "hashId": "po177",
  • "generatedAt": "2019-12-31T15:23Z",
  • "channelIndex": 0,
  • "channelMeasurementIndex": 0,
  • "reportHashId": "qoa978",
  • "pinHashId": "e13d57",
  • "orderOfMagnitude": -3,
  • "significand": -1500,
  • "performance": 0
}

measurementFilter

hashId
required
string
name
required
string <= 100 characters
description
required
string <= 255 characters
required
string or object
includePinsWithoutReports
required
boolean
createdAt
required
string <date-time>
updatedAt
required
string <date-time>
deletedAt
string or null <date-time>
{
  • "hashId": "k8gh3",
  • "name": "North",
  • "description": "Temperatures in the North",
  • "period": "lastMonth",
  • "includePinsWithoutReports": true,
  • "createdAt": "2019-12-31T15:23Z",
  • "updatedAt": "2019-12-31T15:23Z",
  • "deletedAt": "2019-08-24T14:15:22Z"
}

measurementThreshold

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

@@ -4454,7 +4454,7 @@

Headers

fields
required
object

The field configuration is stored in the fieldConfigurations key of the monitoring environment object

deviceLinkHashId
required
string or null

If null, there is no device installed at this location

level
required
integer
Enum: 0 1 2

0: no serious or critical open issues, 1: one or more serious open issues an no critical open issues, 2: one or more critical open issues

-
mapLayer
required
string
mostRecentMeasurementAt
required
string or null <date-time>
deletedAt
required
string or null <date-time>
{
  • "hashId": "dao97",
  • "geometry": {
    },
  • "name": "My location",
  • "symbolKey": "cp-pole",
  • "deviceFields": { },
  • "fields": {
    },
  • "deviceLinkHashId": null,
  • "level": 0,
  • "mapLayer": "myLayer",
  • "mostRecentMeasurementAt": null,
  • "deletedAt": null
}

quantity

hashId
required
string
required
untranslatedString (string) or translations (object) (stringOrTranslations)
color
required
string
unit
string or null

Will be displayed with an SI-prefix (eg. k or M) if relevant

+
mapLayer
required
string
mostRecentMeasurementAt
required
string or null <date-time>
deletedAt
required
string or null <date-time>
{
  • "hashId": "dao97",
  • "geometry": {
    },
  • "name": "My location",
  • "symbolKey": "cp-pole",
  • "deviceFields": { },
  • "fields": {
    },
  • "deviceLinkHashId": null,
  • "level": 0,
  • "mapLayer": "myLayer",
  • "mostRecentMeasurementAt": null,
  • "deletedAt": null
}

quantity

hashId
required
string
required
untranslatedString (string) or translations (object) (stringOrTranslations)
color
required
string
unit
string or null <= 10 characters

Will be displayed with an SI-prefix (eg. k or M) if relevant

defaultOrderOfMagnitude
integer [ -128 .. 127 ]

Defines default order of magnitude to be selected at manual report form

object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

@@ -4464,7 +4464,7 @@

Headers

{
  • "hashId": "sajia1",
  • "name": "untranslated string",
  • "color": "#ff00ff",
  • "unit": "K",
  • "defaultOrderOfMagnitude": -3,
  • "defaultCriticallyLowThreshold": {
    },
  • "defaultLowThreshold": {
    },
  • "defaultHighThreshold": {
    },
  • "defaultCriticallyHighThreshold": {
    },
  • "disableSiPrefixes": true
}

siNumber

orderOfMagnitude
required
integer [ -128 .. 127 ]
significand
required
integer [ -2147483648 .. 2147483647 ]
{
  • "orderOfMagnitude": 0,
  • "significand": 1500
}

stringOrTranslations

Any of
string (untranslatedString)
Example
"untranslated string"

supplier

hashId
required
string
name
required
string
enforceTwoFactorAuthentication
required
boolean

Determines whether users need to have two factor authentication enabled in order to access this environment.

object or null
createdAt
required
string <date-time>
{
  • "hashId": "f1a4w1",
  • "name": "My connectivity environment",
  • "enforceTwoFactorAuthentication": false,
  • "theme": {
    },
  • "createdAt": "2019-12-31T15:23Z"
}

supplierCertificate

hashId
required
string
name
required
string
certificate
required
string

A Base64 encoded intermediate certificate. Should be used to create device certificates.

createdAt
required
string <date-time>
{
  • "hashId": "v19a12",
  • "name": "My certificate",
  • "certificate": "-----BEGIN CERTIFICATE-----\n MIIBNzCB3gIBATAKBggqhkjOPQQDAjAkMREwDwYDVQQKDAhzdXBwbGllcjEPMA0G\n A1UEAwwGeGQycmQ0MB4XDTIwMDIyNDEzNTQwOVoXDTIxMDIyMzEzNTQwOVowLDEP\n MA0GA1UECgwGZGV2aWNlMRkwFwYDVQQDDBB1bnFpZSBpZGVudGlmaWVyMFkwEwYH\n KoZIzj0CAQYIKoZIzj0DAQcDQgAEUPyQwLuDlKw7CA41ADhxXRvD3n9ZFF0XCeI9\n OAgRIgl2mGmnO31wX1DD4weZoB2pswCBrC39FpyHgIz6LK10PzAKBggqhkjOPQQD\n AgNIADBFAiEAyz0Ha4eFfebqSoES4vxguipSHmR/zN8KjEEie7xpqo8CICFS5NWG\n iaT6xhGfChGbQjpmQQYYabau8Ons8F2JNyLu\n -----END CERTIFICATE-----\n ",
  • "createdAt": "2019-12-31T15:23Z"
}

supplierReportType

hashId
required
string
required
untranslatedString (string) or translations (object) (stringOrTranslations)
required
object

See the chapter on open fields on how to use this

-
deletedAt
required
string or null <date-time>
{
  • "hashId": "l19a7s",
  • "name": "untranslated string",
  • "fieldConfigurations": {
    },
  • "deletedAt": null
}

supplierWebhook

hashId
required
string
name
required
string
createdAt
required
string <date-time>
{
  • "hashId": "z812a63",
  • "name": "My webhook",
  • "createdAt": "2019-12-31T15:23Z"
}

threshold

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

+
deletedAt
required
string or null <date-time>
{
  • "hashId": "l19a7s",
  • "name": "untranslated string",
  • "fieldConfigurations": {
    },
  • "deletedAt": null
}

supplierWebhook

hashId
required
string
name
required
string <= 255 characters
createdAt
required
string <date-time>
{
  • "hashId": "z812a63",
  • "name": "My webhook",
  • "createdAt": "2019-12-31T15:23Z"
}

threshold

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

required
object or null (siNumber)

Significant number. Its value is significand * 10 ^ orderOfMagnitude. It has as many significant figures as the significand has (except when the significand is 0, then the number of significant figures is not defined)

@@ -4477,7 +4477,7 @@

Headers

{
  • "hashId": "b45zo0",
  • "email": "info@acme.com",
  • "name": "John Doe",
  • "timezone": "Europe/Amsterdam",
  • "locale": "en",
  • "phone": "string",
  • "company": "string",
  • "rights": [
    ],
  • "twoFactorAuthenticationEnabled": true
}

userEnvironmentSettings

notificationLevel
required
number or null <float>
Enum: 0 1 2

The user is subscribed to every issue created on locations in this environment (0), when the issue gets serious (1) or when the issue gets critical (2). If null, the user is not autmatically subscribed to new issues.

defaultAnalyticsPanelHashId
required
string or null
{
  • "notificationLevel": 0,
  • "defaultAnalyticsPanelHashId": "7usgt"
}

userSubscription

hashId
required
string
objectType
required
string
Enum: "supplierReportType" "deviceType" "supplierWebhook" "supplierCertificate"
objectHashId
required
string
lastNotification
required
string or null <date-time>
alertsSinceLastNotification
required
integer
createdAt
required
string <date-time>
{
  • "hashId": "dfa1p",
  • "objectType": "deviceType",
  • "objectHashId": "wasd2",
  • "lastNotification": "2020-01-31T11:17Z",
  • "alertsSinceLastNotification": 0,
  • "createdAt": "2019-12-31T15:23Z"
}

webRequest

hashId
required
string
incoming
required
boolean
createdAt
required
string <date-time>
required
object
required
object or null
{
  • "hashId": "1a532q",
  • "incoming": true,
  • "createdAt": "2019-12-31T15:23Z",
  • "request": {
    },
  • "response": {
    }
}