Files
2026-11-14 09:56:45 +00:00

42 lines
1.4 KiB
TypeScript

// The events of the knowledge module. A write procedure publishes the request; the module's own
// subscriber (running in the worker's outbox relay) enqueues the job, which is how a web request
// never waits on the platform's knowledge service.
import { defineEvent } from "@conusai-kit/core"
import { z } from "zod"
const inProject = {
orgId: z.string(),
workspaceId: z.string(),
projectId: z.string(),
}
/** A document was asked to be indexed: the subscriber enqueues the index job. */
export const documentIndexRequested = defineEvent(
"knowledge.documentIndexRequested",
z.object({
...inProject,
documentId: z.string(),
collectionName: z.string(),
fileId: z.string(),
}),
)
/**
* A document was asked to be removed: the subscriber enqueues the remove job. `storageKey` names the object to
* remove, resolved when the removal is asked for (from `FileDeleted`, or from the stored file a person removes),
* because the file may be gone when the job runs. It is optional only for a record written before it existed.
*/
export const documentRemoveRequested = defineEvent(
"knowledge.documentRemoveRequested",
z.object({
...inProject,
documentId: z.string(),
collectionName: z.string(),
fileId: z.string(),
storageKey: z.string().optional(),
}),
)
export const KNOWLEDGE_EVENTS = [documentIndexRequested, documentRemoveRequested]