From 0280431f25b29fd88318eee44f17a46da3279ca3 Mon Sep 17 00:00:00 2001 From: Mathieu Collette Date: Wed, 17 Jul 2024 15:17:59 +0200 Subject: [PATCH] refactor: files --- .vscode/extensions.json | 3 +- apps/pathway-design/server/cucumber.js | 4 +-- .../server/src/app/app.controller.ts | 2 -- bunfig.toml | 4 +++ docs/nx/generators.md | 6 ++-- .../{creation => }/client/.keep | 0 .../business/entities/pathway/README.md | 7 ---- .../business/entities/pathway/src/index.ts | 1 - .../entities/pathway/src/lib/pathway.ts | 7 ---- .../usecases/init-pathway/cucumber.js | 14 -------- .../usecases/init-pathway/src/index.ts | 1 - .../init-pathway/src/lib/index.feature | 5 --- .../init-pathway/src/lib/index.step.ts | 23 ------------ .../init-pathway/src/lib/index.usecase.ts | 7 ---- libs/pathway-design/dashboard/.keep | 0 .../{creation => }/server/application/.keep | 0 .../server/business/entities/pathway/.swcrc | 7 +++- .../business/entities/pathway/README.md | 7 ++++ .../business/entities/pathway/biome.json | 4 +-- .../business/entities/pathway/package.json | 2 +- .../business/entities/pathway/project.json | 16 ++++----- .../business/entities/pathway/src/index.ts | 4 +++ .../entities/pathway/src/lib/pathway.ts | 17 +++++++++ .../business/entities/pathway/tsconfig.json | 2 +- .../entities/pathway/tsconfig.lib.json | 2 +- .../business/usecases/init-pathway/.swcrc | 0 .../business/usecases/init-pathway/biome.json | 4 +-- .../usecases/init-pathway/cucumber.js | 15 ++++++++ .../usecases/init-pathway/package.json | 2 +- .../usecases/init-pathway/project.json | 12 +++---- .../usecases/init-pathway/src/index.ts | 1 + .../init-pathway/src/lib/index.feature | 9 +++++ .../init-pathway/src/lib/index.step.ts | 35 +++++++++++++++++++ .../init-pathway/src/lib/index.usecase.ts | 21 +++++++++++ .../usecases/init-pathway/tsconfig.json | 2 +- .../usecases/init-pathway/tsconfig.lib.json | 2 +- .../usecases/init-pathway/tsconfig.spec.json | 0 .../server/infrastructure/.keep | 0 .../{creation => }/server/presenters/.keep | 0 tsconfig.base.json | 8 ++--- 40 files changed, 153 insertions(+), 103 deletions(-) create mode 100644 bunfig.toml rename libs/pathway-design/{creation => }/client/.keep (100%) delete mode 100644 libs/pathway-design/creation/server/business/entities/pathway/README.md delete mode 100644 libs/pathway-design/creation/server/business/entities/pathway/src/index.ts delete mode 100644 libs/pathway-design/creation/server/business/entities/pathway/src/lib/pathway.ts delete mode 100644 libs/pathway-design/creation/server/business/usecases/init-pathway/cucumber.js delete mode 100644 libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts delete mode 100644 libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature delete mode 100644 libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts delete mode 100644 libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.usecase.ts delete mode 100644 libs/pathway-design/dashboard/.keep rename libs/pathway-design/{creation => }/server/application/.keep (100%) rename libs/pathway-design/{creation => }/server/business/entities/pathway/.swcrc (78%) create mode 100644 libs/pathway-design/server/business/entities/pathway/README.md rename libs/pathway-design/{creation => }/server/business/entities/pathway/biome.json (67%) rename libs/pathway-design/{creation => }/server/business/entities/pathway/package.json (72%) rename libs/pathway-design/{creation => }/server/business/entities/pathway/project.json (53%) create mode 100644 libs/pathway-design/server/business/entities/pathway/src/index.ts create mode 100644 libs/pathway-design/server/business/entities/pathway/src/lib/pathway.ts rename libs/pathway-design/{creation => }/server/business/entities/pathway/tsconfig.json (88%) rename libs/pathway-design/{creation => }/server/business/entities/pathway/tsconfig.lib.json (89%) rename libs/pathway-design/{creation => }/server/business/usecases/init-pathway/.swcrc (100%) rename libs/pathway-design/{creation => }/server/business/usecases/init-pathway/biome.json (67%) create mode 100644 libs/pathway-design/server/business/usecases/init-pathway/cucumber.js rename libs/pathway-design/{creation => }/server/business/usecases/init-pathway/package.json (64%) rename libs/pathway-design/{creation => }/server/business/usecases/init-pathway/project.json (65%) create mode 100644 libs/pathway-design/server/business/usecases/init-pathway/src/index.ts create mode 100644 libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.feature create mode 100644 libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.step.ts create mode 100644 libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.usecase.ts rename libs/pathway-design/{creation => }/server/business/usecases/init-pathway/tsconfig.json (89%) rename libs/pathway-design/{creation => }/server/business/usecases/init-pathway/tsconfig.lib.json (78%) rename libs/pathway-design/{creation => }/server/business/usecases/init-pathway/tsconfig.spec.json (100%) rename libs/pathway-design/{creation => }/server/infrastructure/.keep (100%) rename libs/pathway-design/{creation => }/server/presenters/.keep (100%) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 1081004a..07eb684a 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -5,6 +5,7 @@ "oven.bun-vscode", "biomejs.biome", "cucumberopen.cucumber-official", - "github.vscode-github-actions" + "github.vscode-github-actions", + "tamasfe.even-better-toml" ] } diff --git a/apps/pathway-design/server/cucumber.js b/apps/pathway-design/server/cucumber.js index 8a01b291..8bd56352 100644 --- a/apps/pathway-design/server/cucumber.js +++ b/apps/pathway-design/server/cucumber.js @@ -3,8 +3,6 @@ module.exports = { paths: ['apps/pathway-design/server/src/tests/**/*.feature'], requireModule: ['ts-node/register', 'tsconfig-paths/register'], require: ['apps/pathway-design/server/src/tests/**/*.ts'], - format: [ - 'json:dist/apps/pathway-design/server/tests/reports/cucumber_report.json', - ], + format: ['json:dist/reports/apps/pathway-design/cucumber_report.json'], }, }; diff --git a/apps/pathway-design/server/src/app/app.controller.ts b/apps/pathway-design/server/src/app/app.controller.ts index 80b9a310..5151f57c 100644 --- a/apps/pathway-design/server/src/app/app.controller.ts +++ b/apps/pathway-design/server/src/app/app.controller.ts @@ -1,6 +1,5 @@ import { Controller, Get, Inject } from '@nestjs/common'; -import { PathwayDesignCreationServerBusinessEntitiesPathway } from '@bewoak/pathway-design-creation-server-business-entities-pathway'; import { AppService } from './app.service'; @Controller() @@ -9,7 +8,6 @@ export class AppController { @Get() getData() { - new PathwayDesignCreationServerBusinessEntitiesPathway('name'); return this.appService.getData(); } } diff --git a/bunfig.toml b/bunfig.toml new file mode 100644 index 00000000..34540c0f --- /dev/null +++ b/bunfig.toml @@ -0,0 +1,4 @@ +[test] +coverage = true +coverageReporter = ["text", "lcov"] +coverageDir = "dist/reports/coverage" diff --git a/docs/nx/generators.md b/docs/nx/generators.md index 354b6570..0de4995e 100644 --- a/docs/nx/generators.md +++ b/docs/nx/generators.md @@ -7,17 +7,17 @@ ### Create a Nx:Node:Library ```bash -bun run nx generate @nx/js:lib --name=init-pathway --bundler=swc --directory=libs/pathway-design/creation/server/business/usecases --importPath=@bewoak/pathway-design-creation-server-business-usescases-init-pathway --publishable --linter=none --minimal --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived -d +bun run nx generate @nx/js:lib --name=init-pathway --bundler=swc --directory=libs/pathway-design/server/business/usecases --importPath=@bewoak/pathway-design-server-business-usescases-init-pathway --publishable --linter=none --minimal --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived -d ``` ### Create a Nx:Nest:Library ```bash -bun run nx generate @nx/nest:lib --name=pathway --buildable --publishable --directory=libs/pathway-design/creation/server/business/entities --importPath=@bewoak/pathway-design-creation-server-business-entities-pathway --linter=none --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived --standaloneConfig -d +bun run nx generate @nx/nest:lib --name=pathway --buildable --publishable --directory=libs/pathway-design/server/business/entities --importPath=@bewoak/pathway-design-server-business-entities-pathway --linter=none --strict --tags=type:business:pathway-design:server --unitTestRunner=none --projectNameAndRootFormat=derived --standaloneConfig -d ``` ### Convert a Nx:Library to swc compiler ```bash -bun run nx g @nx/js:convert-to-swc pathway-design-creation-server-business-entities-pathway +bun run nx g @nx/js:convert-to-swc pathway-design-server-business-entities-pathway ``` diff --git a/libs/pathway-design/creation/client/.keep b/libs/pathway-design/client/.keep similarity index 100% rename from libs/pathway-design/creation/client/.keep rename to libs/pathway-design/client/.keep diff --git a/libs/pathway-design/creation/server/business/entities/pathway/README.md b/libs/pathway-design/creation/server/business/entities/pathway/README.md deleted file mode 100644 index e871e149..00000000 --- a/libs/pathway-design/creation/server/business/entities/pathway/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# pathway-design-creation-server-business-entities-pathway - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build pathway-design-creation-server-business-entities-pathway` to build the library. diff --git a/libs/pathway-design/creation/server/business/entities/pathway/src/index.ts b/libs/pathway-design/creation/server/business/entities/pathway/src/index.ts deleted file mode 100644 index 4b3f2a97..00000000 --- a/libs/pathway-design/creation/server/business/entities/pathway/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { PathwayDesignCreationServerBusinessEntitiesPathway } from './lib/pathway'; diff --git a/libs/pathway-design/creation/server/business/entities/pathway/src/lib/pathway.ts b/libs/pathway-design/creation/server/business/entities/pathway/src/lib/pathway.ts deleted file mode 100644 index 776c3151..00000000 --- a/libs/pathway-design/creation/server/business/entities/pathway/src/lib/pathway.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class PathwayDesignCreationServerBusinessEntitiesPathway { - name: string; - - constructor(name: string) { - this.name = name; - } -} diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/cucumber.js b/libs/pathway-design/creation/server/business/usecases/init-pathway/cucumber.js deleted file mode 100644 index fcbb0206..00000000 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/cucumber.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - default: { - paths: [ - 'libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/**/*.feature', - ], - requireModule: ['ts-node/register', 'tsconfig-paths/register'], - require: [ - 'libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/**/*.ts', - ], - format: [ - 'json:dist/libs/pathway-design/creation/server/business/usecases/init-pathway/tests/cucumber_report.json', - ], - }, -}; diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts deleted file mode 100644 index b731a5e9..00000000 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { PathwayDesignCreationServerBusinessUsecasesInitPathway } from './lib/index.usecase'; diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature deleted file mode 100644 index 46855e0e..00000000 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.feature +++ /dev/null @@ -1,5 +0,0 @@ -Feature: Initiate Pathway - - Scenario: I want to initiate a pathway - When I initiate a pathway with the name "My Pathway" - Then I should retrieve a pathway initiated with the name "My Pathway" diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts deleted file mode 100644 index 747d0cb4..00000000 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.step.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { PathwayDesignCreationServerBusinessEntitiesPathway } from '@bewoak/pathway-design-creation-server-business-entities-pathway'; -import { binding, then, when } from 'cucumber-tsflow'; -import { strict as assert } from 'node:assert'; -import { PathwayDesignCreationServerBusinessUsecasesInitPathway } from './index.usecase'; - -@binding() -export default class ControllerSteps { - private initPathwayUsecase: PathwayDesignCreationServerBusinessUsecasesInitPathway = - new PathwayDesignCreationServerBusinessUsecasesInitPathway(); - private pathway: - | PathwayDesignCreationServerBusinessEntitiesPathway - | undefined; - - @when('I initiate a pathway with the name {string}') - public whenIInitiateAPathway(name: string) { - this.pathway = this.initPathwayUsecase?.execute({ name }); - } - - @then('I should retrieve a pathway initiated with the name {string}') - public thenIShouldSeeAPathwayInitiated(name: string) { - assert.equal(this.pathway?.name, name); - } -} diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.usecase.ts b/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.usecase.ts deleted file mode 100644 index a5fbc086..00000000 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/src/lib/index.usecase.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { PathwayDesignCreationServerBusinessEntitiesPathway } from '@bewoak/pathway-design-creation-server-business-entities-pathway'; - -export class PathwayDesignCreationServerBusinessUsecasesInitPathway { - execute({ name }: { name: string }) { - return new PathwayDesignCreationServerBusinessEntitiesPathway(name); - } -} diff --git a/libs/pathway-design/dashboard/.keep b/libs/pathway-design/dashboard/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/libs/pathway-design/creation/server/application/.keep b/libs/pathway-design/server/application/.keep similarity index 100% rename from libs/pathway-design/creation/server/application/.keep rename to libs/pathway-design/server/application/.keep diff --git a/libs/pathway-design/creation/server/business/entities/pathway/.swcrc b/libs/pathway-design/server/business/entities/pathway/.swcrc similarity index 78% rename from libs/pathway-design/creation/server/business/entities/pathway/.swcrc rename to libs/pathway-design/server/business/entities/pathway/.swcrc index 96c917cd..c23557a2 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/.swcrc +++ b/libs/pathway-design/server/business/entities/pathway/.swcrc @@ -18,5 +18,10 @@ "type": "es6" }, "sourceMaps": true, - "exclude": [".*\\.spec.tsx?$", ".*\\.test.tsx?$", ".*.js$"] + "exclude": [ + ".*\\.spec.tsx?$", + ".*\\.test.tsx?$", + ".*\\.step.tsx?$", + ".*.js$" + ] } diff --git a/libs/pathway-design/server/business/entities/pathway/README.md b/libs/pathway-design/server/business/entities/pathway/README.md new file mode 100644 index 00000000..f1ef96b1 --- /dev/null +++ b/libs/pathway-design/server/business/entities/pathway/README.md @@ -0,0 +1,7 @@ +# pathway-design-server-business-entities-pathway + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build pathway-design-server-business-entities-pathway` to build the library. diff --git a/libs/pathway-design/creation/server/business/entities/pathway/biome.json b/libs/pathway-design/server/business/entities/pathway/biome.json similarity index 67% rename from libs/pathway-design/creation/server/business/entities/pathway/biome.json rename to libs/pathway-design/server/business/entities/pathway/biome.json index 8732f7eb..6f3a18f1 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/biome.json +++ b/libs/pathway-design/server/business/entities/pathway/biome.json @@ -1,6 +1,6 @@ { - "$schema": "../../../../../../../node_modules/@biomejs/biome/configuration_schema.json", - "extends": ["../../../../../../../biome.json"], + "$schema": "../../../../../../node_modules/@biomejs/biome/configuration_schema.json", + "extends": ["../../../../../../biome.json"], "linter": { "rules": { "nursery": { diff --git a/libs/pathway-design/creation/server/business/entities/pathway/package.json b/libs/pathway-design/server/business/entities/pathway/package.json similarity index 72% rename from libs/pathway-design/creation/server/business/entities/pathway/package.json rename to libs/pathway-design/server/business/entities/pathway/package.json index 04afe808..60e51ad4 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/package.json +++ b/libs/pathway-design/server/business/entities/pathway/package.json @@ -1,5 +1,5 @@ { - "name": "@bewoak/pathway-design-creation-server-business-entities-pathway", + "name": "@bewoak/pathway-design-server-business-entities-pathway", "version": "0.0.1", "dependencies": { "@swc/helpers": "~0.5.11", diff --git a/libs/pathway-design/creation/server/business/entities/pathway/project.json b/libs/pathway-design/server/business/entities/pathway/project.json similarity index 53% rename from libs/pathway-design/creation/server/business/entities/pathway/project.json rename to libs/pathway-design/server/business/entities/pathway/project.json index 363a6ae5..d33d1f83 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/project.json +++ b/libs/pathway-design/server/business/entities/pathway/project.json @@ -1,7 +1,7 @@ { - "name": "pathway-design-creation-server-business-entities-pathway", - "$schema": "../../../../../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/pathway-design/creation/server/business/entities/pathway/src", + "name": "pathway-design-server-business-entities-pathway", + "$schema": "../../../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/pathway-design/server/business/entities/pathway/src", "projectType": "library", "release": { "version": { @@ -17,12 +17,12 @@ "executor": "@nx/js:swc", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/libs/pathway-design/creation/server/business/entities/pathway", - "tsConfig": "libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json", - "packageJson": "libs/pathway-design/creation/server/business/entities/pathway/package.json", - "main": "libs/pathway-design/creation/server/business/entities/pathway/src/index.ts", + "outputPath": "dist/libs/pathway-design/server/business/entities/pathway", + "tsConfig": "libs/pathway-design/server/business/entities/pathway/tsconfig.lib.json", + "packageJson": "libs/pathway-design/server/business/entities/pathway/package.json", + "main": "libs/pathway-design/server/business/entities/pathway/src/index.ts", "assets": [ - "libs/pathway-design/creation/server/business/entities/pathway/*.md" + "libs/pathway-design/server/business/entities/pathway/*.md" ] } }, diff --git a/libs/pathway-design/server/business/entities/pathway/src/index.ts b/libs/pathway-design/server/business/entities/pathway/src/index.ts new file mode 100644 index 00000000..a2ef4292 --- /dev/null +++ b/libs/pathway-design/server/business/entities/pathway/src/index.ts @@ -0,0 +1,4 @@ +export { + PathwayDesignServerBusinessEntitiesPathway, + PathwayDesignServerBusinessEntitiesPathwayInitDto, +} from './lib/pathway'; diff --git a/libs/pathway-design/server/business/entities/pathway/src/lib/pathway.ts b/libs/pathway-design/server/business/entities/pathway/src/lib/pathway.ts new file mode 100644 index 00000000..011bccae --- /dev/null +++ b/libs/pathway-design/server/business/entities/pathway/src/lib/pathway.ts @@ -0,0 +1,17 @@ +export class PathwayDesignServerBusinessEntitiesPathway { + name: string | undefined; + description: string | undefined; + field: string | undefined; + + init(data: PathwayDesignServerBusinessEntitiesPathwayInitDto) { + this.name = data.name; + this.description = data.description; + this.field = data.field; + } +} + +export interface PathwayDesignServerBusinessEntitiesPathwayInitDto { + name: string; + description: string; + field: string; +} diff --git a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.json b/libs/pathway-design/server/business/entities/pathway/tsconfig.json similarity index 88% rename from libs/pathway-design/creation/server/business/entities/pathway/tsconfig.json rename to libs/pathway-design/server/business/entities/pathway/tsconfig.json index e4a17eff..709eeeaf 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.json +++ b/libs/pathway-design/server/business/entities/pathway/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../../../../../tsconfig.base.json", + "extends": "../../../../../../tsconfig.base.json", "compilerOptions": { "module": "ES2022", "forceConsistentCasingInFileNames": true, diff --git a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json b/libs/pathway-design/server/business/entities/pathway/tsconfig.lib.json similarity index 89% rename from libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json rename to libs/pathway-design/server/business/entities/pathway/tsconfig.lib.json index bffd7342..8cc74955 100644 --- a/libs/pathway-design/creation/server/business/entities/pathway/tsconfig.lib.json +++ b/libs/pathway-design/server/business/entities/pathway/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../../../../../../dist/out-tsc", + "outDir": "../../../../../../dist/out-tsc", "declaration": true, "types": ["node"], "target": "es2022", diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/.swcrc b/libs/pathway-design/server/business/usecases/init-pathway/.swcrc similarity index 100% rename from libs/pathway-design/creation/server/business/usecases/init-pathway/.swcrc rename to libs/pathway-design/server/business/usecases/init-pathway/.swcrc diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/biome.json b/libs/pathway-design/server/business/usecases/init-pathway/biome.json similarity index 67% rename from libs/pathway-design/creation/server/business/usecases/init-pathway/biome.json rename to libs/pathway-design/server/business/usecases/init-pathway/biome.json index 8732f7eb..6f3a18f1 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/biome.json +++ b/libs/pathway-design/server/business/usecases/init-pathway/biome.json @@ -1,6 +1,6 @@ { - "$schema": "../../../../../../../node_modules/@biomejs/biome/configuration_schema.json", - "extends": ["../../../../../../../biome.json"], + "$schema": "../../../../../../node_modules/@biomejs/biome/configuration_schema.json", + "extends": ["../../../../../../biome.json"], "linter": { "rules": { "nursery": { diff --git a/libs/pathway-design/server/business/usecases/init-pathway/cucumber.js b/libs/pathway-design/server/business/usecases/init-pathway/cucumber.js new file mode 100644 index 00000000..39b94535 --- /dev/null +++ b/libs/pathway-design/server/business/usecases/init-pathway/cucumber.js @@ -0,0 +1,15 @@ +module.exports = { + default: { + paths: [ + 'libs/pathway-design/server/business/usecases/init-pathway/src/lib/**/*.feature', + ], + requireModule: ['ts-node/register', 'tsconfig-paths/register'], + require: [ + 'libs/pathway-design/server/business/usecases/init-pathway/src/lib/**/*.ts', + ], + format: [ + 'json:dist/reports/libs/pathway-design/init-pathway/tests/index.json', + 'html:dist/reports/libs/pathway-design/init-pathway/test/index.html', + ], + }, +}; diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/package.json b/libs/pathway-design/server/business/usecases/init-pathway/package.json similarity index 64% rename from libs/pathway-design/creation/server/business/usecases/init-pathway/package.json rename to libs/pathway-design/server/business/usecases/init-pathway/package.json index fcf0619d..e01f9e61 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/package.json +++ b/libs/pathway-design/server/business/usecases/init-pathway/package.json @@ -1,5 +1,5 @@ { - "name": "@bewoak/pathway-design-creation-server-business-usescases-init-pathway", + "name": "@bewoak/pathway-design-server-business-usescases-init-pathway", "version": "0.0.1", "dependencies": { "@swc/helpers": "~0.5.11" diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/project.json b/libs/pathway-design/server/business/usecases/init-pathway/project.json similarity index 65% rename from libs/pathway-design/creation/server/business/usecases/init-pathway/project.json rename to libs/pathway-design/server/business/usecases/init-pathway/project.json index 1d84e961..4ab155e9 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/project.json +++ b/libs/pathway-design/server/business/usecases/init-pathway/project.json @@ -1,16 +1,16 @@ { - "name": "pathway-design-creation-server-business-usecases-init-pathway", - "$schema": "../../../../../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/pathway-design/creation/server/business/usecases/init-pathway/src", + "name": "pathway-design-server-business-usecases-init-pathway", + "$schema": "../../../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/pathway-design/server/business/usecases/init-pathway/src", "projectType": "library", "targets": { "build": { "executor": "@nx/js:swc", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/libs/pathway-design/creation/server/business/usecases/init-pathway", - "main": "libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts", - "tsConfig": "libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.lib.json", + "outputPath": "dist/libs/pathway-design/server/business/usecases/init-pathway", + "main": "libs/pathway-design/server/business/usecases/init-pathway/src/index.ts", + "tsConfig": "libs/pathway-design/server/business/usecases/init-pathway/tsconfig.lib.json", "assets": [] } }, diff --git a/libs/pathway-design/server/business/usecases/init-pathway/src/index.ts b/libs/pathway-design/server/business/usecases/init-pathway/src/index.ts new file mode 100644 index 00000000..2063f00b --- /dev/null +++ b/libs/pathway-design/server/business/usecases/init-pathway/src/index.ts @@ -0,0 +1 @@ +export { PathwayDesignServerBusinessUsecasesInitPathway } from './lib/index.usecase'; diff --git a/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.feature b/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.feature new file mode 100644 index 00000000..6d60aca2 --- /dev/null +++ b/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.feature @@ -0,0 +1,9 @@ +Feature: Initiate a Pathway + + Scenario: I want to initiate a pathway + When I want to initiate a pathway with these data + | name | description | field | + | My Pathway | A test pathway | biology | + Then I should retrieve a pathway initiated with its data + | name | description | field | + | My Pathway | A test pathway | biology | diff --git a/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.step.ts b/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.step.ts new file mode 100644 index 00000000..6c725736 --- /dev/null +++ b/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.step.ts @@ -0,0 +1,35 @@ +import type { + PathwayDesignServerBusinessEntitiesPathway, + PathwayDesignServerBusinessEntitiesPathwayInitDto, +} from '@bewoak/pathway-design-server-business-entities-pathway'; +import type { DataTable } from '@cucumber/cucumber'; +import { binding, then, when } from 'cucumber-tsflow'; +import { strict as assert } from 'node:assert'; +import { PathwayDesignServerBusinessUsecasesInitPathway } from './index.usecase'; + +@binding() +export default class ControllerSteps { + private initPathwayUsecase: PathwayDesignServerBusinessUsecasesInitPathway = + new PathwayDesignServerBusinessUsecasesInitPathway(); + private pathway: PathwayDesignServerBusinessEntitiesPathway | undefined; + + @when('I want to initiate a pathway with these data') + public whenIInitiateAPathway(dataTable: DataTable) { + const data = + dataTable.hashes()[0] as unknown as PathwayDesignServerBusinessEntitiesPathwayInitDto; + this.pathway = this.initPathwayUsecase.execute({ + name: data.name, + description: data.description, + field: data.field, + }); + } + + @then('I should retrieve a pathway initiated with its data') + public thenIShouldSeeAPathwayInitiated(dataTable: DataTable) { + const data = + dataTable.hashes()[0] as unknown as PathwayDesignServerBusinessEntitiesPathwayInitDto; + assert.equal(this.pathway?.name, data.name); + assert.equal(this.pathway?.description, data.description); + assert.equal(this.pathway?.field, data.field); + } +} diff --git a/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.usecase.ts b/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.usecase.ts new file mode 100644 index 00000000..86aa26ba --- /dev/null +++ b/libs/pathway-design/server/business/usecases/init-pathway/src/lib/index.usecase.ts @@ -0,0 +1,21 @@ +import { + PathwayDesignServerBusinessEntitiesPathway, + type PathwayDesignServerBusinessEntitiesPathwayInitDto, +} from '@bewoak/pathway-design-server-business-entities-pathway'; + +export class PathwayDesignServerBusinessUsecasesInitPathway { + execute({ + name, + description, + field, + }: PathwayDesignServerBusinessEntitiesPathwayInitDto) { + const pathway = new PathwayDesignServerBusinessEntitiesPathway(); + pathway.init({ + name, + description, + field, + }); + + return pathway; + } +} diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.json b/libs/pathway-design/server/business/usecases/init-pathway/tsconfig.json similarity index 89% rename from libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.json rename to libs/pathway-design/server/business/usecases/init-pathway/tsconfig.json index fabbd6c9..27fb839a 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.json +++ b/libs/pathway-design/server/business/usecases/init-pathway/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../../../../../tsconfig.base.json", + "extends": "../../../../../../tsconfig.base.json", "compilerOptions": { "module": "es2022", "forceConsistentCasingInFileNames": true, diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.lib.json b/libs/pathway-design/server/business/usecases/init-pathway/tsconfig.lib.json similarity index 78% rename from libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.lib.json rename to libs/pathway-design/server/business/usecases/init-pathway/tsconfig.lib.json index 89c519b4..8f8c5e7e 100644 --- a/libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.lib.json +++ b/libs/pathway-design/server/business/usecases/init-pathway/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../../../../../../dist/out-tsc", + "outDir": "../../../../../../dist/out-tsc", "types": ["node"] }, "include": ["src/**/*.ts"], diff --git a/libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.spec.json b/libs/pathway-design/server/business/usecases/init-pathway/tsconfig.spec.json similarity index 100% rename from libs/pathway-design/creation/server/business/usecases/init-pathway/tsconfig.spec.json rename to libs/pathway-design/server/business/usecases/init-pathway/tsconfig.spec.json diff --git a/libs/pathway-design/creation/server/infrastructure/.keep b/libs/pathway-design/server/infrastructure/.keep similarity index 100% rename from libs/pathway-design/creation/server/infrastructure/.keep rename to libs/pathway-design/server/infrastructure/.keep diff --git a/libs/pathway-design/creation/server/presenters/.keep b/libs/pathway-design/server/presenters/.keep similarity index 100% rename from libs/pathway-design/creation/server/presenters/.keep rename to libs/pathway-design/server/presenters/.keep diff --git a/tsconfig.base.json b/tsconfig.base.json index 4d3e4d86..090df5ae 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -15,11 +15,11 @@ "skipDefaultLibCheck": true, "baseUrl": ".", "paths": { - "@bewoak/pathway-design-creation-server-business-entities-pathway": [ - "libs/pathway-design/creation/server/business/entities/pathway/src/index.ts" + "@bewoak/pathway-design-server-business-entities-pathway": [ + "libs/pathway-design/server/business/entities/pathway/src/index.ts" ], - "@bewoak/pathway-design-creation-server-business-usescases-init-pathway": [ - "libs/pathway-design/creation/server/business/usecases/init-pathway/src/index.ts" + "@bewoak/pathway-design-server-business-usescases-init-pathway": [ + "libs/pathway-design/server/business/usecases/init-pathway/src/index.ts" ] } },