-
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.
Completed implementation of Solution and refactoring
- Loading branch information
Showing
42 changed files
with
512 additions
and
423 deletions.
There are no files selected for viewing
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
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,11 @@ | ||
import type Solution from '~/domain/Solution.mjs'; | ||
import SolutionToJsonMapper from '~/mappers/SolutionToJsonMapper.mjs'; | ||
import pkg from '~/../package.json' with { type: 'json' }; | ||
import type { SemVerString } from '~/lib/SemVer.mjs'; | ||
import SlugRepository from './SlugRepository.mjs'; | ||
|
||
export default class SolutionRepository extends SlugRepository<Solution> { | ||
constructor(storage: Storage) { | ||
super('solution', storage, new SolutionToJsonMapper(pkg.version as SemVerString)); | ||
} | ||
} |
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,11 @@ | ||
import type System from '~/domain/System.mjs'; | ||
import type { SemVerString } from '~/lib/SemVer.mjs'; | ||
import StorageRepository from './StorageRepository.mjs'; | ||
import pkg from '~/../package.json' with { type: 'json' }; | ||
import SystemToJsonMapper from '~/mappers/SystemToJsonMapper.mjs'; | ||
|
||
export default class SystemRepository extends StorageRepository<System> { | ||
constructor(storage: Storage) { | ||
super('system', storage, new SystemToJsonMapper(pkg.version as SemVerString)); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import type { Properties } from '~/types/Properties.mjs'; | ||
import type { Uuid } from '~/types/Uuid.mjs'; | ||
import PEGS from './PEGS.mjs'; | ||
import Entity from './Entity.mjs'; | ||
|
||
/** | ||
* Goals are the needs and wants of an organization. | ||
* They are the things that the organization wants to achieve. | ||
*/ | ||
export default class Goals extends PEGS { | ||
export default class Goals extends Entity { | ||
/** | ||
* Functional behaviors specify what results or effects are expected from the system. | ||
* They specify "what" the system should do, not "how" it should do it. | ||
*/ | ||
functionalBehaviors: Uuid[]; | ||
functionalBehaviorIds: Uuid[]; | ||
objective: string; | ||
outcomes: string; | ||
stakeholders: Uuid[]; | ||
stakeholderIds: Uuid[]; | ||
situation: string; | ||
useCases: Uuid[]; | ||
limits: Uuid[]; | ||
useCaseIds: Uuid[]; | ||
limitIds: Uuid[]; | ||
|
||
constructor(options: Properties<Goals>) { | ||
super(options); | ||
this.functionalBehaviors = options.functionalBehaviors; | ||
this.functionalBehaviorIds = options.functionalBehaviorIds; | ||
this.objective = options.objective; | ||
this.outcomes = options.outcomes; | ||
this.stakeholders = options.stakeholders; | ||
this.stakeholderIds = options.stakeholderIds; | ||
this.situation = options.situation; | ||
this.useCases = options.useCases; | ||
this.limits = options.limits; | ||
this.useCaseIds = options.useCaseIds; | ||
this.limitIds = options.limitIds; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import PEGS from './PEGS.mjs'; | ||
import Entity from './Entity.mjs'; | ||
|
||
/** | ||
* A Project is the set of human processes involved in the planning, | ||
* construction, revision, and operation of an associated system. | ||
* @extends PEGS | ||
*/ | ||
export default class Project extends PEGS { } | ||
export default class Project extends Entity { } |
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,45 @@ | ||
import type { Properties } from '~/types/Properties.mjs'; | ||
import slugify from '~/lib/slugify.mjs'; | ||
import Entity from './Entity.mjs'; | ||
|
||
export default class SlugEntity extends Entity { | ||
static readonly maxNameLength = 60; | ||
static readonly maxDescriptionLength = 200; | ||
|
||
#name!: string; | ||
#description!: string; | ||
|
||
constructor(options: Properties<SlugEntity>) { | ||
super(options); | ||
this.name = options.name; | ||
this.description = options.description; | ||
} | ||
|
||
get name(): string { | ||
return this.#name; | ||
} | ||
|
||
set name(value: string) { | ||
const trimmed = value.trim(), | ||
Clazz = this.constructor as typeof SlugEntity; | ||
if (trimmed.length >= Clazz.maxNameLength) | ||
throw new Error('Entity name cannot be longer than 60 characters'); | ||
this.#name = trimmed; | ||
} | ||
|
||
get description(): string { | ||
return this.#description; | ||
} | ||
|
||
set description(value: string) { | ||
const trimmed = value.trim(), | ||
Clazz = this.constructor as typeof SlugEntity; | ||
if (trimmed.length >= Clazz.maxDescriptionLength) | ||
throw new Error('Project description cannot be longer than 200 characters'); | ||
this.#description = trimmed; | ||
} | ||
|
||
slug(): string { | ||
return slugify(this.name); | ||
} | ||
} |
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,15 @@ | ||
import type { Properties } from '~/types/Properties.mjs'; | ||
import type { Uuid } from '~/types/Uuid.mjs'; | ||
import SlugEntity from './SlugEntity.mjs'; | ||
|
||
export default class Solution extends SlugEntity { | ||
projectId!: Uuid; | ||
environmentId!: Uuid; | ||
goalsId!: Uuid; | ||
systemId!: Uuid; | ||
|
||
constructor(options: Properties<Solution>) { | ||
super(options); | ||
Object.assign(this, options); | ||
} | ||
} |
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 type { Properties } from '~/types/Properties.mjs'; | ||
import Entity from './Entity.mjs'; | ||
|
||
export default class System extends Entity { | ||
constructor(properties: Properties<System>) { | ||
super(properties); | ||
} | ||
} |
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,5 @@ | ||
export default (str: string) => | ||
str.toLowerCase().trim() | ||
.replace(/\s/g, '-') | ||
.replace(/[^\w-]+/g, '') | ||
.replace(/--+/g, '-'); |
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
Oops, something went wrong.