mirror of
https://github.com/hanzoai/dataroom.git
synced 2026-10-30 18:41:07 +00:00
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.
64 lines
1.6 KiB
TypeScript
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");
|
|
}
|
|
}
|
|
|