/** * Defines groups of typed events for the unstable event-log system. * * An `EventGroup` collects event definitions that belong together. Start with * `empty`, add events with their payload, success, and error schemas, then use * the group to build clients with `EventLog.schema` and server handlers with * `EventLog.group`. The group only describes events; it does not write or run * them. * * @stability unstable * @since 4.0.0 */ import { type Pipeable } from "../Pipeable.ts"; import * as Record from "../Record.ts"; import type * as Schema from "../Schema.ts"; import * as Event from "./Event.ts"; /** * Unique type identifier used to mark event log event groups. * * @stability unstable * @category type IDs * @since 4.0.0 */ export type TypeId = "~effect/eventlog/EventGroup"; /** * Runtime type identifier used to mark event log event groups. * * @stability unstable * @category type IDs * @since 4.0.0 */ export declare const TypeId: TypeId; /** * Returns `true` when a value is an event log event group. * * @stability unstable * @category guards * @since 4.0.0 */ export declare const isEventGroup: (u: unknown) => u is Any; /** * Typed collection of event definitions that represents a portion of an event log * domain. * * **When to use** * * Use when build groups from `empty.add(...)`, then provide implementations for the events * with `EventLog.group`. * * @stability unstable * @category models * @since 4.0.0 */ export interface EventGroup extends Pipeable { readonly [TypeId]: TypeId; readonly events: Record.ReadonlyRecord; /** * Add an `Event` to the `EventGroup`. */ add(options: { readonly tag: Tag; readonly primaryKey: (payload: Schema.Schema.Type) => string; readonly payload?: Payload; readonly success?: Success; readonly error?: Error; }): EventGroup>; /** * Add an error schema to all the events in the `EventGroup`. */ addError(error: Error): EventGroup>; } /** * Type-erased marker for an event log event group. * * @stability unstable * @category models * @since 4.0.0 */ export interface Any { readonly [TypeId]: TypeId; } /** * Type-erased event group with its events record available structurally. * * @stability unstable * @category models * @since 4.0.0 */ export type AnyWithProps = EventGroup; /** * Derives the handler service markers required for all events in an event group. * * @stability unstable * @category utility types * @since 4.0.0 */ export type ToService = A extends EventGroup ? Event.ToService<_Events> : never; /** * Extracts the union of event definitions contained in an event group. * * @stability unstable * @category utility types * @since 4.0.0 */ export type Events = Group extends EventGroup ? _Events : never; /** * Client-side schema services required by all events in an event group. * * @stability unstable * @category utility types * @since 4.0.0 */ export type ServicesClient = Event.ServicesClient>; /** * Server-side schema services required by all events in an event group. * * @stability unstable * @category utility types * @since 4.0.0 */ export type ServicesServer = Event.ServicesServer>; /** * Creates an empty event group used as the starting point for defining a group. * * **When to use** * * Use when you need the starting `EventGroup` value before adding event * definitions with `.add(...)`. * * @stability unstable * @category constructors * @since 4.0.0 */ export declare const empty: EventGroup; //# sourceMappingURL=EventGroup.d.ts.map