Files
dataroom/features/ai/lib/file-processing/extract-document-metadata.ts
zeekay a15864b16b ci: amd64-only build (matches hanzo runner pool topology)
hanzo-build-linux-amd64 is the only ARC runner pool installed on
hanzo-k8s today (arm64 pool is paused until DigitalOcean ships
arm64 droplets, per ~/work/hanzo/.github/RUNNERS.md). The arm64
job was waiting on spark-hanzoai-arm64 — not provisioned in this
cluster — so every build sat in queue forever and the amd64 leg
got cancelled.

Set platforms: linux/amd64 on the reusable build call to skip
arm64 entirely. Re-add arm64 if/when DO ships arm64 droplets and
the spark runner pool comes back online.
2026-06-07 11:38:49 -07:00

64 lines
1.6 KiB
TypeScript

import prisma from "@/lib/prisma";
interface DocumentMetadata {
documentId: string;
documentName: string;
versionId: string;
dataroomId?: string;
folderId?: string;
teamId: string;
}
/**
* Extract metadata from a document for vector store tagging
* @param documentId - The document ID
* @param versionId - The document version ID
* @returns Document metadata
*/
export async function extractDocumentMetadata(
documentId: string,
versionId: string,
): Promise<DocumentMetadata> {
try {
const documentVersion = await prisma.documentVersion.findUnique({
where: { id: versionId },
include: {
document: {
include: {
datarooms: {
include: {
dataroom: true,
folder: true,
},
},
},
},
},
});
if (!documentVersion) {
throw new Error("Document version not found");
}
const document = documentVersion.document;
// Get dataroom and folder info if document is in a dataroom
const dataroomDocument = document.datarooms[0]; // Get first dataroom association
const metadata: DocumentMetadata = {
documentId: document.id,
documentName: document.name,
versionId: documentVersion.id,
teamId: document.teamId,
dataroomId: dataroomDocument?.dataroomId,
folderId: dataroomDocument?.folderId || document.folderId || undefined,
};
return metadata;
} catch (error) {
console.error("Error extracting document metadata:", error);
throw new Error("Failed to extract document metadata");
}
}