-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor executable IDs to use strings $262
This commit unifies executable ID structure across categories and scripts, paving the way for more complex ID solutions for $262. It also refactors related code to adapt to the changes. Key changes: - Change numeric IDs to string IDs for categories - Use named types for string IDs to improve code clarity - Add unit tests to verify ID uniqueness Other supporting changes: - Separate concerns in entities for data access and executables by using separate abstractions (`Identifiable` and `RepositoryEntity`) - Simplify usage and construction of entities. - Remove `BaseEntity` for simplicity. - Move creation of categories/scripts to domain layer - Refactor CategoryCollection for better validation logic isolation - Rename some categories to keep the names (used as pseudo-IDs) unique on Windows.
- Loading branch information
1 parent
6fbc816
commit ad2e1a0
Showing
115 changed files
with
2,232 additions
and
1,285 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
2 changes: 1 addition & 1 deletion
2
src/application/Context/State/Filter/Strategy/FilterStrategy.ts
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
2 changes: 1 addition & 1 deletion
2
src/application/Context/State/Filter/Strategy/LinearFilterStrategy.ts
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
6 changes: 2 additions & 4 deletions
6
src/application/Context/State/Selection/Script/SelectedScript.ts
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,9 +1,7 @@ | ||
import type { IEntity } from '@/infrastructure/Entity/IEntity'; | ||
import type { Script } from '@/domain/Executables/Script/Script'; | ||
import type { RepositoryEntity } from '@/application/Repository/RepositoryEntity'; | ||
|
||
type ScriptId = Script['id']; | ||
|
||
export interface SelectedScript extends IEntity<ScriptId> { | ||
export interface SelectedScript extends RepositoryEntity { | ||
readonly script: Script; | ||
readonly revert: boolean; | ||
} |
11 changes: 5 additions & 6 deletions
11
src/application/Context/State/Selection/Script/UserSelectedScript.ts
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,17 +1,16 @@ | ||
import { BaseEntity } from '@/infrastructure/Entity/BaseEntity'; | ||
import type { Script } from '@/domain/Executables/Script/Script'; | ||
import type { SelectedScript } from './SelectedScript'; | ||
import type { RepositoryEntity } from '@/application/Repository/RepositoryEntity'; | ||
|
||
type SelectedScriptId = SelectedScript['id']; | ||
export class UserSelectedScript implements RepositoryEntity { | ||
public readonly id: string; | ||
|
||
export class UserSelectedScript extends BaseEntity<SelectedScriptId> { | ||
constructor( | ||
public readonly script: Script, | ||
public readonly revert: boolean, | ||
) { | ||
super(script.id); | ||
this.id = script.executableId; | ||
if (revert && !script.canRevert()) { | ||
throw new Error(`The script with ID '${script.id}' is not reversible and cannot be reverted.`); | ||
throw new Error(`The script with ID '${script.executableId}' is not reversible and cannot be reverted.`); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import type { IEntity } from '@/infrastructure/Entity/IEntity'; | ||
import type { RepositoryEntity } from './RepositoryEntity'; | ||
|
||
export interface ReadonlyRepository<TKey, TEntity extends IEntity<TKey>> { | ||
type EntityId = RepositoryEntity['id']; | ||
|
||
export interface ReadonlyRepository<TEntity extends RepositoryEntity> { | ||
readonly length: number; | ||
getItems(predicate?: (entity: TEntity) => boolean): readonly TEntity[]; | ||
getById(id: TKey): TEntity; | ||
exists(id: TKey): boolean; | ||
getById(id: EntityId): TEntity; | ||
exists(id: EntityId): boolean; | ||
} | ||
|
||
export interface MutableRepository<TKey, TEntity extends IEntity<TKey>> { | ||
export interface MutableRepository<TEntity extends RepositoryEntity> { | ||
addItem(item: TEntity): void; | ||
addOrUpdateItem(item: TEntity): void; | ||
removeItem(id: TKey): void; | ||
removeItem(id: EntityId): void; | ||
} | ||
|
||
export interface Repository<TKey, TEntity extends IEntity<TKey>> | ||
extends ReadonlyRepository<TKey, TEntity>, MutableRepository<TKey, TEntity> { } | ||
export interface Repository<TEntity extends RepositoryEntity> | ||
extends ReadonlyRepository<TEntity>, MutableRepository<TEntity> { } |
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,6 @@ | ||
/** Aggregate root */ | ||
export type RepositoryEntityId = string; | ||
|
||
export interface RepositoryEntity { | ||
readonly id: RepositoryEntityId; | ||
} |
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.