ConusAI vendor v0.1.0-beta.114
ci / gate (push) Waiting to run

This commit is contained in:
ConusAI vendor v0.1.0-beta.114
2026-11-14 09:56:45 +00:00
commit 1ce8d23c35
867 changed files with 122104 additions and 0 deletions
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
// A domain producer supplies only its recipient, occurrence and authorized app route. Inbox
// storage, read state, localization and rendering remain the notifications kit's responsibility.
import type { Container, ProjectScope } from "@conusai-kit/core"
import { DATA_SOURCE } from "@conusai-kit/data"
import { files } from "@conusai-kit/files"
import { deliverNotification } from "@conusai-kit/notifications"
import { organizations, projects, workspaces } from "@conusai-kit/tenancy"
import { documents } from "../contract/index.js"
export async function notifyDocumentResult(container: Container, scope: ProjectScope, fileId: string): Promise<void> {
await container.resolve(DATA_SOURCE).unitOfWork.run(scope, async (tx) => {
const row = (await tx.of(documents).list({ where: [{ field: "fileId", op: "eq", value: fileId }], limit: 1 }))
.items[0]
const file = await tx.of(files).get(fileId)
if (!row || !file || row.status === "processing" || row.finishedAt === null) return
const [org, workspace, project] = await Promise.all([
tx.global(organizations).require(scope.orgId),
tx.of(workspaces).require(scope.workspaceId),
tx.of(projects).require(scope.projectId),
])
await deliverNotification(tx, {
recipientId: file.uploadedBy,
key: `documents:${row.id}:${row.status}`,
category: "job",
code: row.status === "failed" ? "job_failed" : "job_completed",
href: `/${org.slug}/${workspace.slug}/${project.slug}/documents/${fileId}`,
})
})
}