From 5d6d0bdd7f7499960418f832185eb464308c305c Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Fri, 27 Mar 2026 16:04:38 +0100 Subject: [PATCH] Move document classification from document to document version Classification now lives exclusively on DocumentVersion. The field is removed from the Document model, all SQL queries, GraphQL Document type, SignableDocument type, UpdateDocumentInput, and MCP Document schema. New documents still accept classification in CreateDocumentInput, applied to the first version. New drafts inherit classification from the previous version. PDF generation uses the version classification. The drawer allows editing classification on draft versions via the updateDocumentVersion mutation. Classification is read-only on published versions. Signed-off-by: Sacha Al Himdani --- .../_components/DocumentLayoutDrawer.tsx | 70 ++++++++++++------- .../_components/DocumentListItem.tsx | 29 ++++---- .../_components/ApprovableDocumentRow.tsx | 11 ++- .../employee/_components/DocumentRow.tsx | 11 ++- e2e/console/document_test.go | 8 +-- pkg/coredata/document.go | 36 +++------- pkg/coredata/migrations/20260328T120000Z.sql | 2 + pkg/probo/document_service.go | 28 ++++---- pkg/server/api/console/v1/schema.graphql | 7 +- pkg/server/api/console/v1/types/document.go | 1 - .../api/console/v1/types/employee_document.go | 14 ++-- pkg/server/api/console/v1/v1_resolver.go | 59 ++++++++-------- pkg/server/api/mcp/v1/schema.resolvers.go | 6 +- pkg/server/api/mcp/v1/specification.yaml | 11 +-- pkg/server/api/mcp/v1/types/document.go | 1 - pkg/trust/document_service.go | 12 ++-- 16 files changed, 155 insertions(+), 151 deletions(-) create mode 100644 pkg/coredata/migrations/20260328T120000Z.sql diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentLayoutDrawer.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentLayoutDrawer.tsx index cf7496e12..3a9fba7d7 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentLayoutDrawer.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentLayoutDrawer.tsx @@ -16,19 +16,18 @@ import { documentClassifications, documentTypes, formatDate, getDocumentClassifi import { useTranslate } from "@probo/i18n"; import { Badge, Button, Drawer, IconCheckmark1, IconCrossLargeX, IconPencil, PropertyRow } from "@probo/ui"; import { useState } from "react"; -import { useFragment } from "react-relay"; +import { useFragment, useMutation } from "react-relay"; import { graphql } from "relay-runtime"; import { z } from "zod"; import type { DocumentLayoutDrawer_documentFragment$key } from "#/__generated__/core/DocumentLayoutDrawer_documentFragment.graphql"; +import type { DocumentLayoutDrawer_updateClassificationMutation } from "#/__generated__/core/DocumentLayoutDrawer_updateClassificationMutation.graphql"; import type { DocumentLayoutDrawer_versionFragment$key } from "#/__generated__/core/DocumentLayoutDrawer_versionFragment.graphql"; import type { DocumentLayoutDrawerMutation } from "#/__generated__/core/DocumentLayoutDrawerMutation.graphql"; import { ControlledField } from "#/components/form/ControlledField"; import { DocumentClassificationOptions } from "#/components/form/DocumentClassificationOptions"; import { DocumentTypeOptions } from "#/components/form/DocumentTypeOptions"; import { useFormWithSchema } from "#/hooks/useFormWithSchema"; -import { useMutationWithToasts } from "#/hooks/useMutationWithToasts"; - const documentFragment = graphql` fragment DocumentLayoutDrawer_documentFragment on Document { id @@ -57,6 +56,16 @@ const updateDocumentMutation = graphql` document { id documentType + } + } + } +`; + +const updateClassificationMutation = graphql` + mutation DocumentLayoutDrawer_updateClassificationMutation($input: UpdateDocumentVersionInput!) { + updateDocumentVersion(input: $input) { + documentVersion { + id classification } } @@ -65,6 +74,9 @@ const updateDocumentMutation = graphql` const schema = z.object({ documentType: z.enum(documentTypes), +}); + +const classificationSchema = z.object({ classification: z.enum(documentClassifications), }); @@ -90,47 +102,56 @@ export function DocumentLayoutDrawer(props: { { defaultValues: { documentType: document.documentType, + }, + }, + ); + + const { + control: classificationControl, + handleSubmit: handleClassificationSubmit, + reset: resetClassification, + } = useFormWithSchema( + classificationSchema, + { + defaultValues: { classification: version.classification, }, }, ); const [updateDocument, isUpdatingDocument] - = useMutationWithToasts( - updateDocumentMutation, - { - successMessage: __("Document updated successfully."), - errorMessage: __("Failed to update document"), - }, - ); + = useMutation(updateDocumentMutation); - const handleUpdateDocumentType = async (data: { + const [updateClassification, isUpdatingClassification] + = useMutation(updateClassificationMutation); + + const handleUpdateDocumentType = (data: { documentType: (typeof documentTypes)[number]; }) => { - await updateDocument({ + updateDocument({ variables: { input: { id: document.id, documentType: data.documentType, }, }, - onSuccess: () => { + onCompleted: () => { setIsEditingType(false); }, }); }; - const handleUpdateClassification = async (data: { + const handleUpdateClassification = (data: { classification: (typeof documentClassifications)[number]; }) => { - await updateDocument({ + updateClassification({ variables: { input: { - id: document.id, + documentVersionId: version.id, classification: data.classification, }, }, - onSuccess: () => { + onCompleted: () => { setIsEditingClassification(false); }, }); @@ -176,16 +197,16 @@ export function DocumentLayoutDrawer(props: { {isEditingClassification ? ( void handleSubmit(handleUpdateClassification)()} + onSave={() => void handleClassificationSubmit(handleUpdateClassification)()} onCancel={() => { setIsEditingClassification(false); - reset(); + resetClassification(); }} - disabled={isUpdatingDocument} + disabled={isUpdatingClassification} > @@ -195,13 +216,10 @@ export function DocumentLayoutDrawer(props: { : ( setIsEditingClassification(true)} - canEdit={canEdit} + canEdit={canEdit && isDraft} >
- {getDocumentClassificationLabel( - __, - version.classification, - )} + {getDocumentClassificationLabel(__, version.classification)}
)} diff --git a/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx b/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx index fe07f2ff6..ca30c240e 100644 --- a/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx +++ b/apps/console/src/pages/organizations/documents/_components/DocumentListItem.tsx @@ -15,12 +15,11 @@ import { formatDate, getDocumentClassificationLabel, getDocumentTypeLabel, sprintf } from "@probo/helpers"; import { useTranslate } from "@probo/i18n"; import { ActionDropdown, Badge, Checkbox, DropdownItem, IconTrashCan, Td, Tr, useConfirm } from "@probo/ui"; -import { useFragment } from "react-relay"; +import { useFragment, useMutation } from "react-relay"; import { type DataID, graphql } from "relay-runtime"; import type { DocumentListItem_deleteMutation } from "#/__generated__/core/DocumentListItem_deleteMutation.graphql"; import type { DocumentListItemFragment$key } from "#/__generated__/core/DocumentListItemFragment.graphql"; -import { useMutationWithToasts } from "#/hooks/useMutationWithToasts"; import { useOrganizationId } from "#/hooks/useOrganizationId"; const fragment = graphql` @@ -28,7 +27,6 @@ const fragment = graphql` id title documentType - classification updatedAt canDelete: permission(action: "core:document:delete") recentVersions: versions(first: 2 orderBy: { field: CREATED_AT direction: DESC }) { @@ -38,6 +36,7 @@ const fragment = graphql` status major minor + classification approvalQuorums(first: 1, orderBy: { field: CREATED_AT, direction: DESC }) { edges { node { @@ -117,23 +116,21 @@ export function DocumentListItem(props: { PUBLISHED: __("Published"), } as const; - const [deleteDocument] = useMutationWithToasts( - deleteDocumentMutation, - { - successMessage: __("Document deleted successfully."), - errorMessage: __("Failed to delete document"), - }, - ); + const [deleteDocument] = useMutation(deleteDocumentMutation); const confirm = useConfirm(); const handleDelete = () => { confirm( () => - deleteDocument({ - variables: { - connections: [connectionId], - input: { documentId: document.id }, - }, + new Promise((resolve, reject) => { + deleteDocument({ + variables: { + connections: [connectionId], + input: { documentId: document.id }, + }, + onCompleted: () => resolve(), + onError: err => reject(err), + }); }), { message: sprintf( @@ -171,7 +168,7 @@ export function DocumentListItem(props: { {getDocumentTypeLabel(__, document.documentType)} - {getDocumentClassificationLabel(__, document.classification)} + {getDocumentClassificationLabel(__, lastVersion.classification)} {(() => { diff --git a/apps/console/src/pages/organizations/employee/_components/ApprovableDocumentRow.tsx b/apps/console/src/pages/organizations/employee/_components/ApprovableDocumentRow.tsx index db39c9e83..94f3535cd 100644 --- a/apps/console/src/pages/organizations/employee/_components/ApprovableDocumentRow.tsx +++ b/apps/console/src/pages/organizations/employee/_components/ApprovableDocumentRow.tsx @@ -28,9 +28,15 @@ const fragment = graphql` id title documentType - classification approvalState updatedAt + lastVersion: versions(first: 1 orderBy: { field: CREATED_AT direction: DESC }) { + edges { + node { + classification + } + } + } } `; @@ -42,6 +48,7 @@ export function ApprovableDocumentRow({ organizationId: string; }) { const document = useFragment(fragment, fKey); + const lastVersion = document.lastVersion.edges[0].node; const { __ } = useTranslate(); const stateVariant = document.approvalState === "APPROVED" @@ -64,7 +71,7 @@ export function ApprovableDocumentRow({ - {getDocumentClassificationLabel(__, document.classification)} + {getDocumentClassificationLabel(__, lastVersion.classification)} {formatDate(document.updatedAt)} diff --git a/apps/console/src/pages/organizations/employee/_components/DocumentRow.tsx b/apps/console/src/pages/organizations/employee/_components/DocumentRow.tsx index 4e1d7623c..08e74211e 100644 --- a/apps/console/src/pages/organizations/employee/_components/DocumentRow.tsx +++ b/apps/console/src/pages/organizations/employee/_components/DocumentRow.tsx @@ -28,9 +28,15 @@ const fragment = graphql` id title documentType - classification signed updatedAt + lastVersion: versions(first: 1 orderBy: { field: CREATED_AT direction: DESC }) { + edges { + node { + classification + } + } + } } `; @@ -42,6 +48,7 @@ export function DocumentRow({ organizationId: string; }) { const document = useFragment(fragment, fKey); + const lastVersion = document.lastVersion.edges[0].node; const { __ } = useTranslate(); return ( @@ -52,7 +59,7 @@ export function DocumentRow({ - {getDocumentClassificationLabel(__, document.classification)} + {getDocumentClassificationLabel(__, lastVersion.classification)} {formatDate(document.updatedAt)} diff --git a/e2e/console/document_test.go b/e2e/console/document_test.go index ede36c5f3..e0583c1cf 100644 --- a/e2e/console/document_test.go +++ b/e2e/console/document_test.go @@ -104,7 +104,6 @@ func TestDocument_Create(t *testing.T) { id title documentType - classification } } } @@ -120,10 +119,9 @@ func TestDocument_Create(t *testing.T) { CreateDocument struct { DocumentEdge struct { Node struct { - ID string `json:"id"` - Title string `json:"title"` - DocumentType string `json:"documentType"` - Classification string `json:"classification"` + ID string `json:"id"` + Title string `json:"title"` + DocumentType string `json:"documentType"` } `json:"node"` } `json:"documentEdge"` } `json:"createDocument"` diff --git a/pkg/coredata/document.go b/pkg/coredata/document.go index e7d2509d0..119e413a0 100644 --- a/pkg/coredata/document.go +++ b/pkg/coredata/document.go @@ -30,18 +30,17 @@ import ( type ( Document struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - Title string `db:"title"` - DocumentType DocumentType `db:"document_type"` - Classification DocumentClassification `db:"classification"` - CurrentPublishedMajor *int `db:"current_published_major"` - CurrentPublishedMinor *int `db:"current_published_minor"` - TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` - Status DocumentStatus `db:"status"` - ArchivedAt *time.Time `db:"archived_at"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + Title string `db:"title"` + DocumentType DocumentType `db:"document_type"` + CurrentPublishedMajor *int `db:"current_published_major"` + CurrentPublishedMinor *int `db:"current_published_minor"` + TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"` + Status DocumentStatus `db:"status"` + ArchivedAt *time.Time `db:"archived_at"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } Documents []*Document @@ -128,7 +127,6 @@ SELECT organization_id, title, document_type, - classification, current_published_major, current_published_minor, trust_center_visibility, @@ -182,7 +180,6 @@ SELECT organization_id, title, document_type, - classification, current_published_major, current_published_minor, trust_center_visibility, @@ -237,7 +234,6 @@ SELECT organization_id, title, document_type, - classification, current_published_major, current_published_minor, trust_center_visibility, @@ -321,7 +317,6 @@ SELECT organization_id, title, document_type, - classification, current_published_major, current_published_minor, trust_center_visibility, @@ -374,7 +369,6 @@ SELECT organization_id, title, document_type, - classification, current_published_major, current_published_minor, trust_center_visibility, @@ -441,7 +435,6 @@ SELECT organization_id, COALESCE(published_title, title) AS title, document_type, - classification, current_published_major, current_published_minor, trust_center_visibility, @@ -491,7 +484,6 @@ INSERT INTO organization_id, title, document_type, - classification, current_published_major, current_published_minor, trust_center_visibility, @@ -506,7 +498,6 @@ VALUES ( @organization_id, @title, @document_type, - @classification, @current_published_major, @current_published_minor, @trust_center_visibility, @@ -523,7 +514,6 @@ VALUES ( "organization_id": p.OrganizationID, "title": p.Title, "document_type": p.DocumentType, - "classification": p.Classification, "current_published_major": p.CurrentPublishedMajor, "current_published_minor": p.CurrentPublishedMinor, "trust_center_visibility": p.TrustCenterVisibility, @@ -586,7 +576,6 @@ SET current_published_major = @current_published_major, current_published_minor = @current_published_minor, document_type = @document_type, - classification = @classification, trust_center_visibility = @trust_center_visibility, status = @status, archived_at = @archived_at, @@ -605,7 +594,6 @@ WHERE "current_published_major": p.CurrentPublishedMajor, "current_published_minor": p.CurrentPublishedMinor, "document_type": p.DocumentType, - "classification": p.Classification, "trust_center_visibility": p.TrustCenterVisibility, "status": p.Status, "archived_at": p.ArchivedAt, @@ -678,7 +666,6 @@ SELECT scoped_documents.organization_id, scoped_documents.title, scoped_documents.document_type, - scoped_documents.classification, scoped_documents.current_published_major, scoped_documents.current_published_minor, scoped_documents.trust_center_visibility, @@ -770,7 +757,6 @@ SELECT scoped_documents.organization_id, scoped_documents.title, scoped_documents.document_type, - scoped_documents.classification, scoped_documents.current_published_major, scoped_documents.current_published_minor, scoped_documents.trust_center_visibility, diff --git a/pkg/coredata/migrations/20260328T120000Z.sql b/pkg/coredata/migrations/20260328T120000Z.sql new file mode 100644 index 000000000..ecdc95ce2 --- /dev/null +++ b/pkg/coredata/migrations/20260328T120000Z.sql @@ -0,0 +1,2 @@ +-- TODO: drop the classification column from documents. +ALTER TABLE documents ALTER COLUMN classification SET DEFAULT 'SECRET'; diff --git a/pkg/probo/document_service.go b/pkg/probo/document_service.go index 97b5349bd..7dd7f9b06 100644 --- a/pkg/probo/document_service.go +++ b/pkg/probo/document_service.go @@ -85,14 +85,14 @@ type ( UpdateDocumentRequest struct { DocumentID gid.GID Title *string - Classification *coredata.DocumentClassification DocumentType *coredata.DocumentType TrustCenterVisibility *coredata.TrustCenterVisibility } UpdateDocumentVersionRequest struct { - ID gid.GID - Content string + ID gid.GID + Content *string + Classification *coredata.DocumentClassification } RequestSignatureRequest struct { @@ -133,7 +133,6 @@ func (udr *UpdateDocumentRequest) Validate() error { v.Check(udr.DocumentID, "document_id", validator.Required(), validator.GID(coredata.DocumentEntityType)) v.Check(udr.Title, "title", validator.SafeTextNoNewLine(TitleMaxLength)) - v.Check(udr.Classification, "classification", validator.OneOfSlice(coredata.DocumentClassifications())) v.Check(udr.DocumentType, "document_type", validator.OneOfSlice(coredata.DocumentTypes())) v.Check(udr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities())) @@ -144,7 +143,8 @@ func (udvr *UpdateDocumentVersionRequest) Validate() error { v := validator.New() v.Check(udvr.ID, "id", validator.Required(), validator.GID(coredata.DocumentVersionEntityType)) - v.Check(udvr.Content, "content", validator.Required(), validator.NotEmpty(), validator.MaxLen(documentMaxLength)) + v.Check(udvr.Content, "content", validator.NotEmpty(), validator.MaxLen(documentMaxLength)) + v.Check(udvr.Classification, "classification", validator.OneOfSlice(coredata.DocumentClassifications())) return v.Error() } @@ -509,7 +509,6 @@ func (s *DocumentService) Create( Title: req.Title, DocumentType: req.DocumentType, TrustCenterVisibility: coredata.TrustCenterVisibilityNone, - Classification: req.Classification, Status: coredata.DocumentStatusActive, CreatedAt: now, UpdatedAt: now, @@ -763,8 +762,12 @@ func (s *DocumentService) UpdateVersion( } documentVersion.Title = document.Title - documentVersion.Classification = document.Classification - documentVersion.Content = req.Content + if req.Content != nil { + documentVersion.Content = *req.Content + } + if req.Classification != nil { + documentVersion.Classification = *req.Classification + } documentVersion.UpdatedAt = time.Now() if err := documentVersion.Update(ctx, conn, s.svc.scope); err != nil { @@ -1002,7 +1005,7 @@ func (s *DocumentService) CreateDraft( draftVersion.Title = document.Title draftVersion.Major = latestVersion.Major draftVersion.Minor = latestVersion.Minor + 1 - draftVersion.Classification = document.Classification + draftVersion.Classification = latestVersion.Classification draftVersion.Content = latestVersion.Content draftVersion.Status = coredata.DocumentVersionStatusDraft draftVersion.CreatedAt = now @@ -1533,10 +1536,6 @@ func (s *DocumentService) Update( document.Title = *req.Title } - if req.Classification != nil { - document.Classification = *req.Classification - } - if req.DocumentType != nil { document.DocumentType = *req.DocumentType } @@ -1559,7 +1558,6 @@ func (s *DocumentService) Update( err := draftVersion.LoadLatestVersion(ctx, tx, s.svc.scope, req.DocumentID) if err == nil && draftVersion.Status == coredata.DocumentVersionStatusDraft { draftVersion.Title = document.Title - draftVersion.Classification = document.Classification draftVersion.UpdatedAt = now if err := draftVersion.Update(ctx, tx, s.svc.scope); err != nil { @@ -1934,7 +1932,7 @@ func exportDocumentPDF( } classification := docgen.ClassificationSecret - switch document.Classification { + switch version.Classification { case coredata.DocumentClassificationPublic: classification = docgen.ClassificationPublic case coredata.DocumentClassificationInternal: diff --git a/pkg/server/api/console/v1/schema.graphql b/pkg/server/api/console/v1/schema.graphql index afe01c8d8..2b947f81b 100644 --- a/pkg/server/api/console/v1/schema.graphql +++ b/pkg/server/api/console/v1/schema.graphql @@ -2440,7 +2440,6 @@ type Document implements Node { title: String! description: String documentType: DocumentType! - classification: DocumentClassification! currentPublishedMajor: Int currentPublishedMinor: Int trustCenterVisibility: TrustCenterVisibility! @@ -2481,7 +2480,6 @@ type EmployeeDocument title: String! description: String documentType: DocumentType! - classification: DocumentClassification! signed: Boolean @goField(forceResolver: true) approvalState: DocumentVersionApprovalDecisionState @goField(forceResolver: true) @@ -2505,6 +2503,7 @@ type EmployeeDocumentVersion major: Int! minor: Int! status: DocumentVersionStatus! + classification: DocumentClassification! signed: Boolean! @goField(forceResolver: true) approvalDecision: DocumentVersionApprovalDecision @goField(forceResolver: true) publishedAt: Datetime @@ -4482,7 +4481,6 @@ input UpdateDocumentInput { title: String content: String documentType: DocumentType - classification: DocumentClassification trustCenterVisibility: TrustCenterVisibility } @@ -5738,7 +5736,8 @@ input DeleteDraftDocumentVersionInput { input UpdateDocumentVersionInput { documentVersionId: ID! - content: String! + content: String + classification: DocumentClassification } input CancelSignatureRequestInput { diff --git a/pkg/server/api/console/v1/types/document.go b/pkg/server/api/console/v1/types/document.go index 30ca61e70..7da415cba 100644 --- a/pkg/server/api/console/v1/types/document.go +++ b/pkg/server/api/console/v1/types/document.go @@ -81,7 +81,6 @@ func NewDocument(document *coredata.Document) *Document { ID: document.OrganizationID, }, DocumentType: document.DocumentType, - Classification: document.Classification, CurrentPublishedMajor: document.CurrentPublishedMajor, CurrentPublishedMinor: document.CurrentPublishedMinor, TrustCenterVisibility: document.TrustCenterVisibility, diff --git a/pkg/server/api/console/v1/types/employee_document.go b/pkg/server/api/console/v1/types/employee_document.go index ae30b423f..02be4011b 100644 --- a/pkg/server/api/console/v1/types/employee_document.go +++ b/pkg/server/api/console/v1/types/employee_document.go @@ -42,13 +42,12 @@ type ( } EmployeeDocument struct { - ID gid.GID - Title string - Description *string - DocumentType coredata.DocumentType - Classification coredata.DocumentClassification - CreatedAt time.Time - UpdatedAt time.Time + ID gid.GID + Title string + Description *string + DocumentType coredata.DocumentType + CreatedAt time.Time + UpdatedAt time.Time FilterMode EmployeeDocumentFilterMode } @@ -69,6 +68,7 @@ type ( Major int Minor int Status coredata.DocumentVersionStatus + Classification coredata.DocumentClassification PublishedAt *time.Time CreatedAt time.Time UpdatedAt time.Time diff --git a/pkg/server/api/console/v1/v1_resolver.go b/pkg/server/api/console/v1/v1_resolver.go index ca784ecd2..25f569da4 100644 --- a/pkg/server/api/console/v1/v1_resolver.go +++ b/pkg/server/api/console/v1/v1_resolver.go @@ -1664,6 +1664,7 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl Major: v.Major, Minor: v.Minor, Status: v.Status, + Classification: v.Classification, PublishedAt: v.PublishedAt, CreatedAt: v.CreatedAt, UpdatedAt: v.UpdatedAt, @@ -4669,7 +4670,6 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat probo.UpdateDocumentRequest{ DocumentID: input.ID, Title: input.Title, - Classification: input.Classification, DocumentType: input.DocumentType, TrustCenterVisibility: input.TrustCenterVisibility, }, @@ -5410,8 +5410,9 @@ func (r *mutationResolver) UpdateDocumentVersion(ctx context.Context, input type documentVersion, err := prb.Documents.UpdateVersion( ctx, probo.UpdateDocumentVersionRequest{ - ID: input.DocumentVersionID, - Content: input.Content, + ID: input.DocumentVersionID, + Content: input.Content, + Classification: input.Classification, }, ) if err != nil { @@ -10243,13 +10244,12 @@ func (r *viewerResolver) SignableDocuments(ctx context.Context, obj *types.Viewe employeeDocuments := make([]*types.EmployeeDocument, len(documentsPage.Data)) for i, doc := range documentsPage.Data { employeeDocuments[i] = &types.EmployeeDocument{ - ID: doc.ID, - Title: doc.Title, - DocumentType: doc.DocumentType, - Classification: doc.Classification, - CreatedAt: doc.CreatedAt, - UpdatedAt: doc.UpdatedAt, - FilterMode: types.EmployeeDocumentFilterModeSignature, + ID: doc.ID, + Title: doc.Title, + DocumentType: doc.DocumentType, + CreatedAt: doc.CreatedAt, + UpdatedAt: doc.UpdatedAt, + FilterMode: types.EmployeeDocumentFilterModeSignature, } } @@ -10280,13 +10280,12 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer } return &types.EmployeeDocument{ - ID: document.ID, - Title: document.Title, - DocumentType: document.DocumentType, - Classification: document.Classification, - CreatedAt: document.CreatedAt, - UpdatedAt: document.UpdatedAt, - FilterMode: types.EmployeeDocumentFilterModeSignature, + ID: document.ID, + Title: document.Title, + DocumentType: document.DocumentType, + CreatedAt: document.CreatedAt, + UpdatedAt: document.UpdatedAt, + FilterMode: types.EmployeeDocumentFilterModeSignature, }, nil } @@ -10324,13 +10323,12 @@ func (r *viewerResolver) ApprovableDocuments(ctx context.Context, obj *types.Vie employeeDocuments := make([]*types.EmployeeDocument, len(documentsPage.Data)) for i, doc := range documentsPage.Data { employeeDocuments[i] = &types.EmployeeDocument{ - ID: doc.ID, - Title: doc.Title, - DocumentType: doc.DocumentType, - Classification: doc.Classification, - CreatedAt: doc.CreatedAt, - UpdatedAt: doc.UpdatedAt, - FilterMode: types.EmployeeDocumentFilterModeApproval, + ID: doc.ID, + Title: doc.Title, + DocumentType: doc.DocumentType, + CreatedAt: doc.CreatedAt, + UpdatedAt: doc.UpdatedAt, + FilterMode: types.EmployeeDocumentFilterModeApproval, } } @@ -10361,13 +10359,12 @@ func (r *viewerResolver) ApprovableDocument(ctx context.Context, obj *types.View } return &types.EmployeeDocument{ - ID: document.ID, - Title: document.Title, - DocumentType: document.DocumentType, - Classification: document.Classification, - CreatedAt: document.CreatedAt, - UpdatedAt: document.UpdatedAt, - FilterMode: types.EmployeeDocumentFilterModeApproval, + ID: document.ID, + Title: document.Title, + DocumentType: document.DocumentType, + CreatedAt: document.CreatedAt, + UpdatedAt: document.UpdatedAt, + FilterMode: types.EmployeeDocumentFilterModeApproval, }, nil } diff --git a/pkg/server/api/mcp/v1/schema.resolvers.go b/pkg/server/api/mcp/v1/schema.resolvers.go index 6b8749bdc..81e83e2c3 100644 --- a/pkg/server/api/mcp/v1/schema.resolvers.go +++ b/pkg/server/api/mcp/v1/schema.resolvers.go @@ -2106,7 +2106,6 @@ func (r *Resolver) UpdateDocumentTool(ctx context.Context, req *mcp.CallToolRequ probo.UpdateDocumentRequest{ DocumentID: input.ID, Title: input.Title, - Classification: input.Classification, DocumentType: input.DocumentType, TrustCenterVisibility: input.TrustCenterVisibility, }, @@ -2183,8 +2182,9 @@ func (r *Resolver) UpdateDocumentVersionTool(ctx context.Context, req *mcp.CallT documentVersion, err := svc.Documents.UpdateVersion( ctx, probo.UpdateDocumentVersionRequest{ - ID: input.DocumentVersionID, - Content: input.Content, + ID: input.DocumentVersionID, + Content: input.Content, + Classification: input.Classification, }, ) if err != nil { diff --git a/pkg/server/api/mcp/v1/specification.yaml b/pkg/server/api/mcp/v1/specification.yaml index e8ce19ee1..b855e7304 100644 --- a/pkg/server/api/mcp/v1/specification.yaml +++ b/pkg/server/api/mcp/v1/specification.yaml @@ -5186,7 +5186,6 @@ components: - organization_id - title - document_type - - classification - trust_center_visibility - status - created_at @@ -5204,9 +5203,6 @@ components: document_type: $ref: "#/components/schemas/DocumentType" description: Document type - classification: - $ref: "#/components/schemas/DocumentClassification" - description: Document classification current_published_major: type: - integer @@ -5459,9 +5455,6 @@ components: title: type: string description: Document title - classification: - $ref: "#/components/schemas/DocumentClassification" - description: Document classification document_type: $ref: "#/components/schemas/DocumentType" description: Document type @@ -5580,7 +5573,6 @@ components: type: object required: - document_version_id - - content properties: document_version_id: $ref: "#/components/schemas/GID" @@ -5588,6 +5580,9 @@ components: content: type: string description: Document content + classification: + $ref: "#/components/schemas/DocumentClassification" + description: Document classification UpdateDocumentVersionOutput: type: object diff --git a/pkg/server/api/mcp/v1/types/document.go b/pkg/server/api/mcp/v1/types/document.go index 8e29bbcac..6cdb3b30a 100644 --- a/pkg/server/api/mcp/v1/types/document.go +++ b/pkg/server/api/mcp/v1/types/document.go @@ -25,7 +25,6 @@ func NewDocument(d *coredata.Document) *Document { OrganizationID: d.OrganizationID, Title: d.Title, DocumentType: d.DocumentType, - Classification: d.Classification, CurrentPublishedMajor: d.CurrentPublishedMajor, CurrentPublishedMinor: d.CurrentPublishedMinor, TrustCenterVisibility: d.TrustCenterVisibility, diff --git a/pkg/trust/document_service.go b/pkg/trust/document_service.go index e874a094c..18ae84d18 100644 --- a/pkg/trust/document_service.go +++ b/pkg/trust/document_service.go @@ -219,12 +219,14 @@ func (s *DocumentService) exportPDFData( return nil, err } - classification := docgen.ClassificationInternal - switch document.DocumentType { - case coredata.DocumentTypePolicy: + classification := docgen.ClassificationSecret + switch version.Classification { + case coredata.DocumentClassificationPublic: + classification = docgen.ClassificationPublic + case coredata.DocumentClassificationInternal: + classification = docgen.ClassificationInternal + case coredata.DocumentClassificationConfidential: classification = docgen.ClassificationConfidential - case coredata.DocumentTypeGovernance: - classification = docgen.ClassificationSecret } horizontalLogoBase64 := ""