rename to core
This commit is contained in:
3
core/shared/domain/Entity.ts
Normal file
3
core/shared/domain/Entity.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface IEntity<Id = string> {
|
||||
readonly id: Id;
|
||||
}
|
||||
10
core/shared/domain/IDomainEvent.ts
Normal file
10
core/shared/domain/IDomainEvent.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface IDomainEvent<T = any> {
|
||||
readonly eventType: string;
|
||||
readonly aggregateId: string;
|
||||
readonly eventData: T;
|
||||
readonly occurredAt: Date;
|
||||
}
|
||||
|
||||
export interface IDomainEventPublisher {
|
||||
publish(event: IDomainEvent): Promise<void>;
|
||||
}
|
||||
7
core/shared/domain/Option.ts
Normal file
7
core/shared/domain/Option.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function coalesce<T>(value: T | undefined | null, fallback: T): T {
|
||||
return value ?? fallback;
|
||||
}
|
||||
|
||||
export function present<T>(value: T | undefined | null): T | undefined {
|
||||
return value === undefined || value === null ? undefined : value;
|
||||
}
|
||||
24
core/shared/domain/Service.ts
Normal file
24
core/shared/domain/Service.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { Result } from '../result/Result';
|
||||
import type { IDomainError } from '../errors/DomainError';
|
||||
|
||||
export interface IDomainService {
|
||||
readonly serviceName?: string;
|
||||
}
|
||||
|
||||
export interface IDomainCalculationService<Input, Output> extends IDomainService {
|
||||
calculate(input: Input): Output;
|
||||
}
|
||||
|
||||
export interface IResultDomainCalculationService<Input, Output, Error = IDomainError>
|
||||
extends IDomainService {
|
||||
calculate(input: Input): Result<Output, Error>;
|
||||
}
|
||||
|
||||
export interface IDomainValidationService<Input, Output, Error = IDomainError>
|
||||
extends IDomainService {
|
||||
validate(input: Input): Result<Output, Error>;
|
||||
}
|
||||
|
||||
export interface IDomainFactoryService<Input, Output> extends IDomainService {
|
||||
create(input: Input): Output;
|
||||
}
|
||||
4
core/shared/domain/ValueObject.ts
Normal file
4
core/shared/domain/ValueObject.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface IValueObject<Props> {
|
||||
readonly props: Props;
|
||||
equals(other: IValueObject<Props>): boolean;
|
||||
}
|
||||
4
core/shared/domain/index.ts
Normal file
4
core/shared/domain/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './Entity';
|
||||
export * from './ValueObject';
|
||||
export * from './Service';
|
||||
export * from './Option';
|
||||
Reference in New Issue
Block a user