// The module's domain events (spec ยง8). Each is written to the outbox by the transaction that made // the change, so a rolled-back write publishes nothing and the relay delivers it exactly once per // subscriber. The audit event and the usage fact of this module hang off these records, not off // the request that happened to run (core/subscribers.ts). import { defineEvent } from "@conusai-kit/core" import { z } from "zod" const inProject = { orgId: z.string(), workspaceId: z.string(), projectId: z.string() } export const noteCreated = defineEvent( "notes.NoteCreated", z.object({ ...inProject, noteId: z.string(), createdBy: z.string() }), ) export const noteUpdated = defineEvent( "notes.NoteUpdated", z.object({ ...inProject, noteId: z.string(), version: z.number().int(), updatedBy: z.string() }), ) export const noteDeleted = defineEvent( "notes.NoteDeleted", z.object({ ...inProject, noteId: z.string(), deletedBy: z.string(), attachmentCount: z.number().int() }), ) export const attachmentAdded = defineEvent( "notes.AttachmentAdded", z.object({ ...inProject, noteId: z.string(), attachmentId: z.string(), fileId: z.string(), attachedBy: z.string() }), ) export const attachmentRemoved = defineEvent( "notes.AttachmentRemoved", z.object({ ...inProject, noteId: z.string(), attachmentId: z.string(), fileId: z.string(), removedBy: z.string(), }), ) /** Every event this module publishes, for the manifest. */ export const NOTES_EVENTS = [noteCreated, noteUpdated, noteDeleted, attachmentAdded, attachmentRemoved]