Move document type from document to document version

Follow the same pattern used for classification: document type now lives
exclusively on DocumentVersion. A migration copies existing values from
documents to their versions. The document filter uses a subquery on the
latest version. All three API surfaces (GraphQL, MCP, CLI), resolvers,
frontend, and e2e tests are updated accordingly.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-03-31 19:57:52 +02:00
parent 28cf3f167a
commit 9a418a7711
29 changed files with 396 additions and 314 deletions

View File

@@ -20,28 +20,3 @@ export const trustCenterDocumentAccessStatus = {
} as const;
export type TrustCenterDocumentAccessStatus = (typeof trustCenterDocumentAccessStatus)[keyof typeof trustCenterDocumentAccessStatus];
export type TrustCenterDocumentAccess = {
id: string;
status: TrustCenterDocumentAccessStatus;
document?: {
id: string;
title: string;
documentType: string;
} | null;
report?: {
id: string;
filename: string;
audit?: {
id: string;
framework?: {
name: string;
} | null;
} | null;
} | null;
trustCenterFile?: {
id: string;
name: string;
category: string;
} | null;
};

View File

@@ -13,6 +13,5 @@
// PERFORMANCE OF THIS SOFTWARE.
export type {
TrustCenterDocumentAccess,
TrustCenterDocumentAccessStatus,
} from "./TrustCenterDocumentAccess";

View File

@@ -107,7 +107,6 @@ export { detectSocialName } from "./socialUrl";
export { formatError, type GraphQLError } from "./error";
export { Role, roles, getAssignableRoles } from "./roles";
export {
getTrustCenterDocumentAccessInfo,
getTrustCenterDocumentAccessStatusBadgeVariant,
getTrustCenterDocumentAccessStatusLabel,
type TrustCenterDocumentAccessInfo,

View File

@@ -12,7 +12,7 @@
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
import type { TrustCenterDocumentAccess, TrustCenterDocumentAccessStatus } from "@probo/coredata";
import type { TrustCenterDocumentAccessStatus } from "@probo/coredata";
export function getTrustCenterDocumentAccessStatusBadgeVariant(status: TrustCenterDocumentAccessStatus) {
switch (status) {
@@ -63,46 +63,3 @@ export type TrustCenterDocumentAccessInfo = ITrustCenterDocumentAccessInfo & (
}
)
export function getTrustCenterDocumentAccessInfo(
docAccess: TrustCenterDocumentAccess,
__: (key: string) => string
): TrustCenterDocumentAccessInfo {
if (docAccess.document) {
return {
persisted: docAccess.id !== docAccess.document.id,
variant: "info" as const,
name: docAccess.document.title,
type: "document",
typeLabel: __("Document"),
category: docAccess.document.documentType,
id: docAccess.document.id,
status: docAccess.status,
};
}
if (docAccess.report) {
return {
persisted: docAccess.id !== docAccess.report.id,
variant: "success" as const,
name: docAccess.report.filename,
type: "report",
typeLabel: __("Report"),
category: docAccess.report.audit?.framework?.name ?? "",
id: docAccess.report.id,
status: docAccess.status,
};
}
if (docAccess.trustCenterFile) {
return {
persisted: docAccess.id !== docAccess.trustCenterFile.id,
variant: "highlight" as const,
name: docAccess.trustCenterFile.name,
type: "file",
typeLabel: __("File"),
category: docAccess.trustCenterFile.category,
id: docAccess.trustCenterFile.id,
status: docAccess.status,
};
}
throw new Error("Unknown trust center access document type");
}