projection.ts
This file
Path
packages/project/src/projection.ts
28 lines · 831 bytes · TypeScript
Last changed by
Merge build/comments-project into mainoscabrielbefore adoption49efd2a
History of this fileTake it
1234567891011121314151617181920212223242526272829import { ProjectEvent } from "@repo/protocol/domain/event";import { ProjectName } from "@repo/protocol/ids";import { Context, Schema } from "effect";import type { Effect } from "effect";
import type { OutboxRow } from "./project-store/rows.ts";
export const ProjectedEvent = Schema.TaggedStruct("Projected", { event: ProjectEvent, project: ProjectName,});
export type ProjectedEvent = typeof ProjectedEvent.Type;
export class ProjectionFailed extends Schema.TaggedError<ProjectionFailed>()( "ProjectionFailed", { reason: Schema.String }) {}
export class Projection extends Context.Service< Projection, { /** Retried on failure: idempotent by `(project, event.seq)`. */ readonly apply: ( rows: readonly OutboxRow[] ) => Effect.Effect<void, ProjectionFailed>; }>()("project/Projection") {}