import { Effect, ParseResult, Schema } from 'effect'; import { EventStreamId, EventNumber } from './streamTypes'; import type { EventStore } from './services'; /** * Gets the current end position of a stream * * @since 0.5.0 * @example * ```typescript * import { currentEnd } from '@codeforbreakfast/eventsourcing-store'; * * const getStreamEnd = currentEnd(eventStore); * const endPosition = await Effect.runPromise(getStreamEnd(streamId)); * ``` * * @param eventStore - The event store service instance * @returns A function that takes a stream ID and returns the end position * @throws {EventStoreError} If the stream cannot be read */ export declare const currentEnd: (eventStore: EventStore) => (streamId: EventStreamId) => Effect.Effect<{ readonly streamId: string & import("effect/Brand").Brand<"EventStreamId">; readonly eventNumber: number; }, unknown, never>; /** * Creates an EventStreamPosition from a stream ID and event number * * @since 0.5.0 * @example * ```typescript * import { positionFromEventNumber } from '@codeforbreakfast/eventsourcing-store'; * * const position = await Effect.runPromise( * positionFromEventNumber('stream-123', 5) * ); * ``` * * @param streamId - The stream identifier * @param eventNumber - The event number in the stream * @returns An Effect that resolves to an EventStreamPosition * @throws {ParseResult.ParseError} If the values cannot be parsed into valid position */ export declare const positionFromEventNumber: (streamId: EventStreamId, eventNumber: EventNumber) => Effect.Effect<{ readonly streamId: string & import("effect/Brand").Brand<"EventStreamId">; readonly eventNumber: number; }, ParseResult.ParseError, never>; export { type EventStore, EventStore as EventStoreTag } from './services'; export { ConcurrencyConflictError } from './errors'; /** * Creates an event store that encodes/decodes events using a schema * * @since 0.5.0 * @example * ```typescript * import { encodedEventStore } from '@codeforbreakfast/eventsourcing-store'; * import { Schema } from 'effect'; * * const MyEvent = Schema.Struct({ * type: Schema.Literal('MyEvent'), * data: Schema.String * }); * * const stringEventStore: EventStore = ...; * const typedEventStore = encodedEventStore(MyEvent)(stringEventStore); * ``` * * @param schema - The schema for encoding/decoding events * @returns A function that takes an event store and returns an encoded event store * @throws {ParseResult.ParseError} If events cannot be encoded/decoded using the schema */ export declare const encodedEventStore: (schema: Schema.Schema) => (eventstore: Readonly>) => EventStore; //# sourceMappingURL=eventstore.d.ts.map