-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Goals -> Use Cases feature
- Loading branch information
Showing
22 changed files
with
300 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import UseCase from '~/domain/UseCase.mjs'; | ||
import { LocalStorageRepository } from './LocalStorageRepository.mjs'; | ||
import UseCaseToJsonMapper from '~/mappers/UseCaseToJsonMapper.mjs'; | ||
import pkg from '~/../package.json' with { type: 'json' }; | ||
|
||
export default class UseCaseRepository extends LocalStorageRepository<UseCase> { | ||
constructor() { super('use-case', new UseCaseToJsonMapper(pkg.version)); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Properties } from '~/types/Properties.mjs'; | ||
import type { Uuid } from '~/types/Uuid.mjs'; | ||
import Behavior from './Behavior.mjs'; | ||
|
||
/** | ||
* A Use Case specifies a scenario of a complete interaction of an actor with a system. | ||
*/ | ||
export default class UseCase extends Behavior { | ||
/** | ||
* The actor that is involved in the use case. | ||
*/ | ||
actor: Uuid; | ||
|
||
constructor(properties: Properties<UseCase>) { | ||
super(properties); | ||
|
||
this.actor = properties.actor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const groupBy = <T, K extends keyof any>(arr: T[], key: (i: T) => K) => | ||
arr.reduce((groups, item) => { | ||
(groups[key(item)] ||= []).push(item); | ||
|
||
return groups; | ||
}, {} as Record<K, T[]>); | ||
|
||
export default groupBy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import UseCase from '~/domain/UseCase.mjs'; | ||
import BehaviorToJsonMapper, { type BehaviorJson } from './BehaviorToJsonMapper.mjs'; | ||
import type { Uuid } from '~/types/Uuid.mjs'; | ||
|
||
export interface UseCaseJson extends BehaviorJson { | ||
actor: Uuid; | ||
} | ||
|
||
export default class UseCaseToJsonMapper extends BehaviorToJsonMapper { | ||
override mapFrom(target: UseCaseJson): UseCase { | ||
const version = target.serializationVersion ?? '{undefined}'; | ||
|
||
if (version.startsWith('0.3.')) | ||
return new UseCase(target); | ||
|
||
throw new Error(`Unsupported serialization version: ${version}`); | ||
} | ||
override mapTo(source: UseCase): UseCaseJson { | ||
return { | ||
...super.mapTo(source), | ||
actor: source.actor | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.