-
Notifications
You must be signed in to change notification settings - Fork 2
es cqrs
- Aggregate
- AggregateNotFoundException
- DefaultEvent
- ESCQRSModule
- EventBus
- EventStoreException
- InmemoryEventStore
- ReplayFinished
- ReplayService
- Repository
- RevisionConflictException
- AsyncProvider
- AsyncProviderFactory
- CustomEventOptions
- Event
- EventStoreAsyncOptions
- EventStoreOptions
- EventStoreOptionsFactory
- EventStoreProvider
- EventStoreProviderFactory
- ReplayOptions
Ƭ AggregateConstructor<T
>: (id
: string
, userId
: string
) => T
Name | Type |
---|---|
T |
extends Aggregate
|
• (id
, userId
): T
Name | Type |
---|---|
id |
string |
userId |
string |
T
packages/es-cqrs/src/aggregate.ts:97
Ƭ Command: INestCommand
Command interface
Implement this to create unique commands. There is no restriction on what the command class can have.
Example:
import { Command } from '@sclable/es-cqrs'
import { v4 } from 'uuid'
export class CreateAccountCommand implements Command {}
export class AccountNameChangeCommand implements Command {
public constructor(public readonly id: string, public readonly name: string) {}
}
To handle these commands implement the ICommandHandler
interface so that it finds or creates the needed aggregate,
call the modifying method that will create the event and persist the aggregate in the repository. The resolve
method should return the object needed for this command to finish (usually an ID).
Example:
import { CommandHandler, ICommandHandler, InjectRepository, Repository } from '@sclable/es-cqrs'
import { AccountNameChangeCommand } from './commands'
import { AccountAggregate } from './aggregates'
@CommandHandler(AccountNameChangeCommand)
export class SomeCommandHandler implements ICommandHandler<AccountNameChangeCommand> {
public constructor(@InjectRepository(AccountAggregate) private readonly repo: Repository<AccountAggregate>) {}
async execute(command: AccountNameChangeCommand): Promise<any> {
const agg = await this.repo.find(command.id)
agg.changeName(command.name)
return this.repo.persist(agg)
}
}
packages/es-cqrs/src/interfaces/command.ts:43
Ƭ EventConstructor: (aggregateId
: string
, aggregateType
: string
, revision
: number
, createdAt
: Date
, userId
: string
, data
: any
, customOptions?
: CustomEventOptions
) => Event
Constructor signature used to reconstruct an Event instance from the event store
• (aggregateId
, aggregateType
, revision
, createdAt
, userId
, data
, customOptions?
): Event
Name | Type |
---|---|
aggregateId |
string |
aggregateType |
string |
revision |
number |
createdAt |
Date |
userId |
string |
data |
any |
customOptions? |
CustomEventOptions |
packages/es-cqrs/src/interfaces/event.ts:109
• Const
InmemoryEventStoreProvider: AsyncProvider
<EventStoreProvider
>
packages/es-cqrs/src/event-store/inmemory-event-store.ts:98
▸ EventSourcableAggregate(...events
): ClassDecorator
Decorator to define events that can affect the aggregate
Name | Type |
---|---|
...events |
EventConstructor [] |
ClassDecorator
packages/es-cqrs/src/decorators/event-sourcable-aggregate.decorator.ts:7
▸ InjectRepository<T
>(aggregate
): PropertyDecorator
& ParameterDecorator
Aggregate repository injector for command handlers
Name | Type |
---|---|
T |
extends Aggregate
|
Name | Type |
---|---|
aggregate |
AggregateConstructor <T > |
PropertyDecorator
& ParameterDecorator
packages/es-cqrs/src/decorators/inject-repository.decorator.ts:9
▸ createAsyncProvider<T
>(provider
, token
): Provider
Name |
---|
T |
Name | Type |
---|---|
provider |
AsyncProvider <T > |
token |
string |
Provider
packages/es-cqrs/src/interfaces/async-provider.ts:16
▸ createAsyncProviders<T
>(provider
, token
): Provider
[]
Name |
---|
T |
Name | Type |
---|---|
provider |
AsyncProvider <T > |
token |
string |
Provider
[]