From 55b08bda14304dfd6a4e2182f9063bb47bc86bf4 Mon Sep 17 00:00:00 2001 From: Olivier Albertini Date: Tue, 10 Nov 2020 17:09:35 -0500 Subject: [PATCH] ci: update deps and remove console.log (#215) Signed-off-by: Olivier Albertini --- eslint.rules.js | 84 +++++++++++-------- examples/basic/.eslintrc.js | 6 +- examples/basic/package.json | 26 +++--- examples/binding/.eslintrc.js | 6 +- examples/binding/package.json | 26 +++--- .../binding/src/create-process-instances.ts | 4 +- examples/binding/src/worker.ts | 2 +- examples/camunda-cloud/.eslintrc.js | 6 +- examples/camunda-cloud/package.json | 22 ++--- examples/event/.eslintrc.js | 6 +- examples/event/package.json | 24 +++--- examples/failure-strategy/.eslintrc.js | 6 +- examples/failure-strategy/package.json | 26 +++--- examples/opentelemetry/.eslintrc.js | 6 +- examples/opentelemetry/package.json | 26 +++--- examples/parallel/.eslintrc.js | 6 +- examples/parallel/package.json | 26 +++--- package.json | 4 +- packages/workit-bpm-client/package.json | 30 +++---- .../workit-bpm-client/src/camundaBpmClient.ts | 24 +++--- .../src/camundaMapperProperties.ts | 7 +- .../workit-bpm-client/src/camundaMessage.ts | 17 ++-- .../src/config/constants/identifiers.ts | 2 +- .../workit-bpm-client/src/config/container.ts | 4 +- packages/workit-bpm-client/src/logger.ts | 5 ++ .../src/repositories/camundaRepository.ts | 31 ++++--- .../src/utils/paginationUtils.ts | 6 +- packages/workit-bpm-client/src/utils/utils.ts | 16 +++- .../tests/functionals/__mocks__/message.ts | 2 +- .../tests/functionals/camunda.spec.ts | 32 +++---- .../tests/functionals/camundaManager.spec.ts | 28 +++---- .../tests/functionals/camundaMessage.spec.ts | 8 +- .../tests/units/camundaClient.spec.ts | 2 +- .../tests/units/camundaMessage.spec.ts | 2 +- .../tests/units/utils.spec.ts | 16 ++-- packages/workit-camunda/package.json | 28 +++---- .../workit-camunda/src/camunda-n-mq/client.ts | 8 +- .../src/camunda-n-mq/clientManager.ts | 2 +- .../src/config/constants/identifiers.ts | 2 +- .../src/config/constants/index.ts | 2 +- .../src/config/constants/tag.ts | 2 +- .../workit-camunda/src/config/container.ts | 12 +-- packages/workit-camunda/src/config/ioc.ts | 2 +- .../tests/functionals/__mocks__/message.ts | 2 +- .../tests/functionals/camunda.spec.ts | 30 +++---- .../tests/functionals/camundaManager.spec.ts | 28 +++---- .../tests/functionals/zeebe.spec.ts | 18 ++-- .../tests/integrations/zeebe.spec.ts | 52 ++++++------ packages/workit-cli/.eslintrc.js | 23 ++++- packages/workit-cli/package.json | 24 +++--- .../src/command/create/task/index.ts | 12 +-- packages/workit-cli/src/command/init/index.ts | 2 +- .../templates/node/default/src/package.json | 22 ++--- .../node/default/src/src/config/index.ts | 6 +- .../node/default/src/src/config/ioc.ts | 2 +- .../node/default/src/src/enums/environment.ts | 2 +- .../templates/node/default/src/src/worker.ts | 2 +- .../src/configs/constants/symbols.ts | 2 +- packages/workit-core/package.json | 28 +++---- packages/workit-core/src/IoC.ts | 7 +- packages/workit-core/src/common/noopLogger.ts | 23 +++++ .../src/config/constants/identifiers.ts | 2 +- .../workit-core/src/config/constants/index.ts | 2 +- packages/workit-core/src/interceptors.ts | 1 + .../simpleCamundaProcessHandler.ts | 14 ++-- packages/workit-core/src/proxyFactory.ts | 5 +- packages/workit-core/src/proxyObserver.ts | 10 ++- .../src/strategies/FailureStrategySimple.ts | 26 ++++-- packages/workit-core/src/utils/concat.ts | 2 +- packages/workit-core/src/utils/utils.ts | 5 +- .../tests/functionals/interceptors.spec.ts | 20 ++--- .../workit-core/tests/units/utils.spec.ts | 4 +- packages/workit-types/package.json | 24 +++--- .../src/camundaBpm/camundaConfig.ts | 2 + .../src/camundaBpm/camundaRepository.ts | 6 +- packages/workit-types/src/commons/logger.ts | 14 ++++ packages/workit-types/src/http/httpOptions.ts | 2 +- packages/workit-types/src/index.ts | 1 + packages/workit-zeebe-client/package.json | 28 +++---- .../src/config/constants/identifiers.ts | 2 +- .../src/config/container.ts | 10 +-- .../src/utils/paginationUtils.ts | 6 +- .../workit-zeebe-client/src/zeebeClient.ts | 18 ++-- .../src/zeebeMapperProperties.ts | 9 +- .../workit-zeebe-client/src/zeebeMessage.ts | 11 +-- .../tests/functionals/zeebe.spec.ts | 16 ++-- .../tests/functionals/zeebeMessage.spec.ts | 4 +- .../tests/integrations/zeebe.spec.ts | 54 ++++++------ .../zeebe-elasticsearch-client/.eslintrc.js | 7 +- .../zeebe-elasticsearch-client/package.json | 26 +++--- .../src/enums/httpMethods.ts | 2 +- .../src/models/config/index.ts | 6 +- .../src/repositories/zbElasticClient.ts | 50 +++++------ .../src/specs/options.ts | 2 +- .../src/tests/getWorkflows.spec.ts | 16 ++-- .../src/utils/utils.ts | 10 +-- 96 files changed, 721 insertions(+), 583 deletions(-) create mode 100644 packages/workit-core/src/common/noopLogger.ts create mode 100644 packages/workit-types/src/commons/logger.ts diff --git a/eslint.rules.js b/eslint.rules.js index 6bc6c2bd..02ea64c0 100644 --- a/eslint.rules.js +++ b/eslint.rules.js @@ -1,39 +1,49 @@ module.exports = { - // prettier conflicts - "no-underscore-dangle": "off", - "max-len": "off", - "max-classes-per-file": "off", - "class-methods-use-this": "off", - "no-await-in-loop": "off", - "import/prefer-default-export": "off", - "comma-dangle": "off", - "object-curly-newline":"off", - "arrow-parens": "off", - "implicit-arrow-linebreak": "off", - "prettier/prettier": "error", - "@typescript-eslint/no-useless-constructor": "off", // not good with inversify - "@typescript-eslint/no-misused-promises": "off", - "@typescript-eslint/interface-name-prefix": ["error", { "prefixWithI": "always" }], - "@typescript-eslint/explicit-member-accessibility": ["error", { - "accessibility": "explicit", - "overrides": { - "accessors": "explicit", - "constructors": "no-public", - "methods": "explicit", - "properties": "explicit", - "parameterProperties": "explicit" - } - }], - "@typescript-eslint/naming-convention": [ - "error", - { - "selector": "memberLike", - "modifiers": ["private"], - "format": ["camelCase", "UPPER_CASE"], - "leadingUnderscore": "require" - } - ], - "header/header": [2, "block", [ - `\n * Copyright (c) ${new Date().getFullYear()} Ville de Montreal. All rights reserved.\n * Licensed under the MIT license.\n * See LICENSE file in the project root for full license information.\n ` - ]] + // prettier conflicts + "no-underscore-dangle": "off", + "max-len": "off", + "max-classes-per-file": "off", + "class-methods-use-this": "off", + "no-await-in-loop": "off", + "import/prefer-default-export": "off", + "comma-dangle": "off", + "object-curly-newline": "off", + "arrow-parens": "off", + "implicit-arrow-linebreak": "off", + "prettier/prettier": "error", + "@typescript-eslint/no-useless-constructor": "off", // not good with inversify + "@typescript-eslint/no-misused-promises": "off", + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "interface", + "format": ["PascalCase"], + "custom": { + "regex": "^I[A-Z]", + "match": true + } + } + ], + "@typescript-eslint/explicit-member-accessibility": ["error", { + "accessibility": "explicit", + "overrides": { + "accessors": "explicit", + "constructors": "no-public", + "methods": "explicit", + "properties": "explicit", + "parameterProperties": "explicit" + } + }], + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "memberLike", + "modifiers": ["private"], + "format": ["camelCase", "UPPER_CASE"], + "leadingUnderscore": "require" + } + ], + "header/header": [2, "block", [ + `\n * Copyright (c) ${new Date().getFullYear()} Ville de Montreal. All rights reserved.\n * Licensed under the MIT license.\n * See LICENSE file in the project root for full license information.\n ` + ]] }; \ No newline at end of file diff --git a/examples/basic/.eslintrc.js b/examples/basic/.eslintrc.js index a801fa19..9a6388c0 100644 --- a/examples/basic/.eslintrc.js +++ b/examples/basic/.eslintrc.js @@ -17,6 +17,10 @@ module.exports = { }, "rules": { ...require('../../eslint.rules.js'), - "no-console": "off" + "no-console": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off" } } diff --git a/examples/basic/package.json b/examples/basic/package.json index a9a173f4..155e4280 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -25,20 +25,20 @@ "url": "git+https://github.com/VilledeMontreal/workit.git" }, "devDependencies": { - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", - "prettier": "^2.0.1", - "typescript": "^3.8.3" + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", + "prettier": "^2.1.2", + "typescript": "^4.0.5" }, "dependencies": { - "axios": "^0.19.2", + "axios": "^0.21.0", "workit-camunda": "^4.2.2", "workit-core": "^4.2.2", "workit-types": "^4.2.2" @@ -55,4 +55,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "homepage": "https://github.com/VilledeMontreal/workit#readme" -} +} \ No newline at end of file diff --git a/examples/binding/.eslintrc.js b/examples/binding/.eslintrc.js index a801fa19..9a6388c0 100644 --- a/examples/binding/.eslintrc.js +++ b/examples/binding/.eslintrc.js @@ -17,6 +17,10 @@ module.exports = { }, "rules": { ...require('../../eslint.rules.js'), - "no-console": "off" + "no-console": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off" } } diff --git a/examples/binding/package.json b/examples/binding/package.json index 34b8f88b..38c438b9 100644 --- a/examples/binding/package.json +++ b/examples/binding/package.json @@ -25,20 +25,20 @@ "url": "git+https://github.com/VilledeMontreal/workit.git" }, "devDependencies": { - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", - "prettier": "^1.19.1", - "typescript": "^3.8.3" + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", + "prettier": "^2.1.2", + "typescript": "^4.0.5" }, "dependencies": { - "axios": "^0.19.2", + "axios": "^0.21.0", "workit-camunda": "^4.2.2", "workit-core": "^4.2.2", "workit-types": "^4.2.2" @@ -55,4 +55,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "homepage": "https://github.com/VilledeMontreal/workit#readme" -} +} \ No newline at end of file diff --git a/examples/binding/src/create-process-instances.ts b/examples/binding/src/create-process-instances.ts index a4be97f1..a5f31889 100644 --- a/examples/binding/src/create-process-instances.ts +++ b/examples/binding/src/create-process-instances.ts @@ -15,8 +15,8 @@ import { IWorkflowClient } from 'workit-types'; bpmnProcessId: 'BPMN_P_DEMO', variables: { amount: 1000, - hello: 'world' - } + hello: 'world', + }, }); } console.log('Success!'); diff --git a/examples/binding/src/worker.ts b/examples/binding/src/worker.ts index d5ba2402..452afc6e 100644 --- a/examples/binding/src/worker.ts +++ b/examples/binding/src/worker.ts @@ -13,7 +13,7 @@ import { HelloWorldTaskV3 } from '../tasks/helloWorldTaskV3'; enum LOCAL_IDENTIFIER { activity1 = 'activity_1', activity2 = 'activity_2', - activity3 = 'activity_3' + activity3 = 'activity_3', } const BPMN_PROCESS_ID = 'BPMN_P_DEMO'; diff --git a/examples/camunda-cloud/.eslintrc.js b/examples/camunda-cloud/.eslintrc.js index a801fa19..9a6388c0 100644 --- a/examples/camunda-cloud/.eslintrc.js +++ b/examples/camunda-cloud/.eslintrc.js @@ -17,6 +17,10 @@ module.exports = { }, "rules": { ...require('../../eslint.rules.js'), - "no-console": "off" + "no-console": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off" } } diff --git a/examples/camunda-cloud/package.json b/examples/camunda-cloud/package.json index 7704be60..577f2dc2 100644 --- a/examples/camunda-cloud/package.json +++ b/examples/camunda-cloud/package.json @@ -26,16 +26,16 @@ }, "devDependencies": { "@types/node": "^13.9.3", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", - "prettier": "^2.0.1", - "typescript": "^3.8.3" + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", + "prettier": "^2.1.2", + "typescript": "^4.0.5" }, "dependencies": { "workit-camunda": "^4.2.2", @@ -54,4 +54,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "homepage": "https://github.com/VilledeMontreal/workit#readme" -} +} \ No newline at end of file diff --git a/examples/event/.eslintrc.js b/examples/event/.eslintrc.js index a801fa19..9a6388c0 100644 --- a/examples/event/.eslintrc.js +++ b/examples/event/.eslintrc.js @@ -17,6 +17,10 @@ module.exports = { }, "rules": { ...require('../../eslint.rules.js'), - "no-console": "off" + "no-console": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off" } } diff --git a/examples/event/package.json b/examples/event/package.json index 1be2475b..9fb71205 100644 --- a/examples/event/package.json +++ b/examples/event/package.json @@ -25,17 +25,17 @@ "url": "git+https://github.com/VilledeMontreal/workit.git" }, "devDependencies": { - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", - "prettier": "^2.0.1", - "typescript": "^3.8.3" + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", + "prettier": "^2.1.2", + "typescript": "^4.0.5" }, "dependencies": { "axios": "^0.19.0", @@ -55,4 +55,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "homepage": "https://github.com/VilledeMontreal/workit#readme" -} +} \ No newline at end of file diff --git a/examples/failure-strategy/.eslintrc.js b/examples/failure-strategy/.eslintrc.js index a801fa19..9a6388c0 100644 --- a/examples/failure-strategy/.eslintrc.js +++ b/examples/failure-strategy/.eslintrc.js @@ -17,6 +17,10 @@ module.exports = { }, "rules": { ...require('../../eslint.rules.js'), - "no-console": "off" + "no-console": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off" } } diff --git a/examples/failure-strategy/package.json b/examples/failure-strategy/package.json index 86c24bff..8798cd97 100644 --- a/examples/failure-strategy/package.json +++ b/examples/failure-strategy/package.json @@ -25,20 +25,20 @@ "url": "git+https://github.com/VilledeMontreal/workit.git" }, "devDependencies": { - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", - "prettier": "^2.0.1", - "typescript": "^3.8.3" + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", + "prettier": "^2.1.2", + "typescript": "^4.0.5" }, "dependencies": { - "axios": "^0.19.2", + "axios": "^0.21.0", "workit-camunda": "^4.2.2", "workit-core": "^4.2.2", "workit-types": "^4.2.2" @@ -54,4 +54,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "homepage": "https://github.com/VilledeMontreal/workit#readme" -} +} \ No newline at end of file diff --git a/examples/opentelemetry/.eslintrc.js b/examples/opentelemetry/.eslintrc.js index a801fa19..9a6388c0 100644 --- a/examples/opentelemetry/.eslintrc.js +++ b/examples/opentelemetry/.eslintrc.js @@ -17,6 +17,10 @@ module.exports = { }, "rules": { ...require('../../eslint.rules.js'), - "no-console": "off" + "no-console": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off" } } diff --git a/examples/opentelemetry/package.json b/examples/opentelemetry/package.json index 68428d44..36ad5cfd 100644 --- a/examples/opentelemetry/package.json +++ b/examples/opentelemetry/package.json @@ -25,17 +25,17 @@ "url": "git+https://github.com/VilledeMontreal/workit.git" }, "devDependencies": { - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", - "prettier": "^2.0.1", - "typescript": "^3.8.3" + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", + "prettier": "^2.1.2", + "typescript": "^4.0.5" }, "dependencies": { "@opentelemetry/exporter-jaeger": "0.4.0", @@ -43,7 +43,7 @@ "@opentelemetry/plugin-http": "0.4.0", "@opentelemetry/plugin-https": "0.4.0", "@opentelemetry/tracing": "0.4.0", - "axios": "^0.19.2", + "axios": "^0.21.0", "workit-camunda": "^4.2.2", "workit-core": "^4.2.2", "workit-types": "^4.2.2" @@ -60,4 +60,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "homepage": "https://github.com/VilledeMontreal/workit#readme" -} +} \ No newline at end of file diff --git a/examples/parallel/.eslintrc.js b/examples/parallel/.eslintrc.js index a801fa19..9a6388c0 100644 --- a/examples/parallel/.eslintrc.js +++ b/examples/parallel/.eslintrc.js @@ -17,6 +17,10 @@ module.exports = { }, "rules": { ...require('../../eslint.rules.js'), - "no-console": "off" + "no-console": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off" } } diff --git a/examples/parallel/package.json b/examples/parallel/package.json index a57fa5a2..60c6684c 100644 --- a/examples/parallel/package.json +++ b/examples/parallel/package.json @@ -25,20 +25,20 @@ "url": "git+https://github.com/VilledeMontreal/workit.git" }, "devDependencies": { - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.1", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", - "prettier": "^2.0.1", - "typescript": "^3.8.3" + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", + "prettier": "^2.1.2", + "typescript": "^4.0.5" }, "dependencies": { - "axios": "^0.19.2", + "axios": "^0.21.0", "workit-camunda": "^4.2.2", "workit-core": "^4.2.2", "workit-types": "^4.2.2" @@ -55,4 +55,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "homepage": "https://github.com/VilledeMontreal/workit#readme" -} +} \ No newline at end of file diff --git a/package.json b/package.json index ba72c5cd..e69ac36b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "codecov": "lerna run codecov" }, "devDependencies": { - "@types/node": "^14.0.0", + "@types/node": "^14.14.7", "@commitlint/cli": "^8.3.5", "@commitlint/config-conventional": "^8.3.4", "codecov": "^3.6.5", @@ -30,7 +30,7 @@ "lerna-changelog": "^1.0.1", "remark-cli": "^8.0.0", "remark-preset-lint-recommended": "^4.0.0", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "husky": { "hooks": { diff --git a/packages/workit-bpm-client/package.json b/packages/workit-bpm-client/package.json index 03165d11..4b7d3362 100644 --- a/packages/workit-bpm-client/package.json +++ b/packages/workit-bpm-client/package.json @@ -8,9 +8,9 @@ "main": "lib/src/index.js", "typings": "lib/src/index.d.ts", "dependencies": { - "axios": "~0.19.2", + "axios": "^0.21.0", "camunda-external-task-client-js": "^1.3.0", - "debug": "~4.1.1", + "debug": "^4.2.0", "fast-safe-stringify": "~2.0.7", "form-data": "~2.5.1", "inversify": "~5.0.1", @@ -29,25 +29,25 @@ "@types/form-data": "~2.5.0", "@types/jest": "^25.1.4", "@types/nock": "^10.0.3", - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.23.0", - "@typescript-eslint/parser": "^2.23.0", + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "chai": "^4.2.0", "codecov": "^3.6.5", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.0.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", "husky": "^4.2.4", "jest": "^25.1.0", "nock": "^10.0.6", - "prettier": "^1.19.1", - "source-map-support": "^0.5.16", + "prettier": "^2.1.2", + "source-map-support": "^0.5.19", "ts-jest": "^26.0.0", "typedoc": "^0.16.11", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "engines": { "node": ">=8.11.4" @@ -98,4 +98,4 @@ "access": "public" }, "gitHead": "a122cb022d456027da28874b789616ebd0cb2284" -} +} \ No newline at end of file diff --git a/packages/workit-bpm-client/src/camundaBpmClient.ts b/packages/workit-bpm-client/src/camundaBpmClient.ts index 71c973bc..fc1cd249 100644 --- a/packages/workit-bpm-client/src/camundaBpmClient.ts +++ b/packages/workit-bpm-client/src/camundaBpmClient.ts @@ -28,7 +28,7 @@ import { IWorkflowDefinition, IWorkflowDefinitionRequest, IWorkflowOptions, - IWorkflowProcessIdDefinition + IWorkflowProcessIdDefinition, } from 'workit-types'; import { PaginationUtils } from './utils/paginationUtils'; @@ -37,7 +37,7 @@ import { CamundaRepository } from './repositories/camundaRepository'; export class CamundaBpmClient implements IClient, IWorkflowClient { private static _getWorkflowParams(options?: Partial): any { - const _params = {} as any; + const _params = {} as Record; if (options && (options as IWorkflowOptions).bpmnProcessId) { _params.key = options.bpmnProcessId; } @@ -95,17 +95,19 @@ export class CamundaBpmClient implements IClient, IWorkflowClie bpmnProcessId: definition.key, workflowKey: definition.id, resourceName: definition.resource, - version: definition.version - } + version: definition.version, + }, ]; return { workflows, - key: response.id + key: response.id, }; } public async getWorkflows(options?: Partial): Promise> { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const params = CamundaBpmClient._getWorkflowParams(options); + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const apiOptions = { params }; const requests: [ Promise>, @@ -117,16 +119,16 @@ export class CamundaBpmClient implements IClient, IWorkflowClie ] = [this._repo.getWorkflows(apiOptions), this._repo.getWorkflowCount(apiOptions)]; const [result, repCount] = await Promise.all(requests); const bpmns = result.data; - const workflows = bpmns.map(definition => ({ + const workflows = bpmns.map((definition) => ({ bpmnProcessId: definition.key, workflowKey: definition.id, resourceName: definition.resource, - version: definition.version + version: definition.version, })); return { paging: PaginationUtils.getPagingFromOptions(repCount.data.count, options), - items: workflows + items: workflows, }; } @@ -143,7 +145,7 @@ export class CamundaBpmClient implements IClient, IWorkflowClie bpmnXml: definition.bpmn20Xml, resourceName: definition.resource, version: definition.version, - workflowKey: definition.id + workflowKey: definition.id, }; } @@ -160,7 +162,7 @@ export class CamundaBpmClient implements IClient, IWorkflowClie messageName: payload.name, processInstanceId: payload.messageId as string, correlationKeys: payload.correlation, - variables: payload.variables + variables: payload.variables, }); } @@ -173,7 +175,7 @@ export class CamundaBpmClient implements IClient, IWorkflowClie bpmnProcessId: bpmnDef[0], version: (bpmnDef[1] as unknown) as number, workflowInstanceKey: response.id, - workflowKey: response.definitionId + workflowKey: response.definitionId, }; } diff --git a/packages/workit-bpm-client/src/camundaMapperProperties.ts b/packages/workit-bpm-client/src/camundaMapperProperties.ts index e3260718..04f5d14d 100644 --- a/packages/workit-bpm-client/src/camundaMapperProperties.ts +++ b/packages/workit-bpm-client/src/camundaMapperProperties.ts @@ -4,6 +4,11 @@ * See LICENSE file in the project root for full license information. */ +/* eslint @typescript-eslint/no-unsafe-assignment: 0 */ +/* eslint @typescript-eslint/no-unsafe-call: 0 */ +/* eslint @typescript-eslint/no-unsafe-member-access: 0 */ +/* eslint @typescript-eslint/no-unsafe-return: 0 */ + import { IVariablePayload, IWorkflowProps } from 'workit-types'; export class CamundaMapperProperties { @@ -21,7 +26,7 @@ export class CamundaMapperProperties { retries: task.retries, topicName: task.topicName, workerId: task.workerId, - lockExpirationTime: new Date(task.lockExpirationTime) + lockExpirationTime: new Date(task.lockExpirationTime), }; } diff --git a/packages/workit-bpm-client/src/camundaMessage.ts b/packages/workit-bpm-client/src/camundaMessage.ts index 68e03389..2ce7d2ba 100644 --- a/packages/workit-bpm-client/src/camundaMessage.ts +++ b/packages/workit-bpm-client/src/camundaMessage.ts @@ -4,6 +4,10 @@ * See LICENSE file in the project root for full license information. */ +/* eslint @typescript-eslint/no-unsafe-assignment: 0 */ +/* eslint @typescript-eslint/no-unsafe-call: 0 */ +/* eslint @typescript-eslint/no-unsafe-member-access: 0 */ + import { getVariablesWhenChanged, ProxyFactory } from 'workit-core'; import { FailureException, ICamundaService, IMessage, IVariablePayload, IVariables } from 'workit-types'; import { CamundaMapperProperties } from './camundaMapperProperties'; @@ -18,12 +22,12 @@ export class CamundaMessage { const properties = CamundaMapperProperties.map(task); const messageWithoutSpan = { body: task.variables.getAll(), - properties + properties, }; // TODO: create a CamundaMessage builder const msg = ProxyFactory.create({ body: messageWithoutSpan.body, - properties: messageWithoutSpan.properties + properties: messageWithoutSpan.properties, }); return [ msg, @@ -39,7 +43,7 @@ export class CamundaMessage { return; } - const vars = getVariablesWhenChanged(message, m => CamundaMessage.unwrap(m)); + const vars = getVariablesWhenChanged(message, (m) => CamundaMessage.unwrap(m)); await payload.taskService.complete(task, vars); this.hasBeenThreated = true; @@ -60,11 +64,11 @@ export class CamundaMessage { errorDetails: stringify(error), retries, // TODO: Add to configuration - retryTimeout: retryTimeoutInMs + retryTimeout: retryTimeoutInMs, }); this.hasBeenThreated = true; - } - } + }, + }, ]; } @@ -81,6 +85,7 @@ export class CamundaMessage { } }); CamundaMessage._setCustomHeaders(vars, message.properties.customHeaders); + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return vars; } diff --git a/packages/workit-bpm-client/src/config/constants/identifiers.ts b/packages/workit-bpm-client/src/config/constants/identifiers.ts index a716f746..7be357cd 100644 --- a/packages/workit-bpm-client/src/config/constants/identifiers.ts +++ b/packages/workit-bpm-client/src/config/constants/identifiers.ts @@ -35,5 +35,5 @@ export const SERVICE_IDENTIFIER = { /** * Bind your own config for Camunda system */ - camunda_config: Symbol('camunda_config') + camunda_config: Symbol('camunda_config'), }; diff --git a/packages/workit-bpm-client/src/config/container.ts b/packages/workit-bpm-client/src/config/container.ts index 651fdfd4..534c4a56 100644 --- a/packages/workit-bpm-client/src/config/container.ts +++ b/packages/workit-bpm-client/src/config/container.ts @@ -11,14 +11,14 @@ import { SERVICE_IDENTIFIER } from './constants/identifiers'; const configBase: ICamundaConfig = { workerId: 'demo', baseUrl: `__undefined__`, - topicName: 'topic_demo' + topicName: 'topic_demo', }; const bpmnPlatformClientConfig = { ...configBase, baseUrl: process.env.CAMUNDA_BPM_ADDRESS || `http://localhost:8080/engine-rest`, maxTasks: 32, - autoPoll: false + autoPoll: false, }; kernel.bind(SERVICE_IDENTIFIER.camunda_external_config).toConstantValue(bpmnPlatformClientConfig); diff --git a/packages/workit-bpm-client/src/logger.ts b/packages/workit-bpm-client/src/logger.ts index 9aea9563..cd358998 100644 --- a/packages/workit-bpm-client/src/logger.ts +++ b/packages/workit-bpm-client/src/logger.ts @@ -4,6 +4,11 @@ * See LICENSE file in the project root for full license information. */ +/* eslint @typescript-eslint/no-unsafe-assignment: 0 */ // --> OFF +/* eslint @typescript-eslint/ban-types: 0 */ // --> OFF +/* eslint @typescript-eslint/restrict-template-expressions: 0 */ // --> OFF +/* eslint @typescript-eslint/no-unsafe-call: 0 */ // --> OFF +/* eslint @typescript-eslint/no-unsafe-member-access: 0 */ // --> OFF // eslint-disable-next-line @typescript-eslint/no-var-requires const stringify = require('fast-safe-stringify'); diff --git a/packages/workit-bpm-client/src/repositories/camundaRepository.ts b/packages/workit-bpm-client/src/repositories/camundaRepository.ts index 742f0639..322efa42 100644 --- a/packages/workit-bpm-client/src/repositories/camundaRepository.ts +++ b/packages/workit-bpm-client/src/repositories/camundaRepository.ts @@ -4,6 +4,13 @@ * See LICENSE file in the project root for full license information. */ +/* eslint @typescript-eslint/no-unsafe-assignment: 0 */ +/* eslint @typescript-eslint/ban-types: 0 */ +/* eslint @typescript-eslint/restrict-template-expressions: 0 */ +/* eslint @typescript-eslint/no-unsafe-call: 0 */ +/* eslint @typescript-eslint/no-unsafe-member-access: 0 */ +/* eslint @typescript-eslint/no-unsafe-return: 0 */ + import axios, { AxiosInstance } from 'axios'; import * as FormData from 'form-data'; import * as fs from 'fs'; @@ -19,7 +26,7 @@ import { IIncident, IProcessDefinition, IProcessXmlDefinition, - IResolveIncident + IResolveIncident, } from 'workit-types'; import { SERVICE_IDENTIFIER } from '../config/constants/identifiers'; import { Utils } from '../utils/utils'; @@ -60,13 +67,13 @@ export class CamundaRepository implements ICamundaRepository { const headers = { Accept: 'application/json', 'Content-Type': 'application/json', - 'X-APP': this._configs.workerId || 'unknow' + 'X-APP': this._configs.workerId || 'unknow', }; this._headers = CamundaRepository._setStaticHeaders(configs, headers); this._request = axios.create({ baseURL: this._configs.baseUrl, timeout: 30000, - headers: this._headers + headers: this._headers, }); } @@ -76,7 +83,7 @@ export class CamundaRepository implements ICamundaRepository { formData.append('deployment-name', deployName); formData.append('process', xmlStream); return this._request.post('/deployment/create', formData, { - headers: { ...this._headers, 'content-type': `multipart/form-data; boundary=${formData.getBoundary()}` } + headers: { ...this._headers, 'content-type': `multipart/form-data; boundary=${formData.getBoundary()}` }, }); } @@ -95,7 +102,7 @@ export class CamundaRepository implements ICamundaRepository { const url = CamundaRepository._getworkflowInstanceUrl(idOrKey); return this._request.post(url, { businessKey: typeof variables === 'object' ? (variables as any).businessKey : undefined, - variables: Utils.serializeVariables(variables) + variables: Utils.serializeVariables(variables), }); } @@ -106,7 +113,7 @@ export class CamundaRepository implements ICamundaRepository { messageName, processInstanceId, variables, - correlationKeys + correlationKeys, }: { messageName: string; processInstanceId: string; @@ -120,7 +127,7 @@ export class CamundaRepository implements ICamundaRepository { businessKey: typeof variables === 'object' ? (variables as any).businessKey : undefined, processVariables: Utils.serializeVariables(variables), resultEnabled: false, - all: true // same behaviour than Zeebe + all: true, // same behaviour than Zeebe }); } @@ -144,9 +151,9 @@ export class CamundaRepository implements ICamundaRepository { instructions: [ { type: 'cancel', // change for enum - activityId: incident.activityId - } - ] + activityId: incident.activityId, + }, + ], } as IResolveIncident); } @@ -170,7 +177,7 @@ export class CamundaRepository implements ICamundaRepository { public updateJobRetries(id: string, retries: number): Promise> { return this._request.put(`/external-task/${id}/retries`, { - retries + retries, }); } @@ -180,7 +187,7 @@ export class CamundaRepository implements ICamundaRepository { local = false ): Promise> { return this._request.post(`/process-instance/${processInstanceId}/variables`, { - modifications: Utils.serializeVariables(variables, local) + modifications: Utils.serializeVariables(variables, local), }); } } diff --git a/packages/workit-bpm-client/src/utils/paginationUtils.ts b/packages/workit-bpm-client/src/utils/paginationUtils.ts index df411e5f..17d5da33 100644 --- a/packages/workit-bpm-client/src/utils/paginationUtils.ts +++ b/packages/workit-bpm-client/src/utils/paginationUtils.ts @@ -24,13 +24,15 @@ export class PaginationUtils { return { from: 0, size: PaginationUtils._DEFAULT_SIZE_ITEMS, - totalCount + totalCount, }; } return { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment from: typeof options.from === 'number' ? options.from : 0, + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment size: options.size || PaginationUtils._DEFAULT_SIZE_ITEMS, - totalCount + totalCount, }; } diff --git a/packages/workit-bpm-client/src/utils/utils.ts b/packages/workit-bpm-client/src/utils/utils.ts index b05e10d6..846da82f 100644 --- a/packages/workit-bpm-client/src/utils/utils.ts +++ b/packages/workit-bpm-client/src/utils/utils.ts @@ -4,6 +4,13 @@ * See LICENSE file in the project root for full license information. */ +/* eslint @typescript-eslint/no-unsafe-assignment: 0 */ +/* eslint @typescript-eslint/ban-types: 0 */ +/* eslint @typescript-eslint/restrict-template-expressions: 0 */ +/* eslint @typescript-eslint/no-unsafe-call: 0 */ +/* eslint @typescript-eslint/no-unsafe-member-access: 0 */ +/* eslint @typescript-eslint/no-unsafe-return: 0 */ + import { BasicAuthInterceptor } from 'camunda-external-task-client-js'; import { IoC } from 'workit-core'; import { ICamundaConfig, IReadOnlyVariables, IVariables } from 'workit-types'; @@ -12,6 +19,7 @@ import { Variables } from '../variables'; const GLOBAL_TIMEOUT_PULL = 60000; const CONSTANTS_INTEGER_VALUE = 2 ** 31; + /** * Checks if parameter is undefined or null */ @@ -74,12 +82,12 @@ const typeMatchers = { */ json(a: unknown) { return typeof a === 'object'; - } + }, }; export class Utils { public static assign(target: IVariables, object: any): IVariables { - Object.entries(object).forEach(keyVal => target.set(keyVal[0], keyVal[1])); + Object.entries(object).forEach((keyVal) => target.set(keyVal[0], keyVal[1])); return target; } @@ -106,12 +114,12 @@ export class Utils { interceptors: Utils.defaultInterceptors(), use: Utils.getLogger(), topicName: 'topic_demo', - ...config + ...config, }; } public static serializeVariable({ - typedValue + typedValue, }: { typedValue: { value?: any; type: string; valueInfo?: unknown; [custom: string]: any }; }) { diff --git a/packages/workit-bpm-client/tests/functionals/__mocks__/message.ts b/packages/workit-bpm-client/tests/functionals/__mocks__/message.ts index 1c9745e5..72a91c3b 100644 --- a/packages/workit-bpm-client/tests/functionals/__mocks__/message.ts +++ b/packages/workit-bpm-client/tests/functionals/__mocks__/message.ts @@ -12,5 +12,5 @@ export const message = { }, get properties(): any { return this._properties; - } + }, }; diff --git a/packages/workit-bpm-client/tests/functionals/camunda.spec.ts b/packages/workit-bpm-client/tests/functionals/camunda.spec.ts index 9870485e..4ee44ea4 100644 --- a/packages/workit-bpm-client/tests/functionals/camunda.spec.ts +++ b/packages/workit-bpm-client/tests/functionals/camunda.spec.ts @@ -21,7 +21,7 @@ let failureHandler: FailureStrategySimple; let client: CamundaBpmClient; let processHandler: SCProcessHandler; -describe('Camunda Worker', function() { +describe('Camunda Worker', function () { beforeEach(() => { const basicOauth = { username: 'admin', password: 'admin123' }; config = { @@ -32,12 +32,12 @@ describe('Camunda Worker', function() { bpmnKey: 'BPMN_DEMO', autoPoll: false, - interceptors: [new BasicAuthInterceptor(basicOauth)] + interceptors: [new BasicAuthInterceptor(basicOauth)], }; const handlerConfig = { enableTracing: false, - interceptors: [] + interceptors: [], }; // init @@ -57,23 +57,23 @@ describe('Camunda Worker', function() { nock.cleanAll(); }); - it('should call the url passed in the ctor', done => { + it('should call the url passed in the ctor', (done) => { const scoped = nock('http://localhost:8080', { encodedQueryParams: true } as any) .post('/engine-rest/external-task/fetchAndLock') .reply(200, [] as any); run(worker, scoped, done); }); - it('should have Basic Auth', done => { + it('should have Basic Auth', (done) => { const scoped = nock('http://localhost:8080', { encodedQueryParams: true } as any) .post('/engine-rest/external-task/fetchAndLock') - .reply(function() { + .reply(function () { expect(this.req.headers.authorization).toStrictEqual('Basic YWRtaW46YWRtaW4xMjM='); }); run(worker, scoped, done); }); - it('should get the task and send failure to Camunda since no task is bound', done => { + it('should get the task and send failure to Camunda since no task is bound', (done) => { const scoped = nock('http://localhost:8080') .post('/engine-rest/external-task/fetchAndLock') .reply(200, () => { @@ -85,7 +85,7 @@ describe('Camunda Worker', function() { run(worker, scoped, done, 500); }); - it('should get the task and send success to Camunda since task is bound', done => { + it('should get the task and send success to Camunda since task is bound', (done) => { const fakeTask = new FakeTask(); fakeTask.execute = jest.fn().mockResolvedValueOnce({}); IoC.unbind(taskName); @@ -107,7 +107,7 @@ describe('Camunda Worker', function() { done(); }, 500); }); - it('should execute interceptors', done => { + it('should execute interceptors', (done) => { const fakeTask = new FakeTask(); const executeTaskMock: jest.Mock = (fakeTask.execute = jest.fn().mockResolvedValueOnce({})); IoC.unbind(taskName); @@ -138,8 +138,8 @@ describe('Camunda Worker', function() { retries: 1, lockExpirationTime: new Date(), topicName: 'topic_demo', - workerId: 'demo' - } + workerId: 'demo', + }, }); }, (message: IMessage): Promise => { @@ -158,13 +158,13 @@ describe('Camunda Worker', function() { retries: 1, lockExpirationTime: new Date(), topicName: 'topic_demo', - workerId: 'demo' - } + workerId: 'demo', + }, }); - } + }, ], autoPoll: false, - enableTracing: false + enableTracing: false, }; const newProcessHandler = new SCProcessHandler(successHandler, failureHandler, NOOP_TRACER, configWithInterceptors); worker = new Worker(client, newProcessHandler); @@ -195,7 +195,7 @@ describe('Camunda Worker', function() { await expect(worker.stop()).resolves.toBeUndefined(); worker.run(); setTimeout( - async _work => { + async (_work) => { await expect(_work.stop()).resolves.toBeUndefined(); }, 700, diff --git a/packages/workit-bpm-client/tests/functionals/camundaManager.spec.ts b/packages/workit-bpm-client/tests/functionals/camundaManager.spec.ts index b6dcc28d..71da0ec1 100644 --- a/packages/workit-bpm-client/tests/functionals/camundaManager.spec.ts +++ b/packages/workit-bpm-client/tests/functionals/camundaManager.spec.ts @@ -11,14 +11,14 @@ import { CamundaBpmClient } from '../../src/camundaBpmClient'; let manager: CamundaBpmClient; -describe('Client Manager (Camunda BPM)', function() { +describe('Client Manager (Camunda BPM)', function () { beforeAll(() => { const config = { maxTasks: 1, workerId: 'demo', baseUrl: `http://localhost:8080/engine-rest`, topicName: 'topic_demo', - autoPoll: false + autoPoll: false, }; const clientLib: ICamundaClient = new CamundaExternalClient(config) as any; @@ -42,16 +42,14 @@ describe('Client Manager (Camunda BPM)', function() { }); it('Publish message', async () => { - const scope = nock('http://localhost:8080') - .post('/engine-rest/message') - .reply(200); + const scope = nock('http://localhost:8080').post('/engine-rest/message').reply(200); const result = await manager.publishMessage({ correlation: undefined, name: '__MESSAGE_START_EVENT__', variables: { amount: 1000 }, timeToLive: undefined, - messageId: undefined + messageId: undefined, }); expect(result).toBeUndefined(); @@ -67,8 +65,8 @@ describe('Client Manager (Camunda BPM)', function() { bpmnProcessId: 'message-event', variables: { amount: 1000, - hello: 'world' - } + hello: 'world', + }, }); expect(result).toMatchObject(require('./__mocks__/createInstanceResult.json')); @@ -146,7 +144,7 @@ describe('Client Manager (Camunda BPM)', function() { .reply(200, require('./__mocks__/getWorkflowResponse.1.camunda.json')); const result = await manager.getWorkflow({ - bpmnProcessId + bpmnProcessId, }); expect(result).toMatchObject(require('./__mocks__/getWorkflowResult.json')); @@ -162,7 +160,7 @@ describe('Client Manager (Camunda BPM)', function() { .reply(200, require('./__mocks__/getWorkflowResponse.1.camunda.json')); const result = await manager.getWorkflow({ - workflowKey + workflowKey, }); expect(result).toMatchObject(require('./__mocks__/getWorkflowResult.json')); @@ -177,8 +175,8 @@ describe('Client Manager (Camunda BPM)', function() { const result = await manager.updateVariables({ processInstanceId, variables: { - amount: 5 - } + amount: 5, + }, }); expect(result).toBeUndefined(); @@ -187,13 +185,11 @@ describe('Client Manager (Camunda BPM)', function() { it('Update retries', async () => { const jobKey = '76c93b00-5410-11e9-8953-0242ac110002'; - const scope = nock('http://localhost:8080') - .put(`/engine-rest/external-task/${jobKey}/retries`) - .reply(204); + const scope = nock('http://localhost:8080').put(`/engine-rest/external-task/${jobKey}/retries`).reply(204); const result = await manager.updateJobRetries({ jobKey, - retries: 0 + retries: 0, }); expect(result).toBeUndefined(); diff --git a/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts b/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts index a39d767f..b79c1ccd 100644 --- a/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts +++ b/packages/workit-bpm-client/tests/functionals/camundaMessage.spec.ts @@ -24,8 +24,8 @@ describe('camundaMessage', () => { retries: 1, lockExpirationTime: new Date(1562269537659), topicName: 'topic_demo', - workerId: 'demo' - } + workerId: 'demo', + }, }; const camundaObject = CamundaMessage.unwrap(message); expect(camundaObject).toMatchSnapshot(); @@ -36,8 +36,8 @@ describe('camundaMessage', () => { task: { processInstanceId: '38963', processDefinitionId: 'xxxxx', variables: new Variables() } as any, taskService: { handleFailure: jest.fn(), - complete: jest.fn() - } + complete: jest.fn(), + }, }; const [, service] = CamundaMessage.wrap(camundaPayload); service.nack({ name: 'error', message: 'Oopps', retries: 0, retryTimeout: 15_000 }); diff --git a/packages/workit-bpm-client/tests/units/camundaClient.spec.ts b/packages/workit-bpm-client/tests/units/camundaClient.spec.ts index b19abc83..7c0343be 100644 --- a/packages/workit-bpm-client/tests/units/camundaClient.spec.ts +++ b/packages/workit-bpm-client/tests/units/camundaClient.spec.ts @@ -21,7 +21,7 @@ describe('Camunda Client', () => { baseUrl: `http://localhost:8080/engine-rest`, topicName: 'topic_demo', bpmnKey: 'BPMN_DEMO', - autoPoll: false + autoPoll: false, }; IoC.unbind(SERVICE_IDENTIFIER.logger); diff --git a/packages/workit-bpm-client/tests/units/camundaMessage.spec.ts b/packages/workit-bpm-client/tests/units/camundaMessage.spec.ts index 11409013..48c11b15 100644 --- a/packages/workit-bpm-client/tests/units/camundaMessage.spec.ts +++ b/packages/workit-bpm-client/tests/units/camundaMessage.spec.ts @@ -12,7 +12,7 @@ describe('Camunda Message', () => { const cDate = new Date(); const message = { body: { a: 1, b: true, c: cDate, d: { d1: new Date() }, e: [] }, - properties: { customHeaders: {} } as any + properties: { customHeaders: {} } as any, }; const variables = CamundaMessage.unwrap(message); const data: any = variables.getAll(); diff --git a/packages/workit-bpm-client/tests/units/utils.spec.ts b/packages/workit-bpm-client/tests/units/utils.spec.ts index 7271b940..314c939a 100644 --- a/packages/workit-bpm-client/tests/units/utils.spec.ts +++ b/packages/workit-bpm-client/tests/units/utils.spec.ts @@ -22,11 +22,11 @@ describe('utils', () => { const typedValue = { value: parsedValue, type: 'json', - valueInfo: {} + valueInfo: {}, }; const expectedTypedValue = { ...typedValue, - value: JSON.stringify(parsedValue) + value: JSON.stringify(parsedValue), }; // then @@ -39,7 +39,7 @@ describe('utils', () => { const typedValue = { value, type: 'json', - valueInfo: {} + valueInfo: {}, }; // then @@ -54,7 +54,7 @@ describe('utils', () => { const typedValue = { value: dateObj, type: 'Date', - valueInfo: {} + valueInfo: {}, }; // then @@ -76,11 +76,11 @@ describe('utils', () => { const typedValue = { value: parsedValue, type: 'json', - valueInfo: {} + valueInfo: {}, }; const expectedTypedValue = { ...typedValue, - value: JSON.stringify(parsedValue) + value: JSON.stringify(parsedValue), }; // then @@ -93,7 +93,7 @@ describe('utils', () => { const typedValue = { value, type: 'string', // notice that we could detect that it's json but is it expected ? - valueInfo: {} + valueInfo: {}, }; // then @@ -108,7 +108,7 @@ describe('utils', () => { const typedValue = { value: formattedDate, type: 'date', - valueInfo: {} + valueInfo: {}, }; // then diff --git a/packages/workit-camunda/package.json b/packages/workit-camunda/package.json index e1732faa..718df9d9 100644 --- a/packages/workit-camunda/package.json +++ b/packages/workit-camunda/package.json @@ -25,26 +25,26 @@ "@types/events": "~3.0.0", "@types/jest": "^25.1.4", "@types/nock": "^10.0.3", - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.23.0", - "@typescript-eslint/parser": "^2.23.0", - "axios": "^0.19.2", + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", + "axios": "^0.21.0", "chai": "^4.2.0", "codecov": "^3.6.5", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.0.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", "husky": "^4.2.4", "jest": "^25.1.0", "nock": "^10.0.6", - "prettier": "^1.19.1", - "source-map-support": "^0.5.16", + "prettier": "^2.1.2", + "source-map-support": "^0.5.19", "ts-jest": "^26.0.0", "typedoc": "^0.16.11", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "engines": { "node": ">=8.11.4" @@ -97,4 +97,4 @@ "access": "public" }, "gitHead": "a122cb022d456027da28874b789616ebd0cb2284" -} +} \ No newline at end of file diff --git a/packages/workit-camunda/src/camunda-n-mq/client.ts b/packages/workit-camunda/src/camunda-n-mq/client.ts index 2774f4db..42108119 100644 --- a/packages/workit-camunda/src/camunda-n-mq/client.ts +++ b/packages/workit-camunda/src/camunda-n-mq/client.ts @@ -8,10 +8,7 @@ import { inject, injectable } from 'inversify'; import 'reflect-metadata'; import { IClient, IMessage } from 'workit-types'; import { SERVICE_IDENTIFIER } from '../config/constants/identifiers'; -// eslint-disable-next-line import/order -import debug = require('debug'); -const log = debug('workit:clientBase'); @injectable() export class Client { protected _onMessageReceived!: (message: IMessage, service: unknown) => Promise; @@ -30,7 +27,7 @@ export class Client { } public async unsubscribe(): Promise { - await this._execute(x => x.unsubscribe()); + await this._execute((x) => x.unsubscribe()); } private async _execute( @@ -40,7 +37,6 @@ export class Client { try { return await action(this._client); } catch (ex) { - log(ex.message); if (!onException) { return Promise.resolve(); } @@ -50,7 +46,7 @@ export class Client { private async _startSubscriber(): Promise { if (this._client != null) { - await this._execute(x => x.subscribe(this._onMessageReceived)); + await this._execute((x) => x.subscribe(this._onMessageReceived)); } } } diff --git a/packages/workit-camunda/src/camunda-n-mq/clientManager.ts b/packages/workit-camunda/src/camunda-n-mq/clientManager.ts index 1f500243..5f833e77 100644 --- a/packages/workit-camunda/src/camunda-n-mq/clientManager.ts +++ b/packages/workit-camunda/src/camunda-n-mq/clientManager.ts @@ -19,7 +19,7 @@ import { IWorkflowClient, IWorkflowDefinition, IWorkflowDefinitionRequest, - IWorkflowOptions + IWorkflowOptions, } from 'workit-types'; import debug = require('debug'); diff --git a/packages/workit-camunda/src/config/constants/identifiers.ts b/packages/workit-camunda/src/config/constants/identifiers.ts index 8e7a5666..28a0b21c 100644 --- a/packages/workit-camunda/src/config/constants/identifiers.ts +++ b/packages/workit-camunda/src/config/constants/identifiers.ts @@ -26,5 +26,5 @@ export const SERVICE_IDENTIFIER = { /** * Bind your own config for Camunda system */ - camunda_config: Symbol('camunda_config') + camunda_config: Symbol('camunda_config'), }; diff --git a/packages/workit-camunda/src/config/constants/index.ts b/packages/workit-camunda/src/config/constants/index.ts index c1cb4e2d..b061e540 100644 --- a/packages/workit-camunda/src/config/constants/index.ts +++ b/packages/workit-camunda/src/config/constants/index.ts @@ -20,7 +20,7 @@ export class Constants { // ========================================== // "production" seems to be the standard Node label, not "prod". // ========================================== - prod: 'production' + prod: 'production', }; } diff --git a/packages/workit-camunda/src/config/constants/tag.ts b/packages/workit-camunda/src/config/constants/tag.ts index 71cc522f..b5913622 100644 --- a/packages/workit-camunda/src/config/constants/tag.ts +++ b/packages/workit-camunda/src/config/constants/tag.ts @@ -6,5 +6,5 @@ export const TAG = { zeebe: Symbol('zeebe'), - camundaBpm: Symbol('camundaBpm') + camundaBpm: Symbol('camundaBpm'), }; diff --git a/packages/workit-camunda/src/config/container.ts b/packages/workit-camunda/src/config/container.ts index 57ae596f..734520a6 100644 --- a/packages/workit-camunda/src/config/container.ts +++ b/packages/workit-camunda/src/config/container.ts @@ -9,13 +9,7 @@ import { kernel } from 'workit-core'; import { constants } from './constants'; import { SERVICE_IDENTIFIER } from './constants/identifiers'; -kernel - .bind(SERVICE_IDENTIFIER.logger) - .toConstantValue(camundaLogger) - .whenTargetIsDefault(); -Object.values(constants.envs).forEach(env => { - kernel - .bind(SERVICE_IDENTIFIER.logger) - .toConstantValue(logger) - .whenTargetNamed(env); +kernel.bind(SERVICE_IDENTIFIER.logger).toConstantValue(camundaLogger).whenTargetIsDefault(); +Object.values(constants.envs).forEach((env) => { + kernel.bind(SERVICE_IDENTIFIER.logger).toConstantValue(logger).whenTargetNamed(env); }); diff --git a/packages/workit-camunda/src/config/ioc.ts b/packages/workit-camunda/src/config/ioc.ts index a1d0bd61..abb92faa 100644 --- a/packages/workit-camunda/src/config/ioc.ts +++ b/packages/workit-camunda/src/config/ioc.ts @@ -22,7 +22,7 @@ IoC.bindTo( [ SERVICE_IDENTIFIER.zeebe_external_config, SERVICE_IDENTIFIER.camunda_external_client, - SERVICE_IDENTIFIER.zeebe_elastic_exporter_config + SERVICE_IDENTIFIER.zeebe_elastic_exporter_config, ], TAG.zeebe, false diff --git a/packages/workit-camunda/tests/functionals/__mocks__/message.ts b/packages/workit-camunda/tests/functionals/__mocks__/message.ts index 1c9745e5..72a91c3b 100644 --- a/packages/workit-camunda/tests/functionals/__mocks__/message.ts +++ b/packages/workit-camunda/tests/functionals/__mocks__/message.ts @@ -12,5 +12,5 @@ export const message = { }, get properties(): any { return this._properties; - } + }, }; diff --git a/packages/workit-camunda/tests/functionals/camunda.spec.ts b/packages/workit-camunda/tests/functionals/camunda.spec.ts index 07f3323d..50435305 100644 --- a/packages/workit-camunda/tests/functionals/camunda.spec.ts +++ b/packages/workit-camunda/tests/functionals/camunda.spec.ts @@ -23,7 +23,7 @@ let failureHandler: FailureStrategySimple; let client: Client; let processHandler: SCProcessHandler; -describe('Camunda Worker', function() { +describe('Camunda Worker', function () { beforeEach(() => { // init const basicOauth = { username: 'admin', password: 'admin123' }; @@ -37,7 +37,7 @@ describe('Camunda Worker', function() { topicName: 'topic_demo', bpmnKey: 'BPMN_DEMO', autoPoll: false, - interceptors: Utils.defaultInterceptors() + interceptors: Utils.defaultInterceptors(), }; const clientLib: ICamundaClient = new CamundaExternalClient(config) as any; @@ -58,23 +58,23 @@ describe('Camunda Worker', function() { nock.cleanAll(); }); - it('should call the url passed in the ctor', done => { + it('should call the url passed in the ctor', (done) => { const scoped = nock('http://localhost:8080', { encodedQueryParams: true } as any) .post('/engine-rest/external-task/fetchAndLock') .reply(200, [] as any); run(worker, scoped, done); }); - it('should have Basic Auth', done => { + it('should have Basic Auth', (done) => { const scoped = nock('http://localhost:8080', { encodedQueryParams: true } as any) .post('/engine-rest/external-task/fetchAndLock') - .reply(function() { + .reply(function () { expect(this.req.headers.authorization).toStrictEqual('Basic YWRtaW46YWRtaW4xMjM='); }); run(worker, scoped, done); }); - it('should get the task and send failure to Camunda since no task is bound', done => { + it('should get the task and send failure to Camunda since no task is bound', (done) => { const scoped = nock('http://localhost:8080') .post('/engine-rest/external-task/fetchAndLock') .reply(200, () => { @@ -86,7 +86,7 @@ describe('Camunda Worker', function() { run(worker, scoped, done, 500); }); - it('should get the task and send success to Camunda since task is bound', done => { + it('should get the task and send success to Camunda since task is bound', (done) => { const fakeTask = new FakeTask(); fakeTask.execute = jest.fn().mockResolvedValueOnce({}); IoC.unbind(taskName); @@ -108,7 +108,7 @@ describe('Camunda Worker', function() { done(); }, 500); }); - it('should execute interceptors', done => { + it('should execute interceptors', (done) => { const fakeTask = new FakeTask(); const executeTaskMock: jest.Mock = (fakeTask.execute = jest.fn().mockResolvedValueOnce({})); IoC.unbind(taskName); @@ -139,8 +139,8 @@ describe('Camunda Worker', function() { retries: 1, lockExpirationTime: new Date(), topicName: 'topic_demo', - workerId: 'demo' - } + workerId: 'demo', + }, }); }, (message: IMessage): Promise => { @@ -159,13 +159,13 @@ describe('Camunda Worker', function() { retries: 1, lockExpirationTime: new Date(), topicName: 'topic_demo', - workerId: 'demo' - } + workerId: 'demo', + }, }); - } + }, ], autoPoll: false, - enableTracing: false + enableTracing: false, }; const newProcessHandler = new SCProcessHandler(successHandler, failureHandler, NOOP_TRACER, configWithInterceptors); worker = new Worker(client, newProcessHandler); @@ -196,7 +196,7 @@ describe('Camunda Worker', function() { await expect(worker.stop()).resolves.toBeUndefined(); worker.run(); setTimeout( - async _work => { + async (_work) => { await expect(_work.stop()).resolves.toBeUndefined(); }, 700, diff --git a/packages/workit-camunda/tests/functionals/camundaManager.spec.ts b/packages/workit-camunda/tests/functionals/camundaManager.spec.ts index 3b6e7e72..44d269a0 100644 --- a/packages/workit-camunda/tests/functionals/camundaManager.spec.ts +++ b/packages/workit-camunda/tests/functionals/camundaManager.spec.ts @@ -12,14 +12,14 @@ import '../../src/config/ioc'; let manager: CamundaManager; -describe('Client Manager (Camunda BPM)', function() { +describe('Client Manager (Camunda BPM)', function () { beforeAll(() => { const config = { maxTasks: 1, workerId: 'demo', baseUrl: `http://localhost:8080/engine-rest`, topicName: 'topic_demo', - autoPoll: false + autoPoll: false, }; const clientLib: ICamundaClient = new CamundaExternalClient(config) as any; @@ -45,16 +45,14 @@ describe('Client Manager (Camunda BPM)', function() { }); it('Publish message', async () => { - const scope = nock('http://localhost:8080') - .post('/engine-rest/message') - .reply(200); + const scope = nock('http://localhost:8080').post('/engine-rest/message').reply(200); const result = await manager.publishMessage({ correlation: undefined, name: '__MESSAGE_START_EVENT__', variables: { amount: 1000 }, timeToLive: undefined, - messageId: undefined + messageId: undefined, }); expect(result).toBeUndefined(); @@ -70,8 +68,8 @@ describe('Client Manager (Camunda BPM)', function() { bpmnProcessId: 'message-event', variables: { amount: 1000, - hello: 'world' - } + hello: 'world', + }, }); expect(result).toMatchObject(require('./__mocks__/createInstanceResult.json')); @@ -149,7 +147,7 @@ describe('Client Manager (Camunda BPM)', function() { .reply(200, require('./__mocks__/getWorkflowResponse.1.camunda.json')); const result = await manager.getWorkflow({ - bpmnProcessId + bpmnProcessId, }); expect(result).toMatchObject(require('./__mocks__/getWorkflowResult.json')); @@ -165,7 +163,7 @@ describe('Client Manager (Camunda BPM)', function() { .reply(200, require('./__mocks__/getWorkflowResponse.1.camunda.json')); const result = await manager.getWorkflow({ - workflowKey + workflowKey, }); expect(result).toMatchObject(require('./__mocks__/getWorkflowResult.json')); @@ -180,8 +178,8 @@ describe('Client Manager (Camunda BPM)', function() { const result = await manager.updateVariables({ processInstanceId, variables: { - amount: 5 - } + amount: 5, + }, }); expect(result).toBeUndefined(); @@ -190,13 +188,11 @@ describe('Client Manager (Camunda BPM)', function() { it('Update retries', async () => { const jobKey = '76c93b00-5410-11e9-8953-0242ac110002'; - const scope = nock('http://localhost:8080') - .put(`/engine-rest/external-task/${jobKey}/retries`) - .reply(204); + const scope = nock('http://localhost:8080').put(`/engine-rest/external-task/${jobKey}/retries`).reply(204); const result = await manager.updateJobRetries({ jobKey, - retries: 0 + retries: 0, }); expect(result).toBeUndefined(); diff --git a/packages/workit-camunda/tests/functionals/zeebe.spec.ts b/packages/workit-camunda/tests/functionals/zeebe.spec.ts index 6804aa72..98d973ee 100644 --- a/packages/workit-camunda/tests/functionals/zeebe.spec.ts +++ b/packages/workit-camunda/tests/functionals/zeebe.spec.ts @@ -21,7 +21,7 @@ const run = (worker: Worker, done: any, delay: number = 500) => { }, delay); }; -describe('Zeebe Worker', function() { +describe('Zeebe Worker', function () { let worker: Worker; let config: ICamundaConfig; @@ -32,11 +32,11 @@ describe('Zeebe Worker', function() { baseUrl: `localhost:26500`, topicName: 'demo-service', bpmnKey: 'test', - autoPoll: false + autoPoll: false, }; }); - it('should instanciate the worker', done => { + it('should instanciate the worker', (done) => { (async () => { const zeebeClient = new ZeebeClient(config); const successHandler = new SuccessStrategySimple(); @@ -56,7 +56,7 @@ describe('Zeebe Worker', function() { .reply(200, require('../data/elasticResponse.workflow')); const zeebeClient = new ZeebeClient(config, undefined, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows(); @@ -70,7 +70,7 @@ describe('Zeebe Worker', function() { .reply(200, require('../data/elasticResponseAgg.workflow')); const zeebeClient = new ZeebeClient(config, undefined, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflow({ bpmnProcessId: 'MESSAGE_EVENT' }); @@ -94,7 +94,7 @@ describe('Zeebe Worker', function() { .reply(200, require('../data/elasticResponse.paginated')); const zeebeClient = new ZeebeClient(config, undefined, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows({ size }); scope.done(); @@ -111,7 +111,7 @@ describe('Zeebe Worker', function() { .reply(200, require('../data/elasticResponse.paginated.skip')); const zeebeClient = new ZeebeClient(config, undefined, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows({ size, from }); scope.done(); @@ -124,13 +124,13 @@ describe('Zeebe Worker', function() { const bpmnProcessId = 'MESSAGE_EVENT'; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', { - query: { bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }] } } + query: { bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }] } }, }) .query({ _source_excludes: 'bpmnXml', size }) .reply(200, require('../data/elasticResponseBpmnProcessId.paginated')); const zeebeClient = new ZeebeClient(config, undefined, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows({ size, bpmnProcessId }); scope.done(); diff --git a/packages/workit-camunda/tests/integrations/zeebe.spec.ts b/packages/workit-camunda/tests/integrations/zeebe.spec.ts index 260cc113..d13c4444 100644 --- a/packages/workit-camunda/tests/integrations/zeebe.spec.ts +++ b/packages/workit-camunda/tests/integrations/zeebe.spec.ts @@ -97,13 +97,13 @@ describe('ZeebeClient', () => { const workflowInstance = await zbc.createWorkflowInstance({ bpmnProcessId: 'hello-world', - variables: {} + variables: {}, }); expect(workflowInstance.bpmnProcessId).toBe('hello-world'); expect(workflowInstance.workflowInstanceKey).toBeTruthy(); }); - it('Can receive a valid workflow instance', async done => { + it('Can receive a valid workflow instance', async (done) => { await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/hello-world.bpmn')); workers.unshift(createWorkerInstance('console-log', done)); try { @@ -113,7 +113,7 @@ describe('ZeebeClient', () => { } }); - it('Can start a workflow with a message', async done => { + it('Can start a workflow with a message', async (done) => { const deploy = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/msg-start.bpmn')); expect(deploy.key).toBeTruthy(); @@ -124,15 +124,15 @@ describe('ZeebeClient', () => { name: 'MSG-START_JOB', timeToLive: 1000, variables: { - testKey: randomId - } + testKey: randomId, + }, }); workers.unshift(createWorkerInstance('console-log-msg', done)); IoC.unbind('ServiceTask_0f6zc7d'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.customHeaders.message.indexOf('Workflow') !== -1).toBe(true); expect(message.body.testKey).toBe(randomId); // Makes sure the worker isn't responding to another message }), @@ -146,14 +146,14 @@ describe('ZeebeClient', () => { } }); - it('Can cancel a workflow', async done => { + it('Can cancel a workflow', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/hello-world.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('hello-world'); const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'hello-world', - variables: {} + variables: {}, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -184,7 +184,7 @@ describe('ZeebeClient', () => { } }); - it('Correctly branches on variables', async done => { + it('Correctly branches on variables', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/conditional-pathway.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('condition-test'); @@ -192,8 +192,8 @@ describe('ZeebeClient', () => { const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'condition-test', variables: { - conditionVariable: true - } + conditionVariable: true, + }, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -203,14 +203,14 @@ describe('ZeebeClient', () => { IoC.unbind('ServiceTask_0cz2k8t'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); }), 'ServiceTask_0cz2k8t' ); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); expect(message.body.conditionVariable).toBe(true); }), @@ -225,7 +225,7 @@ describe('ZeebeClient', () => { } }); - it('Can update workflow variables', async done => { + it('Can update workflow variables', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/conditional-pathway.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('condition-test'); @@ -233,8 +233,8 @@ describe('ZeebeClient', () => { const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'condition-test', variables: { - conditionVariable: true - } + conditionVariable: true, + }, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -243,8 +243,8 @@ describe('ZeebeClient', () => { processInstanceId: wfi, local: false, variables: { - conditionVariable: false - } + conditionVariable: false, + }, }); workers.unshift(createWorkerInstance('wait', () => {})); @@ -252,14 +252,14 @@ describe('ZeebeClient', () => { IoC.unbind('ServiceTask_0cz2k8t'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); }), 'ServiceTask_0cz2k8t' ); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); expect(message.body.conditionVariable).toBe(false); }), @@ -274,7 +274,7 @@ describe('ZeebeClient', () => { } }); - it('Causes 2 retries handled by FailureStrategySimple', async done => { + it('Causes 2 retries handled by FailureStrategySimple', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/conditional-pathway.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('condition-test'); @@ -282,8 +282,8 @@ describe('ZeebeClient', () => { const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'condition-test', variables: { - conditionVariable: true - } + conditionVariable: true, + }, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -292,15 +292,15 @@ describe('ZeebeClient', () => { processInstanceId: wfi, local: false, variables: { - conditionVariable: false - } + conditionVariable: false, + }, }); workers.unshift(createWorkerInstance('wait', done)); IoC.unbind('ServiceTask_0cz2k8t'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); let retries = message.properties.retries || 0; retries++; diff --git a/packages/workit-cli/.eslintrc.js b/packages/workit-cli/.eslintrc.js index 990d2744..2e4461bd 100644 --- a/packages/workit-cli/.eslintrc.js +++ b/packages/workit-cli/.eslintrc.js @@ -14,7 +14,7 @@ module.exports = { "parser": "@typescript-eslint/parser", "parserOptions": { "project": "./tsconfig.json" - }, + }, "rules": { // prettier conflicts "no-underscore-dangle": "off", @@ -24,14 +24,31 @@ module.exports = { "no-await-in-loop": "off", "import/prefer-default-export": "off", "comma-dangle": "off", - "object-curly-newline":"off", + "object-curly-newline": "off", "arrow-parens": "off", "implicit-arrow-linebreak": "off", "function-paren-newline": "off", "prettier/prettier": "error", "@typescript-eslint/no-misused-promises": "off", - "@typescript-eslint/interface-name-prefix": ["error", { "prefixWithI": "always" }], + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "interface", + "format": ["PascalCase"], + "custom": { + "regex": "^I[A-Z]", + "match": true + } + } + ], + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/comma-dangle": "off", "import/no-dynamic-require": "off", "global-require": "off" } diff --git a/packages/workit-cli/package.json b/packages/workit-cli/package.json index d027f024..2b0b7bd9 100644 --- a/packages/workit-cli/package.json +++ b/packages/workit-cli/package.json @@ -36,22 +36,22 @@ "@commitlint/config-conventional": "^8.3.4", "@types/he": "^1.1.1", "@types/jest": "^25.1.4", - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "codecov": "^3.6.5", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", "husky": "^4.2.4", "jest": "^25.1.0", - "prettier": "^1.19.1", - "source-map-support": "^0.5.16", + "prettier": "^2.1.2", + "source-map-support": "^0.5.19", "ts-jest": "^26.0.0", "typedoc": "^0.17.1", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "husky": { "hooks": { @@ -78,4 +78,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "gitHead": "4d109b9f2978bac5ec5338a39adc49ccf9bf2651" -} +} \ No newline at end of file diff --git a/packages/workit-cli/src/command/create/task/index.ts b/packages/workit-cli/src/command/create/task/index.ts index 9dab1551..5b004ea3 100644 --- a/packages/workit-cli/src/command/create/task/index.ts +++ b/packages/workit-cli/src/command/create/task/index.ts @@ -71,11 +71,11 @@ function processHandler(className, contentFile, isBpmn = false): Promise { if (imports.length === 0) { file.addImportDeclaration({ moduleSpecifier: `../tasks/${classNameSanitized}`, - namedImports: [{ name: classNameWithMaj }] + namedImports: [{ name: classNameWithMaj }], }); file.addImportDeclaration({ moduleSpecifier: `workit-core`, - namedImports: [{ name: 'IoC' }] + namedImports: [{ name: 'IoC' }], }); } else { const firstImport = imports[0]; @@ -85,7 +85,7 @@ function processHandler(className, contentFile, isBpmn = false): Promise { } if (statements.length === 0) { - file.addStatements(writer => + file.addStatements((writer) => writer.newLine().writeLine(`IoC.bindTo(${classNameWithMaj}, '${isBpmn ? className : ''}');`) ); } else { @@ -116,8 +116,8 @@ function getExternalTasks(pathToFile: string): Set { format: false, indentBy: ' ', supressEmptyNode: false, - tagValueProcessor: a => he.encode(a, { useNamedReferences: true }), // default is a=>a - attrValueProcessor: a => he.encode(a, { isAttributeValue: true, useNamedReferences: true }) // default is a=>a + tagValueProcessor: (a) => he.encode(a, { useNamedReferences: true }), // default is a=>a + attrValueProcessor: (a) => he.encode(a, { isAttributeValue: true, useNamedReferences: true }), // default is a=>a }; const xmlData = fs.readFileSync(pathToFile).toString(); @@ -190,7 +190,7 @@ export const task = async (args, options, logger): Promise => { complete: '=', incomplete: ' ', width: 30, - total: tasks.size + total: tasks.size, }); // eslint-disable-next-line no-restricted-syntax diff --git a/packages/workit-cli/src/command/init/index.ts b/packages/workit-cli/src/command/init/index.ts index a99e3bb2..5abc02f6 100644 --- a/packages/workit-cli/src/command/init/index.ts +++ b/packages/workit-cli/src/command/init/index.ts @@ -71,7 +71,7 @@ export const init = (args, options, logger): void => { shell.ls('-Rl', '.').forEach((entry: any) => { if (entry.isFile()) { // Replace '[VARIABLE]` with the corresponding variable value from the prompt - variables.forEach(variable => { + variables.forEach((variable) => { shell.sed('-i', `\\[${variable.name.toUpperCase()}\\]`, result[variable.name], entry.name); }); diff --git a/packages/workit-cli/src/command/init/templates/node/default/src/package.json b/packages/workit-cli/src/command/init/templates/node/default/src/package.json index 8901484c..6c4fe30b 100644 --- a/packages/workit-cli/src/command/init/templates/node/default/src/package.json +++ b/packages/workit-cli/src/command/init/templates/node/default/src/package.json @@ -25,17 +25,17 @@ "check-conflicts": "eslint --print-config tests/utils/func-test.ts | eslint-config-prettier-check" }, "devDependencies": { - "@types/node": "^14.0.0", - "prettier": "^1.19.1", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.2.0", - "eslint-plugin-import": "^2.20.1", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-prettier": "^3.1.2", - "@typescript-eslint/eslint-plugin": "^2.24.0", - "@typescript-eslint/parser": "^2.24.0", + "@types/node": "^14.14.7", + "prettier": "^2.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-plugin-import": "^2.22.1", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-prettier": "^3.1.4", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "husky": "^4.2.4", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "dependencies": { "workit-camunda": "^4.1.0", @@ -43,4 +43,4 @@ "workit-types": "^4.1.0", "config": "^3.3.0" } -} +} \ No newline at end of file diff --git a/packages/workit-cli/src/command/init/templates/node/default/src/src/config/index.ts b/packages/workit-cli/src/command/init/templates/node/default/src/src/config/index.ts index a0cccc80..5971b29d 100644 --- a/packages/workit-cli/src/command/init/templates/node/default/src/src/config/index.ts +++ b/packages/workit-cli/src/command/init/templates/node/default/src/src/config/index.ts @@ -5,7 +5,7 @@ import { ICamundaConfig } from '../specs/camundaConfig'; let message = `\n------------------------------------\n`; message += `Configuration files loaded:\n`; const sources = config.util.getConfigSources(); -sources.forEach(source => { +sources.forEach((source) => { message += `- ${source.name}\n`; }); message += `------------------------------------\n`; @@ -33,7 +33,7 @@ export class Configs { workerId: config.get('camunda.workerId'), baseUrl: config.get('camunda.baseUrl'), maxTasks: config.get('camunda.maxTasks'), - topicName: config.get('camunda.topicName') + topicName: config.get('camunda.topicName'), }; } @@ -55,7 +55,7 @@ export class Configs { type: this._environment, isDev: this._environment === ENV.DEV, isAcc: this._environment === ENV.ACCEPTATION, - isProd: this._environment === ENV.PROD + isProd: this._environment === ENV.PROD, }; } diff --git a/packages/workit-cli/src/command/init/templates/node/default/src/src/config/ioc.ts b/packages/workit-cli/src/command/init/templates/node/default/src/src/config/ioc.ts index d986a0e1..96fdb17f 100644 --- a/packages/workit-cli/src/command/init/templates/node/default/src/src/config/ioc.ts +++ b/packages/workit-cli/src/command/init/templates/node/default/src/src/config/ioc.ts @@ -4,7 +4,7 @@ import { configs } from '.'; import { HelloWorldTask } from '../tasks/helloWorldTask'; enum LOCAL_IDENTIFIER { - sampleActivity = 'sample_activity' + sampleActivity = 'sample_activity', } IoC.bindTo(HelloWorldTask, LOCAL_IDENTIFIER.sampleActivity); diff --git a/packages/workit-cli/src/command/init/templates/node/default/src/src/enums/environment.ts b/packages/workit-cli/src/command/init/templates/node/default/src/src/enums/environment.ts index 8c12bc7e..8c2392ba 100644 --- a/packages/workit-cli/src/command/init/templates/node/default/src/src/enums/environment.ts +++ b/packages/workit-cli/src/command/init/templates/node/default/src/src/enums/environment.ts @@ -1,5 +1,5 @@ export enum ENV { ACCEPTATION = 'acceptation', DEV = 'development', - PROD = 'production' + PROD = 'production', } diff --git a/packages/workit-cli/src/command/init/templates/node/default/src/src/worker.ts b/packages/workit-cli/src/command/init/templates/node/default/src/src/worker.ts index f5605996..4d660872 100644 --- a/packages/workit-cli/src/command/init/templates/node/default/src/src/worker.ts +++ b/packages/workit-cli/src/command/init/templates/node/default/src/src/worker.ts @@ -4,7 +4,7 @@ import './config/ioc'; const worker = IoC.get(CORE_IDENTIFIER.worker, TAG.camundaBpm); worker.start(); -worker.run().catch(err => { +worker.run().catch((err) => { console.error('DO SOMETHING', err); }); diff --git a/packages/workit-cli/src/configs/constants/symbols.ts b/packages/workit-cli/src/configs/constants/symbols.ts index ee328f58..ead4cc47 100644 --- a/packages/workit-cli/src/configs/constants/symbols.ts +++ b/packages/workit-cli/src/configs/constants/symbols.ts @@ -9,7 +9,7 @@ export const symbols = { ok: '✓', err: '✖', - dot: '․' + dot: '․', }; // With node.js on Windows: use symbols available in terminal default fonts diff --git a/packages/workit-core/package.json b/packages/workit-core/package.json index 730e73d8..630f7f52 100644 --- a/packages/workit-core/package.json +++ b/packages/workit-core/package.json @@ -14,7 +14,7 @@ "fast-safe-stringify": "~2.0.7", "inversify": "~5.0.1", "reflect-metadata": "~0.1.13", - "uuid": "^3.4.0", + "uuid": "^8.3.1", "workit-types": "^4.2.2" }, "devDependencies": { @@ -23,21 +23,21 @@ "@types/debug": "~4.1.5", "@types/events": "~3.0.0", "@types/jest": "^25.1.4", - "@types/node": "^14.0.0", - "@types/uuid": "^3.4.7", - "@typescript-eslint/eslint-plugin": "^2.23.0", - "@typescript-eslint/parser": "^2.23.0", + "@types/node": "^14.14.7", + "@types/uuid": "^8.3.0", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "codecov": "^3.6.5", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.0.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", "husky": "^4.2.4", "jest": "^25.1.0", - "prettier": "^1.19.1", - "source-map-support": "^0.5.16", + "prettier": "^2.1.2", + "source-map-support": "^0.5.19", "ts-jest": "^26.0.0", "typedoc": "^0.16.9", "typescript": "^3.7.5" @@ -91,4 +91,4 @@ "access": "public" }, "gitHead": "a122cb022d456027da28874b789616ebd0cb2284" -} +} \ No newline at end of file diff --git a/packages/workit-core/src/IoC.ts b/packages/workit-core/src/IoC.ts index 8746ec34..5c262fe2 100644 --- a/packages/workit-core/src/IoC.ts +++ b/packages/workit-core/src/IoC.ts @@ -86,15 +86,12 @@ export class IOC { public bindToAsDefault(ctor: any, serviceIdentifier: string | symbol, dependencies?: (symbol | string)[]): void { IOC._inject(ctor, dependencies); - this._container - .bind(serviceIdentifier) - .to(ctor) - .inSingletonScope() - .whenTargetIsDefault(); + this._container.bind(serviceIdentifier).to(ctor).inSingletonScope().whenTargetIsDefault(); } // todo: merge with bindTo public bindToObject(obj: any, serviceIdentifier: symbol | string, named?: string): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const newObj = IOC._overrideConfig(obj, serviceIdentifier); const service = this._container.bind(serviceIdentifier).toConstantValue(newObj); if (named) { diff --git a/packages/workit-core/src/common/noopLogger.ts b/packages/workit-core/src/common/noopLogger.ts new file mode 100644 index 00000000..71dc6062 --- /dev/null +++ b/packages/workit-core/src/common/noopLogger.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Ville de Montreal. All rights reserved. + * Licensed under the MIT license. + * See LICENSE file in the project root for full license information. + */ +import { ILogger } from 'workit-types'; + +/** No-op implementation of ILogger */ +export class NoopLogger implements ILogger { + // By default does nothing + public debug(message: string, ...args: unknown[]) {} + + // By default does nothing + public error(message: string, ...args: unknown[]) {} + + // By default does nothing + public warn(message: string, ...args: unknown[]) {} + + // By default does nothing + public info(message: string, ...args: unknown[]) {} +} + +export const NOOP_LOGGER = new NoopLogger(); diff --git a/packages/workit-core/src/config/constants/identifiers.ts b/packages/workit-core/src/config/constants/identifiers.ts index 5fb56fa5..96d29c2e 100644 --- a/packages/workit-core/src/config/constants/identifiers.ts +++ b/packages/workit-core/src/config/constants/identifiers.ts @@ -40,5 +40,5 @@ export const SERVICE_IDENTIFIER = { * Pass your custom propagator in order to get traceId from Camunda platform. * "TracerPropagator" must be bound in the IoC defaul is a NoopTracerPropagator */ - tracer_propagator: Symbol('tracer_propagator') + tracer_propagator: Symbol('tracer_propagator'), }; diff --git a/packages/workit-core/src/config/constants/index.ts b/packages/workit-core/src/config/constants/index.ts index a4b874ff..cf42c380 100644 --- a/packages/workit-core/src/config/constants/index.ts +++ b/packages/workit-core/src/config/constants/index.ts @@ -20,7 +20,7 @@ export class Constants { // ========================================== // "production" seems to be the standard Node label, not "prod". // ========================================== - prod: 'production' + prod: 'production', }; } diff --git a/packages/workit-core/src/interceptors.ts b/packages/workit-core/src/interceptors.ts index e088777d..83c005c5 100644 --- a/packages/workit-core/src/interceptors.ts +++ b/packages/workit-core/src/interceptors.ts @@ -49,6 +49,7 @@ export class Interceptors { msg = await interceptor(msg); } Interceptors._validateMessage(msg); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (!(msg as any).__proxy__ || ProxyFactory.cacheChanges.has(msg)) { ProxyFactory.cacheChanges.set(msg, true); return ProxyFactory.create(msg); diff --git a/packages/workit-core/src/processHandler/simpleCamundaProcessHandler.ts b/packages/workit-core/src/processHandler/simpleCamundaProcessHandler.ts index 72939abe..464d4ca8 100644 --- a/packages/workit-core/src/processHandler/simpleCamundaProcessHandler.ts +++ b/packages/workit-core/src/processHandler/simpleCamundaProcessHandler.ts @@ -17,7 +17,7 @@ import { ISuccessStrategy, ITask, ITracerPropagator, - IWorkflowProps + IWorkflowProps, } from 'workit-types'; import { SERVICE_IDENTIFIER } from '../config/constants/identifiers'; import { Interceptors } from '../interceptors'; @@ -28,7 +28,8 @@ import debug = require('debug'); const log = debug('workit:processHandler'); @injectable() -export class SCProcessHandler extends EventEmitter +export class SCProcessHandler + extends EventEmitter implements IProcessHandler { protected readonly _config: Partial; @@ -76,8 +77,8 @@ export class SCProcessHandler>(properties.activityId, workflowCriteria); @@ -111,7 +112,8 @@ export class SCProcessHandler(object: T): T { - return new ProxyObserver(object, function(path, value, previousValue) { + return new ProxyObserver(object, function (path, value, previousValue) { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions log(`message change. Previous value ${previousValue}, new value ${value} on ${path}`); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access ProxyFactory.cacheChanges.set(this._proxy, true); }) as T; } diff --git a/packages/workit-core/src/proxyObserver.ts b/packages/workit-core/src/proxyObserver.ts index 8ea0f74b..e8e81548 100644 --- a/packages/workit-core/src/proxyObserver.ts +++ b/packages/workit-core/src/proxyObserver.ts @@ -8,6 +8,12 @@ import { isPrimitive } from './utils/isPrimitive'; import { concatPath } from './utils/concat'; const proxyTarget = Symbol('ProxyTarget'); +/* eslint @typescript-eslint/restrict-template-expressions: 0 */ +/* eslint @typescript-eslint/no-unsafe-assignment: 0 */ +/* eslint @typescript-eslint/no-unsafe-call: 0 */ +/* eslint @typescript-eslint/no-unsafe-member-access: 0 */ +/* eslint @typescript-eslint/no-unsafe-return: 0 */ +/* eslint @typescript-eslint/ban-types: 0 */ /** * It's for observing an object. In this package, @@ -111,7 +117,7 @@ export class ProxyObserver { } return Reflect.apply(target, thisArg, argumentsList); - } + }, }; constructor(object: any, onChangeFunc: (proxy: any, property: any, value: any, previous: any) => void) { @@ -121,7 +127,7 @@ export class ProxyObserver { value: true, enumerable: false, configurable: false, - writable: false + writable: false, }); this._proxy = new Proxy(object, this._handler); return this._proxy; diff --git a/packages/workit-core/src/strategies/FailureStrategySimple.ts b/packages/workit-core/src/strategies/FailureStrategySimple.ts index 6931807f..4cf4d904 100644 --- a/packages/workit-core/src/strategies/FailureStrategySimple.ts +++ b/packages/workit-core/src/strategies/FailureStrategySimple.ts @@ -4,20 +4,29 @@ * See LICENSE file in the project root for full license information. */ -import { injectable } from 'inversify'; +import { injectable, optional, inject } from 'inversify'; import 'reflect-metadata'; -import { ICamundaService, IFailureStrategy, IMessage, IWorkflowProps } from 'workit-types'; +import { ICamundaService, IFailureStrategy, IMessage, IWorkflowProps, ILogger } from 'workit-types'; +import { SERVICE_IDENTIFIER } from '../config/constants/identifiers'; +import { NOOP_LOGGER } from '../common/noopLogger'; // eslint-disable-next-line const stringify = require('fast-safe-stringify'); @injectable() export class FailureStrategySimple implements IFailureStrategy { - constructor() { - console.log('warning: You should not use this failure strategy class in production'); + private readonly _logger: ILogger; + + constructor(@inject(SERVICE_IDENTIFIER.logger) @optional() logger: ILogger = NOOP_LOGGER) { + this._logger = logger; + this._logger.debug('warning: You should not use this failure strategy class in production'); } - public async handle(error: any, message: IMessage, service: ICamundaService): Promise { + public async handle( + error: T, + message: IMessage, + service: ICamundaService + ): Promise { const { properties } = message; let retries = properties.retries as number; @@ -31,19 +40,20 @@ export class FailureStrategySimple implements IFailureStrategy retries = 0; } - console.log( + this._logger.debug( JSON.stringify({ errorMessage: error.message, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call errorDetails: stringify(error), retries, - retryTimeout: 1000 * retries * 2 + retryTimeout: 1000 * retries * 2, }) ); await service.nack({ ...error, retries, - retryTimeout: 1000 * retries * 2 + retryTimeout: 1000 * retries * 2, }); } } diff --git a/packages/workit-core/src/utils/concat.ts b/packages/workit-core/src/utils/concat.ts index 7d0ef823..3b03567f 100644 --- a/packages/workit-core/src/utils/concat.ts +++ b/packages/workit-core/src/utils/concat.ts @@ -3,7 +3,7 @@ * Licensed under the MIT license. * See LICENSE file in the project root for full license information. */ -export const concatPath = (path: string, property: any) => { +export const concatPath = (path: string, property: string | number | symbol) => { let clonePath = path; if (property && property.toString) { if (path) { diff --git a/packages/workit-core/src/utils/utils.ts b/packages/workit-core/src/utils/utils.ts index a0c20040..d91bc836 100644 --- a/packages/workit-core/src/utils/utils.ts +++ b/packages/workit-core/src/utils/utils.ts @@ -24,6 +24,7 @@ export const getVariablesWhenChanged = ( unwrap: (message: IMessage>) => T ): T | undefined => { let vars: T | undefined; + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if ((message && !(message as any).__proxy__) || ProxyFactory.cacheChanges.has(message)) { vars = unwrap(message); } @@ -31,11 +32,11 @@ export const getVariablesWhenChanged = ( }; export function parseCommaSeparatedBaggage(baggage: any, values: string): void { - values.split(',').forEach(keyVal => { + values.split(',').forEach((keyVal) => { const splitKeyVal: string[] = keyVal.trim().split('='); if (splitKeyVal.length === 2) { const [key, val] = splitKeyVal; - // eslint-disable-next-line no-param-reassign + // eslint-disable-next-line no-param-reassign, @typescript-eslint/no-unsafe-member-access baggage[key] = val; } }); diff --git a/packages/workit-core/tests/functionals/interceptors.spec.ts b/packages/workit-core/tests/functionals/interceptors.spec.ts index d2818603..9d09f33e 100644 --- a/packages/workit-core/tests/functionals/interceptors.spec.ts +++ b/packages/workit-core/tests/functionals/interceptors.spec.ts @@ -13,7 +13,7 @@ describe('Interceptors', () => { const cDate = new Date(); const message = ProxyFactory.create({ body: { a: 1, b: true, c: cDate, d: { d1: new Date() }, e: [] }, - properties: { customHeaders: {} } as any + properties: { customHeaders: {} } as any, }); const interceptorExecution = Interceptors.execute([null as any], message); return expect(interceptorExecution).rejects.toThrow('interceptors passed in parameter are not valid.'); @@ -22,7 +22,7 @@ describe('Interceptors', () => { const cDate = new Date(); const message = ProxyFactory.create({ body: { a: 1, b: true, c: cDate, d: { d1: cDate }, e: [] }, - properties: { customHeaders: {} } as any + properties: { customHeaders: {} } as any, }); const interceptorExecution = Interceptors.execute([], message); return expect(interceptorExecution).resolves.toStrictEqual(message); @@ -31,13 +31,13 @@ describe('Interceptors', () => { const cDate = new Date(); const message = ProxyFactory.create({ body: { a: 1, b: true, c: cDate, d: { d1: cDate }, e: [] }, - properties: { customHeaders: {} } as any + properties: { customHeaders: {} } as any, }); const messageFromInterceptor = Interceptors.execute( [ - _ => { + (_) => { return null as any; - } + }, ] as Interceptor[], message ); @@ -47,23 +47,23 @@ describe('Interceptors', () => { const cDate = new Date(); const message = ProxyFactory.create({ body: { a: 1, b: true, c: cDate, d: { d1: new Date() }, e: [] }, - properties: { customHeaders: {} } as any + properties: { customHeaders: {} } as any, }); const interceptorMessage = { body: message.body, - properties: { customHeaders: { hello: 'world' } } as any + properties: { customHeaders: { hello: 'world' } } as any, }; const interceptorExecution = Interceptors.execute( [ - _ => { + (_) => { return Promise.resolve(interceptorMessage); - } + }, ] as Interceptor[], message ); return expect(interceptorExecution).resolves.toStrictEqual({ body: message.body, - properties: interceptorMessage.properties + properties: interceptorMessage.properties, }); }); // it.skip('should only merge custom headers in properties object', () => { diff --git a/packages/workit-core/tests/units/utils.spec.ts b/packages/workit-core/tests/units/utils.spec.ts index e2eb367a..baeb0323 100644 --- a/packages/workit-core/tests/units/utils.spec.ts +++ b/packages/workit-core/tests/units/utils.spec.ts @@ -23,7 +23,7 @@ describe('utils', () => { }); describe('andArrayWith', () => { it('should apply test function on each element on the array and ANDs the results', () => { - const biggerThan5 = a => a > 5; + const biggerThan5 = (a) => a > 5; const arr1 = [1, 2, 3, 4]; const arr2 = [6, 7, 8, 9]; const arr3 = [6, 7, 2, 8, 9]; @@ -50,7 +50,7 @@ describe('utils', () => { }, () => { // - } + }, ]) ).toBeTruthy(); }); diff --git a/packages/workit-types/package.json b/packages/workit-types/package.json index 3dbb4259..6187c03c 100644 --- a/packages/workit-types/package.json +++ b/packages/workit-types/package.json @@ -13,20 +13,20 @@ "devDependencies": { "@commitlint/cli": "^8.3.5", "@commitlint/config-conventional": "^8.3.4", - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.23.0", - "@typescript-eslint/parser": "^2.23.0", + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "codecov": "^3.6.5", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.0.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", "husky": "^4.2.4", - "prettier": "^1.19.1", + "prettier": "^2.1.2", "typedoc": "^0.16.11", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "engines": { "node": ">=8.11.4" @@ -75,4 +75,4 @@ "access": "public" }, "gitHead": "a122cb022d456027da28874b789616ebd0cb2284" -} +} \ No newline at end of file diff --git a/packages/workit-types/src/camundaBpm/camundaConfig.ts b/packages/workit-types/src/camundaBpm/camundaConfig.ts index 942da21b..b29c19e1 100644 --- a/packages/workit-types/src/camundaBpm/camundaConfig.ts +++ b/packages/workit-types/src/camundaBpm/camundaConfig.ts @@ -37,6 +37,7 @@ export interface ICamundaConfig { /** * Function(s) that have access to the client instance as soon as it is created and before any polling happens. Check out logger for a better understanding of the usage of middlewares. */ + // eslint-disable-next-line @typescript-eslint/ban-types use?: Function | Function[]; bpmnKey?: string; autoPoll?: boolean; @@ -48,5 +49,6 @@ export interface ICamundaConfig { * The Long Polling timeout in milliseconds. */ asyncResponseTimeout?: number; + // eslint-disable-next-line @typescript-eslint/ban-types interceptors?: Function | Function[]; } diff --git a/packages/workit-types/src/camundaBpm/camundaRepository.ts b/packages/workit-types/src/camundaBpm/camundaRepository.ts index 653c7a78..c91720f9 100644 --- a/packages/workit-types/src/camundaBpm/camundaRepository.ts +++ b/packages/workit-types/src/camundaBpm/camundaRepository.ts @@ -12,8 +12,8 @@ import { IProcessXmlDefinition } from './processXmlDefinition'; export interface ICamundaRepository { deployWorkflow(deployName: string, absPath: string): Promise>; - getWorkflows(options?: { params: {} }): Promise>; - getWorkflowCount(options?: { params: {} }): Promise>; + getWorkflows(options?: { params: Record }): Promise>; + getWorkflowCount(options?: { params: Record }): Promise>; getWorkflow(idOrKey: string): Promise; updateVariables(processInstanceId: string, variables: T): Promise>; updateJobRetries(id: string, retries: number): Promise>; @@ -25,7 +25,7 @@ export interface ICamundaRepository { messageName, processInstanceId, variables, - correlationKeys + correlationKeys, }: { messageName: string; processInstanceId: string; diff --git a/packages/workit-types/src/commons/logger.ts b/packages/workit-types/src/commons/logger.ts new file mode 100644 index 00000000..97fa2732 --- /dev/null +++ b/packages/workit-types/src/commons/logger.ts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2020 Ville de Montreal. All rights reserved. + * Licensed under the MIT license. + * See LICENSE file in the project root for full license information. + */ +export type LogFunction = (message: string, ...args: unknown[]) => void; + +/** Defines a logger interface. */ +export interface ILogger { + error: LogFunction; + warn: LogFunction; + info: LogFunction; + debug: LogFunction; +} diff --git a/packages/workit-types/src/http/httpOptions.ts b/packages/workit-types/src/http/httpOptions.ts index 7742c8c6..92105721 100644 --- a/packages/workit-types/src/http/httpOptions.ts +++ b/packages/workit-types/src/http/httpOptions.ts @@ -8,5 +8,5 @@ import { IHeaders } from './headers'; export interface IHttpOptions { headers: IHeaders; - params: {}; + params: Record; } diff --git a/packages/workit-types/src/index.ts b/packages/workit-types/src/index.ts index 5a5f58d8..896be6c2 100644 --- a/packages/workit-types/src/index.ts +++ b/packages/workit-types/src/index.ts @@ -9,6 +9,7 @@ export * from './commons/pagination'; export * from './commons/paginationOptions'; export * from './commons/paging'; export * from './commons/logLevel'; +export * from './commons/logger'; // ProcessHandler export * from './process/process'; diff --git a/packages/workit-zeebe-client/package.json b/packages/workit-zeebe-client/package.json index 7c886c3e..717be4ae 100644 --- a/packages/workit-zeebe-client/package.json +++ b/packages/workit-zeebe-client/package.json @@ -8,7 +8,7 @@ "main": "lib/src/index.js", "typings": "lib/src/index.d.ts", "dependencies": { - "debug": "~4.1.1", + "debug": "^4.2.0", "inversify": "~5.0.1", "reflect-metadata": "~0.1.13", "workit-core": "^4.2.2", @@ -25,24 +25,24 @@ "@types/events": "~3.0.0", "@types/jest": "^25.1.3", "@types/nock": "^11.1.0", - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.23.0", - "@typescript-eslint/parser": "^2.23.0", + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "codecov": "^3.6.5", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.0.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", "husky": "^4.2.4", "jest": "^25.1.0", "nock": "^11.8.2", - "prettier": "^1.19.1", - "source-map-support": "^0.5.16", + "prettier": "^2.1.2", + "source-map-support": "^0.5.19", "ts-jest": "^26.0.0", "typedoc": "^0.16.11", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "engines": { "node": ">=8.11.4" @@ -95,4 +95,4 @@ "access": "public" }, "gitHead": "a122cb022d456027da28874b789616ebd0cb2284" -} +} \ No newline at end of file diff --git a/packages/workit-zeebe-client/src/config/constants/identifiers.ts b/packages/workit-zeebe-client/src/config/constants/identifiers.ts index 73c73f41..11974ea2 100644 --- a/packages/workit-zeebe-client/src/config/constants/identifiers.ts +++ b/packages/workit-zeebe-client/src/config/constants/identifiers.ts @@ -19,5 +19,5 @@ export const SERVICE_IDENTIFIER = { /** * Bind your own Elastic exporter config for Zeebe */ - zeebe_elastic_exporter_config: Symbol('zeebe_elastic_exporter_config') + zeebe_elastic_exporter_config: Symbol('zeebe_elastic_exporter_config'), }; diff --git a/packages/workit-zeebe-client/src/config/container.ts b/packages/workit-zeebe-client/src/config/container.ts index 2d1b016d..06493ae9 100644 --- a/packages/workit-zeebe-client/src/config/container.ts +++ b/packages/workit-zeebe-client/src/config/container.ts @@ -11,20 +11,20 @@ import { SERVICE_IDENTIFIER } from './constants/identifiers'; const configBase: ICamundaConfig = { workerId: 'demo', baseUrl: `__undefined__`, - topicName: 'topic_demo' + topicName: 'topic_demo', }; const zeebeElasticExporterConfig = { - url: `http://localhost:9200` + url: `http://localhost:9200`, }; -const camundaCloudConfig = {} as Partial<{ oAuth: object }>; +const camundaCloudConfig = {} as Partial<{ oAuth: Record }>; if (process.env.ZEEBE_AUTHORIZATION_SERVER_URL) { camundaCloudConfig.oAuth = Object.entries({ url: process.env.ZEEBE_AUTHORIZATION_SERVER_URL, audience: process.env.ZEEBE_ADDRESS?.split(':')[0], clientId: process.env.ZEEBE_CLIENT_ID, - clientSecret: process.env.ZEEBE_CLIENT_SECRET + clientSecret: process.env.ZEEBE_CLIENT_SECRET, }).reduce((acc, [key, val]) => { if (val) acc[key] = val; return acc; @@ -34,7 +34,7 @@ if (process.env.ZEEBE_AUTHORIZATION_SERVER_URL) { const zeebeClientConfig = { ...configBase, baseUrl: process.env.ZEEBE_ADDRESS || `localhost:26500`, - ...camundaCloudConfig + ...camundaCloudConfig, }; kernel.bind(SERVICE_IDENTIFIER.zeebe_external_config).toConstantValue(zeebeClientConfig); kernel.bind(SERVICE_IDENTIFIER.zeebe_elastic_exporter_config).toConstantValue(zeebeElasticExporterConfig); diff --git a/packages/workit-zeebe-client/src/utils/paginationUtils.ts b/packages/workit-zeebe-client/src/utils/paginationUtils.ts index de28e045..38ebdebb 100644 --- a/packages/workit-zeebe-client/src/utils/paginationUtils.ts +++ b/packages/workit-zeebe-client/src/utils/paginationUtils.ts @@ -16,19 +16,19 @@ class PaginationUtils { return { ...params, from: options.from, size: options.size }; } - public static getPagingFromOptions(totalCount: number, options?: (any & IPaginationOptions) | undefined): IPaging { + public static getPagingFromOptions(totalCount: number, options?: Partial): IPaging { // https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html if (!options) { return { from: 0, size: PaginationUtils._DEFAULT_SIZE_ITEMS, - totalCount + totalCount, }; } return { from: typeof options.from === 'number' ? options.from : 0, size: options.size || PaginationUtils._DEFAULT_SIZE_ITEMS, - totalCount + totalCount, }; } diff --git a/packages/workit-zeebe-client/src/zeebeClient.ts b/packages/workit-zeebe-client/src/zeebeClient.ts index 12f07b94..67e7acaa 100644 --- a/packages/workit-zeebe-client/src/zeebeClient.ts +++ b/packages/workit-zeebe-client/src/zeebeClient.ts @@ -25,7 +25,7 @@ import { IWorkflowOptions, IWorkflowProcessIdDefinition, IWorkflowProps, - IZeebeOptions + IZeebeOptions, } from 'workit-types'; import { Configs, IAPIConfig as IElasticExporterConfig, ZBElasticClient } from 'zeebe-elasticsearch-client'; import { ZBClient, ZBWorker } from 'zeebe-node'; @@ -96,7 +96,7 @@ export class ZeebeClient { + const data = elasticResult.hits.map((doc) => { const workflow = doc._source; return { bpmnProcessId: workflow.bpmnProcessId, version: workflow.version, workflowKey: workflow.key.toString(), - resourceName: workflow.resourceName + resourceName: workflow.resourceName, }; }); return { paging: PaginationUtils.getPagingFromOptions(elasticResult.total, options), - items: data + items: data, }; } @@ -132,7 +132,7 @@ export class ZeebeClient({ elementInstanceKey: model.processInstanceId, variables: model.variables, - local: !!model.local + local: !!model.local, }); } @@ -174,7 +174,7 @@ export class ZeebeClient(obj: IPayload): IWorkflowProps { let businessKey; - if (obj.variables || (obj.variables as any).businessKey) { - businessKey = (obj.variables as any).businessKey; + if (obj.variables || (obj.variables as Record).businessKey) { + businessKey = (obj.variables as Record).businessKey; } return { + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment businessKey, // retro compatibility with bpmn workflow engine activityId: obj.elementId, processInstanceId: obj.elementInstanceKey, @@ -25,7 +26,7 @@ export class ZeebeMapperProperties { retries: obj.retries, topicName: obj.type, workerId: obj.worker, - lockExpirationTime: new Date(Number(obj.deadline)) + lockExpirationTime: new Date(Number(obj.deadline)), }; } @@ -42,7 +43,7 @@ export class ZeebeMapperProperties { deadline: props.lockExpirationTime.getTime().toString(), customHeaders: { ...props.customHeaders }, key: props.jobKey, - type: props.topicName + type: props.topicName, }; } } diff --git a/packages/workit-zeebe-client/src/zeebeMessage.ts b/packages/workit-zeebe-client/src/zeebeMessage.ts index c7902cea..41af4b84 100644 --- a/packages/workit-zeebe-client/src/zeebeMessage.ts +++ b/packages/workit-zeebe-client/src/zeebeMessage.ts @@ -18,7 +18,7 @@ export class ZeebeMessage { return [ { body: payload.variables, - properties + properties, }, { hasBeenThreated: false, @@ -28,8 +28,9 @@ export class ZeebeMessage { } // TODO: change any to real type body - const vars = getVariablesWhenChanged(message, msg => ZeebeMessage.unwrap(msg)); - + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const vars = getVariablesWhenChanged(message, (msg) => ZeebeMessage.unwrap(msg)); + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access this.hasBeenThreated = await complete.success(vars?.variables); }, nack(error: FailureException) { @@ -40,8 +41,8 @@ export class ZeebeMessage { // TODO: check if zeebe-node made the type correction this.hasBeenThreated = (complete.failure(error.message, retries) as unknown) as boolean; return Promise.resolve(); - } - } + }, + }, ]; } diff --git a/packages/workit-zeebe-client/tests/functionals/zeebe.spec.ts b/packages/workit-zeebe-client/tests/functionals/zeebe.spec.ts index afb2a5c2..84d33743 100644 --- a/packages/workit-zeebe-client/tests/functionals/zeebe.spec.ts +++ b/packages/workit-zeebe-client/tests/functionals/zeebe.spec.ts @@ -30,11 +30,11 @@ describe('Zeebe Worker', () => { workerId: 'test-worker', baseUrl: 'localhost:26500', topicName: 'demo-service', - bpmnKey: 'test' + bpmnKey: 'test', }; }); - it('should instanciate the worker', done => { + it('should instanciate the worker', (done) => { (async () => { const zeebeClient = new ZeebeClient(config); const successHandler = new SuccessStrategySimple(); @@ -52,7 +52,7 @@ describe('Zeebe Worker', () => { .query({ _source_excludes: 'bpmnXml' }) .reply(200, require(`${process.cwd()}/tests/data/elasticResponse.workflow`)); const zeebeClient = new ZeebeClient(config, undefined, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows(); @@ -66,7 +66,7 @@ describe('Zeebe Worker', () => { .reply(200, require(`${process.cwd()}/tests/data/elasticResponseAgg.workflow`)); const zeebeClient = new ZeebeClient(config, undefined, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflow({ bpmnProcessId: 'MESSAGE_EVENT' }); @@ -90,7 +90,7 @@ describe('Zeebe Worker', () => { .reply(200, require(`${process.cwd()}/tests/data/elasticResponse.paginated`)); const zeebeClient = new ZeebeClient(config, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows({ size }); scope.done(); @@ -107,7 +107,7 @@ describe('Zeebe Worker', () => { .reply(200, require(`${process.cwd()}/tests/data/elasticResponse.paginated.skip`)); const zeebeClient = new ZeebeClient(config, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows({ size, from }); scope.done(); @@ -120,13 +120,13 @@ describe('Zeebe Worker', () => { const bpmnProcessId = 'MESSAGE_EVENT'; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', { - query: { bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }] } } + query: { bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }] } }, }) .query({ _source_excludes: 'bpmnXml', size }) .reply(200, require(`${process.cwd()}/tests/data/elasticResponseBpmnProcessId.paginated`)); const zeebeClient = new ZeebeClient(config, { - url: 'http://localhost:9200' + url: 'http://localhost:9200', }); const response = await zeebeClient.getWorkflows({ size, bpmnProcessId }); scope.done(); diff --git a/packages/workit-zeebe-client/tests/functionals/zeebeMessage.spec.ts b/packages/workit-zeebe-client/tests/functionals/zeebeMessage.spec.ts index dac64c34..e449b25c 100644 --- a/packages/workit-zeebe-client/tests/functionals/zeebeMessage.spec.ts +++ b/packages/workit-zeebe-client/tests/functionals/zeebeMessage.spec.ts @@ -23,8 +23,8 @@ describe('zeebeMessage', () => { retries: 1, lockExpirationTime: new Date(1562269537659), topicName: 'topic_demo', - workerId: 'demo' - } + workerId: 'demo', + }, }; const zeebeObject = ZeebeMessage.unwrap(message); expect(zeebeObject).toMatchSnapshot(); diff --git a/packages/workit-zeebe-client/tests/integrations/zeebe.spec.ts b/packages/workit-zeebe-client/tests/integrations/zeebe.spec.ts index c82b8aab..06c83ac4 100644 --- a/packages/workit-zeebe-client/tests/integrations/zeebe.spec.ts +++ b/packages/workit-zeebe-client/tests/integrations/zeebe.spec.ts @@ -69,7 +69,7 @@ describe('ZeebeClient', () => { afterEach(async () => { try { await Promise.all( - workers.map(async worker => { + workers.map(async (worker) => { await worker.stop(); }) ); @@ -104,13 +104,13 @@ describe('ZeebeClient', () => { const workflowInstance = await zbc.createWorkflowInstance({ bpmnProcessId: 'hello-world', - variables: {} + variables: {}, }); expect(workflowInstance.bpmnProcessId).toBe('hello-world'); expect(workflowInstance.workflowInstanceKey).toBeTruthy(); }); - it('Can receive a valid workflow instance', async done => { + it('Can receive a valid workflow instance', async (done) => { await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/hello-world.bpmn')); workers.unshift(createWorkerInstance('console-log', done)); try { @@ -120,7 +120,7 @@ describe('ZeebeClient', () => { } }); - it('Can start a workflow with a message', async done => { + it('Can start a workflow with a message', async (done) => { const deploy = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/msg-start.bpmn')); expect(deploy.key).toBeTruthy(); @@ -131,8 +131,8 @@ describe('ZeebeClient', () => { name: 'MSG-START_JOB', timeToLive: 30_000, variables: { - testKey: randomId - } + testKey: randomId, + }, }); try { @@ -140,7 +140,7 @@ describe('ZeebeClient', () => { IoC.unbind('ServiceTask_0f6zc7d'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.customHeaders.message.indexOf('Workflow') !== -1).toBe(true); expect(message.body.testKey).toBe(randomId); // Makes sure the worker isn't responding to another message }), @@ -152,14 +152,14 @@ describe('ZeebeClient', () => { } }); - it('Can cancel a workflow', async done => { + it('Can cancel a workflow', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/hello-world.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('hello-world'); const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'hello-world', - variables: {} + variables: {}, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -190,7 +190,7 @@ describe('ZeebeClient', () => { } }); - it('Correctly branches on variables', async done => { + it('Correctly branches on variables', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/conditional-pathway.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('condition-test'); @@ -198,8 +198,8 @@ describe('ZeebeClient', () => { const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'condition-test', variables: { - conditionVariable: true - } + conditionVariable: true, + }, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -209,14 +209,14 @@ describe('ZeebeClient', () => { IoC.unbind('ServiceTask_0cz2k8t'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); }), 'ServiceTask_0cz2k8t' ); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); expect(message.body.conditionVariable).toBe(true); }), @@ -231,7 +231,7 @@ describe('ZeebeClient', () => { } }); - it('Can update workflow variables', async done => { + it('Can update workflow variables', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/conditional-pathway.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('condition-test'); @@ -239,8 +239,8 @@ describe('ZeebeClient', () => { const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'condition-test', variables: { - conditionVariable: true - } + conditionVariable: true, + }, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -249,8 +249,8 @@ describe('ZeebeClient', () => { processInstanceId: wfi, local: false, variables: { - conditionVariable: false - } + conditionVariable: false, + }, }); workers.unshift(createWorkerInstance('wait', () => {})); @@ -258,14 +258,14 @@ describe('ZeebeClient', () => { IoC.unbind('ServiceTask_0cz2k8t'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); }), 'ServiceTask_0cz2k8t' ); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); expect(message.body.conditionVariable).toBe(false); }), @@ -280,7 +280,7 @@ describe('ZeebeClient', () => { } }); - it('Causes 2 retries handled by FailureStrategySimple', async done => { + it('Causes 2 retries handled by FailureStrategySimple', async (done) => { const res = await zbc.deployWorkflow(path.join(__dirname, '..', './data/bpmn/zeebe/conditional-pathway.bpmn')); expect(res.workflows.length).toBe(1); expect(res.workflows[0].bpmnProcessId).toBe('condition-test'); @@ -288,8 +288,8 @@ describe('ZeebeClient', () => { const wf = await zbc.createWorkflowInstance({ bpmnProcessId: 'condition-test', variables: { - conditionVariable: true - } + conditionVariable: true, + }, }); const wfi = wf.workflowInstanceKey; expect(wfi).toBeTruthy(); @@ -298,15 +298,15 @@ describe('ZeebeClient', () => { processInstanceId: wfi, local: false, variables: { - conditionVariable: false - } + conditionVariable: false, + }, }); workers.unshift(createWorkerInstance('wait', done)); IoC.unbind('ServiceTask_0cz2k8t'); IoC.bindToObject( - new HelloWorldTask(message => { + new HelloWorldTask((message) => { expect(message.properties.workflowInstanceKey).toBe(wfi); let retries = message.properties.retries || 0; retries += 1; diff --git a/packages/zeebe-elasticsearch-client/.eslintrc.js b/packages/zeebe-elasticsearch-client/.eslintrc.js index 0c4fb924..a15d835f 100644 --- a/packages/zeebe-elasticsearch-client/.eslintrc.js +++ b/packages/zeebe-elasticsearch-client/.eslintrc.js @@ -16,5 +16,10 @@ module.exports = { "parserOptions": { "project": "./tsconfig.json" }, - "rules": require('../../eslint.rules.js') + "rules": { + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + ...require('../../eslint.rules.js') + } } \ No newline at end of file diff --git a/packages/zeebe-elasticsearch-client/package.json b/packages/zeebe-elasticsearch-client/package.json index d6355554..c059caa5 100644 --- a/packages/zeebe-elasticsearch-client/package.json +++ b/packages/zeebe-elasticsearch-client/package.json @@ -32,24 +32,24 @@ "@types/form-data": "2.5.0", "@types/jest": "^25.1.4", "@types/nock": "^11.1.0", - "@types/node": "^14.0.0", - "@typescript-eslint/eslint-plugin": "^2.23.0", - "@typescript-eslint/parser": "^2.23.0", + "@types/node": "^14.14.7", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "codecov": "^3.6.5", - "eslint": "^6.8.0", - "eslint-config-airbnb-typescript": "^7.0.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-header": "^3.0.0", - "eslint-plugin-import": "^2.20.1", - "eslint-plugin-prettier": "^3.1.2", + "eslint": "^7.13.0", + "eslint-config-airbnb-typescript": "^12.0.0", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-header": "^3.1.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.1.4", "husky": "^4.2.4", "jest": "^24.9.0", "nock": "^11.7.0", - "prettier": "^1.19.1", - "source-map-support": "^0.5.16", + "prettier": "^2.1.2", + "source-map-support": "^0.5.19", "ts-jest": "^26.0.0", "typedoc": "^0.16.11", - "typescript": "^3.8.3" + "typescript": "^4.0.5" }, "repository": { "type": "git", @@ -71,4 +71,4 @@ "url": "https://github.com/VilledeMontreal/workit/issues" }, "gitHead": "4d109b9f2978bac5ec5338a39adc49ccf9bf2651" -} +} \ No newline at end of file diff --git a/packages/zeebe-elasticsearch-client/src/enums/httpMethods.ts b/packages/zeebe-elasticsearch-client/src/enums/httpMethods.ts index 141ad252..1e361944 100644 --- a/packages/zeebe-elasticsearch-client/src/enums/httpMethods.ts +++ b/packages/zeebe-elasticsearch-client/src/enums/httpMethods.ts @@ -8,5 +8,5 @@ export enum HttpMethods { POST = 'POST', PUT = 'PUT', PATCH = 'PATCH', - DELETE = 'DELETE' + DELETE = 'DELETE', } diff --git a/packages/zeebe-elasticsearch-client/src/models/config/index.ts b/packages/zeebe-elasticsearch-client/src/models/config/index.ts index d0c79fec..3cd3b115 100644 --- a/packages/zeebe-elasticsearch-client/src/models/config/index.ts +++ b/packages/zeebe-elasticsearch-client/src/models/config/index.ts @@ -9,7 +9,7 @@ export enum Env { local = 'local', dev = 'development', accept = 'acceptation', - prod = 'production' + prod = 'production', } export class Configs { @@ -19,11 +19,11 @@ export class Configs { this._elastic = { url: `http://localhost:9200`, endpoints: { - workflows: '/operate-workflow_alias' + workflows: '/operate-workflow_alias', }, retry: 3, timeout: 30000, - ...customConfig + ...customConfig, } as IAPIConfig; } diff --git a/packages/zeebe-elasticsearch-client/src/repositories/zbElasticClient.ts b/packages/zeebe-elasticsearch-client/src/repositories/zbElasticClient.ts index cb225f29..2705cd4a 100644 --- a/packages/zeebe-elasticsearch-client/src/repositories/zbElasticClient.ts +++ b/packages/zeebe-elasticsearch-client/src/repositories/zbElasticClient.ts @@ -31,8 +31,8 @@ export class ZBElasticClient { maxRedirects: config.retry, headers: { Accept: 'application/json', - 'Content-Type': 'application/json' - } + 'Content-Type': 'application/json', + }, }); Utils.addInterceptors(this._request, configs.elastic.interceptors); } @@ -59,7 +59,7 @@ export class ZBElasticClient { _shards: data._shards, timed_out: data.timed_out, took: data.took, - hits: aggs.doc_with_latestVersion.hits + hits: aggs.doc_with_latestVersion.hits, }; } @@ -67,7 +67,7 @@ export class ZBElasticClient { headers: response.headers, data, status: response.status, - statusText: response.statusText + statusText: response.statusText, }; } @@ -86,7 +86,7 @@ export class ZBElasticClient { data: doc, params: _options.params, withCredentials: true, - headers: _options.headers + headers: _options.headers, }); } @@ -96,7 +96,7 @@ export class ZBElasticClient { method: HttpMethods.GET, params: _options.params, withCredentials: true, - headers: _options.headers + headers: _options.headers, }); } @@ -106,9 +106,9 @@ export class ZBElasticClient { const q: any = { query: { bool: { - must: [] as any[] - } - } + must: [] as any[], + }, + }, }; const { key } = model; @@ -116,18 +116,18 @@ export class ZBElasticClient { const mustMatchKey = { match: { key: { - query: key - } - } + query: key, + }, + }, }; q.query.bool.must.push(mustMatchKey); } else if (model.bpmnProcessId) { const mustMatchBpmnProcessId = { match: { bpmnProcessId: { - query: model.bpmnProcessId - } - } + query: model.bpmnProcessId, + }, + }, }; q.query.bool.must.push(mustMatchBpmnProcessId); } @@ -140,25 +140,25 @@ export class ZBElasticClient { sort: [ { version: { - order: 'desc' - } - } + order: 'desc', + }, + }, ], - size: 1 - } - } + size: 1, + }, + }, }; } else if (hasVersionParam) { const mustMatchVersion = { match: { version: { - query: model.version - } - } + query: model.version, + }, + }, }; q.query.bool.must.push(mustMatchVersion); } - + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return q; } } diff --git a/packages/zeebe-elasticsearch-client/src/specs/options.ts b/packages/zeebe-elasticsearch-client/src/specs/options.ts index e29f03ee..9f6fdf9b 100644 --- a/packages/zeebe-elasticsearch-client/src/specs/options.ts +++ b/packages/zeebe-elasticsearch-client/src/specs/options.ts @@ -7,5 +7,5 @@ import { IHeaders } from './headers'; export interface IOptions { headers: IHeaders; - params: {}; + params: Record; } diff --git a/packages/zeebe-elasticsearch-client/src/tests/getWorkflows.spec.ts b/packages/zeebe-elasticsearch-client/src/tests/getWorkflows.spec.ts index 9cca45ef..5efd7e1a 100644 --- a/packages/zeebe-elasticsearch-client/src/tests/getWorkflows.spec.ts +++ b/packages/zeebe-elasticsearch-client/src/tests/getWorkflows.spec.ts @@ -54,7 +54,7 @@ describe('getWorkflows', () => { it.skip('Should not get workflow by bpmnProcessId and latest version with "from" out of range', async () => { const query = { query: { bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }] } }, - aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } } + aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } }, }; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', query) @@ -83,7 +83,7 @@ describe('getWorkflows', () => { const query = { size: 0, query: { bool: { must: [{ match: { bpmnProcessId: { query: 'MESSAGE_EVENT' } } }] } }, - aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } } + aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } }, }; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', query) @@ -100,7 +100,7 @@ describe('getWorkflows', () => { const query = { query: { bool: { must: [] } }, size: 0, - aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } } + aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } }, }; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', query) @@ -114,8 +114,8 @@ describe('getWorkflows', () => { it('Should get workflow by bpmnProcessId and version', async () => { const query = { query: { - bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }, { match: { version: { query: 1 } } }] } - } + bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }, { match: { version: { query: 1 } } }] }, + }, }; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', query) @@ -129,8 +129,8 @@ describe('getWorkflows', () => { it('Should not get workflow with bad version but good bpmnProcessId', async () => { const query = { query: { - bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }, { match: { version: { query: 0 } } }] } - } + bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }, { match: { version: { query: 0 } } }] }, + }, }; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', query) @@ -145,7 +145,7 @@ describe('getWorkflows', () => { const query = { query: { bool: { must: [{ match: { bpmnProcessId: { query: bpmnProcessId } } }] } }, size: 0, - aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } } + aggs: { doc_with_latestVersion: { top_hits: { sort: [{ version: { order: 'desc' } }], size: 1 } } }, }; const scope = nock('http://localhost:9200') .post('/operate-workflow_alias/_search', query) diff --git a/packages/zeebe-elasticsearch-client/src/utils/utils.ts b/packages/zeebe-elasticsearch-client/src/utils/utils.ts index a1156263..c0b368f3 100644 --- a/packages/zeebe-elasticsearch-client/src/utils/utils.ts +++ b/packages/zeebe-elasticsearch-client/src/utils/utils.ts @@ -11,24 +11,24 @@ export class Utils { public static addRequestInterceptors( request: AxiosInstance, interceptors?: ((config: IRequestConfig) => IRequestConfig)[] - ) { + ): void { if (!Array.isArray(interceptors)) { return; } - interceptors.forEach(interceptor => request.interceptors.request.use(interceptor)); + interceptors.forEach((interceptor) => request.interceptors.request.use(interceptor)); } public static addResponseInterceptors( request: AxiosInstance, interceptors?: (((value: IResponse) => IResponse | Promise>) | undefined)[] - ) { + ): void { if (!Array.isArray(interceptors)) { return; } - interceptors.forEach(interceptor => request.interceptors.response.use(interceptor as any)); + interceptors.forEach((interceptor) => request.interceptors.response.use(interceptor as any)); } - public static addInterceptors(request: AxiosInstance, interceptors: Partial) { + public static addInterceptors(request: AxiosInstance, interceptors: Partial): void { if (typeof interceptors !== 'object') { return; }