website refactor
This commit is contained in:
@@ -17,7 +17,7 @@ const mockRepository = {
|
||||
create: vi.fn(),
|
||||
update: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
} as unknown as IAdminUserRepository;
|
||||
} as unknown as AdminUserRepository;
|
||||
|
||||
describe('ListUsersUseCase', () => {
|
||||
let useCase: ListUsersUseCase;
|
||||
|
||||
@@ -44,7 +44,7 @@ export type ListUsersApplicationError = ApplicationErrorCode<ListUsersErrorCode,
|
||||
*/
|
||||
export class ListUsersUseCase {
|
||||
constructor(
|
||||
private readonly adminUserRepository: IAdminUserRepository,
|
||||
private readonly adminUserRepository: AdminUserRepository,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Entity } from '@core/shared/domain/Entity';
|
||||
import { Entity } from '@core/shared/domain/Entity';
|
||||
import { AdminDomainInvariantError, AdminDomainValidationError } from '../errors/AdminDomainError';
|
||||
import { Email } from '../value-objects/Email';
|
||||
import { UserId } from '../value-objects/UserId';
|
||||
@@ -17,8 +17,7 @@ export interface AdminUserProps {
|
||||
primaryDriverId: string | undefined;
|
||||
}
|
||||
|
||||
export class AdminUser implements Entity<UserId> {
|
||||
readonly id: UserId;
|
||||
export class AdminUser extends Entity<UserId> {
|
||||
private _email: Email;
|
||||
private _roles: UserRole[];
|
||||
private _status: UserStatus;
|
||||
@@ -29,7 +28,8 @@ export class AdminUser implements Entity<UserId> {
|
||||
private _primaryDriverId: string | undefined;
|
||||
|
||||
private constructor(props: AdminUserProps) {
|
||||
this.id = props.id;
|
||||
super(props.id);
|
||||
|
||||
this._email = props.email;
|
||||
this._roles = props.roles;
|
||||
this._status = props.status;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { DomainError, CommonDomainErrorKind } from '@core/shared/errors';
|
||||
import type { DomainErrorProps, CommonDomainErrorKind } from '@core/shared/errors/DomainError';
|
||||
|
||||
export abstract class AdminDomainError extends Error implements DomainError<CommonDomainErrorKind> {
|
||||
export abstract class AdminDomainError extends Error implements DomainErrorProps<CommonDomainErrorKind> {
|
||||
readonly type = 'domain' as const;
|
||||
readonly context = 'admin-domain';
|
||||
abstract readonly kind: CommonDomainErrorKind;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@core/shared/domain';
|
||||
import { ValueObject } from '@core/shared/domain/ValueObject';
|
||||
import { AdminDomainValidationError } from '../errors/AdminDomainError';
|
||||
|
||||
export interface EmailProps {
|
||||
@@ -40,7 +40,7 @@ export class Email implements ValueObject<EmailProps> {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
equals(other: IValueObject<EmailProps>): boolean {
|
||||
equals(other: ValueObject<EmailProps>): boolean {
|
||||
return this.value === other.props.value;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@core/shared/domain';
|
||||
import { ValueObject } from '@core/shared/domain/ValueObject';
|
||||
import { AdminDomainValidationError } from '../errors/AdminDomainError';
|
||||
|
||||
export interface UserIdProps {
|
||||
@@ -28,7 +28,7 @@ export class UserId implements ValueObject<UserIdProps> {
|
||||
return { value: this.value };
|
||||
}
|
||||
|
||||
equals(other: IValueObject<UserIdProps>): boolean {
|
||||
equals(other: ValueObject<UserIdProps>): boolean {
|
||||
return this.value === other.props.value;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@core/shared/domain';
|
||||
import { ValueObject } from '@core/shared/domain/ValueObject';
|
||||
import { AdminDomainValidationError } from '../errors/AdminDomainError';
|
||||
|
||||
export type UserRoleValue = string;
|
||||
@@ -41,7 +41,7 @@ export class UserRole implements ValueObject<UserRoleProps> {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
equals(other: IValueObject<UserRoleProps>): boolean {
|
||||
equals(other: ValueObject<UserRoleProps>): boolean {
|
||||
return this.value === other.props.value;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@core/shared/domain';
|
||||
import { ValueObject } from '@core/shared/domain/ValueObject';
|
||||
import { AdminDomainValidationError } from '../errors/AdminDomainError';
|
||||
|
||||
export type UserStatusValue = string;
|
||||
@@ -41,7 +41,7 @@ export class UserStatus implements ValueObject<UserStatusProps> {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
equals(other: IValueObject<UserStatusProps>): boolean {
|
||||
equals(other: ValueObject<UserStatusProps>): boolean {
|
||||
return this.value === other.props.value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user