diff --git a/.eslintrc.js b/.eslintrc.js index a58cd2bf61b3a8c16150db3b0e15e2dbf09b30c7..c530b15ec20d2b125c46be84ed446cc5380cd05b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,24 +3,19 @@ module.exports = { env: { browser: true, node: true, - 'jest/globals': true, + es6: true, }, parserOptions: { parser: '@babel/eslint-parser', - // Fix "No Babel config file detected for [file]" error - // https://github.com/babel/babel/issues/11975#issuecomment-786803214 + sourceType: 'module', requireConfigFile: false, + ecmaVersion: 'latest', }, - extends: [ - 'eslint:recommended', - 'prettier', - ], - // required to lint *.vue files - plugins: ['vue', 'jest', 'prettier'], + extends: ['eslint:recommended', 'plugin:prettier/recommended'], + ignorePatterns: ['**/dist/'], // add your custom rules here rules: { - 'no-console': ['warn', { allow: ['warn', 'error'] }], - 'no-debugger': 'warn', + 'no-console': ['error', { allow: ['warn', 'error'] }], 'no-unused-vars': ['error', { args: 'none' }], }, }; diff --git a/.prettierignore b/.prettierignore index 97c3543e6d226808b11fed9d892638d56198e2e0..edcf56289df9368cd39624a9bef62592b61990af 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,62 +1,8 @@ -### -# Place your Prettier ignore content here - -### -# .gitignore content is duplicated here due to https://github.com/prettier/prettier/issues/8506 - -# Created by .ignore support plugin (hsz.mobi) -### Node template -# Logs -/logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Dependency directories -node_modules/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# IDE / Editor -.idea - -# macOS -.DS_Store - -# Vim swap files -*.swp +# Ignore artifacts: +**/dist/ +**/*.esm.js +**/*.ssr.js +**/*.min.js +**/.nyc-output/ +**/.nuxt/ +**/.turbo/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 767ae1a76d739236ed403dbc64723f691aa16013..0000000000000000000000000000000000000000 --- a/.prettierrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "trailingComma": "es5", - "tabWidth": 2, - "useTabs": false, - "semi": true, - "singleQuote": true, - "bracketSameLine": false, - "arrowParens": "always", - "endOfLine": "lf" -} diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000000000000000000000000000000000..151eab7986d0948f9389a0586f9360536dd1a949 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,10 @@ +module.exports = { + trailingComma: 'es5', + tabWidth: 2, + useTabs: false, + semi: true, + singleQuote: true, + bracketSameLine: false, + arrowParens: 'always', + endOfLine: 'lf', +}; diff --git a/LICENCE.md b/LICENCE.md index 10bb2c1d9c3f4c2ce46ae0c2dc0e06f93491a807..d50329317cd814ce46b6da6cf3d6704121e4ffa2 100644 --- a/LICENCE.md +++ b/LICENCE.md @@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index ed6e5f7be15e70acbf67af519d6ab33f7efa6dec..c3b78c5e54a7cab6b4b61667fabc8cb6c92a0526 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ # backbone-adapter-javascript -Generic adapter for the communications-backbone. +Generic adapter for the communications-backbone. Implements: -- client credentials grant -- http send/receive/notify to backbone -- websockets send and receive -- validation of messages against a specified OpenAPI schema +- client credentials grant +- http send/receive/notify to backbone +- websockets send and receive +- validation of messages against a specified OpenAPI schema - decode/encode stubs -## Setup +## Setup ``` yarn install @@ -18,27 +18,27 @@ yarn install yarn copytests ``` -## Test +## Test The tests are written in [cucumber](https://cucumber.io/docs/installation/javascript/) This means we can have a common suite of [gherkin](https://github.com/cucumber/gherkin) -tests across adapter ports written in multiple languages. +tests across adapter ports written in multiple languages. ``` yarn test ``` -## Installing in your project +## Installing in your project -We may publish this to a public registry but for now you need to install the package -from git. +We may publish this to a public registry but for now you need to install the package +from git. -### Requirements +### Requirements -An `axios` library. Axios is included as a dev dependency to run the tests. -I've not installed it as a runtime dependency because in nuxt you need to -use `@nuxtjs/axios` instead. +An `axios` library. Axios is included as a dev dependency to run the tests. +I've not installed it as a runtime dependency because in nuxt you need to +use `@nuxtjs/axios` instead. **TODO fix this in rollup config** @@ -54,15 +54,15 @@ yarn add git+https://git.noc.ac.uk/communications-backbone-system/backbone-adapt npm install git+https://git.noc.ac.uk/communications-backbone-system/backbone-adapter-javascript.git ``` -## Schema +## Schema -The example code uses a mock schema with some example messages. The intention is the message -protocol schema is retreived from an external source. +The example code uses a mock schema with some example messages. The intention is the message +protocol schema is retreived from an external source. -## Config +## Config -To run the adapter you need a credentials file called `soar-config.json`. -This will be provided by the backbone operator or requested via the API. +To run the adapter you need a credentials file called `soar-config.json`. +This will be provided by the backbone operator or requested via the API. ```json { @@ -74,44 +74,44 @@ This will be provided by the backbone operator or requested via the API. } ``` -### Topics +### Topics When sending messages you should publish them using a topic matching [this definition](https://git.noc.ac.uk/communications-backbone-system/backbone-message-format#topics). -## Encoding and decoding +## Encoding and decoding -### Decoding +### Decoding -Decoding refers to translation from the backbone message protocol into a -native format for the client app to process. +Decoding refers to translation from the backbone message protocol into a +native format for the client app to process. -All messages received from the backbone are parsed and validated against the -protocol schema and then passed to the protocol decode function. +All messages received from the backbone are parsed and validated against the +protocol schema and then passed to the protocol decode function. -By overriding the decode function the client can define local actions to be -executed when a message of a given type is received. +By overriding the decode function the client can define local actions to be +executed when a message of a given type is received. -### Encoding +### Encoding -Encoding refers to translation from the client app's native format into a -message conforming to the backbone message protocol. +Encoding refers to translation from the client app's native format into a +message conforming to the backbone message protocol. -The equivalent encode method allows the client to define translations per -message type to transform local data into a message conforming to the -protocol schema for transmission. +The equivalent encode method allows the client to define translations per +message type to transform local data into a message conforming to the +protocol schema for transmission. -Messages passed to the publish and broadcast methods should have been +Messages passed to the publish and broadcast methods should have been encoded and validated against the protocol schema. -## Publish vs Broadcast +## Publish vs Broadcast -It is intended that all normal-operation messages will be published on -a given topic allowing clients to choose which message topics to -subscribe to. +It is intended that all normal-operation messages will be published on +a given topic allowing clients to choose which message topics to +subscribe to. -Broadcast is provided for contingency scenarios. The intention is that -in the case of a failure/abort a message can be sent to all parties -which bypasses any existing messages in the publish queue. +Broadcast is provided for contingency scenarios. The intention is that +in the case of a failure/abort a message can be sent to all parties +which bypasses any existing messages in the publish queue. -The client implementation can chose to take no-action on decoding one of -these messages but they will be made available to all clients. +The client implementation can chose to take no-action on decoding one of +these messages but they will be made available to all clients. diff --git a/cucumber.js b/cucumber.js index d8f0599f6fd7a32d56647c30e9fa16f7a637ae24..71fcee6a557e9b6aa70113ce1171fba537f3748c 100644 --- a/cucumber.js +++ b/cucumber.js @@ -1,9 +1,9 @@ module.exports = { default: { formatOptions: { - snippetInterface: "synchronous" + snippetInterface: 'synchronous', }, - paths: [ 'test/features/**/*.feature' ], - require: [ 'test/cucumber/**/*.steps.js' ], + paths: ['test/features/**/*.feature'], + require: ['test/cucumber/**/*.steps.js'], }, }; diff --git a/dist/adapter.esm.js b/dist/adapter.esm.js index 21ced71a3bcb874e7945aa992d73409f9d46d12a..862552155c8e296fb791c512cac2c438de251a06 100644 --- a/dist/adapter.esm.js +++ b/dist/adapter.esm.js @@ -12,14 +12,14 @@ class Adapter { /** * Test parsing the message based on the provided protocol schema - * - * The message must be successfully json decoded into an object + * + * The message must be successfully json decoded into an object * prior to validation - * - * At present this returns the validation result which is an - * object containing a boolean valid field as well as details - * of any errors. - * @param {object} message + * + * At present this returns the validation result which is an + * object containing a boolean valid field as well as details + * of any errors. + * @param {object} message * @returns {object} */ validate(message) { @@ -81,12 +81,12 @@ class Adapter { /** * Call the GET /receive endpoint and process the messages with decode - * + * * Returns the response - * @param {boolean} is_retry + * @param {boolean} is_retry * @returns {object} */ - poll(is_retry=false) { + poll(is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -109,11 +109,13 @@ class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } @@ -124,15 +126,15 @@ class Adapter { } /** - * Publish a message to the backbone with the specified topic - * + * Publish a message to the backbone with the specified topic + * * Messages should be passed through encode before sending - * @param {string} topic - * @param {string} body + * @param {string} topic + * @param {string} body * @param {boolean} is_retry - * @returns + * @returns */ - publish(topic, body, is_retry=false) { + publish(topic, body, is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -152,11 +154,13 @@ class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } @@ -168,17 +172,17 @@ class Adapter { /** * Broadcast the message on the backbone - * - * Broadcast messages bypass the normal publisher queues - * this means they can be used to deliver messages more + * + * Broadcast messages bypass the normal publisher queues + * this means they can be used to deliver messages more * quickly in an emergency scenario. - * + * * Messages should be passed through encode before sending - * @param {string} body + * @param {string} body * @param {boolean} is_retry - * @returns + * @returns */ - broadcast(body, is_retry=false) { + broadcast(body, is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -197,11 +201,13 @@ class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } diff --git a/dist/adapter.js b/dist/adapter.js index 5eb10e870ffaf2543563c15392f601ad0baa5dbb..c1f0e28e2fa62fdf78acd646cc8f3f4a54c08c85 100644 --- a/dist/adapter.js +++ b/dist/adapter.js @@ -14,14 +14,14 @@ class Adapter { /** * Test parsing the message based on the provided protocol schema - * - * The message must be successfully json decoded into an object + * + * The message must be successfully json decoded into an object * prior to validation - * - * At present this returns the validation result which is an - * object containing a boolean valid field as well as details - * of any errors. - * @param {object} message + * + * At present this returns the validation result which is an + * object containing a boolean valid field as well as details + * of any errors. + * @param {object} message * @returns {object} */ validate(message) { @@ -83,12 +83,12 @@ class Adapter { /** * Call the GET /receive endpoint and process the messages with decode - * + * * Returns the response - * @param {boolean} is_retry + * @param {boolean} is_retry * @returns {object} */ - poll(is_retry=false) { + poll(is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -111,11 +111,13 @@ class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } @@ -126,15 +128,15 @@ class Adapter { } /** - * Publish a message to the backbone with the specified topic - * + * Publish a message to the backbone with the specified topic + * * Messages should be passed through encode before sending - * @param {string} topic - * @param {string} body + * @param {string} topic + * @param {string} body * @param {boolean} is_retry - * @returns + * @returns */ - publish(topic, body, is_retry=false) { + publish(topic, body, is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -154,11 +156,13 @@ class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } @@ -170,17 +174,17 @@ class Adapter { /** * Broadcast the message on the backbone - * - * Broadcast messages bypass the normal publisher queues - * this means they can be used to deliver messages more + * + * Broadcast messages bypass the normal publisher queues + * this means they can be used to deliver messages more * quickly in an emergency scenario. - * + * * Messages should be passed through encode before sending - * @param {string} body + * @param {string} body * @param {boolean} is_retry - * @returns + * @returns */ - broadcast(body, is_retry=false) { + broadcast(body, is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -199,11 +203,13 @@ class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } diff --git a/dist/protocol.esm.js b/dist/protocol.esm.js index 2cb93de2e679f20f7c02275d4ad6dec1033c2c8a..71a3d8207ba98ca435045d6e697b14d62d9d14c4 100644 --- a/dist/protocol.esm.js +++ b/dist/protocol.esm.js @@ -3,25 +3,25 @@ import Validator from 'swagger-model-validator'; /** * GenericProtocol defines a simple passthru handler for messages - * This can be extended to handle different schemas - * - * The assumption is that all messages conform to a single - * wrapper schema definition. Different payloads are handled - * by a oneOf definitions within the schema determined by a - * field value. - * - * This class can be extended and overridden to handle - * different schemas and to implement the client specific - * logic related to be executed when invoked for a given - * message type. - * - * By default encode and decode are just passthru stubs - * + * This can be extended to handle different schemas + * + * The assumption is that all messages conform to a single + * wrapper schema definition. Different payloads are handled + * by a oneOf definitions within the schema determined by a + * field value. + * + * This class can be extended and overridden to handle + * different schemas and to implement the client specific + * logic related to be executed when invoked for a given + * message type. + * + * By default encode and decode are just passthru stubs + * * decode is invoked when receiving a message from the backbone - * encode is invoked before delivering a message to the backbone - * + * encode is invoked before delivering a message to the backbone + * * The intention is that these allow you to transform the message - * and call invoke internal functions and services as required + * and call invoke internal functions and services as required */ class GenericProtocol { constructor(schema, services) { @@ -32,7 +32,7 @@ class GenericProtocol { /** * Create a Validator from the provided JSONSchema - * @param {object} schema + * @param {object} schema * @returns {Validator} */ createValidator(schema) { @@ -40,8 +40,8 @@ class GenericProtocol { } /** - * Validate that a message meets the reqiured schema - * @param {object} message + * Validate that a message meets the reqiured schema + * @param {object} message * @returns {object} */ validate(message) { @@ -56,35 +56,34 @@ class GenericProtocol { /** * Identify the payload type from the message content - * @param {object} message + * @param {object} message * @returns {string} */ getType(message) { try { return message.payload.message_type; - } catch(error) { + } catch (error) { return null; } } /** - * Invoked on receiving a message from the backbone - * - * Whilst type isn't used in the generic stub it will + * Invoked on receiving a message from the backbone + * + * Whilst type isn't used in the generic stub it will * be needed by sub-classes overriding the decode method - * @param {string} type - * @param {object} message + * @param {string} type + * @param {object} message * @returns {*} */ decode(type, message) { return message; } - /** - * Invoked on receiving an invalid message from the backbone - * - * @param {object} message + * Invoked on receiving an invalid message from the backbone + * + * @param {object} message * @param {object} validation * @returns {*} */ @@ -94,11 +93,11 @@ class GenericProtocol { /** * Optionally invoked before delivering a message to the backbone - * - * Whilst type isn't used in the generic stub it will + * + * Whilst type isn't used in the generic stub it will * be needed by sub-classes overriding the encode method - * @param {string} type - * @param {*} message + * @param {string} type + * @param {*} message * @returns {object} */ encode(type, message) { @@ -106,12 +105,11 @@ class GenericProtocol { } } - /** * GenericSoarProtocol defines a simple passthru handler for messages - * - * This provides the same as above but loads a version of the - * SoAR message protocol + * + * This provides the same as above but loads a version of the + * SoAR message protocol */ class GenericSoarProtocol extends GenericProtocol { constructor(schema, services) { @@ -120,42 +118,41 @@ class GenericSoarProtocol extends GenericProtocol { /** * Create a Validator from the provided JSONSchema - * - * If schema is a string build a URL and retrieve the - * schema from gitlab - * @param {string|object} schema + * + * If schema is a string build a URL and retrieve the + * schema from gitlab + * @param {string|object} schema * @returns {object} */ createValidator(schema) { - if (typeof schema === 'string' && schema.match(/^[\w\.]+$/)) { - this.loadSchema(schema) - .then((schema) => { - this.validator = new Validator(schema); + if (typeof schema === 'string' && schema.match(/^[\w.]+$/)) { + this.loadSchema(schema).then((schema) => { + this.validator = new Validator(schema); }); } else { this.validator = new Validator(schema); - } + } } /** - * Load schema from gitlab by tag/branch/commitref + * Load schema from gitlab by tag/branch/commitref * @param {string} version - * @returns {object} + * @returns {object} */ loadSchema(version) { this.axios = axios; - let repository = "https://git.noc.ac.uk/communications-backbone-system/backbone-message-format"; + let repository = + 'https://git.noc.ac.uk/communications-backbone-system/backbone-message-format'; let url = `${repository}/-/raw/${version}/project/soar/swagger.json`; - return this.axios.get(url) - .then((response) => { + return this.axios.get(url).then((response) => { this.schema = response.data; return response.data; }); } /** - * Validate that a message meets the reqiured schema - * @param {object} message + * Validate that a message meets the reqiured schema + * @param {object} message * @returns {object} */ validate(message) { diff --git a/dist/protocol.js b/dist/protocol.js index e7099c90863e0347ef87daab85d482d474007ef8..e2c74bd15eb889140af9fa6fd70ff7241679e7f3 100644 --- a/dist/protocol.js +++ b/dist/protocol.js @@ -5,25 +5,25 @@ var Validator = require('swagger-model-validator'); /** * GenericProtocol defines a simple passthru handler for messages - * This can be extended to handle different schemas - * - * The assumption is that all messages conform to a single - * wrapper schema definition. Different payloads are handled - * by a oneOf definitions within the schema determined by a - * field value. - * - * This class can be extended and overridden to handle - * different schemas and to implement the client specific - * logic related to be executed when invoked for a given - * message type. - * - * By default encode and decode are just passthru stubs - * + * This can be extended to handle different schemas + * + * The assumption is that all messages conform to a single + * wrapper schema definition. Different payloads are handled + * by a oneOf definitions within the schema determined by a + * field value. + * + * This class can be extended and overridden to handle + * different schemas and to implement the client specific + * logic related to be executed when invoked for a given + * message type. + * + * By default encode and decode are just passthru stubs + * * decode is invoked when receiving a message from the backbone - * encode is invoked before delivering a message to the backbone - * + * encode is invoked before delivering a message to the backbone + * * The intention is that these allow you to transform the message - * and call invoke internal functions and services as required + * and call invoke internal functions and services as required */ class GenericProtocol { constructor(schema, services) { @@ -34,7 +34,7 @@ class GenericProtocol { /** * Create a Validator from the provided JSONSchema - * @param {object} schema + * @param {object} schema * @returns {Validator} */ createValidator(schema) { @@ -42,8 +42,8 @@ class GenericProtocol { } /** - * Validate that a message meets the reqiured schema - * @param {object} message + * Validate that a message meets the reqiured schema + * @param {object} message * @returns {object} */ validate(message) { @@ -58,35 +58,34 @@ class GenericProtocol { /** * Identify the payload type from the message content - * @param {object} message + * @param {object} message * @returns {string} */ getType(message) { try { return message.payload.message_type; - } catch(error) { + } catch (error) { return null; } } /** - * Invoked on receiving a message from the backbone - * - * Whilst type isn't used in the generic stub it will + * Invoked on receiving a message from the backbone + * + * Whilst type isn't used in the generic stub it will * be needed by sub-classes overriding the decode method - * @param {string} type - * @param {object} message + * @param {string} type + * @param {object} message * @returns {*} */ decode(type, message) { return message; } - /** - * Invoked on receiving an invalid message from the backbone - * - * @param {object} message + * Invoked on receiving an invalid message from the backbone + * + * @param {object} message * @param {object} validation * @returns {*} */ @@ -96,11 +95,11 @@ class GenericProtocol { /** * Optionally invoked before delivering a message to the backbone - * - * Whilst type isn't used in the generic stub it will + * + * Whilst type isn't used in the generic stub it will * be needed by sub-classes overriding the encode method - * @param {string} type - * @param {*} message + * @param {string} type + * @param {*} message * @returns {object} */ encode(type, message) { @@ -108,12 +107,11 @@ class GenericProtocol { } } - /** * GenericSoarProtocol defines a simple passthru handler for messages - * - * This provides the same as above but loads a version of the - * SoAR message protocol + * + * This provides the same as above but loads a version of the + * SoAR message protocol */ class GenericSoarProtocol extends GenericProtocol { constructor(schema, services) { @@ -122,42 +120,41 @@ class GenericSoarProtocol extends GenericProtocol { /** * Create a Validator from the provided JSONSchema - * - * If schema is a string build a URL and retrieve the - * schema from gitlab - * @param {string|object} schema + * + * If schema is a string build a URL and retrieve the + * schema from gitlab + * @param {string|object} schema * @returns {object} */ createValidator(schema) { - if (typeof schema === 'string' && schema.match(/^[\w\.]+$/)) { - this.loadSchema(schema) - .then((schema) => { - this.validator = new Validator(schema); + if (typeof schema === 'string' && schema.match(/^[\w.]+$/)) { + this.loadSchema(schema).then((schema) => { + this.validator = new Validator(schema); }); } else { this.validator = new Validator(schema); - } + } } /** - * Load schema from gitlab by tag/branch/commitref + * Load schema from gitlab by tag/branch/commitref * @param {string} version - * @returns {object} + * @returns {object} */ loadSchema(version) { this.axios = axios; - let repository = "https://git.noc.ac.uk/communications-backbone-system/backbone-message-format"; + let repository = + 'https://git.noc.ac.uk/communications-backbone-system/backbone-message-format'; let url = `${repository}/-/raw/${version}/project/soar/swagger.json`; - return this.axios.get(url) - .then((response) => { + return this.axios.get(url).then((response) => { this.schema = response.data; return response.data; }); } /** - * Validate that a message meets the reqiured schema - * @param {object} message + * Validate that a message meets the reqiured schema + * @param {object} message * @returns {object} */ validate(message) { diff --git a/jest.config.js b/jest.config.js index 86db0877f2387259954d2052c3e072735d41bfbd..c0df3dac2afb0dbd58ad3917031af6c414f96591 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,7 +8,6 @@ module.exports = { '^.+\\.js$': 'babel-jest', }, collectCoverage: true, - collectCoverageFrom: [ - ], + collectCoverageFrom: [], testEnvironment: 'jsdom', }; diff --git a/package.json b/package.json index bc3b97b2e235a787f2d1fb9244bb5090bbe4fc8f..d7c8fee449f6b2905eceb1147f322c54be4d4deb 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "copytest:features": "npx recursive-copy -w node_modules/backbone-adapter-testsuite/features test/features", "copytest:fixtures": "npx recursive-copy -w node_modules/backbone-adapter-testsuite/fixtures test/fixtures", "copytests": "npm run copytest:features && npm run copytest:fixtures", - "lint:js": "eslint --ext \".js\" --ignore-path .gitignore .", + "lint:js": "eslint -c .eslintrc.js --ext .js --ignore-path .gitignore .", "lint:prettier": "prettier --check .", "lint": "yarn lint:js && yarn lint:prettier", "lintfix": "prettier --write --list-different . && yarn lint:js --fix", @@ -51,14 +51,14 @@ "babel-jest": "^27.4.4", "backbone-adapter-testsuite": "git+https://git.noc.ac.uk/communications-backbone-system/backbone-adapter-testsuite.git#dev", "cross-env": "^7.0.3", - "eslint": "^8.4.1", + "eslint": "^8.36.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.2.1", "husky": "^7.0.4", "jest": "^27.4.4", "lint-staged": "^12.1.2", "openapi-schema-validator": "^12.1.0", - "prettier": "^2.5.1", + "prettier": "^2.8.4", "recursive-copy-cli": "^1.0.20", "rollup": "^3.9.1" } diff --git a/src/adapter/index.js b/src/adapter/index.js index 8489f83fe66d5cc9529f1f9c1ed999103d5b47ca..ef71cc39fbd2d8adfb931f29db5a08adfe2f45c7 100644 --- a/src/adapter/index.js +++ b/src/adapter/index.js @@ -12,14 +12,14 @@ export class Adapter { /** * Test parsing the message based on the provided protocol schema - * - * The message must be successfully json decoded into an object + * + * The message must be successfully json decoded into an object * prior to validation - * - * At present this returns the validation result which is an - * object containing a boolean valid field as well as details - * of any errors. - * @param {object} message + * + * At present this returns the validation result which is an + * object containing a boolean valid field as well as details + * of any errors. + * @param {object} message * @returns {object} */ validate(message) { @@ -81,12 +81,12 @@ export class Adapter { /** * Call the GET /receive endpoint and process the messages with decode - * + * * Returns the response - * @param {boolean} is_retry + * @param {boolean} is_retry * @returns {object} */ - poll(is_retry=false) { + poll(is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -109,11 +109,13 @@ export class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } @@ -124,15 +126,15 @@ export class Adapter { } /** - * Publish a message to the backbone with the specified topic - * + * Publish a message to the backbone with the specified topic + * * Messages should be passed through encode before sending - * @param {string} topic - * @param {string} body + * @param {string} topic + * @param {string} body * @param {boolean} is_retry - * @returns + * @returns */ - publish(topic, body, is_retry=false) { + publish(topic, body, is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -152,11 +154,13 @@ export class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } @@ -168,17 +172,17 @@ export class Adapter { /** * Broadcast the message on the backbone - * - * Broadcast messages bypass the normal publisher queues - * this means they can be used to deliver messages more + * + * Broadcast messages bypass the normal publisher queues + * this means they can be used to deliver messages more * quickly in an emergency scenario. - * + * * Messages should be passed through encode before sending - * @param {string} body + * @param {string} body * @param {boolean} is_retry - * @returns + * @returns */ - broadcast(body, is_retry=false) { + broadcast(body, is_retry = false) { let adapterConfig = this.config; return this.getAuthorizationHeader() .then((headers) => { @@ -197,11 +201,13 @@ export class Adapter { }) .catch((error) => { let retry = false; - switch(error.response.status) { - case 403: { - this.credentials = null; - retry = true; - } break; + switch (error.response.status) { + case 403: + { + this.credentials = null; + retry = true; + } + break; case 503: { retry = true; } diff --git a/src/protocol/example-client.js b/src/protocol/example-client.js index bbbb3b2a5c95b2b9de549a4c2aa2f7b20d0b0844..86e56627c333e023d0ab01932fc504fbd23683bb 100644 --- a/src/protocol/example-client.js +++ b/src/protocol/example-client.js @@ -1,29 +1,28 @@ import { GenericProtocol } from '~/modules/comms-adapter/protocol'; /** - * + * */ export class ExampleClientProtocol extends GenericProtocol { - constructor(schema, services) { super(schema, services); - // bootstrap any injected services + // bootstrap any injected services } /** - * Process a message received from the backbone - * - * This method is overridden to take appropriate - * action for each message type. - * - * Further methods can then be defined to handle - * each message type. - * - * You can use this to take action directly or + * Process a message received from the backbone + * + * This method is overridden to take appropriate + * action for each message type. + * + * Further methods can then be defined to handle + * each message type. + * + * You can use this to take action directly or * transform that data to invoke an existing process. - * @param {string} type - * @param {object} message - * @returns + * @param {string} type + * @param {object} message + * @returns */ decode(type, message) { switch (type) { @@ -39,13 +38,13 @@ export class ExampleClientProtocol extends GenericProtocol { /** * Transform local data into a message conforming to the protocol schema - * - * When a client event occurs the local data is passed through - * encode to handle the translation from the native client format - * into a message conforming to the protocol schema. - * @param {string} type - * @param {object} message - * @returns + * + * When a client event occurs the local data is passed through + * encode to handle the translation from the native client format + * into a message conforming to the protocol schema. + * @param {string} type + * @param {object} message + * @returns */ encode(type, message) { return message; @@ -53,8 +52,8 @@ export class ExampleClientProtocol extends GenericProtocol { /** * Act upon a received VehicleStatus message - * @param {object} message - * @returns {object} + * @param {object} message + * @returns {object} */ decodeVehicleStatus(message) { const battery = message.battery_percentage; @@ -66,7 +65,7 @@ export class ExampleClientProtocol extends GenericProtocol { /** * Act upon a received VehicleMission message - * @param {object} message + * @param {object} message * @returns {object} */ decodeVehicleMission(message) { @@ -76,7 +75,7 @@ export class ExampleClientProtocol extends GenericProtocol { /** * Transform local data into a VehicleStatus message - * @param {object} message + * @param {object} message * @returns {object} */ encodeVehicleStatus(message) { diff --git a/src/protocol/index.js b/src/protocol/index.js index dcc87cdfcd5b139515e1033906e433dd75cb49f3..e1f35d334f0a3b3b42c42e23f09c87d7cd991f48 100644 --- a/src/protocol/index.js +++ b/src/protocol/index.js @@ -3,25 +3,25 @@ import Validator from 'swagger-model-validator'; /** * GenericProtocol defines a simple passthru handler for messages - * This can be extended to handle different schemas - * - * The assumption is that all messages conform to a single - * wrapper schema definition. Different payloads are handled - * by a oneOf definitions within the schema determined by a - * field value. - * - * This class can be extended and overridden to handle - * different schemas and to implement the client specific - * logic related to be executed when invoked for a given - * message type. - * - * By default encode and decode are just passthru stubs - * + * This can be extended to handle different schemas + * + * The assumption is that all messages conform to a single + * wrapper schema definition. Different payloads are handled + * by a oneOf definitions within the schema determined by a + * field value. + * + * This class can be extended and overridden to handle + * different schemas and to implement the client specific + * logic related to be executed when invoked for a given + * message type. + * + * By default encode and decode are just passthru stubs + * * decode is invoked when receiving a message from the backbone - * encode is invoked before delivering a message to the backbone - * + * encode is invoked before delivering a message to the backbone + * * The intention is that these allow you to transform the message - * and call invoke internal functions and services as required + * and call invoke internal functions and services as required */ export class GenericProtocol { constructor(schema, services) { @@ -32,7 +32,7 @@ export class GenericProtocol { /** * Create a Validator from the provided JSONSchema - * @param {object} schema + * @param {object} schema * @returns {Validator} */ createValidator(schema) { @@ -40,8 +40,8 @@ export class GenericProtocol { } /** - * Validate that a message meets the reqiured schema - * @param {object} message + * Validate that a message meets the reqiured schema + * @param {object} message * @returns {object} */ validate(message) { @@ -56,35 +56,34 @@ export class GenericProtocol { /** * Identify the payload type from the message content - * @param {object} message + * @param {object} message * @returns {string} */ getType(message) { try { return message.payload.message_type; - } catch(error) { + } catch (error) { return null; } } /** - * Invoked on receiving a message from the backbone - * - * Whilst type isn't used in the generic stub it will + * Invoked on receiving a message from the backbone + * + * Whilst type isn't used in the generic stub it will * be needed by sub-classes overriding the decode method - * @param {string} type - * @param {object} message + * @param {string} type + * @param {object} message * @returns {*} */ decode(type, message) { return message; } - /** - * Invoked on receiving an invalid message from the backbone - * - * @param {object} message + * Invoked on receiving an invalid message from the backbone + * + * @param {object} message * @param {object} validation * @returns {*} */ @@ -94,11 +93,11 @@ export class GenericProtocol { /** * Optionally invoked before delivering a message to the backbone - * - * Whilst type isn't used in the generic stub it will + * + * Whilst type isn't used in the generic stub it will * be needed by sub-classes overriding the encode method - * @param {string} type - * @param {*} message + * @param {string} type + * @param {*} message * @returns {object} */ encode(type, message) { @@ -106,12 +105,11 @@ export class GenericProtocol { } } - /** * GenericSoarProtocol defines a simple passthru handler for messages - * - * This provides the same as above but loads a version of the - * SoAR message protocol + * + * This provides the same as above but loads a version of the + * SoAR message protocol */ export class GenericSoarProtocol extends GenericProtocol { constructor(schema, services) { @@ -120,42 +118,41 @@ export class GenericSoarProtocol extends GenericProtocol { /** * Create a Validator from the provided JSONSchema - * - * If schema is a string build a URL and retrieve the - * schema from gitlab - * @param {string|object} schema + * + * If schema is a string build a URL and retrieve the + * schema from gitlab + * @param {string|object} schema * @returns {object} */ createValidator(schema) { - if (typeof schema === 'string' && schema.match(/^[\w\.]+$/)) { - this.loadSchema(schema) - .then((schema) => { - this.validator = new Validator(schema); + if (typeof schema === 'string' && schema.match(/^[\w.]+$/)) { + this.loadSchema(schema).then((schema) => { + this.validator = new Validator(schema); }); } else { this.validator = new Validator(schema); - } + } } /** - * Load schema from gitlab by tag/branch/commitref + * Load schema from gitlab by tag/branch/commitref * @param {string} version - * @returns {object} + * @returns {object} */ loadSchema(version) { this.axios = axios; - let repository = "https://git.noc.ac.uk/communications-backbone-system/backbone-message-format"; + let repository = + 'https://git.noc.ac.uk/communications-backbone-system/backbone-message-format'; let url = `${repository}/-/raw/${version}/project/soar/swagger.json`; - return this.axios.get(url) - .then((response) => { - this.schema = response.data + return this.axios.get(url).then((response) => { + this.schema = response.data; return response.data; }); } /** - * Validate that a message meets the reqiured schema - * @param {object} message + * Validate that a message meets the reqiured schema + * @param {object} message * @returns {object} */ validate(message) { @@ -167,4 +164,4 @@ export class GenericSoarProtocol extends GenericProtocol { false ); } -} \ No newline at end of file +} diff --git a/test/cucumber/adapter/auth.steps.js b/test/cucumber/adapter/auth.steps.js index 386c5f5a5ebfc09684e240f7e54a53266da199d5..3ef9c7e842ee7d4d783df31cb3481930a2b4b7b1 100644 --- a/test/cucumber/adapter/auth.steps.js +++ b/test/cucumber/adapter/auth.steps.js @@ -3,17 +3,19 @@ const { When, Then } = require('@cucumber/cucumber'); const { fixtures } = require('../../fixtures/server'); -When('the auth method is called', async function() { +When('the auth method is called', async function () { await this.adapter.auth(); }); -Then('the adapter credentials are populated', function() { - assert.equal(this.adapter.credentials.token, fixtures.get('response-valid-token').token); +Then('the adapter credentials are populated', function () { + assert.equal( + this.adapter.credentials.token, + fixtures.get('response-valid-token').token + ); }); -Then('the adapter auth fails', function() { - this.adapter.auth() - .catch((error) => { +Then('the adapter auth fails', function () { + this.adapter.auth().catch((error) => { assert.equal(error.response.status, 403); }); -}); \ No newline at end of file +}); diff --git a/test/cucumber/adapter/before.steps.js b/test/cucumber/adapter/before.steps.js index 1ac9d79ba1fdf259d20d7affb9ebff72f45f18cf..98fd3450c7db54c5f035705ae1da1118b19ea9c6 100644 --- a/test/cucumber/adapter/before.steps.js +++ b/test/cucumber/adapter/before.steps.js @@ -1,8 +1,8 @@ const assert = require('assert'); const { Before } = require('@cucumber/cucumber'); -const axios = require("axios"); -const MockAdapter = require("axios-mock-adapter"); +const axios = require('axios'); +const MockAdapter = require('axios-mock-adapter'); // This sets the mock adapter on the default instance const mockAxios = new MockAdapter(axios); @@ -17,13 +17,13 @@ const { GenericProtocol } = require('../../../dist/protocol'); const { Adapter } = require('../../../dist/adapter'); /** - * Use assert.CallTracker to track internal method calls - * Instead of adding trackers to each method, create a + * Use assert.CallTracker to track internal method calls + * Instead of adding trackers to each method, create a * single tracked stub function and then use the parameters - * to record what is being tracked. + * to record what is being tracked. */ const tracker = new assert.CallTracker(); -const trackedFunction = function(method, params) { +const trackedFunction = function (method, params) { // do nothing; }; const recorder = tracker.calls(trackedFunction); @@ -51,7 +51,7 @@ class TrackedAdapter extends Adapter { } getTrackedCalls(method) { let calls = this.tracker.getCalls(this.recorder); - let methodCalls = calls.filter(call => call.arguments[0] === method); + let methodCalls = calls.filter((call) => call.arguments[0] === method); return methodCalls; } resetTracker() { @@ -65,20 +65,20 @@ class TrackedGenericProtocol extends GenericProtocol { this.tracker = tracker; } encode(type, message) { - this.recorder('encode', {type, message}); - return super.encode(type, message) + this.recorder('encode', { type, message }); + return super.encode(type, message); } decode(type, message) { - this.recorder('decode', {type, message}); - return super.decode(type, message) + this.recorder('decode', { type, message }); + return super.decode(type, message); } validate(message) { - this.recorder('validate', {message}); + this.recorder('validate', { message }); return super.validate(message); } getTrackedCalls(method) { let calls = this.tracker.getCalls(this.recorder); - let methodCalls = calls.filter(call => call.arguments[0] === method); + let methodCalls = calls.filter((call) => call.arguments[0] === method); return methodCalls; } resetTracker() { @@ -86,35 +86,45 @@ class TrackedGenericProtocol extends GenericProtocol { } } -Before(function() { +Before(function () { this.api = mockValidConfig.api; this.schema = mockSchema; this.tracker = tracker; this.recorder = recorder; let services = { recorder, - tracker + tracker, }; this.classes = { TrackedAdapter, TrackedGenericProtocol, }; this.callCounts = {}; - this.protocol = new this.classes.TrackedGenericProtocol(this.schema, services); + this.protocol = new this.classes.TrackedGenericProtocol( + this.schema, + services + ); this.protocol.setupCallTracking(this.recorder, this.tracker); this.protocol.resetTracker(); this.mockAxios = mockAxios; this.mockAxios.reset(); this.mockAxios.resetHistory(); - this.mockAxios.onGet( - `${mockValidConfig.api}/token`, - { params: { client_id: mockValidConfig.client_id, secret: mockValidConfig.secret } } - ).reply(200, fixtures.get('response-valid-token')); + this.mockAxios + .onGet(`${mockValidConfig.api}/token`, { + params: { + client_id: mockValidConfig.client_id, + secret: mockValidConfig.secret, + }, + }) + .reply(200, fixtures.get('response-valid-token')); - this.mockAxios.onGet( - `${mockInvalidConfig.api}/token`, - { params: { client_id: mockInvalidConfig.client_id, secret: mockInvalidConfig.secret } } - ).reply(403, fixtures.get('response-denied-token')); - -}); \ No newline at end of file + this.mockAxios + .onGet(`${mockInvalidConfig.api}/token`, { + params: { + client_id: mockInvalidConfig.client_id, + secret: mockInvalidConfig.secret, + }, + }) + .reply(403, fixtures.get('response-denied-token')); +}); diff --git a/test/cucumber/adapter/broadcast.steps.js b/test/cucumber/adapter/broadcast.steps.js index 05a9cd07254c23b92525b18aa55252c9aa0ca7c7..a70cec62378d67ae76051d57f15f31259d78bc52 100644 --- a/test/cucumber/adapter/broadcast.steps.js +++ b/test/cucumber/adapter/broadcast.steps.js @@ -5,24 +5,25 @@ const { fixtures } = require('../../fixtures/server'); const mockValidConfig = fixtures.get('config-valid'); -When('a mock notify API response is configured to return success', function() { +When('a mock notify API response is configured to return success', function () { const response = {}; - this.mockAxios.onPost( - `${mockValidConfig.api}/notify`, - ).reply(200, response); + this.mockAxios.onPost(`${mockValidConfig.api}/notify`).reply(200, response); }); -When('a mock notify API response is configured to return a {int} error', function(statusCode) { - const statusMessages = { - 403: 'Token expired', - 503: 'Service unavailable' - }; - this.mockAxios.onPost( - `${mockValidConfig.api}/notify`, - ).reply(statusCode, { message: statusMessages[statusCode] }) -}); - -When('the broadcast method is called', function() { +When( + 'a mock notify API response is configured to return a {int} error', + function (statusCode) { + const statusMessages = { + 403: 'Token expired', + 503: 'Service unavailable', + }; + this.mockAxios + .onPost(`${mockValidConfig.api}/notify`) + .reply(statusCode, { message: statusMessages[statusCode] }); + } +); + +When('the broadcast method is called', function () { const message = fixtures.get('message-vehicle-status'); this.message = message; const body = JSON.stringify(message); @@ -30,7 +31,7 @@ When('the broadcast method is called', function() { this.callCounts.broadcast = this.adapter.getTrackedCalls('broadcast').length; }); -When('the broadcast method is called with is_retry on', function() { +When('the broadcast method is called with is_retry on', function () { const message = fixtures.get('message-vehicle-status'); this.message = message; const body = JSON.stringify(message); @@ -38,13 +39,13 @@ When('the broadcast method is called with is_retry on', function() { this.callCounts.broadcast = this.adapter.getTrackedCalls('broadcast').length; }); -Then('the broadcast method was called with is_retry on', function() { +Then('the broadcast method was called with is_retry on', function () { let broadcastCalls = this.adapter.getTrackedCalls('broadcast'); - let lastCall = broadcastCalls[broadcastCalls.length-1]; + let lastCall = broadcastCalls[broadcastCalls.length - 1]; assert.ok(lastCall.arguments[1].is_retry); }); -Then('the broadcast method is not called again', function() { +Then('the broadcast method is not called again', function () { let newBroadcastCallCount = this.adapter.getTrackedCalls('broadcast').length; assert.equal(this.callCounts.broadcast, newBroadcastCallCount); -}); \ No newline at end of file +}); diff --git a/test/cucumber/adapter/common.steps.js b/test/cucumber/adapter/common.steps.js index a0f065c9a98eae23b1993f6ccb63e420434efa88..e0902cbf35c8b0ba6286a7d340e62a30b851d1b6 100644 --- a/test/cucumber/adapter/common.steps.js +++ b/test/cucumber/adapter/common.steps.js @@ -8,60 +8,71 @@ const mockInvalidConfig = fixtures.get('config-invalid'); const mockSchema = require('../../mock/swagger.json'); // const { Adapter } = require('../../../dist/adapter'); -Given('valid config', function() { - this.config = mockValidConfig +Given('valid config', function () { + this.config = mockValidConfig; }); -Given('invalid config', function() { +Given('invalid config', function () { this.schema = mockSchema; this.config = mockInvalidConfig; }); -When('the adapter instance is created', function() { +When('the adapter instance is created', function () { this.adapter = new this.classes.TrackedAdapter(this.protocol, this.config); this.adapter.setupCallTracking(this.recorder, this.tracker); }); -Then('a successful response is returned with status {int}', function(expectedStatus) { - this.call - .then(response => { - assert.equal(response.status, expectedStatus); - }); -}); +Then( + 'a successful response is returned with status {int}', + function (expectedStatus) { + this.call.then((response) => { + assert.equal(response.status, expectedStatus); + }); + } +); -Then('an error response is returned with status {int}', function(expectedStatus) { - this.call - .catch((error) => { - assert.equal(error.response.status, expectedStatus); - }); -}); +Then( + 'an error response is returned with status {int}', + function (expectedStatus) { + this.call.catch((error) => { + assert.equal(error.response.status, expectedStatus); + }); + } +); -Then('the credentials are deleted', function() { +Then('the credentials are deleted', function () { assert.equal(this.adapter.credentials, null); }); -Then('the credentials are not deleted', function() { +Then('the credentials are not deleted', function () { assert.notEqual(this.adapter.credentials, null); }); -When('the {string} method call counts are checked', function(method) { +When('the {string} method call counts are checked', function (method) { let newCallCount = this.adapter.getTrackedCalls(method).length; this.callCounts[method] = newCallCount; }); -Then('the {string} method is not called again', function(method) { +Then('the {string} method is not called again', function (method) { let newCallCount = this.adapter.getTrackedCalls(method).length; assert.equal(this.callCounts[method], newCallCount); }); -Then('the total number of calls to {string} was {int}', function(method, expectedCallCount) { - let callCount = this.adapter.getTrackedCalls(method).length; - assert.equal(callCount, expectedCallCount); -}); - -Then('the total number of {string} requests to {string} was {int}', function(method, endpoint, expectedCallCount) { - let url = `${this.api}${endpoint}`; - let requestHistory = this.mockAxios.history[method.toLowerCase()].filter((request) => request.url === url); - assert.equal(requestHistory.length, expectedCallCount); -}); +Then( + 'the total number of calls to {string} was {int}', + function (method, expectedCallCount) { + let callCount = this.adapter.getTrackedCalls(method).length; + assert.equal(callCount, expectedCallCount); + } +); +Then( + 'the total number of {string} requests to {string} was {int}', + function (method, endpoint, expectedCallCount) { + let url = `${this.api}${endpoint}`; + let requestHistory = this.mockAxios.history[method.toLowerCase()].filter( + (request) => request.url === url + ); + assert.equal(requestHistory.length, expectedCallCount); + } +); diff --git a/test/cucumber/adapter/get-authorization-header.steps.js b/test/cucumber/adapter/get-authorization-header.steps.js index a9fd6525480aca700b27a1e3f4c568308edd759b..3fceb8a9554cdefc6d48bb10779b838643886445 100644 --- a/test/cucumber/adapter/get-authorization-header.steps.js +++ b/test/cucumber/adapter/get-authorization-header.steps.js @@ -1,17 +1,20 @@ const assert = require('assert'); const { When, Then } = require('@cucumber/cucumber'); -When('the getAuthorizationHeader method is called', function() { +When('the getAuthorizationHeader method is called', function () { this.call = this.adapter.getAuthorizationHeader(); let callCount = this.adapter.getTrackedCalls('getAuthorizationHeader').length; this.callCounts.getAuthorizationHeader = callCount; }); -Then('a headers object is returned containing a bearer token authorization header', function() { - this.call.then(headers => { - assert.ok('Authorization' in headers); - const authHeaderWords = headers.Authorization.split(" "); - assert.ok(authHeaderWords[0] === 'Bearer'); - assert.ok(authHeaderWords[1] === this.adapter.credentials.token); - }); -}); +Then( + 'a headers object is returned containing a bearer token authorization header', + function () { + this.call.then((headers) => { + assert.ok('Authorization' in headers); + const authHeaderWords = headers.Authorization.split(' '); + assert.ok(authHeaderWords[0] === 'Bearer'); + assert.ok(authHeaderWords[1] === this.adapter.credentials.token); + }); + } +); diff --git a/test/cucumber/adapter/poll.steps.js b/test/cucumber/adapter/poll.steps.js index a2b50a03cf745ebc9d086f1957e2ebd22723c155..02b8b16e3d9b4c2e2cfd7a75840f5a028f9ba80c 100644 --- a/test/cucumber/adapter/poll.steps.js +++ b/test/cucumber/adapter/poll.steps.js @@ -5,64 +5,73 @@ const { fixtures } = require('../../fixtures/server'); const mockValidConfig = fixtures.get('config-valid'); -const xMessageResponse = function(xMessages) { +const xMessageResponse = function (xMessages) { const message = fixtures.get('message-vehicle-status'); let response = []; - for (let i=0; i<xMessages; i++) { + for (let i = 0; i < xMessages; i++) { response.push({ - topic: "broadcast", - message: JSON.stringify(message) + topic: 'broadcast', + message: JSON.stringify(message), }); } return response; }; -When('a mock receive API response is configured to return {int} messages', function(xMessages) { - const response = xMessageResponse(xMessages); - this.mockAxios.onGet( - `${mockValidConfig.api}/receive`, - ).reply(200, response); -}); +When( + 'a mock receive API response is configured to return {int} messages', + function (xMessages) { + const response = xMessageResponse(xMessages); + this.mockAxios.onGet(`${mockValidConfig.api}/receive`).reply(200, response); + } +); -When('a mock receive API response is configured to return a {int} error', function(statusCode) { - const statusMessages = { - 403: 'Token expired', - 503: 'Service unavailable' - }; - this.mockAxios.onGet( - `${mockValidConfig.api}/receive`, - ).reply(statusCode, { message: statusMessages[statusCode] }) -}); +When( + 'a mock receive API response is configured to return a {int} error', + function (statusCode) { + const statusMessages = { + 403: 'Token expired', + 503: 'Service unavailable', + }; + this.mockAxios + .onGet(`${mockValidConfig.api}/receive`) + .reply(statusCode, { message: statusMessages[statusCode] }); + } +); -When('the poll method is called', function() { +When('the poll method is called', function () { this.call = this.adapter.poll(); this.callCounts.poll = this.adapter.getTrackedCalls('poll').length; }); -Then('a successful response is returned with {int} messages', function(xMessages) { - this.call - .then(response => { - assert.equal(response.data.length, xMessages); - }); -}); +Then( + 'a successful response is returned with {int} messages', + function (xMessages) { + this.call.then((response) => { + assert.equal(response.data.length, xMessages); + }); + } +); -Then('the protocol {string} method is called {int} times', function(method, xInvokes) { - const decodes = this.protocol.getTrackedCalls(method); - assert.equal(decodes.length, xInvokes); -}); +Then( + 'the protocol {string} method is called {int} times', + function (method, xInvokes) { + const decodes = this.protocol.getTrackedCalls(method); + assert.equal(decodes.length, xInvokes); + } +); -When('the poll method is called with is_retry on', function() { +When('the poll method is called with is_retry on', function () { this.call = this.adapter.poll(true); this.callCounts.poll = this.adapter.getTrackedCalls('poll').length; }); -Then('the poll method was called with is_retry on', function() { +Then('the poll method was called with is_retry on', function () { let pollCalls = this.adapter.getTrackedCalls('poll'); - let lastCall = pollCalls[pollCalls.length-1]; + let lastCall = pollCalls[pollCalls.length - 1]; assert.ok(lastCall.arguments[1].is_retry); }); -Then('the poll method is not called again', function() { +Then('the poll method is not called again', function () { let newPollCallCount = this.adapter.getTrackedCalls('poll').length; assert.equal(this.callCounts.poll, newPollCallCount); }); diff --git a/test/cucumber/adapter/publish.steps.js b/test/cucumber/adapter/publish.steps.js index e207488c52ec6439bb5b14298e450f689d6c23c6..b0050c490b8d2a9fabf8e006f4713d3ded2eb170 100644 --- a/test/cucumber/adapter/publish.steps.js +++ b/test/cucumber/adapter/publish.steps.js @@ -5,24 +5,25 @@ const { fixtures } = require('../../fixtures/server'); const mockValidConfig = fixtures.get('config-valid'); -When('a mock send API response is configured to return success', function() { +When('a mock send API response is configured to return success', function () { const response = {}; - this.mockAxios.onPost( - `${mockValidConfig.api}/send`, - ).reply(200, response); + this.mockAxios.onPost(`${mockValidConfig.api}/send`).reply(200, response); }); -When('a mock send API response is configured to return a {int} error', function(statusCode) { - const statusMessages = { - 403: 'Token expired', - 503: 'Service unavailable' - }; - this.mockAxios.onPost( - `${mockValidConfig.api}/send`, - ).reply(statusCode, { message: statusMessages[statusCode] }) -}); - -When('the publish method is called', function() { +When( + 'a mock send API response is configured to return a {int} error', + function (statusCode) { + const statusMessages = { + 403: 'Token expired', + 503: 'Service unavailable', + }; + this.mockAxios + .onPost(`${mockValidConfig.api}/send`) + .reply(statusCode, { message: statusMessages[statusCode] }); + } +); + +When('the publish method is called', function () { const message = fixtures.get('message-vehicle-status'); this.message = message; const topic = message.metadata.destination; @@ -31,7 +32,7 @@ When('the publish method is called', function() { this.callCounts.publish = this.adapter.getTrackedCalls('publish').length; }); -When('the publish method is called with is_retry on', function() { +When('the publish method is called with is_retry on', function () { const message = fixtures.get('message-vehicle-status'); this.message = message; const topic = message.metadata.destination; @@ -40,13 +41,13 @@ When('the publish method is called with is_retry on', function() { this.callCounts.publish = this.adapter.getTrackedCalls('publish').length; }); -Then('the publish method was called with is_retry on', function() { +Then('the publish method was called with is_retry on', function () { let publishCalls = this.adapter.getTrackedCalls('publish'); - let lastCall = publishCalls[publishCalls.length-1]; + let lastCall = publishCalls[publishCalls.length - 1]; assert.ok(lastCall.arguments[1].is_retry); }); -Then('the publish method is not called again', function() { +Then('the publish method is not called again', function () { let newPublishCallCount = this.adapter.getTrackedCalls('publish').length; assert.equal(this.callCounts.publish, newPublishCallCount); -}); \ No newline at end of file +}); diff --git a/test/cucumber/adapter/token-valid.steps.js b/test/cucumber/adapter/token-valid.steps.js index 8ac886d516f47109b8f3e8d92e77dd61fd0e541e..57f210fd12ccf318602862d9d3fb1b2023797ceb 100644 --- a/test/cucumber/adapter/token-valid.steps.js +++ b/test/cucumber/adapter/token-valid.steps.js @@ -1,26 +1,26 @@ const assert = require('assert'); const { When, Then } = require('@cucumber/cucumber'); -When('the token expiry is in the future', function() { +When('the token expiry is in the future', function () { const expiry = new Date(); - expiry.setHours(expiry.getHours()+1); + expiry.setHours(expiry.getHours() + 1); this.adapter.credentials.expiry = expiry.toISOString(); }); -When('the token expiry is in the past', function() { +When('the token expiry is in the past', function () { const expiry = new Date(); - expiry.setHours(expiry.getHours()-1); - this.adapter.credentials.expiry = expiry.toISOString(); + expiry.setHours(expiry.getHours() - 1); + this.adapter.credentials.expiry = expiry.toISOString(); }); // Boolean parameters are not supported // and returns "true" would be misleading -Then('tokenValid returns true', function() { +Then('tokenValid returns true', function () { const isValid = this.adapter.tokenValid(); assert.ok(isValid); }); -Then('tokenValid returns false', function() { +Then('tokenValid returns false', function () { const isValid = this.adapter.tokenValid(); assert.ok(!isValid); -}); \ No newline at end of file +}); diff --git a/test/cucumber/adapter/validate.steps.js b/test/cucumber/adapter/validate.steps.js index a55a00df051e889f46adff57a88b5b256fe7198a..8507c35965e3cb0d5c94190dd5c9b92923a11e31 100644 --- a/test/cucumber/adapter/validate.steps.js +++ b/test/cucumber/adapter/validate.steps.js @@ -1,16 +1,15 @@ -const assert = require('assert'); -const { Given, When, Then } = require('@cucumber/cucumber'); +const { Given, When } = require('@cucumber/cucumber'); const { fixtures } = require('../../fixtures/server'); -Given('a valid message', function() { +Given('a valid message', function () { this.message = fixtures.get('message-vehicle-status'); }); -Given('an invalid message', function() { +Given('an invalid message', function () { this.message = fixtures.get('message-vehicle-status-invalid'); }); -When('the validate method is called', function() { +When('the validate method is called', function () { this.validation = this.adapter.validate(this.message); -}); \ No newline at end of file +}); diff --git a/test/cucumber/protocol/common.steps.js b/test/cucumber/protocol/common.steps.js index 734211ce74e25bcdf00a1d7cd0eb0176f5171f4b..641b07025bfd243088c3f86b8d74fb172aa74499 100644 --- a/test/cucumber/protocol/common.steps.js +++ b/test/cucumber/protocol/common.steps.js @@ -1,6 +1,6 @@ const assert = require('assert'); const { Then } = require('@cucumber/cucumber'); -Then('the message is returned unaltered', function() { +Then('the message is returned unaltered', function () { assert.equal(this.message, this.response); -}); \ No newline at end of file +}); diff --git a/test/cucumber/protocol/decode.steps.js b/test/cucumber/protocol/decode.steps.js index d831b8103de466f3e1840a19eedb5ead4572da4c..4c6d8aa5d310a6628c30ff192cccea42a510d48f 100644 --- a/test/cucumber/protocol/decode.steps.js +++ b/test/cucumber/protocol/decode.steps.js @@ -1,6 +1,6 @@ const { When } = require('@cucumber/cucumber'); -When('the protocol.decode method is called', function() { +When('the protocol.decode method is called', function () { const type = this.protocol.getType(this.message); this.response = this.protocol.decode(type, this.message); -}); \ No newline at end of file +}); diff --git a/test/cucumber/protocol/encode.steps.js b/test/cucumber/protocol/encode.steps.js index be79d26fd765ff58139d03812f0ce5da4b7543c6..e6fac9a38fabdece8f27912a8a0ad00573d438a7 100644 --- a/test/cucumber/protocol/encode.steps.js +++ b/test/cucumber/protocol/encode.steps.js @@ -1,6 +1,6 @@ const { When } = require('@cucumber/cucumber'); -When('the protocol.encode method is called', function() { +When('the protocol.encode method is called', function () { const type = this.protocol.getType(this.message); this.response = this.protocol.encode(type, this.message); -}); \ No newline at end of file +}); diff --git a/test/cucumber/protocol/get-type.steps.js b/test/cucumber/protocol/get-type.steps.js index 61b7808298e5eea62b751ae17b5d12109b65d5c2..70e549b50510be7bdde680c080e99b2df07f8a8e 100644 --- a/test/cucumber/protocol/get-type.steps.js +++ b/test/cucumber/protocol/get-type.steps.js @@ -1,14 +1,17 @@ const assert = require('assert'); const { When, Then } = require('@cucumber/cucumber'); -When('protocol getType is called', function() { +When('protocol getType is called', function () { this.type = this.protocol.getType(this.message); }); -Then('getType returns message.payload.message_type if present', function() { +Then('getType returns message.payload.message_type if present', function () { assert.equal(this.type, this.message.payload.message_type); }); -Then('getType returns null if message.payload.message_type is not present', function() { - assert.equal(this.type, null); -}); \ No newline at end of file +Then( + 'getType returns null if message.payload.message_type is not present', + function () { + assert.equal(this.type, null); + } +); diff --git a/test/cucumber/protocol/validate.steps.js b/test/cucumber/protocol/validate.steps.js index fdf86abf61b2675bb957fcd4908fe93d37fce67a..4335118eedfcad7589f2181f0f9533652fcf0df1 100644 --- a/test/cucumber/protocol/validate.steps.js +++ b/test/cucumber/protocol/validate.steps.js @@ -1,16 +1,16 @@ const assert = require('assert'); const { When, Then } = require('@cucumber/cucumber'); -When('the protocol.validate method is called', function() { +When('the protocol.validate method is called', function () { this.validation = this.protocol.validate(this.message); }); -Then('the message is validated successfully', function() { +Then('the message is validated successfully', function () { assert.equal(this.validation.valid, true); assert.equal(this.validation.errorCount, 0); }); -Then('the message fails to validate', function() { +Then('the message fails to validate', function () { assert.equal(this.validation.valid, false); assert.notEqual(this.validation.errorCount, 0); -}); \ No newline at end of file +}); diff --git a/test/cucumber/schema/validate.steps.js b/test/cucumber/schema/validate.steps.js index 58a4964594d054e8e9d43437d6dffa931e28931e..a540d9500166e826f4deef0d9d2d0942aca750c9 100644 --- a/test/cucumber/schema/validate.steps.js +++ b/test/cucumber/schema/validate.steps.js @@ -6,18 +6,18 @@ const fs = require('fs'); const schemaLocation = './test/mock/swagger.json'; -Given('the test schema', function() { +Given('the test schema', function () { this.schema = JSON.parse(fs.readFileSync(schemaLocation)); }); -When('it is validated', function() { +When('it is validated', function () { const validator = new OpenAPISchemaValidator({ version: 3 }); this.validation = validator.validate(this.schema); }); -Then('it matches the OpenAPI specification', function() { - // According to the docs this should return a valid:boolean - // but if you look at the code it just returns a list of errors +Then('it matches the OpenAPI specification', function () { + // According to the docs this should return a valid:boolean + // but if you look at the code it just returns a list of errors // which is empty for a valid result assert.equal(this.validation.errors.length, 0); -}); \ No newline at end of file +}); diff --git a/test/fixtures/server.js b/test/fixtures/server.js index f541f7b55981c9d0f96d06511bb93aae46452fa9..38193b692e25ebfbce7193c4b97aed4ed73347d3 100644 --- a/test/fixtures/server.js +++ b/test/fixtures/server.js @@ -4,12 +4,14 @@ const path = require('path'); exports.fixtures = { get: function (fixtureName) { try { - let fixtureContent = fs.readFileSync(path.join(__dirname, `${fixtureName}.json`)); + let fixtureContent = fs.readFileSync( + path.join(__dirname, `${fixtureName}.json`) + ); let fixture = JSON.parse(fixtureContent); return fixture; - } catch(e) { + } catch (e) { console.error('Fixture not found', fixtureName); return null; } - } -} \ No newline at end of file + }, +}; diff --git a/test/mock/messages/Message_VehicleMission.json b/test/mock/messages/Message_VehicleMission.json index 15365bed2f5dcddb830264e99e50f61937b91b4d..030d4e6c0585997059a8816945e54e385e0da15d 100644 --- a/test/mock/messages/Message_VehicleMission.json +++ b/test/mock/messages/Message_VehicleMission.json @@ -14,7 +14,7 @@ "longitude": -10.432, "depth": 50, "projection": 4326 - }, + }, "actions": [] } } diff --git a/test/mock/messages/Message_VehicleStatus.json b/test/mock/messages/Message_VehicleStatus.json index 55cdd818781ab404ebf70d3087a7f6c83396cc3a..dd3e610a281d68f70e3ec8cc6c14a3c5aebc905d 100644 --- a/test/mock/messages/Message_VehicleStatus.json +++ b/test/mock/messages/Message_VehicleStatus.json @@ -17,4 +17,4 @@ }, "battery_percentage": 64 } -} \ No newline at end of file +} diff --git a/test/mock/swagger.json b/test/mock/swagger.json index 35999bc48b202f254f93dcb3c6547e667037705d..005b62833eb5de91df8dd389027f857bd58169b4 100644 --- a/test/mock/swagger.json +++ b/test/mock/swagger.json @@ -64,7 +64,7 @@ "example": "VehicleStatus" } }, - "required": ["source","destination","message_id"], + "required": ["source", "destination", "message_id"], "type": "object" }, "Coordinates": { @@ -128,7 +128,13 @@ "example": 64 } }, - "required": ["message_type", "operator_id", "vehicle_id", "coordinates", "battery_percentage"], + "required": [ + "message_type", + "operator_id", + "vehicle_id", + "coordinates", + "battery_percentage" + ], "type": "object" }, "VehicleMission": { @@ -177,7 +183,13 @@ } } }, - "required": ["message_type", "operator_id", "vehicle_id", "coordinates", "actions"], + "required": [ + "message_type", + "operator_id", + "vehicle_id", + "coordinates", + "actions" + ], "type": "object" }, "AreaOfInterest": { @@ -202,7 +214,12 @@ "$ref": "#/components/schemas/Coordinates" } }, - "required": ["message_type", "operator_id", "vehicle_id", "coordinates"], + "required": [ + "message_type", + "operator_id", + "vehicle_id", + "coordinates" + ], "type": "object" }, "GoToWaypoint": { diff --git a/yarn.lock b/yarn.lock index 38ff398526a1fe2c777feb211dda585662fd8b57..66ab1e0208d098fadd44329407da5397797fe18d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -581,14 +581,26 @@ ts-node "^9" tslib "^2" -"@eslint/eslintrc@^1.4.1": - version "1.4.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.1.tgz#af58772019a2d271b7e2d4c23ff4ddcba3ccfb3e" - integrity sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA== +"@eslint-community/eslint-utils@^4.2.0": + version "4.3.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.3.0.tgz#a556790523a351b4e47e9d385f47265eaaf9780a" + integrity sha512-v3oplH6FYCULtFuCeqyuTd9D2WKO937Dxdq+GmHOLL72TTRriLxz2VLlNfkZRsvj6PKnOPAtuT6dwrs/pA5DvA== + dependencies: + eslint-visitor-keys "^3.3.0" + +"@eslint-community/regexpp@^4.4.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.4.0.tgz#3e61c564fcd6b921cb789838631c5ee44df09403" + integrity sha512-A9983Q0LnDGdLPjxyXQ00sbV+K+O+ko2Dr+CZigbHWtX9pNfxlaBkMR8X1CztI73zuEyEBXTVjx7CE+/VSwDiQ== + +"@eslint/eslintrc@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.1.tgz#7888fe7ec8f21bc26d646dbd2c11cd776e21192d" + integrity sha512-eFRmABvW2E5Ho6f5fHLqgena46rOj7r7OKHYfLElqcBfGFHHpjBhivyi5+jOEQuSpdc/1phIZJlbC2te+tZNIw== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.4.0" + espree "^9.5.0" globals "^13.19.0" ignore "^5.2.0" import-fresh "^3.2.1" @@ -596,6 +608,11 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@eslint/js@8.36.0": + version "8.36.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.36.0.tgz#9837f768c03a1e4a30bd304a64fb8844f0e72efe" + integrity sha512-lxJ9R5ygVm8ZWgYdUweoq5ownDlJ4upvoWmO4eLxBYHdMo+vZ/Rx0EN6MbKWDJOSUGrqJy2Gt+Dyv/VKml0fjg== + "@humanwhocodes/config-array@^0.11.8": version "0.11.8" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" @@ -1898,14 +1915,7 @@ eslint-scope@^7.1.1: esrecurse "^4.3.0" estraverse "^5.2.0" -eslint-utils@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" - integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== - dependencies: - eslint-visitor-keys "^2.0.0" - -eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0: +eslint-visitor-keys@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== @@ -1915,12 +1925,15 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@^8.4.1: - version "8.31.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.31.0.tgz#75028e77cbcff102a9feae1d718135931532d524" - integrity sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA== +eslint@^8.36.0: + version "8.36.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.36.0.tgz#1bd72202200a5492f91803b113fb8a83b11285cf" + integrity sha512-Y956lmS7vDqomxlaaQAHVmeb4tNMp2FWIvU/RnU5BD3IKMD/MJPr76xdyr68P8tV1iNMvN2mRK0yy3c+UjL+bw== dependencies: - "@eslint/eslintrc" "^1.4.1" + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.4.0" + "@eslint/eslintrc" "^2.0.1" + "@eslint/js" "8.36.0" "@humanwhocodes/config-array" "^0.11.8" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" @@ -1931,10 +1944,9 @@ eslint@^8.4.1: doctrine "^3.0.0" escape-string-regexp "^4.0.0" eslint-scope "^7.1.1" - eslint-utils "^3.0.0" eslint-visitor-keys "^3.3.0" - espree "^9.4.0" - esquery "^1.4.0" + espree "^9.5.0" + esquery "^1.4.2" esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" @@ -1955,15 +1967,14 @@ eslint@^8.4.1: minimatch "^3.1.2" natural-compare "^1.4.0" optionator "^0.9.1" - regexpp "^3.2.0" strip-ansi "^6.0.1" strip-json-comments "^3.1.0" text-table "^0.2.0" -espree@^9.4.0: - version "9.4.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.4.1.tgz#51d6092615567a2c2cff7833445e37c28c0065bd" - integrity sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg== +espree@^9.5.0: + version "9.5.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.5.0.tgz#3646d4e3f58907464edba852fa047e6a27bdf113" + integrity sha512-JPbJGhKc47++oo4JkEoTe2wjy4fmMwvFpgJT9cQzmfXKp22Dr6Hf1tdCteLz1h0P3t+mGvWZ+4Uankvh8+c6zw== dependencies: acorn "^8.8.0" acorn-jsx "^5.3.2" @@ -1974,10 +1985,10 @@ esprima@^4.0.0, esprima@^4.0.1: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" - integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== +esquery@^1.4.2: + version "1.5.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" + integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== dependencies: estraverse "^5.1.0" @@ -3720,10 +3731,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.5.1: - version "2.8.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.2.tgz#c4ea1b5b454d7c4b59966db2e06ed7eec5dfd160" - integrity sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw== +prettier@^2.8.4: + version "2.8.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3" + integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw== pretty-format@^27.5.1: version "27.5.1" @@ -3905,11 +3916,6 @@ regexp-tree@^0.1.11: resolved "https://registry.yarnpkg.com/regexp-tree/-/regexp-tree-0.1.24.tgz#3d6fa238450a4d66e5bc9c4c14bb720e2196829d" integrity sha512-s2aEVuLhvnVJW6s/iPgEGK6R+/xngd2jNQ+xy4bXNDKxZKJH6jpPHY6kVeVv1IeLCHgswRj+Kl3ELaDjG6V1iw== -regexpp@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" - integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== - repeat-string@^1.5.2, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"