From eaf14e324c5ee035b22c023bdbcd8504c9606701 Mon Sep 17 00:00:00 2001 From: Olivier Albertini Date: Thu, 29 Feb 2024 16:20:53 -0500 Subject: [PATCH] docs: update readme for stepfunctions work in progress Signed-off-by: Olivier Albertini --- README.md | 71 +------- README_FR.md | 44 +---- examples/README.md | 6 +- examples/basic/README.md | 4 +- .../basic/src/create-process-instances.ts | 2 +- examples/basic/src/deploy.ts | 51 +++--- .../{bpmn => workflow/camunda}/BPMN_DEMO.bpmn | 0 .../stepfunctions/WORKFLOW_DEMO.json} | 0 examples/binding/README.md | 6 +- examples/binding/package.json | 6 +- examples/binding/src/deploy.ts | 2 +- .../camunda}/BPMN_P_DEMO.bpmn | 0 .../stepfunctions/WORKFLOW_P_DEMO.json | 117 ++++++++++++ examples/event/.eslintignore | 7 - examples/event/.eslintrc.js | 26 --- examples/event/CHANGELOG.md | 172 ------------------ examples/event/LICENSE | 16 -- examples/event/README.md | 38 ---- examples/event/bpmn/MESSAGE_EVENT.bpmn | 81 --------- examples/event/package.json | 58 ------ examples/event/prettier.config.js | 4 - .../event/src/create-process-instances.ts | 21 --- examples/event/src/deploy.ts | 16 -- examples/event/src/worker.ts | 37 ---- examples/event/tasks/helloWorldTask.ts | 25 --- examples/event/tsconfig.json | 17 -- examples/failure-strategy/README.md | 6 +- examples/failure-strategy/package.json | 6 +- examples/failure-strategy/src/deploy.ts | 2 +- .../{bpmn => workflow/camunda}/BPMN_DEMO.bpmn | 0 .../workflow/stepfunctions/WORKFLOW_DEMO.json | 37 ++++ examples/opentelemetry/README.md | 4 +- examples/opentelemetry/package.json | 6 +- examples/opentelemetry/src/deploy.ts | 2 +- .../camunda}/BPMN_P_DEMO.bpmn | 0 examples/parallel/README.md | 6 +- examples/parallel/package.json | 6 +- examples/parallel/src/deploy.ts | 2 +- examples/parallel/tsconfig.json | 21 +-- .../camunda}/BPMN_P_DEMO.bpmn | 0 .../stepfunctions/WORKFLOW_P_DEMO.json | 117 ++++++++++++ getting-started/README.md | 16 +- 42 files changed, 346 insertions(+), 712 deletions(-) rename examples/basic/{bpmn => workflow/camunda}/BPMN_DEMO.bpmn (100%) rename examples/basic/{bpmn/stepfunction/BPMN_DEMO.json => workflow/stepfunctions/WORKFLOW_DEMO.json} (100%) rename examples/binding/{bpmn => workflow/camunda}/BPMN_P_DEMO.bpmn (100%) create mode 100644 examples/binding/workflow/stepfunctions/WORKFLOW_P_DEMO.json delete mode 100644 examples/event/.eslintignore delete mode 100644 examples/event/.eslintrc.js delete mode 100644 examples/event/CHANGELOG.md delete mode 100644 examples/event/LICENSE delete mode 100644 examples/event/README.md delete mode 100644 examples/event/bpmn/MESSAGE_EVENT.bpmn delete mode 100644 examples/event/package.json delete mode 100644 examples/event/prettier.config.js delete mode 100644 examples/event/src/create-process-instances.ts delete mode 100644 examples/event/src/deploy.ts delete mode 100644 examples/event/src/worker.ts delete mode 100644 examples/event/tasks/helloWorldTask.ts delete mode 100644 examples/event/tsconfig.json rename examples/failure-strategy/{bpmn => workflow/camunda}/BPMN_DEMO.bpmn (100%) create mode 100644 examples/failure-strategy/workflow/stepfunctions/WORKFLOW_DEMO.json rename examples/opentelemetry/{bpmn => workflow/camunda}/BPMN_P_DEMO.bpmn (100%) rename examples/parallel/{bpmn => workflow/camunda}/BPMN_P_DEMO.bpmn (100%) create mode 100644 examples/parallel/workflow/stepfunctions/WORKFLOW_P_DEMO.json diff --git a/README.md b/README.md index db330eea..14ed9797 100644 --- a/README.md +++ b/README.md @@ -39,39 +39,13 @@ This package can be useful because: | Package | Description | | ---------------------------------------- | -----------------| | [workit-bpm-client](https://github.com/VilledeMontreal/workit/tree/master/packages/workit-bpm-client) | This module provides a full control over the Camunda Bpm platform.
It use [`camunda-external-task-client-js`](https://github.com/camunda/camunda-external-task-client-js) by default. | +| [workit-stepfunction-client](https://github.com/VilledeMontreal/workit/tree/master/packages/workit-stepfunction-client) | This module provides a full control over the Step functions platform.
It use `@aws-sdk/client-sqs`, `@aws-sdk/client-sfn` by default. | ## Installing ```bash npm i @villedemontreal/workit ``` -or using the generator below -### Yo! - -

- -This generator will help you during your development with this library. It provides handy tools. - -```bash -npm i -g @villedemontreal/workit-cli -``` - -#### Install a fresh new project - -```bash -workit init -``` -#### Generate tasks from your existing BPMN - -```bash -workit create task --file /your/path.bpmn -``` - -#### Generate new task - -```bash -workit create task -``` ## How to use @@ -108,28 +82,6 @@ const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.cam await manager.getWorkflow({ bpmnProcessId: "DEMO" }); ``` -### Update variables - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.updateVariables({ - processInstanceId: "5c50c48e-4691-11e9-8b8f-0242ac110002", - variables: { amount: 1000 } -}); -``` - -### Publish message - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.publishMessage({ - correlation: {}, - name: "catching", - variables: { amount: 100 }, - messageId: "5c50c48e-4691-11e9-8b8f-0242ac110002" -}); -``` - ### Create workflow instance ```javascript @@ -142,20 +94,6 @@ await manager.createWorkflowInstance({ }); ``` -### Cancel workflow instance - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.cancelWorkflowInstance("4651614f-4b3c-11e9-b5b3-ee5801424400"); -``` - -### Resolve incident - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.resolveIncident("c84fce6c-518e-11e9-bd78-0242ac110003"); -``` - ### Define tasks (your bpmn activities) You can define many tasks to one worker. It will handle all messages and will route to the right tasks. @@ -172,7 +110,6 @@ export class HelloWorldTask extends TaskBase { } } - enum LOCAL_IDENTIFIER { // sample_activity must match the activityId in your bpmn sample_activity= 'sample_activity' @@ -351,7 +288,9 @@ npm test ## Built With * [camunda-external-task-client-js](https://github.com/camunda/camunda-external-task-client-js) - nodejs client for Camunda BPM -* [inversify](https://github.com/inversify/InversifyJS) - Dependency injection +* [@aws-sdk/client-sqs](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sqs/) - nodejs client for receiving messages from the queue +* [@aws-sdk/client-sfn](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sfn/) - nodejs client for managing state machines and acknowledging process +* [inversify](https://github.com/inversify/InversifyJS) - dependency injection * [opentelemetry](https://opentelemetry.io/) - add instrumentation to the operations (provides a single set of APIs, libraries to capture distributed traces) ## Philosophy @@ -386,7 +325,7 @@ We use [SemVer](http://semver.org/) for versioning. For the versions available, workit | AWS Step function | Camunda BPM -- | -- | -- -\>=6.0.0 | TODO | 7.6 to latest +\>=6.0.0 | all | 7.6 to latest ## Maintainers diff --git a/README_FR.md b/README_FR.md index 593d9cf5..0bad9fb4 100644 --- a/README_FR.md +++ b/README_FR.md @@ -39,7 +39,7 @@ Ce framework offre les avantages suivants: | Librairie | Description | | ----------------------- | -----------------| | [workit-bpm-client](https://github.com/VilledeMontreal/workit/tree/master/packages/workit-bpm-client) | Ce module fournit un contrôle complet pour intéragir avec la plateforme Camunda Bpm.
Il utilise [`camunda-external-task-client-js`](https://github.com/camunda/camunda-external-task-client-js) par défaut. | - +| [workit-stepfunction-client](https://github.com/VilledeMontreal/workit/tree/master/packages/workit-stepfunction-client) | Ce module fournit un contrôle complet pour intéragir avec la plateforme Step functions.
Par défaut, il utilise `@aws-sdk/client-sqs`, `@aws-sdk/client-sfn`. | ## L'installation ```bash @@ -82,28 +82,6 @@ const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.cam await manager.getWorkflow({ bpmnProcessId: "DEMO" }); ``` -### Mettre à jour les variables - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.updateVariables({ - processInstanceId: "5c50c48e-4691-11e9-8b8f-0242ac110002", - variables: { amount: 1000 } -}); -``` - -### Publier un message - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.publishMessage({ - correlation: {}, - name: "catching", - variables: { amount: 100 }, - messageId: "5c50c48e-4691-11e9-8b8f-0242ac110002" -}); -``` - ### Créer une instance de flux de travail ```javascript @@ -116,20 +94,6 @@ await manager.createWorkflowInstance({ }); ``` -### Annuler l'instance d'un flux de travail - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.cancelWorkflowInstance("4651614f-4b3c-11e9-b5b3-ee5801424400"); -``` - -### Résoudre l'incident - -```javascript -const manager = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); -await manager.resolveIncident("c84fce6c-518e-11e9-bd78-0242ac110003"); -``` - ### Définir les tâches (vos activités bpmn) Vous pouvez définir plusieurs tâches pour un seul Worker. Il traitera tous les messages et acheminera les requêtes vers les bonnes tâches. @@ -323,7 +287,9 @@ npm test ## Construit avec * [camunda-external-task-client-js](https://github.com/camunda/camunda-external-task-client-js) - client nodejs pour Camunda BPM -* [inversify](https://github.com/inversify/InversifyJS) - injection de dépendence +* [@aws-sdk/client-sqs](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sqs/) - client nodejs pour recevoir les messages de la file d'attente +* [@aws-sdk/client-sfn](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sfn/) - client nodejs pour gérer l'état des processus +* [inversify](https://github.com/inversify/InversifyJS) - injection de dépendance * [opentelemetry](https://opentelemetry.io/) - ajouter de l'instrumentation aux opérations ## Philosophie @@ -348,7 +314,7 @@ Nous utilisons [SemVer](http://semver.org/) pour la gestion des versions. Pour l workit | AWS Step function | Camunda BPM -- | -- | -- -\>=6.0.0 | TODO | 7.6 to latest +\>=6.0.0 | tous | 7.6 to latest ## Mainteneurs diff --git a/examples/README.md b/examples/README.md index 52f98923..dccfefae 100644 --- a/examples/README.md +++ b/examples/README.md @@ -21,11 +21,11 @@ $ npm install $ # inside a directory $ # deploy a bpmn provided in the example -$ npm camunda:deploy +$ npm deploy $ # create instance(s) -$ npm camunda:create-instance +$ npm create-instance $ # run worker -$ npm camunda:worker +$ npm worker ``` ## Useful links diff --git a/examples/basic/README.md b/examples/basic/README.md index f54b2a36..d16ea408 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -21,7 +21,7 @@ Todo: provide steps ##### Manually -In `examples/basic/bpmn/stepfunction/BPMN_DEMO.json`, you will need to specify the `QueueUrl` and in `examples/basic/src/deploy.ts` , you must specify the `roleArn` to use for deploying the new workflow. +In `examples/basic/workflow/stepfunction/WORKFLOW_DEMO.json`, you will need to specify the `QueueUrl` and in `examples/basic/src/deploy.ts` , you must specify the `roleArn` to use for deploying the new workflow. Notice that you can skip this step if you deploy the workflow through the AWS Step function UI and it won't be necessary to run `npm run deploy` @@ -35,7 +35,7 @@ You must specify the following environment variables : - AWS_SQS_QUEUE_URL - AWS_SQS_WAIT_TIME_SECONDS (Optional) -(Optional) Setup, we can switch to `TAG.camundaBpm` or `TAG.stepFunction` in order to use both plateform (some comments are added in the example). +(Optional) Setup, we can switch to `TAG.camundaBpm` or `TAG.stepFunction` in order to use both platforms (some comments are added in the example). ```sh $ # from this directory diff --git a/examples/basic/src/create-process-instances.ts b/examples/basic/src/create-process-instances.ts index 9495934f..51d70c4a 100644 --- a/examples/basic/src/create-process-instances.ts +++ b/examples/basic/src/create-process-instances.ts @@ -22,7 +22,7 @@ import { IWorkflowClient } from '@villedemontreal/workit-types'; bpmnProcessId: platform === TAG.camundaBpm ? 'BPMN_DEMO' - : `arn:aws:states:${process.env.AWS_REGION}::stateMachine:Basic-Exemple`, + : `arn:aws:states:${process.env.AWS_REGION}::stateMachine:Basic-Example`, variables: { amount: 1000, hello: 'world', diff --git a/examples/basic/src/deploy.ts b/examples/basic/src/deploy.ts index f3c91727..a296b51f 100644 --- a/examples/basic/src/deploy.ts +++ b/examples/basic/src/deploy.ts @@ -6,39 +6,30 @@ // you can pass value here or an another (safer) way // process.env.AWS_REGION = 'us-east-1'; -// process.env.AWS_SQS_QUEUE_URL = '' // process.env.AWS_ACCESS_KEY_ID = ''; // process.env.AWS_SECRET_ACCESS_KEY = ''; // process.env.AWS_SQS_WAIT_TIME_SECONDS = '20'; import { SERVICE_IDENTIFIER as CORE_IDENTIFIER, TAG } from '@villedemontreal/workit'; -import { IoC, Worker } from '@villedemontreal/workit-core'; -import { HelloWorldTask } from '../tasks/helloWorldTask'; +import { IoC } from '@villedemontreal/workit-core'; +import { IWorkflowClient } from '@villedemontreal/workit-types'; -enum LOCAL_IDENTIFIER { - sampleActivity = 'Get credit limit', -} - -IoC.bindTo(HelloWorldTask, LOCAL_IDENTIFIER.sampleActivity); -const worker = IoC.get(CORE_IDENTIFIER.worker, TAG.stepFunction); - -const stop = (): void => { - console.info('SIGTERM signal received.'); - console.log('Closing worker'); - worker - .stop() - .then(() => { - console.log('worker closed'); - process.exit(0); - }) - .catch((e: Error) => { - console.log(e); - process.exit(1); - }); -}; - -worker.start(); -worker.run(); - -process.on('SIGINT', stop); -process.on('SIGTERM', stop); +(async (): Promise => { + const platform = TAG.camundaBpm; + const cm = IoC.get(CORE_IDENTIFIER.client_manager, platform); + const path = + platform === TAG.camundaBpm + ? `${process.cwd()}/workflow/camunda/BPMN_DEMO.bpmn` + : `${process.cwd()}/workflow/stepfunction/WORKFLOW_DEMO.json`; + const result = + platform === TAG.camundaBpm + ? await cm.deployWorkflow(path) + : await cm.deployWorkflow(path, { + name: 'Basic-Example', + roleArn: 'arn:aws:iam:::role/service-role/', + }); + console.info('Success!'); + console.warn( + `Please, provide the following value "${result.workflows[0].bpmnProcessId}" to bpmnProcessId variable in create-process-instances.ts file for creating an instance`, + ); +})(); diff --git a/examples/basic/bpmn/BPMN_DEMO.bpmn b/examples/basic/workflow/camunda/BPMN_DEMO.bpmn similarity index 100% rename from examples/basic/bpmn/BPMN_DEMO.bpmn rename to examples/basic/workflow/camunda/BPMN_DEMO.bpmn diff --git a/examples/basic/bpmn/stepfunction/BPMN_DEMO.json b/examples/basic/workflow/stepfunctions/WORKFLOW_DEMO.json similarity index 100% rename from examples/basic/bpmn/stepfunction/BPMN_DEMO.json rename to examples/basic/workflow/stepfunctions/WORKFLOW_DEMO.json diff --git a/examples/binding/README.md b/examples/binding/README.md index 6f5f36c2..217cf4e7 100644 --- a/examples/binding/README.md +++ b/examples/binding/README.md @@ -21,11 +21,11 @@ $ npm run build ```sh $ # from this directory $ # deploy a bpmn provided in the example -$ npm camunda:deploy +$ npm deploy $ # create instance(s) -$ npm camunda:create-instance +$ npm create-instance $ # run worker -$ npm camunda:worker +$ npm worker ``` ## Useful links diff --git a/examples/binding/package.json b/examples/binding/package.json index e929e3e1..79918e58 100644 --- a/examples/binding/package.json +++ b/examples/binding/package.json @@ -16,9 +16,9 @@ "lint": "eslint . --ext .ts && prettier -l \"src/**/*.ts\"", "lint-fix": "prettier \"./**/*.ts\" --write && eslint . --ext .ts --fix", "check-conflicts": "eslint --print-config tests/utils/func-test.ts | eslint-config-prettier-check", - "camunda:deploy": "node ./lib/src/deploy.js", - "camunda:create-instance": "node ./lib/src/create-process-instances.js", - "camunda:worker": "node ./lib/src/worker.js" + "deploy": "node ./lib/src/deploy.js", + "create-instance": "node ./lib/src/create-process-instances.js", + "worker": "node ./lib/src/worker.js" }, "repository": { "type": "git", diff --git a/examples/binding/src/deploy.ts b/examples/binding/src/deploy.ts index 53a89812..e8b8c881 100644 --- a/examples/binding/src/deploy.ts +++ b/examples/binding/src/deploy.ts @@ -9,7 +9,7 @@ import { IWorkflowClient } from '@villedemontreal/workit-types'; (async (): Promise => { const cm = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); - const path = `${process.cwd()}/bpmn/BPMN_P_DEMO.bpmn`; + const path = `${process.cwd()}/workflow/camunda/BPMN_P_DEMO.bpmn`; await cm.deployWorkflow(path); console.log('Success!'); })(); diff --git a/examples/binding/bpmn/BPMN_P_DEMO.bpmn b/examples/binding/workflow/camunda/BPMN_P_DEMO.bpmn similarity index 100% rename from examples/binding/bpmn/BPMN_P_DEMO.bpmn rename to examples/binding/workflow/camunda/BPMN_P_DEMO.bpmn diff --git a/examples/binding/workflow/stepfunctions/WORKFLOW_P_DEMO.json b/examples/binding/workflow/stepfunctions/WORKFLOW_P_DEMO.json new file mode 100644 index 00000000..a5f396ef --- /dev/null +++ b/examples/binding/workflow/stepfunctions/WORKFLOW_P_DEMO.json @@ -0,0 +1,117 @@ +{ + "Comment": "A description of my state machine", + "StartAt": "Parallel", + "States": { + "Parallel": { + "Type": "Parallel", + "Branches": [ + { + "StartAt": "Activity 1", + "States": { + "Activity 1": { + "Type": "Task", + "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken", + "Parameters": { + "MessageBody": { + "body.$": "$", + "properties": { + "activityId": "activity_1", + "retries.$": "$$.State.RetryCount", + "bpmnProcessId.$": "$$.StateMachine.Id", + "jobKey.$": "$$.Task.Token", + "workflowInstanceKey.$": "$$.Execution.Id" + } + }, + "QueueUrl": "" + }, + "End": true, + "Retry": [ + { + "ErrorEquals": [ + "States.ALL" + ], + "BackoffRate": 2, + "IntervalSeconds": 1, + "MaxAttempts": 5, + "Comment": "Basic Retrier" + } + ], + "TimeoutSeconds": 200 + } + } + }, + { + "StartAt": "Activity 2", + "States": { + "Activity 2": { + "Type": "Task", + "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken", + "Parameters": { + "MessageBody": { + "body.$": "$", + "properties": { + "activityId": "activity_2", + "retries.$": "$$.State.RetryCount", + "bpmnProcessId.$": "$$.StateMachine.Id", + "jobKey.$": "$$.Task.Token", + "workflowInstanceKey.$": "$$.Execution.Id" + } + }, + "QueueUrl": "" + }, + "End": true, + "Retry": [ + { + "ErrorEquals": [ + "States.ALL" + ], + "BackoffRate": 2, + "IntervalSeconds": 1, + "MaxAttempts": 5, + "Comment": "Basic Retrier" + } + ], + "TimeoutSeconds": 200 + } + } + }, + { + "StartAt": "Activity 3", + "States": { + "Activity 3": { + "Type": "Task", + "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken", + "Parameters": { + "MessageBody": { + "body.$": "$", + "properties": { + "activityId": "activity_3", + "retries.$": "$$.State.RetryCount", + "bpmnProcessId.$": "$$.StateMachine.Id", + "jobKey.$": "$$.Task.Token", + "workflowInstanceKey.$": "$$.Execution.Id" + } + }, + "QueueUrl": "" + }, + "End": true, + "Retry": [ + { + "ErrorEquals": [ + "States.ALL" + ], + "BackoffRate": 2, + "IntervalSeconds": 1, + "MaxAttempts": 5, + "Comment": "Basic Retrier" + } + ], + "TimeoutSeconds": 200 + } + } + } + ], + "End": true + } + } +} \ No newline at end of file diff --git a/examples/event/.eslintignore b/examples/event/.eslintignore deleted file mode 100644 index 18a3f204..00000000 --- a/examples/event/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules -lib -.vscode -coverage -*lock* -*.md -tests \ No newline at end of file diff --git a/examples/event/.eslintrc.js b/examples/event/.eslintrc.js deleted file mode 100644 index fc5425ee..00000000 --- a/examples/event/.eslintrc.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - "plugins": [ - "@typescript-eslint", - "header" - ], - "extends": [ - "airbnb-typescript/base", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "plugin:prettier/recommended", - "plugin:import/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json" - }, - "rules": { - ...require('../../eslint.rules.js'), - "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/CHANGELOG.md b/examples/event/CHANGELOG.md deleted file mode 100644 index c98af03f..00000000 --- a/examples/event/CHANGELOG.md +++ /dev/null @@ -1,172 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [6.0.3-dev](https://github.com/VilledeMontreal/workit/compare/v6.0.2-dev...v6.0.3-dev) (2024-02-28) - - -### Features - -* add aws step function client ([4d5b372](https://github.com/VilledeMontreal/workit/commit/4d5b372b603713d4c1472c25a7aaf6bba3980c9d)) - - - - - -## [6.0.2-dev](https://github.com/VilledeMontreal/workit/compare/v6.0.0-dev...v6.0.2-dev) (2023-12-13) - -**Note:** Version bump only for package workit-example-event - - - - - -## [5.0.2](https://github.com/VilledeMontreal/workit/compare/v5.0.1...v5.0.2) (2022-03-25) - -**Note:** Version bump only for package workit-example-event - - - - - -## [5.0.1](https://github.com/VilledeMontreal/workit/compare/v5.0.0...v5.0.1) (2022-02-18) - -**Note:** Version bump only for package workit-example-event - - - - - -# [5.0.0](https://github.com/VilledeMontreal/workit/compare/v4.2.9...v5.0.0) (2021-11-26) - -**Note:** Version bump only for package workit-example-event - - - - - -## [4.2.9](https://github.com/VilledeMontreal/workit/compare/v4.2.5...v4.2.9) (2021-07-27) - - -### Bug Fixes - -* prettier on workit-cli package ([#223](https://github.com/VilledeMontreal/workit/issues/223)) ([383de6d](https://github.com/VilledeMontreal/workit/commit/383de6d3890c43ca84cb54e8c20b2680447c7839)) - - - - - -## [4.2.8](https://github.com/VilledeMontreal/workit/compare/v4.2.5...v4.2.8) (2021-07-27) - - -### Bug Fixes - -* prettier on workit-cli package ([#223](https://github.com/VilledeMontreal/workit/issues/223)) ([383de6d](https://github.com/VilledeMontreal/workit/commit/383de6d3890c43ca84cb54e8c20b2680447c7839)) - - - - - -## [4.2.7](https://github.com/VilledeMontreal/workit/compare/v4.2.5...v4.2.7) (2021-07-27) - -**Note:** Version bump only for package workit-example-event - - - - - -## [4.2.5](https://github.com/VilledeMontreal/workit/compare/v4.2.3-alpha.0...v4.2.5) (2021-07-27) - -**Note:** Version bump only for package workit-example-event - - - - - -## [4.2.3-alpha.0](https://github.com/VilledeMontreal/workit/compare/v4.2.2...v4.2.3-alpha.0) (2020-11-27) - -**Note:** Version bump only for package workit-example-event - - - - - -## [4.2.2](https://github.com/VilledeMontreal/workit/compare/v4.2.1...v4.2.2) (2020-09-23) - -**Note:** Version bump only for package workit-example-event - - - - - -## [4.2.1](https://github.com/VilledeMontreal/workit/compare/v4.2.0...v4.2.1) (2020-09-23) - -**Note:** Version bump only for package workit-example-event - - - - - -# [4.2.0](https://github.com/VilledeMontreal/workit/compare/v4.1.0...v4.2.0) (2020-09-15) - - -### Bug Fixes - -* move from tslint to eslint ([#178](https://github.com/VilledeMontreal/workit/issues/178)) ([0dce14b](https://github.com/VilledeMontreal/workit/commit/0dce14b696649cdff886c3e7a0ffdbbd56b548d7)), closes [#159](https://github.com/VilledeMontreal/workit/issues/159) - - - - - -# 4.1.0 (2020-03-12) - - -### Features - -* improve tsconfig ([#106](https://github.com/VilledeMontreal/workit/issues/106)) ([77fb10c](https://github.com/VilledeMontreal/workit/commit/77fb10cee7abe9340d88d301a4066636f7898887)), closes [#105](https://github.com/VilledeMontreal/workit/issues/105) -* **opentelemetry:** switch to opentelemetry ([#110](https://github.com/VilledeMontreal/workit/issues/110)) ([c00356a](https://github.com/VilledeMontreal/workit/commit/c00356aa4d792cfc310825d526f40f7eccb33844)) - - - - - -## [2.0.4](https://github.com/VilledeMontreal/workit/compare/workit-example-event@2.0.3...workit-example-event@2.0.4) (2020-02-05) - -**Note:** Version bump only for package workit-example-event - - - - - -## [2.0.3](https://github.com/VilledeMontreal/workit/compare/workit-example-event@2.0.2...workit-example-event@2.0.3) (2020-01-24) - -**Note:** Version bump only for package workit-example-event - - - - - -## [2.0.2](https://github.com/VilledeMontreal/workit/compare/workit-example-event@2.0.1...workit-example-event@2.0.2) (2019-12-31) - -**Note:** Version bump only for package workit-example-event - - - - - -## [2.0.1](https://github.com/VilledeMontreal/workit/compare/workit-example-event@2.0.0...workit-example-event@2.0.1) (2019-12-31) - -**Note:** Version bump only for package workit-example-event - - - - - -# 2.0.0 (2019-12-31) - - -### Features - -* **opentelemetry:** switch to opentelemetry ([#110](https://github.com/VilledeMontreal/workit/issues/110)) ([c00356a](https://github.com/VilledeMontreal/workit/commit/c00356a)) -* improve tsconfig ([#106](https://github.com/VilledeMontreal/workit/issues/106)) ([77fb10c](https://github.com/VilledeMontreal/workit/commit/77fb10c)), closes [#105](https://github.com/VilledeMontreal/workit/issues/105) diff --git a/examples/event/LICENSE b/examples/event/LICENSE deleted file mode 100644 index a6362599..00000000 --- a/examples/event/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -Copyright 2019 Ville de Montreal - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/examples/event/README.md b/examples/event/README.md deleted file mode 100644 index 7234834a..00000000 --- a/examples/event/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Overview - -This example shows how to use [Workit](https://villedemontreal.github.io/workit/) to create a simple Node.js application - e.g. a worker that executes a simple task. You will learn how to use Camunda BPM platform as well as AWS Step function and using events. - -Have fun! - -## Installation - -```sh -$ # from this directory -$ npm install -``` - -(Optional) Setup, we can switch to `TAG.camundaBpm` or `TAG.stepFunction` in order to use both plateform (some comments are added in the example). - -```sh -$ # from this directory -$ npm run build -``` - -## Run the Application - -```sh -$ # from this directory -$ # deploy a bpmn provided in the example -$ npm camunda:deploy -$ # create instance(s) -$ npm camunda:create-instance -$ # run worker -$ npm camunda:worker -``` - -## Useful links -- For more information on workit, visit: - -## LICENSE - -MIT diff --git a/examples/event/bpmn/MESSAGE_EVENT.bpmn b/examples/event/bpmn/MESSAGE_EVENT.bpmn deleted file mode 100644 index dfccce9f..00000000 --- a/examples/event/bpmn/MESSAGE_EVENT.bpmn +++ /dev/null @@ -1,81 +0,0 @@ - - - - - SequenceFlow_0wiinkt - - - - - SequenceFlow_1pi4btk - - - - - SequenceFlow_0omxigo - - - - SequenceFlow_0y71l9s - - - - SequenceFlow_0wiinkt - SequenceFlow_0omxigo - - - SequenceFlow_1pi4btk - SequenceFlow_0y71l9s - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/event/package.json b/examples/event/package.json deleted file mode 100644 index ed10b23c..00000000 --- a/examples/event/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "workit-example-event", - "private": true, - "version": "6.0.3-dev", - "description": "Show how to send an event with Workit", - "main": "lib/src/worker.js", - "typings": "lib/src/worker.d.ts", - "scripts": { - "test": "echo \"no test specified\"", - "test:all": "echo \"no test specified\"", - "docs": "echo \"no doc specified\"", - "codecov": "echo \"no tests yet\"", - "compile": "rm -rf ./lib/ && npm run build", - "build": "tsc -p ./tsconfig.json", - "watch": "tsc -p ./tsconfig.json --watch", - "lint": "eslint . --ext .ts && prettier -l \"src/**/*.ts\"", - "lint-fix": "prettier \"./**/*.ts\" --write && eslint . --ext .ts --fix", - "check-conflicts": "eslint --print-config tests/utils/func-test.ts | eslint-config-prettier-check", - "camunda:deploy": "node ./lib/src/deploy.js", - "camunda:create-instance": "node ./lib/src/create-process-instances.js", - "camunda:worker": "node ./lib/src/worker.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/VilledeMontreal/workit.git" - }, - "devDependencies": { - "@types/node": "^20.10.8", - "@typescript-eslint/eslint-plugin": "^6.18.1", - "@typescript-eslint/parser": "^6.18.1", - "eslint": "^8.56.0", - "eslint-config-airbnb-typescript": "^17.1.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-header": "^3.1.1", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-prettier": "^5.1.3", - "prettier": "^3.1.1", - "typescript": "^4.9.5" - }, - "dependencies": { - "@villedemontreal/workit": "^6.0.3-dev", - "@villedemontreal/workit-core": "^6.0.3-dev", - "@villedemontreal/workit-types": "^6.0.3-dev", - "axios": "^1.6.2" - }, - "keywords": [ - "workit", - "example", - "camunda", - "stepFunction" - ], - "author": "Montreal City Authors", - "license": "MIT", - "bugs": { - "url": "https://github.com/VilledeMontreal/workit/issues" - }, - "homepage": "https://github.com/VilledeMontreal/workit#readme" -} diff --git a/examples/event/prettier.config.js b/examples/event/prettier.config.js deleted file mode 100644 index f0b3c3c8..00000000 --- a/examples/event/prettier.config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - printWidth: 120, - singleQuote: true -}; diff --git a/examples/event/src/create-process-instances.ts b/examples/event/src/create-process-instances.ts deleted file mode 100644 index 497158f0..00000000 --- a/examples/event/src/create-process-instances.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2024 Ville de Montreal. All rights reserved. - * Licensed under the MIT license. - * See LICENSE file in the project root for full license information. - */ - -import { SERVICE_IDENTIFIER as CORE_IDENTIFIER, TAG } from '@villedemontreal/workit'; -import { IoC } from '@villedemontreal/workit-core'; -import { IWorkflowClient } from '@villedemontreal/workit-types'; - -(async (): Promise => { - const cm = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); - await cm.publishMessage({ - correlation: {}, - name: '__MESSAGE_START_EVENT__', - variables: { amount: 1000 }, - messageId: undefined, - }); - - console.log('Success!'); -})(); diff --git a/examples/event/src/deploy.ts b/examples/event/src/deploy.ts deleted file mode 100644 index 17d9624e..00000000 --- a/examples/event/src/deploy.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2024 Ville de Montreal. All rights reserved. - * Licensed under the MIT license. - * See LICENSE file in the project root for full license information. - */ - -import { SERVICE_IDENTIFIER as CORE_IDENTIFIER, TAG } from '@villedemontreal/workit'; -import { IoC } from '@villedemontreal/workit-core'; -import { IWorkflowClient } from '@villedemontreal/workit-types'; - -(async (): Promise => { - const cm = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); - const path = `${process.cwd()}/bpmn/MESSAGE_EVENT.bpmn`; - await cm.deployWorkflow(path); - console.log('Success!'); -})(); diff --git a/examples/event/src/worker.ts b/examples/event/src/worker.ts deleted file mode 100644 index 091d2837..00000000 --- a/examples/event/src/worker.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2024 Ville de Montreal. All rights reserved. - * Licensed under the MIT license. - * See LICENSE file in the project root for full license information. - */ - -import { SERVICE_IDENTIFIER as CORE_IDENTIFIER, TAG } from '@villedemontreal/workit'; -import { IoC, Worker } from '@villedemontreal/workit-core'; -import { HelloWorldTask } from '../tasks/helloWorldTask'; - -enum LOCAL_IDENTIFIER { - sampleActivity = 'sample_activity', -} - -IoC.bindTo(HelloWorldTask, LOCAL_IDENTIFIER.sampleActivity); -const worker = IoC.get(CORE_IDENTIFIER.worker, TAG.camundaBpm); - -const stop = () => { - console.info('SIGTERM signal received.'); - console.log('Closing worker'); - worker - .stop() - .then(() => { - console.log('worker closed'); - process.exit(0); - }) - .catch((e: Error) => { - console.log(e); - process.exit(1); - }); -}; - -worker.start(); -worker.run(); - -process.on('SIGINT', stop); -process.on('SIGTERM', stop); diff --git a/examples/event/tasks/helloWorldTask.ts b/examples/event/tasks/helloWorldTask.ts deleted file mode 100644 index 5088391e..00000000 --- a/examples/event/tasks/helloWorldTask.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 Ville de Montreal. All rights reserved. - * Licensed under the MIT license. - * See LICENSE file in the project root for full license information. - */ - -import { TaskBase } from '@villedemontreal/workit-core'; -import { IMessage } from '@villedemontreal/workit-types'; -import axios from 'axios'; - -export class HelloWorldTask extends TaskBase { - public async execute(message: IMessage): Promise { - const { properties } = message; - - console.log(`Executing task: ${properties.activityId}`); - console.log(`${properties.bpmnProcessId}::${properties.processInstanceId} Servus!`); - - const response = await axios.get('https://jsonplaceholder.typicode.com/todos/1'); - - console.log('\ndata:'); - console.log(response.data); - - return message; - } -} diff --git a/examples/event/tsconfig.json b/examples/event/tsconfig.json deleted file mode 100644 index 715af149..00000000 --- a/examples/event/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.base", - "compilerOptions": { - "rootDir": ".", - "outDir": "lib", - }, - "exclude": [ - "lib", - "temp", - "node_modules", - "output", - "log", - "mocha", - ".*", - "tests" - ] -} diff --git a/examples/failure-strategy/README.md b/examples/failure-strategy/README.md index bb2a0eca..33884036 100644 --- a/examples/failure-strategy/README.md +++ b/examples/failure-strategy/README.md @@ -21,11 +21,11 @@ $ npm run build ```sh $ # from this directory $ # deploy a bpmn provided in the example -$ npm camunda:deploy +$ npm deploy $ # create instance(s) -$ npm camunda:create-instance +$ npm create-instance $ # run worker -$ npm camunda:worker +$ npm worker ``` ## Useful links diff --git a/examples/failure-strategy/package.json b/examples/failure-strategy/package.json index bdf1f2bb..f1c20bd2 100644 --- a/examples/failure-strategy/package.json +++ b/examples/failure-strategy/package.json @@ -16,9 +16,9 @@ "lint": "eslint . --ext .ts && prettier -l \"src/**/*.ts\"", "lint-fix": "prettier \"./**/*.ts\" --write && eslint . --ext .ts --fix", "check-conflicts": "eslint --print-config tests/utils/func-test.ts | eslint-config-prettier-check", - "camunda:deploy": "node ./lib/src/deploy.js", - "camunda:create-instance": "node ./lib/src/create-process-instances.js", - "camunda:worker": "node ./lib/src/worker.js" + "deploy": "node ./lib/src/deploy.js", + "create-instance": "node ./lib/src/create-process-instances.js", + "worker": "node ./lib/src/worker.js" }, "repository": { "type": "git", diff --git a/examples/failure-strategy/src/deploy.ts b/examples/failure-strategy/src/deploy.ts index bb5acdfc..3351468e 100644 --- a/examples/failure-strategy/src/deploy.ts +++ b/examples/failure-strategy/src/deploy.ts @@ -10,7 +10,7 @@ import { IWorkflowClient } from '@villedemontreal/workit-types'; (async (): Promise => { const cm = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); - const path = `${process.cwd()}/bpmn/BPMN_DEMO.bpmn`; + const path = `${process.cwd()}/workflow/camunda/BPMN_DEMO.bpmn`; await cm.deployWorkflow(path); console.log('Success!'); })(); diff --git a/examples/failure-strategy/bpmn/BPMN_DEMO.bpmn b/examples/failure-strategy/workflow/camunda/BPMN_DEMO.bpmn similarity index 100% rename from examples/failure-strategy/bpmn/BPMN_DEMO.bpmn rename to examples/failure-strategy/workflow/camunda/BPMN_DEMO.bpmn diff --git a/examples/failure-strategy/workflow/stepfunctions/WORKFLOW_DEMO.json b/examples/failure-strategy/workflow/stepfunctions/WORKFLOW_DEMO.json new file mode 100644 index 00000000..184fb39f --- /dev/null +++ b/examples/failure-strategy/workflow/stepfunctions/WORKFLOW_DEMO.json @@ -0,0 +1,37 @@ +{ + "Comment": "A description of my state machine", + "StartAt": "Activity", + "States": { + "Activity": { + "Type": "Task", + "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken", + "Parameters": { + "MessageBody": { + "body.$": "$", + "properties": { + "activityId": "sample_activity", + "retries.$": "$$.State.RetryCount", + "bpmnProcessId.$": "$$.StateMachine.Id", + "jobKey.$": "$$.Task.Token", + "workflowInstanceKey.$": "$$.Execution.Id" + } + }, + "QueueUrl": "" + }, + "End": true, + "Retry": [ + { + "ErrorEquals": [ + "States.ALL" + ], + "BackoffRate": 2, + "IntervalSeconds": 1, + "MaxAttempts": 5, + "Comment": "Basic Retrier" + } + ], + "HeartbeatSeconds": 30, + "TimeoutSeconds": 200 + } + } + } \ No newline at end of file diff --git a/examples/opentelemetry/README.md b/examples/opentelemetry/README.md index 74d2afc7..0bd28ac0 100644 --- a/examples/opentelemetry/README.md +++ b/examples/opentelemetry/README.md @@ -32,11 +32,11 @@ npm i && npm run build ``` and in order to deploy your bpmn and create a process instance in Camunda, run: ```bash -npm run camunda:deploy && npm run camunda:create-instance +npm run deploy && npm run create-instance ``` Finally, run the worker by running the following command: ```bash -npm run camunda:worker +npm run worker ``` You can then navigate to `http://localhost:16686` to access the Jaeger UI. diff --git a/examples/opentelemetry/package.json b/examples/opentelemetry/package.json index 1f6b3d48..128a2aa4 100644 --- a/examples/opentelemetry/package.json +++ b/examples/opentelemetry/package.json @@ -16,9 +16,9 @@ "lint": "eslint . --ext .ts && prettier -l \"src/**/*.ts\"", "lint-fix": "prettier \"./**/*.ts\" --write && eslint . --ext .ts --fix", "check-conflicts": "eslint --print-config tests/utils/func-test.ts | eslint-config-prettier-check", - "camunda:deploy": "node ./lib/src/deploy.js", - "camunda:create-instance": "node ./lib/src/create-process-instances.js", - "camunda:worker": "node ./lib/src/worker.js" + "deploy": "node ./lib/src/deploy.js", + "create-instance": "node ./lib/src/create-process-instances.js", + "worker": "node ./lib/src/worker.js" }, "repository": { "type": "git", diff --git a/examples/opentelemetry/src/deploy.ts b/examples/opentelemetry/src/deploy.ts index e17bf63a..d66bab0d 100644 --- a/examples/opentelemetry/src/deploy.ts +++ b/examples/opentelemetry/src/deploy.ts @@ -10,7 +10,7 @@ import { IWorkflowClient } from '@villedemontreal/workit-types'; (async (): Promise => { const cm = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); - const path = `${process.cwd()}/bpmn/BPMN_P_DEMO.bpmn`; + const path = `${process.cwd()}/workflow/camunda/BPMN_P_DEMO.bpmn`; await cm.deployWorkflow(path); console.log('Success!'); })(); diff --git a/examples/opentelemetry/bpmn/BPMN_P_DEMO.bpmn b/examples/opentelemetry/workflow/camunda/BPMN_P_DEMO.bpmn similarity index 100% rename from examples/opentelemetry/bpmn/BPMN_P_DEMO.bpmn rename to examples/opentelemetry/workflow/camunda/BPMN_P_DEMO.bpmn diff --git a/examples/parallel/README.md b/examples/parallel/README.md index c0be95cd..84de9a0f 100644 --- a/examples/parallel/README.md +++ b/examples/parallel/README.md @@ -21,11 +21,11 @@ $ npm run build ```sh $ # from this directory $ # deploy a bpmn provided in the example -$ npm camunda:deploy +$ npm deploy $ # create instance(s) -$ npm camunda:create-instance +$ npm create-instance $ # run worker -$ npm camunda:worker +$ npm worker ``` ## Useful links diff --git a/examples/parallel/package.json b/examples/parallel/package.json index 4fb5397a..759cdfbf 100644 --- a/examples/parallel/package.json +++ b/examples/parallel/package.json @@ -16,9 +16,9 @@ "lint": "eslint . --ext .ts && prettier -l \"src/**/*.ts\"", "lint-fix": "prettier \"./**/*.ts\" --write && eslint . --ext .ts --fix", "check-conflicts": "eslint --print-config tests/utils/func-test.ts | eslint-config-prettier-check", - "camunda:deploy": "node ./lib/src/deploy.js", - "camunda:create-instance": "node ./lib/src/create-process-instances.js", - "camunda:worker": "node ./lib/src/worker.js" + "deploy": "node ./lib/src/deploy.js", + "create-instance": "node ./lib/src/create-process-instances.js", + "worker": "node ./lib/src/worker.js" }, "repository": { "type": "git", diff --git a/examples/parallel/src/deploy.ts b/examples/parallel/src/deploy.ts index e17bf63a..24474aec 100644 --- a/examples/parallel/src/deploy.ts +++ b/examples/parallel/src/deploy.ts @@ -10,7 +10,7 @@ import { IWorkflowClient } from '@villedemontreal/workit-types'; (async (): Promise => { const cm = IoC.get(CORE_IDENTIFIER.client_manager, TAG.camundaBpm); - const path = `${process.cwd()}/bpmn/BPMN_P_DEMO.bpmn`; + const path = `${process.cwd()}/worklfow/camunda/BPMN_P_DEMO.bpmn`; await cm.deployWorkflow(path); console.log('Success!'); })(); diff --git a/examples/parallel/tsconfig.json b/examples/parallel/tsconfig.json index b04d8061..715af149 100644 --- a/examples/parallel/tsconfig.json +++ b/examples/parallel/tsconfig.json @@ -1,23 +1,8 @@ { + "extends": "../../tsconfig.base", "compilerOptions": { - "skipLibCheck": true, - "declaration": true, - "target": "es2017", - "module": "commonjs", - "charset": "utf8", - "suppressImplicitAnyIndexErrors": true, - "alwaysStrict": true, - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", - "allowSyntheticDefaultImports": true, - "noUnusedLocals": true, - "pretty": true, - "outDir": "./lib", - "sourceMap": true, - "strictPropertyInitialization": true, - "strictNullChecks": true + "rootDir": ".", + "outDir": "lib", }, "exclude": [ "lib", diff --git a/examples/parallel/bpmn/BPMN_P_DEMO.bpmn b/examples/parallel/workflow/camunda/BPMN_P_DEMO.bpmn similarity index 100% rename from examples/parallel/bpmn/BPMN_P_DEMO.bpmn rename to examples/parallel/workflow/camunda/BPMN_P_DEMO.bpmn diff --git a/examples/parallel/workflow/stepfunctions/WORKFLOW_P_DEMO.json b/examples/parallel/workflow/stepfunctions/WORKFLOW_P_DEMO.json new file mode 100644 index 00000000..a5f396ef --- /dev/null +++ b/examples/parallel/workflow/stepfunctions/WORKFLOW_P_DEMO.json @@ -0,0 +1,117 @@ +{ + "Comment": "A description of my state machine", + "StartAt": "Parallel", + "States": { + "Parallel": { + "Type": "Parallel", + "Branches": [ + { + "StartAt": "Activity 1", + "States": { + "Activity 1": { + "Type": "Task", + "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken", + "Parameters": { + "MessageBody": { + "body.$": "$", + "properties": { + "activityId": "activity_1", + "retries.$": "$$.State.RetryCount", + "bpmnProcessId.$": "$$.StateMachine.Id", + "jobKey.$": "$$.Task.Token", + "workflowInstanceKey.$": "$$.Execution.Id" + } + }, + "QueueUrl": "" + }, + "End": true, + "Retry": [ + { + "ErrorEquals": [ + "States.ALL" + ], + "BackoffRate": 2, + "IntervalSeconds": 1, + "MaxAttempts": 5, + "Comment": "Basic Retrier" + } + ], + "TimeoutSeconds": 200 + } + } + }, + { + "StartAt": "Activity 2", + "States": { + "Activity 2": { + "Type": "Task", + "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken", + "Parameters": { + "MessageBody": { + "body.$": "$", + "properties": { + "activityId": "activity_2", + "retries.$": "$$.State.RetryCount", + "bpmnProcessId.$": "$$.StateMachine.Id", + "jobKey.$": "$$.Task.Token", + "workflowInstanceKey.$": "$$.Execution.Id" + } + }, + "QueueUrl": "" + }, + "End": true, + "Retry": [ + { + "ErrorEquals": [ + "States.ALL" + ], + "BackoffRate": 2, + "IntervalSeconds": 1, + "MaxAttempts": 5, + "Comment": "Basic Retrier" + } + ], + "TimeoutSeconds": 200 + } + } + }, + { + "StartAt": "Activity 3", + "States": { + "Activity 3": { + "Type": "Task", + "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken", + "Parameters": { + "MessageBody": { + "body.$": "$", + "properties": { + "activityId": "activity_3", + "retries.$": "$$.State.RetryCount", + "bpmnProcessId.$": "$$.StateMachine.Id", + "jobKey.$": "$$.Task.Token", + "workflowInstanceKey.$": "$$.Execution.Id" + } + }, + "QueueUrl": "" + }, + "End": true, + "Retry": [ + { + "ErrorEquals": [ + "States.ALL" + ], + "BackoffRate": 2, + "IntervalSeconds": 1, + "MaxAttempts": 5, + "Comment": "Basic Retrier" + } + ], + "TimeoutSeconds": 200 + } + } + } + ], + "End": true + } + } +} \ No newline at end of file diff --git a/getting-started/README.md b/getting-started/README.md index 3a8ff9c2..65e2fae2 100644 --- a/getting-started/README.md +++ b/getting-started/README.md @@ -20,18 +20,18 @@ Make sure to have Camunda running at http://localhost:8080/camunda (user/pass de Run in your terminal in the root folder: ```bash -npm run camunda:deploy +npm run deploy ``` Now, You should have a `Demo` process definition visible here: http://localhost:8080/camunda/app/cockpit/default/#/processes ```bash -npm run camunda:create-instance +npm run create-instance ``` Now, in your `Demo` process definition, you should see the bpmn with 1 instance attached to `Activity`. If not, look that you are on the right bpmn version. ```bash -npm run camunda:worker +npm run worker ``` You should see in the console, all activities crushed by the worker. Now, if you look back to the `Demo` Bpmn (refresh the page), you see that the instance has disappeared. @@ -54,7 +54,7 @@ After cloning the repo, open a terminal and go to `examples/basic` Edit the file at `examples/basic/src/deploy.ts`, change the tag to `TAG.stepFunction` and *MUST* use a different bpmn file (one compatible with AWS Step function as content is different) `${ process.cwd() }/bpmn/stepfunction/BPMN_DEMO.bpmn` (the stepfunction folder contains `BPMN_DEMO.json`) ```bash -npm run build && npm run camunda:deploy +npm run build && npm run deploy ``` Now, You should have a `Demo` process definition visible here: http://localhost:8080/#/instances?filter=%7B%22active%22%3Atrue%2C%22incidents%22%3Atrue%2C%22workflow%22%3A%22BPMN_DEMO%22%2C%22version%22%3A%221%22%7D @@ -66,7 +66,7 @@ TODO: Edit the file at `examples/basic/src/create-process-instances.ts`, change the tag to `TAG.stepFunction` ```bash -npm run build && npm run camunda:create-instance +npm run build && npm run create-instance ``` Now, in your `Demo` process definition, you should see the bpmn with 1 instance attached to `Activity`. If not look that you are on the right bpmn version. @@ -74,7 +74,7 @@ If not look that you are on the right bpmn version. Edit the file at `examples/basic/src/worker.ts`, change the tag to `TAG.stepFunction` ```bash -npm run build && npm run camunda:worker +npm run build && npm run worker ``` TODO: @@ -109,11 +109,11 @@ npm i && npm run build ``` and in order to deploy your bpmn and create a process instance in Camunda, run: ```bash -npm run camunda:deploy && npm run camunda:create-instance +npm run deploy && npm run create-instance ``` Finally, run the worker by running the following command: ```bash -npm run camunda:worker +npm run worker ``` You can then navigate to `http://localhost:16686` to access the Jaeger UI.