Skip to content

Commit

Permalink
87 implement system scenarios (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhaufe authored Jun 15, 2024
1 parent d72d1d4 commit 15ef8aa
Show file tree
Hide file tree
Showing 79 changed files with 1,015 additions and 336 deletions.
17 changes: 17 additions & 0 deletions application/Interactor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type Entity from "~/domain/Entity";
import type Repository from "./Repository";
import type { Uuid } from "~/domain/Uuid";

export default abstract class Interactor<E extends Entity> {
constructor(
readonly repository: Repository<E>
) { }

abstract create(item: Omit<E, 'id'>): Promise<Uuid>

abstract delete(id: Uuid): Promise<void>

abstract getAll(parentId: Uuid): Promise<E[]>

abstract update(item: Pick<E, 'id'>): Promise<void>
}
5 changes: 5 additions & 0 deletions domain/Requirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ export default class Requirement extends Entity {
* A human-readable description of a property
*/
statement!: string

/**
* The solution that owns this requirement
*/
solutionId!: Uuid
}
17 changes: 0 additions & 17 deletions domain/UseCase.ts

This file was deleted.

8 changes: 0 additions & 8 deletions domain/UserStory.ts

This file was deleted.

6 changes: 3 additions & 3 deletions mappers/RequirementToJsonMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ export interface RequirementJson extends EntityJson {
statement: string
property: string
parentId: Uuid
solutionId: Uuid
}

export default class RequirementToJsonMapper extends EntityToJsonMapper {
override mapFrom(target: RequirementJson): Requirement {
const version = new SemVer(target.serializationVersion);

return new Requirement(target);
}

Expand All @@ -24,7 +23,8 @@ export default class RequirementToJsonMapper extends EntityToJsonMapper {
parentId: source.parentId,
name: source.name,
statement: source.statement,
property: source.property
property: source.property,
solutionId: source.solutionId
};
}
}
31 changes: 0 additions & 31 deletions mappers/UseCaseToJsonMapper.ts

This file was deleted.

5 changes: 3 additions & 2 deletions modules/environment/application/CreateAssumptionUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type Repository from "~/application/Repository";
import type Environment from "../domain/Environment";
import Assumption from "../domain/Assumption";

type In = Pick<Assumption, 'parentId' | 'name' | 'statement'>
type In = Pick<Assumption, 'parentId' | 'solutionId' | 'name' | 'statement'>

