diff --git a/agnssDeviceRequestsHandler/agnssDeviceRequestsHandler.ts b/agnssDeviceRequestsHandler/agnssDeviceRequestsHandler.ts index c1e11dc37..e64ba2e32 100644 --- a/agnssDeviceRequestsHandler/agnssDeviceRequestsHandler.ts +++ b/agnssDeviceRequestsHandler/agnssDeviceRequestsHandler.ts @@ -8,7 +8,7 @@ import { Static } from '@sinclair/typebox' import { agnssRequestSchema } from '../agnss/types.js' import { fromEnv } from '../lib/fromEnv.js' import { log, logError } from '../lib/log.js' -import { validateWithJSONSchema } from '../lib/validateWithJSONSchema.js' +import { validate } from '../lib/validate.js' type AGNSS = ( | { @@ -29,7 +29,7 @@ type AGNSSContext = Omit & { } } -const validateAgnssRequest = validateWithJSONSchema(agnssRequestSchema) +const validateAgnssRequest = validate(agnssRequestSchema) const config = () => fromEnv({ @@ -102,7 +102,7 @@ const agnssDeviceRequestsHandler = async ( return } deviceRequests.push({ - request: valid, + request: valid.value, deviceId, }) }) diff --git a/agnssResolveRequestFromNrfCloud/agnss.ts b/agnssResolveRequestFromNrfCloud/agnss.ts index c68dc62c8..b14aabfb7 100644 --- a/agnssResolveRequestFromNrfCloud/agnss.ts +++ b/agnssResolveRequestFromNrfCloud/agnss.ts @@ -2,7 +2,7 @@ import { verify } from '@nordicsemiconductor/nrfcloud-location-services-tests' import { Static, Type } from '@sinclair/typebox' import { agnssRequestSchema, AGNSSType } from '../agnss/types.js' import { ErrorInfo, ErrorType } from '../lib/ErrorInfo.js' -import { validateWithJSONSchema } from '../lib/validateWithJSONSchema.js' +import { validate } from '../lib/validate.js' import { apiClient } from '../third-party/nrfcloud.com/apiclient.js' const PositiveInteger = Type.Integer({ minimum: 1, title: 'positive integer' }) @@ -11,7 +11,7 @@ const apiRequestSchema = Type.Object( { eci: PositiveInteger, tac: PositiveInteger, - requestType: Type.RegEx(/^custom$/), + requestType: Type.RegExp(/^custom$/), mcc: Type.Integer({ minimum: 100, maximum: 999 }), mnc: Type.Integer({ minimum: 0, maximum: 99 }), customTypes: Type.Array(Type.Enum(AGNSSType), { minItems: 1 }), @@ -19,7 +19,7 @@ const apiRequestSchema = Type.Object( { additionalProperties: false }, ) -const validateInput = validateWithJSONSchema(agnssRequestSchema) +const validateInput = validate(agnssRequestSchema) export const resolveAgnssRequest = ( @@ -37,7 +37,7 @@ export const resolveAgnssRequest = return valid } - const { mcc, mnc, cell, area, types } = valid + const { mcc, mnc, cell, area, types } = valid.value // Split requests, so that request for Ephemerides is a separate one const otherTypesInRequest = types.filter((t) => t !== AGNSSType.Ephemerides) diff --git a/lib/validate.spec.ts b/lib/validate.spec.ts new file mode 100644 index 000000000..a7889d13a --- /dev/null +++ b/lib/validate.spec.ts @@ -0,0 +1,19 @@ +import { Type } from '@sinclair/typebox' +import { validate } from './validate.js' +import { describe, test as it } from 'node:test' +import assert from 'node:assert/strict' + +void describe('validate', () => { + void it('Should check input is valid', async () => { + const maybeValid = validate(Type.Number())(42) + if ('value' in maybeValid) { + assert.equal(maybeValid.value, 42) + } else { + throw new Error(`It should be valid!`) + } + }) + void it("Should check as 'invalid' values less than 0", () => { + const maybeValid = validate(Type.Number({ minimum: 0 }))(-42) + assert.equal('error' in maybeValid, true) + }) +}) diff --git a/lib/validate.ts b/lib/validate.ts new file mode 100644 index 000000000..1ba9065c8 --- /dev/null +++ b/lib/validate.ts @@ -0,0 +1,32 @@ +import type { Static, TSchema } from '@sinclair/typebox' +import { TypeCompiler } from '@sinclair/typebox/compiler' +import { ErrorInfo, ErrorType } from './ErrorInfo.js' + +/** + * Validate the value against the given TypeBox schema + */ +export const validate = ( + schema: T, +): ((value: unknown) => + | { value: Static } + | { + error: ErrorInfo + }) => { + const C = TypeCompiler.Compile(schema) + return (value: unknown) => { + const firstError = C.Errors(value).First() + if (firstError !== undefined) { + return { + error: { + type: ErrorType.BadRequest, + message: 'Validation failed!', + detail: { + errors: [...C.Errors(value)], + input: value, + }, + }, + } + } + return { value: value as Static } + } +} diff --git a/lib/validateWithJSONSchema.ts b/lib/validateWithJSONSchema.ts deleted file mode 100644 index 747fd396c..000000000 --- a/lib/validateWithJSONSchema.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Static, TObject, TProperties } from '@sinclair/typebox' -import Ajv from 'ajv' -import { ErrorInfo, ErrorType } from './ErrorInfo.js' - -export const validateWithJSONSchema = >( - schema: T, -): (( - value: Record, -) => { error: ErrorInfo } | Static) => { - const ajv = new Ajv() - // see @https://github.com/sinclairzx81/typebox/issues/51 - ajv.addKeyword('kind') - ajv.addKeyword('modifier') - const v = ajv.compile(schema) - return (value: Record) => { - const valid = v(value) - if (valid !== true) { - return { - error: { - type: ErrorType.BadRequest, - message: 'Validation failed!', - detail: { - errors: v.errors, - input: value, - }, - }, - } - } - return value as Static - } -} diff --git a/package-lock.json b/package-lock.json index f8e05642b..b92146b8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,11 +20,10 @@ "@azure/storage-queue": "12.16.0", "@nordicsemiconductor/cell-geolocation-helpers": "6.0.0", "@nordicsemiconductor/nrfcloud-location-services-tests": "6.0.0", - "@nordicsemiconductor/object-to-env": "7.0.3", + "@nordicsemiconductor/object-to-env": "7.0.6", "@nordicsemiconductor/random-words": "8.0.0", "@octokit/rest": "20.0.2", - "@sinclair/typebox": "0.31.28", - "ajv": "8.12.0", + "@sinclair/typebox": "0.32.9", "azure-iot-common": "1.13.2", "azure-iot-provisioning-service": "1.11.2", "azure-iothub": "1.16.4", @@ -36,18 +35,18 @@ "@azure/arm-resources-subscriptions": "2.1.0", "@azure/data-tables": "13.2.2", "@azure/logger": "1.0.4", - "@commitlint/config-conventional": "18.4.3", - "@nordicsemiconductor/asset-tracker-cloud-code-style": "13.1.5", - "@nordicsemiconductor/device-helpers": "17.0.33", + "@commitlint/config-conventional": "18.4.4", + "@nordicsemiconductor/asset-tracker-cloud-code-style": "13.1.8", + "@nordicsemiconductor/device-helpers": "17.0.45", "@nordicsemiconductor/e2e-bdd-test-runner": "17.0.1", "@nordicsemiconductor/eslint-config-asset-tracker-cloud-typescript": "17.0.0", "@types/backoff": "2.5.5", "@types/chai-subset": "1.3.5", "@types/jsonwebtoken": "9.0.5", - "@types/node": "20.10.6", + "@types/node": "20.11.2", "@types/pem": "1.14.4", "@types/semver": "7.5.6", - "@typescript-eslint/eslint-plugin": "6.17.0", + "@typescript-eslint/eslint-plugin": "6.18.1", "chai-subset": "1.6.0", "chalk": "5.3.0", "check-node-version": "4.2.1", @@ -1665,16 +1664,16 @@ } }, "node_modules/@commitlint/cli": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-18.4.3.tgz", - "integrity": "sha512-zop98yfB3A6NveYAZ3P1Mb6bIXuCeWgnUfVNkH4yhIMQpQfzFwseadazOuSn0OOfTt0lWuFauehpm9GcqM5lww==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-18.4.4.tgz", + "integrity": "sha512-Ro3wIo//fV3XiV1EkdpHog6huaEyNcUAVrSmtgKqYM5g982wOWmP4FXvEDFwRMVgz878CNBvvCc33dMZ5AQJ/g==", "dev": true, "dependencies": { - "@commitlint/format": "^18.4.3", - "@commitlint/lint": "^18.4.3", - "@commitlint/load": "^18.4.3", - "@commitlint/read": "^18.4.3", - "@commitlint/types": "^18.4.3", + "@commitlint/format": "^18.4.4", + "@commitlint/lint": "^18.4.4", + "@commitlint/load": "^18.4.4", + "@commitlint/read": "^18.4.4", + "@commitlint/types": "^18.4.4", "execa": "^5.0.0", "lodash.isfunction": "^3.0.9", "resolve-from": "5.0.0", @@ -1689,9 +1688,9 @@ } }, "node_modules/@commitlint/config-conventional": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-18.4.3.tgz", - "integrity": "sha512-729eRRaNta7JZF07qf6SAGSghoDEp9mH7yHU0m7ff0q89W97wDrWCyZ3yoV3mcQJwbhlmVmZPTkPcm7qiAu8WA==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-18.4.4.tgz", + "integrity": "sha512-Bz3sPQSboBN+Et/KyZrR+OJ3z9PrHDw7Bls0/hv94PmuHBtMq1dCGxS9XzTGzxeMNlytCC4kxF083tbhPljl3Q==", "dev": true, "dependencies": { "conventional-changelog-conventionalcommits": "^7.0.2" @@ -1701,12 +1700,12 @@ } }, "node_modules/@commitlint/config-validator": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-18.4.3.tgz", - "integrity": "sha512-FPZZmTJBARPCyef9ohRC9EANiQEKSWIdatx5OlgeHKu878dWwpyeFauVkhzuBRJFcCA4Uvz/FDtlDKs008IHcA==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-18.4.4.tgz", + "integrity": "sha512-/QI8KIg/h7O0Eus36fPcEcO3QPBcdXuGfZeCF5m15k0EB2bcU8s6pHNTNEa6xz9PrAefHCL+yzRJj7w20T6Mow==", "dev": true, "dependencies": { - "@commitlint/types": "^18.4.3", + "@commitlint/types": "^18.4.4", "ajv": "^8.11.0" }, "engines": { @@ -1714,12 +1713,12 @@ } }, "node_modules/@commitlint/ensure": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-18.4.3.tgz", - "integrity": "sha512-MI4fwD9TWDVn4plF5+7JUyLLbkOdzIRBmVeNlk4dcGlkrVA+/l5GLcpN66q9LkFsFv6G2X31y89ApA3hqnqIFg==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-18.4.4.tgz", + "integrity": "sha512-KjD19p6julB5WrQL+Cd8p+AePwpl1XzGAjB0jnuFMKWtji9L7ucCZUKDstGjlkBZGGzH/nvdB8K+bh5K27EVUg==", "dev": true, "dependencies": { - "@commitlint/types": "^18.4.3", + "@commitlint/types": "^18.4.4", "lodash.camelcase": "^4.3.0", "lodash.kebabcase": "^4.1.1", "lodash.snakecase": "^4.1.1", @@ -1731,21 +1730,21 @@ } }, "node_modules/@commitlint/execute-rule": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-18.4.3.tgz", - "integrity": "sha512-t7FM4c+BdX9WWZCPrrbV5+0SWLgT3kCq7e7/GhHCreYifg3V8qyvO127HF796vyFql75n4TFF+5v1asOOWkV1Q==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-18.4.4.tgz", + "integrity": "sha512-a37Nd3bDQydtg9PCLLWM9ZC+GO7X5i4zJvrggJv5jBhaHsXeQ9ZWdO6ODYR+f0LxBXXNYK3geYXJrCWUCP8JEg==", "dev": true, "engines": { "node": ">=v18" } }, "node_modules/@commitlint/format": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-18.4.3.tgz", - "integrity": "sha512-8b+ItXYHxAhRAXFfYki5PpbuMMOmXYuzLxib65z2XTqki59YDQJGpJ/wB1kEE5MQDgSTQWtKUrA8n9zS/1uIDQ==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-18.4.4.tgz", + "integrity": "sha512-2v3V5hVlv0R3pe7p66IX5F7cjeVvGM5JqITRIbBCFvGHPJ/CG74rjTkAu0RBEiIhlk3eOaLjVGq3d5falPkLBA==", "dev": true, "dependencies": { - "@commitlint/types": "^18.4.3", + "@commitlint/types": "^18.4.4", "chalk": "^4.1.0" }, "engines": { @@ -1796,12 +1795,12 @@ } }, "node_modules/@commitlint/is-ignored": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-18.4.3.tgz", - "integrity": "sha512-ZseOY9UfuAI32h9w342Km4AIaTieeFskm2ZKdrG7r31+c6zGBzuny9KQhwI9puc0J3GkUquEgKJblCl7pMnjwg==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-18.4.4.tgz", + "integrity": "sha512-rXWes9owKBTjfTr6Od7YlflRg4N+ngkOH+dUZhk0qL/XQb26mHz0EgVgdixMVBac1OsohRwJaLmVHX+5F6vfmg==", "dev": true, "dependencies": { - "@commitlint/types": "^18.4.3", + "@commitlint/types": "^18.4.4", "semver": "7.5.4" }, "engines": { @@ -1809,31 +1808,30 @@ } }, "node_modules/@commitlint/lint": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-18.4.3.tgz", - "integrity": "sha512-18u3MRgEXNbnYkMOWoncvq6QB8/90m9TbERKgdPqVvS+zQ/MsuRhdvHYCIXGXZxUb0YI4DV2PC4bPneBV/fYuA==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-18.4.4.tgz", + "integrity": "sha512-SoyQstVxMY5Z4GnFRtRzy+NWYb+yVseXgir+7BxnpB59oH05C9XztRrhDw6OnkNeXhjINTpi1HLnuY7So+CaAQ==", "dev": true, "dependencies": { - "@commitlint/is-ignored": "^18.4.3", - "@commitlint/parse": "^18.4.3", - "@commitlint/rules": "^18.4.3", - "@commitlint/types": "^18.4.3" + "@commitlint/is-ignored": "^18.4.4", + "@commitlint/parse": "^18.4.4", + "@commitlint/rules": "^18.4.4", + "@commitlint/types": "^18.4.4" }, "engines": { "node": ">=v18" } }, "node_modules/@commitlint/load": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-18.4.3.tgz", - "integrity": "sha512-v6j2WhvRQJrcJaj5D+EyES2WKTxPpxENmNpNG3Ww8MZGik3jWRXtph0QTzia5ZJyPh2ib5aC/6BIDymkUUM58Q==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-18.4.4.tgz", + "integrity": "sha512-RaDIa9qwOw2xRJ3Jr2DBXd14rmnHJIX2XdZF4kmoF1rgsg/+7cvrExLSUNAkQUNimyjCn1b/bKX2Omm+GdY0XQ==", "dev": true, "dependencies": { - "@commitlint/config-validator": "^18.4.3", - "@commitlint/execute-rule": "^18.4.3", - "@commitlint/resolve-extends": "^18.4.3", - "@commitlint/types": "^18.4.3", - "@types/node": "^18.11.9", + "@commitlint/config-validator": "^18.4.4", + "@commitlint/execute-rule": "^18.4.4", + "@commitlint/resolve-extends": "^18.4.4", + "@commitlint/types": "^18.4.4", "chalk": "^4.1.0", "cosmiconfig": "^8.3.6", "cosmiconfig-typescript-loader": "^5.0.0", @@ -1846,15 +1844,6 @@ "node": ">=v18" } }, - "node_modules/@commitlint/load/node_modules/@types/node": { - "version": "18.19.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.2.tgz", - "integrity": "sha512-6wzfBdbWpe8QykUkXBjtmO3zITA0A3FIjoy+in0Y2K4KrCiRhNYJIdwAPDffZ3G6GnaKaSLSEa9ZuORLfEoiwg==", - "dev": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, "node_modules/@commitlint/load/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -1899,21 +1888,21 @@ } }, "node_modules/@commitlint/message": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-18.4.3.tgz", - "integrity": "sha512-ddJ7AztWUIoEMAXoewx45lKEYEOeOlBVWjk8hDMUGpprkuvWULpaXczqdjwVtjrKT3JhhN+gMs8pm5G3vB2how==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-18.4.4.tgz", + "integrity": "sha512-lHF95mMDYgAI1LBXveJUyg4eLaMXyOqJccCK3v55ZOEUsMPrDi8upqDjd/NmzWmESYihaOMBTAnxm+6oD1WoDQ==", "dev": true, "engines": { "node": ">=v18" } }, "node_modules/@commitlint/parse": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-18.4.3.tgz", - "integrity": "sha512-eoH7CXM9L+/Me96KVcfJ27EIIbA5P9sqw3DqjJhRYuhaULIsPHFs5S5GBDCqT0vKZQDx0DgxhMpW6AQbnKrFtA==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-18.4.4.tgz", + "integrity": "sha512-99G7dyn/OoyNWXJni0Ki0K3aJd01pEb/Im/Id6y4X7PN+kGOahjz2z/cXYYHn7xDdooqFVdiVrVLeChfgpWZ2g==", "dev": true, "dependencies": { - "@commitlint/types": "^18.4.3", + "@commitlint/types": "^18.4.4", "conventional-changelog-angular": "^7.0.0", "conventional-commits-parser": "^5.0.0" }, @@ -1922,14 +1911,13 @@ } }, "node_modules/@commitlint/read": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-18.4.3.tgz", - "integrity": "sha512-H4HGxaYA6OBCimZAtghL+B+SWu8ep4X7BwgmedmqWZRHxRLcX2q0bWBtUm5FsMbluxbOfrJwOs/Z0ah4roP/GQ==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-18.4.4.tgz", + "integrity": "sha512-r58JbWky4gAFPea/CZmvlqP9Ehbs+8gSEUqhIJOojKzTc3xlxFnZUDVPcEnnaqzQEEoV6C69VW7xuzdcBlu/FQ==", "dev": true, "dependencies": { - "@commitlint/top-level": "^18.4.3", - "@commitlint/types": "^18.4.3", - "fs-extra": "^11.0.0", + "@commitlint/top-level": "^18.4.4", + "@commitlint/types": "^18.4.4", "git-raw-commits": "^2.0.11", "minimist": "^1.2.6" }, @@ -1938,13 +1926,13 @@ } }, "node_modules/@commitlint/resolve-extends": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-18.4.3.tgz", - "integrity": "sha512-30sk04LZWf8+SDgJrbJCjM90gTg2LxsD9cykCFeFu+JFHvBFq5ugzp2eO/DJGylAdVaqxej3c7eTSE64hR/lnw==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-18.4.4.tgz", + "integrity": "sha512-RRpIHSbRnFvmGifVk21Gqazf1QF/yeP+Kkg/e3PlkegcOKd/FGOXp/Kx9cvSO2K7ucSn4GD/oBvgasFoy+NCAw==", "dev": true, "dependencies": { - "@commitlint/config-validator": "^18.4.3", - "@commitlint/types": "^18.4.3", + "@commitlint/config-validator": "^18.4.4", + "@commitlint/types": "^18.4.4", "import-fresh": "^3.0.0", "lodash.mergewith": "^4.6.2", "resolve-from": "^5.0.0", @@ -1955,15 +1943,15 @@ } }, "node_modules/@commitlint/rules": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-18.4.3.tgz", - "integrity": "sha512-8KIeukDf45BiY+Lul1T0imSNXF0sMrlLG6JpLLKolkmYVQ6PxxoNOriwyZ3UTFFpaVbPy0rcITaV7U9JCAfDTA==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-18.4.4.tgz", + "integrity": "sha512-6Uzlsnl/GljEI+80NWjf4ThOfR8NIsbm18IfXYuCEchlwMHSxiuYG4rHSK5DNmG/+MIo8eR5VdQ0gQyt7kWzAA==", "dev": true, "dependencies": { - "@commitlint/ensure": "^18.4.3", - "@commitlint/message": "^18.4.3", - "@commitlint/to-lines": "^18.4.3", - "@commitlint/types": "^18.4.3", + "@commitlint/ensure": "^18.4.4", + "@commitlint/message": "^18.4.4", + "@commitlint/to-lines": "^18.4.4", + "@commitlint/types": "^18.4.4", "execa": "^5.0.0" }, "engines": { @@ -1971,18 +1959,18 @@ } }, "node_modules/@commitlint/to-lines": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-18.4.3.tgz", - "integrity": "sha512-fy1TAleik4Zfru1RJ8ZU6cOSvgSVhUellxd3WZV1D5RwHZETt1sZdcA4mQN2y3VcIZsUNKkW0Mq8CM9/L9harQ==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-18.4.4.tgz", + "integrity": "sha512-mwe2Roa59NCz/krniAdCygFabg7+fQCkIhXqBHw00XQ8Y7lw4poZLLxeGI3p3bLpcEOXdqIDrEGLwHmG5lBdwQ==", "dev": true, "engines": { "node": ">=v18" } }, "node_modules/@commitlint/top-level": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-18.4.3.tgz", - "integrity": "sha512-E6fJPBLPFL5R8+XUNSYkj4HekIOuGMyJo3mIx2PkYc3clel+pcWQ7TConqXxNWW4x1ugigiIY2RGot55qUq1hw==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-18.4.4.tgz", + "integrity": "sha512-PBwW1drgeavl9CadB7IPRUk6rkUP/O8jEkxjlC+ofuh3pw0bzJdAT+Kw7M1Yc9KtTb9xTaqUB8uvRtaybHa/tQ==", "dev": true, "dependencies": { "find-up": "^5.0.0" @@ -1992,9 +1980,9 @@ } }, "node_modules/@commitlint/types": { - "version": "18.4.3", - "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-18.4.3.tgz", - "integrity": "sha512-cvzx+vtY/I2hVBZHCLrpoh+sA0hfuzHwDc+BAFPimYLjJkpHnghQM+z8W/KyLGkygJh3BtI3xXXq+dKjnSWEmA==", + "version": "18.4.4", + "resolved": "https://registry.npmjs.org/@commitlint/types/-/types-18.4.4.tgz", + "integrity": "sha512-/FykLtodD8gKs3+VNkAUwofu4LBHankclj+I8fB2jTRvG6PV7k/OUt4P+VbM7ip853qS4F0g7Z6hLNa6JeMcAQ==", "dev": true, "dependencies": { "chalk": "^4.1.0" @@ -2572,17 +2560,17 @@ } }, "node_modules/@nordicsemiconductor/asset-tracker-cloud-code-style": { - "version": "13.1.5", - "resolved": "https://registry.npmjs.org/@nordicsemiconductor/asset-tracker-cloud-code-style/-/asset-tracker-cloud-code-style-13.1.5.tgz", - "integrity": "sha512-QrrxXT1qC5aJVsFIMNQ7usJDsx9G7kPu0gjkXV6BMU5GXHG6RXdkwqLKpFWhQ4KOcQ15Fo24UmdoNd0tvOgtIw==", + "version": "13.1.8", + "resolved": "https://registry.npmjs.org/@nordicsemiconductor/asset-tracker-cloud-code-style/-/asset-tracker-cloud-code-style-13.1.8.tgz", + "integrity": "sha512-xffq08l38JoX673BU5ANShokvjmDXLVUNdWLosIl2X8KFvVFbgYEL8jvRiYBR0Mt1Vpbocc873GGigleuOFUpQ==", "dev": true, "dependencies": { - "@commitlint/cli": "18.4.3", + "@commitlint/cli": "18.4.4", "eslint": "8.56.0", "husky": "8.0.3", "lint-staged": "15.2.0", "pinst": "3.0.0", - "prettier": "3.1.1", + "prettier": "3.2.2", "prettier-plugin-organize-imports": "3.2.4", "typescript": "5.3.3" }, @@ -2603,9 +2591,9 @@ } }, "node_modules/@nordicsemiconductor/device-helpers": { - "version": "17.0.33", - "resolved": "https://registry.npmjs.org/@nordicsemiconductor/device-helpers/-/device-helpers-17.0.33.tgz", - "integrity": "sha512-PjVmKkCdS8wmwwPOku57PWrczGpSYHByP6C6w5ohBQJiy330gqO1fT2jNxfkkJhTNnJh6ImNK9IwGsr1X2aqng==", + "version": "17.0.45", + "resolved": "https://registry.npmjs.org/@nordicsemiconductor/device-helpers/-/device-helpers-17.0.45.tgz", + "integrity": "sha512-WlOvNglf0u/pXFYGmuEeC5pM3wvUoX8eABkCKevY4aFqoVtSD1R42Sc6dVCEd06J3HJXqMTyZIUnfomxa9uKkA==", "dev": true, "dependencies": { "@serialport/parser-readline": "12.0.0", @@ -2728,11 +2716,11 @@ } }, "node_modules/@nordicsemiconductor/object-to-env": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/@nordicsemiconductor/object-to-env/-/object-to-env-7.0.3.tgz", - "integrity": "sha512-jdw7PLuXd9kNpw1QH30NVmE9g12KEfe7OC3wKapHCFkjXvtblKaJGEyI1a9zcBPPcq7aEjWWepgl3dPgXFJ+RQ==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@nordicsemiconductor/object-to-env/-/object-to-env-7.0.6.tgz", + "integrity": "sha512-F7MMy0UDAYZCcTfnL76mFcDWT3cuD04rF9Hn6q8qRg6GCOgaSiRJY6gtoQAm+FRnL3L6fzqPZ/XhQ7YwEm8YPw==", "dependencies": { - "change-case": "5.3.0" + "change-case": "5.4.2" }, "engines": { "node": ">=20", @@ -3135,9 +3123,9 @@ } }, "node_modules/@sinclair/typebox": { - "version": "0.31.28", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.31.28.tgz", - "integrity": "sha512-/s55Jujywdw/Jpan+vsy6JZs1z2ZTGxTmbZTPiuSL2wz9mfzA2gN1zzaqmvfi4pq+uOt7Du85fkiwv5ymW84aQ==" + "version": "0.32.9", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.32.9.tgz", + "integrity": "sha512-6oeJJPTIb0y3cs713HmXmXSx3WRWgid74KICYL9blOhNFuAcAB18dDWfATgcgzynfpF5xDzHGxEVbDYYr6nvgg==" }, "node_modules/@smithy/abort-controller": { "version": "2.0.12", @@ -3742,9 +3730,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.10.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.6.tgz", - "integrity": "sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==", + "version": "20.11.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.2.tgz", + "integrity": "sha512-cZShBaVa+UO1LjWWBPmWRR4+/eY/JR/UIEcDlVsw3okjWEu+rB7/mH6X3B/L+qJVHDLjk9QW/y2upp9wp1yDXA==", "dependencies": { "undici-types": "~5.26.4" } @@ -3811,16 +3799,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.17.0.tgz", - "integrity": "sha512-Vih/4xLXmY7V490dGwBQJTpIZxH4ZFH6eCVmQ4RFkB+wmaCTDAx4dtgoWwMNGKLkqRY1L6rPqzEbjorRnDo4rQ==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz", + "integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.17.0", - "@typescript-eslint/type-utils": "6.17.0", - "@typescript-eslint/utils": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/type-utils": "6.18.1", + "@typescript-eslint/utils": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -3846,13 +3834,13 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.17.0.tgz", - "integrity": "sha512-RX7a8lwgOi7am0k17NUO0+ZmMOX4PpjLtLRgLmT1d3lBYdWH4ssBUbwdmc5pdRX8rXon8v9x8vaoOSpkHfcXGA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", + "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0" + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -3863,9 +3851,9 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.17.0.tgz", - "integrity": "sha512-qRKs9tvc3a4RBcL/9PXtKSehI/q8wuU9xYJxe97WFxnzH8NWWtcW3ffNS+EWg8uPvIerhjsEZ+rHtDqOCiH57A==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", + "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -3876,12 +3864,12 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.17.0.tgz", - "integrity": "sha512-H6VwB/k3IuIeQOyYczyyKN8wH6ed8EwliaYHLxOIhyF0dYEIsN8+Bk3GE19qafeMKyZJJHP8+O1HiFhFLUNKSg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", + "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", + "@typescript-eslint/types": "6.18.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -3991,13 +3979,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.17.0.tgz", - "integrity": "sha512-hDXcWmnbtn4P2B37ka3nil3yi3VCQO2QEB9gBiHJmQp5wmyQWqnjA85+ZcE8c4FqnaB6lBwMrPkgd4aBYz3iNg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz", + "integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.17.0", - "@typescript-eslint/utils": "6.17.0", + "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/utils": "6.18.1", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -4018,9 +4006,9 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.17.0.tgz", - "integrity": "sha512-qRKs9tvc3a4RBcL/9PXtKSehI/q8wuU9xYJxe97WFxnzH8NWWtcW3ffNS+EWg8uPvIerhjsEZ+rHtDqOCiH57A==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", + "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -4031,13 +4019,13 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.17.0.tgz", - "integrity": "sha512-gVQe+SLdNPfjlJn5VNGhlOhrXz4cajwFd5kAgWtZ9dCZf4XJf8xmgCTLIqec7aha3JwgLI2CK6GY1043FRxZwg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", + "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -4059,12 +4047,12 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.17.0.tgz", - "integrity": "sha512-H6VwB/k3IuIeQOyYczyyKN8wH6ed8EwliaYHLxOIhyF0dYEIsN8+Bk3GE19qafeMKyZJJHP8+O1HiFhFLUNKSg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", + "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", + "@typescript-eslint/types": "6.18.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -4154,17 +4142,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.17.0.tgz", - "integrity": "sha512-LofsSPjN/ITNkzV47hxas2JCsNCEnGhVvocfyOcLzT9c/tSZE7SfhS/iWtzP1lKNOEfLhRTZz6xqI8N2RzweSQ==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", + "integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.17.0", - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/typescript-estree": "6.17.0", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/typescript-estree": "6.18.1", "semver": "^7.5.4" }, "engines": { @@ -4179,13 +4167,13 @@ } }, "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.17.0.tgz", - "integrity": "sha512-RX7a8lwgOi7am0k17NUO0+ZmMOX4PpjLtLRgLmT1d3lBYdWH4ssBUbwdmc5pdRX8rXon8v9x8vaoOSpkHfcXGA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", + "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0" + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -4196,9 +4184,9 @@ } }, "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.17.0.tgz", - "integrity": "sha512-qRKs9tvc3a4RBcL/9PXtKSehI/q8wuU9xYJxe97WFxnzH8NWWtcW3ffNS+EWg8uPvIerhjsEZ+rHtDqOCiH57A==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", + "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -4209,13 +4197,13 @@ } }, "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.17.0.tgz", - "integrity": "sha512-gVQe+SLdNPfjlJn5VNGhlOhrXz4cajwFd5kAgWtZ9dCZf4XJf8xmgCTLIqec7aha3JwgLI2CK6GY1043FRxZwg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", + "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", - "@typescript-eslint/visitor-keys": "6.17.0", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -4237,12 +4225,12 @@ } }, "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.17.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.17.0.tgz", - "integrity": "sha512-H6VwB/k3IuIeQOyYczyyKN8wH6ed8EwliaYHLxOIhyF0dYEIsN8+Bk3GE19qafeMKyZJJHP8+O1HiFhFLUNKSg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", + "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.17.0", + "@typescript-eslint/types": "6.18.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -4386,6 +4374,7 @@ }, "node_modules/ajv": { "version": "8.12.0", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -5074,9 +5063,9 @@ } }, "node_modules/change-case": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.3.0.tgz", - "integrity": "sha512-Eykca0fGS/xYlx2fG5NqnGSnsWauhSGiSXYhB1kO6E909GUfo8S54u4UZNS7lMJmgZumZ2SUpWaoLgAcfQRICg==" + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-5.4.2.tgz", + "integrity": "sha512-WB3UiTDpT+vrTilAWaJS4gaIH/jc1He4H9f6erQvraUYas90uWT0JOYFkG1imdNv710XJ6gJvqynrgOHc4ihDA==" }, "node_modules/check-error": { "version": "1.0.3", @@ -6459,6 +6448,7 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", + "dev": true, "license": "MIT" }, "node_modules/fast-glob": { @@ -6736,20 +6726,6 @@ "node": ">=12.20.0" } }, - "node_modules/fs-extra": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", - "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "license": "ISC" @@ -7853,6 +7829,7 @@ }, "node_modules/json-schema-traverse": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { @@ -7879,18 +7856,6 @@ "node": ">= 8" } }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", @@ -9202,9 +9167,9 @@ } }, "node_modules/prettier": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", - "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.2.tgz", + "integrity": "sha512-HTByuKZzw7utPiDO523Tt2pLtEyK7OibUD9suEJQrPUCYQqrHr74GGX6VidMrovbf/I50mPqr8j/II6oBAuc5A==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -9535,6 +9500,7 @@ }, "node_modules/require-from-string": { "version": "2.0.2", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -10529,15 +10495,6 @@ "version": "6.0.0", "license": "ISC" }, - "node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", @@ -10570,6 +10527,7 @@ }, "node_modules/uri-js": { "version": "4.4.1", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" diff --git a/package.json b/package.json index 26a118f6e..60694117b 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,10 @@ "@azure/storage-queue": "12.16.0", "@nordicsemiconductor/cell-geolocation-helpers": "6.0.0", "@nordicsemiconductor/nrfcloud-location-services-tests": "6.0.0", - "@nordicsemiconductor/object-to-env": "7.0.3", + "@nordicsemiconductor/object-to-env": "7.0.6", "@nordicsemiconductor/random-words": "8.0.0", "@octokit/rest": "20.0.2", - "@sinclair/typebox": "0.31.28", - "ajv": "8.12.0", + "@sinclair/typebox": "0.32.9", "azure-iot-common": "1.13.2", "azure-iot-provisioning-service": "1.11.2", "azure-iothub": "1.16.4", @@ -51,18 +50,18 @@ "@azure/arm-resources-subscriptions": "2.1.0", "@azure/data-tables": "13.2.2", "@azure/logger": "1.0.4", - "@commitlint/config-conventional": "18.4.3", - "@nordicsemiconductor/asset-tracker-cloud-code-style": "13.1.5", - "@nordicsemiconductor/device-helpers": "17.0.33", + "@commitlint/config-conventional": "18.4.4", + "@nordicsemiconductor/asset-tracker-cloud-code-style": "13.1.8", + "@nordicsemiconductor/device-helpers": "17.0.45", "@nordicsemiconductor/e2e-bdd-test-runner": "17.0.1", "@nordicsemiconductor/eslint-config-asset-tracker-cloud-typescript": "17.0.0", "@types/backoff": "2.5.5", "@types/chai-subset": "1.3.5", "@types/jsonwebtoken": "9.0.5", - "@types/node": "20.10.6", + "@types/node": "20.11.2", "@types/pem": "1.14.4", "@types/semver": "7.5.6", - "@typescript-eslint/eslint-plugin": "6.17.0", + "@typescript-eslint/eslint-plugin": "6.18.1", "chai-subset": "1.6.0", "chalk": "5.3.0", "check-node-version": "4.2.1", diff --git a/pgpsDeviceRequestsHandler/pgpsDeviceRequestsHandler.ts b/pgpsDeviceRequestsHandler/pgpsDeviceRequestsHandler.ts index 285f80677..4b3e21464 100644 --- a/pgpsDeviceRequestsHandler/pgpsDeviceRequestsHandler.ts +++ b/pgpsDeviceRequestsHandler/pgpsDeviceRequestsHandler.ts @@ -7,7 +7,7 @@ import { import { Static } from '@sinclair/typebox' import { fromEnv } from '../lib/fromEnv.js' import { log, logError } from '../lib/log.js' -import { validateWithJSONSchema } from '../lib/validateWithJSONSchema.js' +import { validate } from '../lib/validate.js' import { pgpsRequestSchema } from '../pgps/types.js' type PGPS = ( @@ -28,7 +28,7 @@ type PGPSContext = Omit & { } } -const validatePgpsRequest = validateWithJSONSchema(pgpsRequestSchema) +const validatePgpsRequest = validate(pgpsRequestSchema) const config = () => fromEnv({ @@ -101,7 +101,7 @@ const pgpsDeviceRequestsHandler = async ( return } deviceRequests.push({ - request: valid, + request: valid.value, deviceId, }) }) diff --git a/pgpsResolveRequestFromNrfCloud/pgps.ts b/pgpsResolveRequestFromNrfCloud/pgps.ts index d71dcbe1a..14794193c 100644 --- a/pgpsResolveRequestFromNrfCloud/pgps.ts +++ b/pgpsResolveRequestFromNrfCloud/pgps.ts @@ -1,6 +1,6 @@ import { Static, Type } from '@sinclair/typebox' import { ErrorInfo } from '../lib/ErrorInfo.js' -import { validateWithJSONSchema } from '../lib/validateWithJSONSchema.js' +import { validate } from '../lib/validate.js' import { defaultInterval, defaultNumberOfPredictions, @@ -54,7 +54,7 @@ const apiResponseSchema = Type.Object( { additionalProperties: false }, ) -const validateInput = validateWithJSONSchema(pgpsRequestSchema) +const validateInput = validate(pgpsRequestSchema) export const resolvePgpsRequest = ( @@ -72,7 +72,7 @@ export const resolvePgpsRequest = return valid } - const { n, int, day, time } = valid + const { n, int, day, time } = valid.value const result = await client.get({ resource: 'location/pgps', diff --git a/storeNcellmeasReportInCosmosDb/storeNcellmeasReportInCosmosDb.ts b/storeNcellmeasReportInCosmosDb/storeNcellmeasReportInCosmosDb.ts index f24f74970..580ec98cb 100644 --- a/storeNcellmeasReportInCosmosDb/storeNcellmeasReportInCosmosDb.ts +++ b/storeNcellmeasReportInCosmosDb/storeNcellmeasReportInCosmosDb.ts @@ -4,7 +4,7 @@ import iothub from 'azure-iothub' import { randomUUID } from 'node:crypto' import { fromEnv } from '../lib/fromEnv.js' import { log, logError } from '../lib/log.js' -import { validateWithJSONSchema } from '../lib/validateWithJSONSchema.js' +import { validate } from '../lib/validate.js' import { ncellmeasReport } from '../ncellmeas/report.js' import { StoredReport } from '../ncellmeas/storedReport.js' const { Registry } = iothub @@ -15,7 +15,7 @@ const { iotHubConnectionString } = fromEnv({ const registry = Registry.fromConnectionString(iotHubConnectionString) -const validateNcellmeasReport = validateWithJSONSchema(ncellmeasReport) +const validateNcellmeasReport = validate(ncellmeasReport) type ReportedUpdateWithNetwork = { properties: { reported: { roam?: { v: { nw: string } } } } @@ -93,7 +93,7 @@ const storeNcellmeasReportInCosmosDb = } const document: StoredReport & { id: string } = { id: randomUUID(), - report: valid, + report: valid.value, deviceId, nw: nw ?? 'LTE-M', timestamp: diff --git a/third-party/nrfcloud.com/apiclient.ts b/third-party/nrfcloud.com/apiclient.ts index b4a251657..18f84ee6c 100644 --- a/third-party/nrfcloud.com/apiclient.ts +++ b/third-party/nrfcloud.com/apiclient.ts @@ -1,39 +1,33 @@ import { Static, TObject, TProperties } from '@sinclair/typebox' -import Ajv from 'ajv' import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http' import { request as nodeRequest, RequestOptions } from 'https' import jwt from 'jsonwebtoken' import { URL } from 'url' import { ErrorInfo, ErrorType } from '../../lib/ErrorInfo.js' import { toQueryString } from './toQueryString.js' +import { TypeCompiler } from '@sinclair/typebox/compiler' -const ajv = new Ajv() -// see @https://github.com/sinclairzx81/typebox/issues/51 -ajv.addKeyword('kind') -ajv.addKeyword('modifier') - -const validate = - >({ - schema, - errorType, - errorMessage, - }: { - schema: Schema - errorType: ErrorType - errorMessage: string - }) => - ( +const validate = >({ + schema, + errorType, + errorMessage, +}: { + schema: Schema + errorType: ErrorType + errorMessage: string +}) => { + const C = TypeCompiler.Compile(schema) + return ( payload: Record, ): { error: ErrorInfo } | Static => { - const v = ajv.compile(schema) - const valid = v(payload) - if (valid !== true) { + const firstError = C.Errors(payload).First() + if (firstError !== undefined) { return { error: { type: errorType, message: errorMessage, detail: { - errors: v.errors, + errors: [...C.Errors(payload)], input: payload, }, }, @@ -41,6 +35,7 @@ const validate = } return payload as Static } +} const doRequest = ({