@codeforbreakfast/eventsourcing-commands
Version:
Wire command validation and dispatch for event sourcing systems - External boundary layer with schema validation
26 lines • 1.75 kB
TypeScript
import { Context, Effect, Layer, Match } from 'effect';
import type { ReadonlyDeep } from 'type-fest';
import { WireCommand, DomainCommand, CommandResult, CommandDefinition, CommandFromDefinitions, CommandMatcher } from './commands';
declare const CommandRegistry_base: Context.TagClass<CommandRegistry, "CommandRegistry", {
readonly dispatch: (wireCommand: ReadonlyDeep<WireCommand>) => Effect.Effect<CommandResult, never, never>;
readonly listCommandNames: () => ReadonlyArray<string>;
}>;
export declare class CommandRegistry extends CommandRegistry_base {
}
export declare const dispatchCommand: (wireCommand: ReadonlyDeep<WireCommand>) => Effect.Effect<CommandResult, never, CommandRegistry>;
/**
* Helper to create a command matcher using Effect's pattern matching
* Since our commands use 'name' instead of '_tag', this provides a convenient API
*/
export declare const createCommandMatcher: <TCommands extends DomainCommand<any>>() => Match.Matcher<TCommands, Match.Types.Without<never>, TCommands, never, never, any>;
/**
* Builds a command registry using Effect's pattern matching
* This ensures exhaustive command handling with compile-time safety
*/
export declare const makeCommandRegistry: <const T extends readonly CommandDefinition<string, any>[]>(commands: ReadonlyDeep<T>, matcher: CommandMatcher<CommandFromDefinitions<T>>) => Context.Tag.Service<typeof CommandRegistry>;
/**
* Creates a Layer with the command registry
*/
export declare const makeCommandRegistryLayer: <const T extends readonly CommandDefinition<string, any>[]>(commands: ReadonlyDeep<T>, matcher: CommandMatcher<CommandFromDefinitions<T>>) => Layer.Layer<CommandRegistry, never, never>;
export {};
//# sourceMappingURL=command-registry.d.ts.map