website refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Result } from './Result';
|
||||
import type { Result } from '../domain/Result';
|
||||
import type { ApplicationErrorCode } from '../errors/ApplicationErrorCode';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import type { Result } from './Result';
|
||||
import type { Result } from '../domain/Result';
|
||||
import type { ApplicationError } from '../errors/ApplicationError';
|
||||
|
||||
export interface IApplicationService {
|
||||
export interface ApplicationService {
|
||||
readonly serviceName?: string;
|
||||
}
|
||||
|
||||
export interface IAsyncApplicationService<Input, Output> extends IApplicationService {
|
||||
export interface AsyncApplicationService<Input, Output> extends ApplicationService {
|
||||
execute(input: Input): Promise<Output>;
|
||||
}
|
||||
|
||||
export interface IAsyncResultApplicationService<
|
||||
export interface AsyncResultApplicationService<
|
||||
Input,
|
||||
Output,
|
||||
Error = ApplicationError
|
||||
> extends IApplicationService {
|
||||
> extends ApplicationService {
|
||||
execute(input: Input): Promise<Result<Output, Error>>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Result } from './Result';
|
||||
import type { Result } from '../domain/Result';
|
||||
import type { ApplicationErrorCode } from '../errors/ApplicationErrorCode';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export * from './UseCase';
|
||||
export * from './AsyncUseCase';
|
||||
export * from './Service';
|
||||
export * from './Logger';
|
||||
export * from './UseCaseOutputPort';
|
||||
export * from './ErrorReporter';
|
||||
export * from './Result';
|
||||
@@ -10,4 +10,4 @@ export interface DomainEventPublisher {
|
||||
}
|
||||
|
||||
// Alias for backward compatibility
|
||||
export interface IDomainEvent<T = unknown> extends DomainEvent<T> {}
|
||||
export type IDomainEvent<T = unknown> = DomainEvent<T>;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
export interface IEntity<Id = string> {
|
||||
export interface EntityProps<Id = string> {
|
||||
readonly id: Id;
|
||||
}
|
||||
|
||||
export abstract class Entity<Id> implements IEntity<Id> {
|
||||
export abstract class Entity<Id> implements EntityProps<Id> {
|
||||
protected constructor(readonly id: Id) {}
|
||||
|
||||
equals(other?: Entity<Id>): boolean {
|
||||
return !!other && this.id === other.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Alias for backward compatibility
|
||||
export type IEntity<Id = string> = EntityProps<Id>;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* @template E - The type of the error value, typically ApplicationErrorCode<string>
|
||||
*/
|
||||
export class Result<T, E = Error> {
|
||||
private constructor(
|
||||
public constructor(
|
||||
private readonly _value?: T,
|
||||
private readonly _error?: E,
|
||||
private readonly _isSuccess: boolean = true
|
||||
@@ -1,24 +1,31 @@
|
||||
import type { Result } from '../application/Result';
|
||||
import type { IDomainError } from '../errors/DomainError';
|
||||
import { Result } from './Result';
|
||||
import type { DomainErrorProps } from '../errors/DomainError';
|
||||
|
||||
export interface IDomainService {
|
||||
export interface DomainService {
|
||||
readonly serviceName?: string;
|
||||
}
|
||||
|
||||
export interface IDomainCalculationService<Input, Output> extends IDomainService {
|
||||
export interface DomainCalculationService<Input, Output> extends DomainService {
|
||||
calculate(input: Input): Output;
|
||||
}
|
||||
|
||||
export interface IResultDomainCalculationService<Input, Output, Error = IDomainError>
|
||||
extends IDomainService {
|
||||
export interface ResultDomainCalculationService<Input, Output, Error = DomainErrorProps>
|
||||
extends DomainService {
|
||||
calculate(input: Input): Result<Output, Error>;
|
||||
}
|
||||
|
||||
export interface IDomainValidationService<Input, Output, Error = IDomainError>
|
||||
extends IDomainService {
|
||||
export interface DomainValidationService<Input, Output, Error = DomainErrorProps>
|
||||
extends DomainService {
|
||||
validate(input: Input): Result<Output, Error>;
|
||||
}
|
||||
|
||||
export interface IDomainFactoryService<Input, Output> extends IDomainService {
|
||||
export interface DomainFactoryService<Input, Output> extends DomainService {
|
||||
create(input: Input): Output;
|
||||
}
|
||||
}
|
||||
|
||||
// Alias for backward compatibility
|
||||
export type IDomainService = DomainService;
|
||||
export type IDomainCalculationService<Input, Output> = DomainCalculationService<Input, Output>;
|
||||
export type IResultDomainCalculationService<Input, Output, Error = DomainErrorProps> = ResultDomainCalculationService<Input, Output, Error>;
|
||||
export type IDomainValidationService<Input, Output, Error = DomainErrorProps> = DomainValidationService<Input, Output, Error>;
|
||||
export type IDomainFactoryService<Input, Output> = DomainFactoryService<Input, Output>;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export interface IValueObject<Props> {
|
||||
export interface ValueObjectProps<Props> {
|
||||
readonly props: Props;
|
||||
equals(other: IValueObject<Props>): boolean;
|
||||
}
|
||||
equals(other: ValueObjectProps<Props>): boolean;
|
||||
}
|
||||
|
||||
// Alias for backward compatibility
|
||||
export type IValueObject<Props> = ValueObjectProps<Props>;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export * from './Entity';
|
||||
export * from './ValueObject';
|
||||
export * from './Service';
|
||||
export * from './Option';
|
||||
export * from './DomainEvent';
|
||||
@@ -1,7 +1,10 @@
|
||||
export type CommonDomainErrorKind = 'validation' | 'invariant' | string;
|
||||
|
||||
export interface IDomainError<K extends string = CommonDomainErrorKind> extends Error {
|
||||
export interface DomainErrorProps<K extends string = CommonDomainErrorKind> extends Error {
|
||||
readonly type: 'domain';
|
||||
readonly context: string;
|
||||
readonly kind: K;
|
||||
}
|
||||
}
|
||||
|
||||
// Alias for backward compatibility
|
||||
export type IDomainError<K extends string = CommonDomainErrorKind> = DomainErrorProps<K>;
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from './DomainError';
|
||||
export * from './ApplicationError';
|
||||
export * from './ApplicationErrorCode';
|
||||
@@ -1,5 +0,0 @@
|
||||
export * from './application/Result';
|
||||
export * as application from './application';
|
||||
export * as domain from './domain';
|
||||
export * as errors from './errors';
|
||||
export * from './application/AsyncUseCase';
|
||||
Reference in New Issue
Block a user