import { Temporal } from 'temporal-polyfill'
import {
AggregateRoot,
type AggregateRootCreateParams,
type AggregateRootProps,
type Email,
type EntityId,
type Error,
Ok,
type Result,
type Version,
type WithGetters,
} from '@xiroi/shared/domain'
import type { CommunicationChannel } from './communication_channel.e'
import type { ErrCreatorCreate } from './creator.error'
import { CreatorCreated } from './events/creator_created.event'
import { CreatorDeleted } from './events/creator_deleted.event'
import type { Platform } from './platform.e'
// AggregateRoot is an entity: `export abstract class AggregateRoot<T extends AggregateRootProps,> extends Entity<T> {}`
export interface CreatorProps extends AggregateRootProps {
communicationChannels: CommunicationChannel[]
email: Email
isEmailVerified: boolean
platforms: Platform[]
}
export class Creator
extends AggregateRoot<CreatorProps>
implements WithGetters<CreatorProps>
{
private constructor(props: CreatorProps, id?: EntityId, version?: Version) {
super(props, id, version)
}
get createdAt(): Temporal.ZonedDateTime {
return this.props.createdAt
}
get communicationChannels(): CommunicationChannel[] {
return this.props.communicationChannels
}
get platforms(): Platform[] {
return this.props.platforms
}
get email(): Email {
return this.props.email
}
get isEmailVerified(): boolean {
return this.props.isEmailVerified
}
public static create(
params: CreatorCreateParams,
id?: EntityId,
version?: Version,
): Result<Creator, ErrCreatorCreate> {
// continued in the thread
import { Temporal } from 'temporal-polyfill'
import {
AggregateRoot,
type AggregateRootCreateParams,
type AggregateRootProps,
type Email,
type EntityId,
type Error,
Ok,
type Result,
type Version,
type WithGetters,
} from '@xiroi/shared/domain'
import type { CommunicationChannel } from './communication_channel.e'
import type { ErrCreatorCreate } from './creator.error'
import { CreatorCreated } from './events/creator_created.event'
import { CreatorDeleted } from './events/creator_deleted.event'
import type { Platform } from './platform.e'
// AggregateRoot is an entity: `export abstract class AggregateRoot<T extends AggregateRootProps,> extends Entity<T> {}`
export interface CreatorProps extends AggregateRootProps {
communicationChannels: CommunicationChannel[]
email: Email
isEmailVerified: boolean
platforms: Platform[]
}
export class Creator
extends AggregateRoot<CreatorProps>
implements WithGetters<CreatorProps>
{
private constructor(props: CreatorProps, id?: EntityId, version?: Version) {
super(props, id, version)
}
get createdAt(): Temporal.ZonedDateTime {
return this.props.createdAt
}
get communicationChannels(): CommunicationChannel[] {
return this.props.communicationChannels
}
get platforms(): Platform[] {
return this.props.platforms
}
get email(): Email {
return this.props.email
}
get isEmailVerified(): boolean {
return this.props.isEmailVerified
}
public static create(
params: CreatorCreateParams,
id?: EntityId,
version?: Version,
): Result<Creator, ErrCreatorCreate> {
// continued in the thread