export default class CreateAssumptionUseCase extends UseCase<In, Uuid> {
constructor(
readonly environmentRepository: Repository<Environment>,
readonly assumptionRepository: Repository<Assumption>
) { super() }

async execute({ parentId, name, statement }: In): Promise<Uuid> {
async execute({ parentId, name, statement, solutionId }: In): Promise<Uuid> {
const environment = await this.environmentRepository.get(parentId)

if (!environment)
Expand All @@ -22,6 +22,7 @@ export default class CreateAssumptionUseCase extends UseCase<In, Uuid> {
id: crypto.randomUUID(),
property: '',
parentId,
solutionId,
name,
statement
}))
Expand Down
5 changes: 3 additions & 2 deletions modules/environment/application/CreateConstraintUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type Repository from "~/application/Repository";
import type Environment from "../domain/Environment";
import Constraint from "../domain/Constraint";

type In = Pick<Constraint, 'parentId' | 'name' | 'statement' | 'category'>
type In = Pick<Constraint, 'parentId' | 'solutionId' | 'name' | 'statement' | 'category'>

export default class CreateConstraintUseCase extends UseCase<In, Uuid> {
constructor(
readonly environmentRepository: Repository<Environment>,
readonly constraintRepository: Repository<Constraint>
) { super() }

async execute({ parentId, name, statement, category }: In): Promise<Uuid> {
async execute({ parentId, solutionId, name, statement, category }: In): Promise<Uuid> {
const environment = await this.environmentRepository.get(parentId)

if (!environment)
Expand All @@ -22,6 +22,7 @@ export default class CreateConstraintUseCase extends UseCase<In, Uuid> {
id: crypto.randomUUID(),
property: '',
parentId,
solutionId,
name,
statement,
category
Expand Down
5 changes: 3 additions & 2 deletions modules/environment/application/CreateEffectUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type Repository from "~/application/Repository";
import type Environment from "../domain/Environment";
import Effect from "../domain/Effect";

type In = Pick<Effect, 'parentId' | 'name' | 'statement'>
type In = Pick<Effect, 'parentId' | 'solutionId' | 'name' | 'statement'>

export default class CreateEffectUseCase extends UseCase<In, Uuid> {
constructor(
readonly environmentRepository: Repository<Environment>,
readonly effectRepository: Repository<Effect>
) { super() }

async execute({ parentId, name, statement }: In): Promise<Uuid> {
async execute({ parentId, solutionId, name, statement }: In): Promise<Uuid> {
const environment = await this.environmentRepository.get(parentId)

if (!environment)
Expand All @@ -22,6 +22,7 @@ export default class CreateEffectUseCase extends UseCase<In, Uuid> {
id: crypto.randomUUID(),
property: '',
parentId,
solutionId,
name,
statement
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type Repository from "~/application/Repository";
import type PEGS from "~/domain/PEGS";
import EnvironmentComponent from "../domain/EnvironmentComponent";

type In = Pick<EnvironmentComponent, 'parentId' | 'name' | 'statement'>
type In = Pick<EnvironmentComponent, 'parentId' | 'solutionId' | 'name' | 'statement'>

export default class CreateEnvironmentComponentUseCase extends UseCase<In, Uuid> {
constructor(
readonly pegsRepository: Repository<PEGS>,
readonly componentRepository: Repository<EnvironmentComponent>
) { super() }

async execute({ parentId, name, statement }: In): Promise<Uuid> {
async execute({ parentId, solutionId, name, statement }: In): Promise<Uuid> {
const pegs = await this.pegsRepository.get(parentId)

if (!pegs)
Expand All @@ -22,6 +22,7 @@ export default class CreateEnvironmentComponentUseCase extends UseCase<In, Uuid>
id: crypto.randomUUID(),
property: '',
parentId,
solutionId,
name,
statement
}))
Expand Down
5 changes: 3 additions & 2 deletions modules/environment/application/CreateGlossaryTermUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import GlossaryTerm from "../domain/GlossaryTerm";
import type Repository from "~/application/Repository";
import type Environment from "../domain/Environment";

type In = Pick<GlossaryTerm, 'parentId' | 'name' | 'statement'>
type In = Pick<GlossaryTerm, 'parentId' | 'solutionId' | 'name' | 'statement'>

export default class CreateGlossaryTermUseCase extends UseCase<In, Uuid> {
constructor(
readonly environmentRepository: Repository<Environment>,
readonly glossaryTermRepository: Repository<GlossaryTerm>
) { super() }

async execute({ parentId, name, statement }: In): Promise<Uuid> {
async execute({ parentId, solutionId, name, statement }: In): Promise<Uuid> {
const environment = await this.environmentRepository.get(parentId)

if (!environment)
Expand All @@ -22,6 +22,7 @@ export default class CreateGlossaryTermUseCase extends UseCase<In, Uuid> {
id: crypto.randomUUID(),
property: '',
parentId,
solutionId,
name,
statement
}))
Expand Down
5 changes: 3 additions & 2 deletions modules/environment/application/CreateInvariantUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type Repository from "~/application/Repository";
import type Environment from "../domain/Environment";
import Invariant from "../domain/Invariant";

type In = Pick<Invariant, 'parentId' | 'name' | 'statement'>
type In = Pick<Invariant, 'parentId' | 'solutionId' | 'name' | 'statement'>

export default class CreateInvariantUseCase extends UseCase<In, Uuid> {
constructor(
readonly environmentRepository: Repository<Environment>,
readonly invariantRepository: Repository<Invariant>
) { super() }

async execute({ parentId, name, statement }: In): Promise<Uuid> {
async execute({ parentId, solutionId, name, statement }: In): Promise<Uuid> {
const environment = await this.environmentRepository.get(parentId)

if (!environment)
Expand All @@ -22,6 +22,7 @@ export default class CreateInvariantUseCase extends UseCase<In, Uuid> {
id: crypto.randomUUID(),
property: '',
parentId,
solutionId,
name,
statement
}))
Expand Down
4 changes: 3 additions & 1 deletion modules/environment/domain/Invariant.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Requirement from "~/domain/Requirement";

/**
* Environment property that must be maintained
* Environment property that must be maintained.
* It exists as both an assumption and an effect.
* (precondition and postcondition)
*/
export default class Invariant extends Requirement { }
8 changes: 2 additions & 6 deletions modules/environment/mappers/AssumptionToJsonMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ export interface AssumptionJson extends RequirementJson { }

export default class AssumptionToJsonMapper extends RequirementToJsonMapper {
override mapTo(source: Assumption): AssumptionJson {
return {
...super.mapTo(source)
};
return { ...super.mapTo(source) };
}

override mapFrom(target: AssumptionJson): Assumption {
return new Assumption({
...super.mapFrom(target),
});
return new Assumption({ ...target });
}
}
9 changes: 1 addition & 8 deletions modules/environment/mappers/ConstraintToJsonMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ export interface ConstraintJson extends RequirementJson {

export default class ConstraintToJsonMapper extends RequirementToJsonMapper {
override mapFrom(target: ConstraintJson): Constraint {
return new Constraint({
category: target.category,
id: target.id,
name: target.name,
parentId: target.parentId,
property: target.property,
statement: target.statement,
});
return new Constraint({ ...target });
}

override mapTo(source: Constraint): ConstraintJson {
Expand Down
8 changes: 2 additions & 6 deletions modules/environment/mappers/EffectToJsonMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ export interface EffectJson extends RequirementJson { }

export default class EffectToJsonMapper extends RequirementToJsonMapper {
override mapTo(source: Effect): EffectJson {
return {
...super.mapTo(source)
};
return { ...super.mapTo(source) };
}

override mapFrom(target: EffectJson): Effect {
return new Effect({
...super.mapFrom(target),
});
return new Effect({ ...target });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ export interface EnvironmentComponentJson extends RequirementJson { }

export default class EnvironmentComponentToJsonMapper extends RequirementToJsonMapper {
override mapTo(source: Component): EnvironmentComponentJson {
return {
...super.mapTo(source)
};
return { ...super.mapTo(source) };
}

override mapFrom(target: EnvironmentComponentJson): Component {
return new Component({
...super.mapFrom(target)
});
return new Component({ ...target });
}
}
8 changes: 2 additions & 6 deletions modules/environment/mappers/GlossaryTermToJsonMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ export interface GlossaryTermJson extends RequirementJson {

export default class GlossaryTermToJsonMapper extends RequirementToJsonMapper {
override mapTo(source: GlossaryTerm): GlossaryTermJson {
return {
...super.mapTo(source)
};
return { ...super.mapTo(source) };
}

override mapFrom(target: GlossaryTermJson): GlossaryTerm {
return new GlossaryTerm({
...super.mapFrom(target),
});
return new GlossaryTerm({ ...target });
}
}
8 changes: 2 additions & 6 deletions modules/environment/mappers/InvariantToJsonMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ export interface InvariantJson extends RequirementJson { }

export default class InvariantToJsonMapper extends RequirementToJsonMapper {
override mapTo(source: Invariant): InvariantJson {
return {
...super.mapTo(source)
};
return { ...super.mapTo(source) };
}

override mapFrom(target: InvariantJson): Invariant {
return new Invariant({
...super.mapFrom(target),
});
return new Invariant({ ...target });
}
}
1 change: 1 addition & 0 deletions modules/environment/ui/pages/Assumptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const filters = ref<Record<string, { value: any, matchMode: string }>>({
const onCreate = async (data: AssumptionViewModel) => {
const newId = await createAssumptionUseCase.execute({
parentId: environment!.id,
solutionId: solution!.id,
name: data.name,
statement: data.statement
})
Expand Down
Loading

0 comments on commit 15ef8aa

Please sign in to comment.