feat: add AI catalog description generation

This commit is contained in:
Codex
2026-08-29 16:42:56 +02:00
parent b0afba81ca
commit 376dd5a09d
76 changed files with 14860 additions and 102 deletions
+25 -16
View File
@@ -43,7 +43,13 @@ function safeError(reply: FastifyReply, error: unknown) {
if (error instanceof CatalogUnavailableError) {
return reply.code(503).send({ code: "catalog_unavailable", message: "Database catalog is unavailable." });
}
if (error instanceof CatalogConflictError || error instanceof CatalogOperationInProgressError) {
if (error instanceof CatalogOperationInProgressError) {
return reply.code(409).send({
code: "database_operation_in_progress",
message: "A database operation is already in progress.",
});
}
if (error instanceof CatalogConflictError) {
return reply.code(409).send({ code: "schema_sync_conflict", message: error.message });
}
if (error instanceof CatalogConnectorError) {
@@ -98,21 +104,24 @@ export function catalogSchemaRoutes(
const tableId = idSchema.parse(params.tableId);
const columnId = idSchema.parse(params.columnId);
const input = metadataSchema.parse(request.body);
const current = await deps.repository.getColumn(databaseId, tableId, columnId);
if (!current) return reply.code(404).send({ code: "column_not_found", message: "Catalog column was not found." });
if (current.version !== input.version) {
return reply.code(409).send({ code: "column_stale", message: "Column metadata changed. Reload and try again." });
}
const updated = await deps.repository.updateColumnMetadata(
databaseId,
tableId,
columnId,
input.version,
normalized(input.description),
normalized(input.generatedDescription),
);
if (!updated) return reply.code(409).send({ code: "column_stale", message: "Column metadata changed. Reload and try again." });
return updated;
const operation = async () => {
const current = await deps.repository.getColumn(databaseId, tableId, columnId);
if (!current) return reply.code(404).send({ code: "column_not_found", message: "Catalog column was not found." });
if (current.version !== input.version) {
return reply.code(409).send({ code: "column_stale", message: "Column metadata changed. Reload and try again." });
}
const updated = await deps.repository.updateColumnMetadata(
databaseId,
tableId,
columnId,
input.version,
normalized(input.description),
normalized(input.generatedDescription),
);
if (!updated) return reply.code(409).send({ code: "column_stale", message: "Column metadata changed. Reload and try again." });
return updated;
};
return deps.operations ? await deps.operations.run(databaseId, operation) : await operation();
} catch (error) { return safeError(reply, error); }
});