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

@@ -2543,7 +2543,6 @@ type Document implements Node {
id: ID!
title: String!
description: String
documentType: DocumentType!
currentPublishedMajor: Int
currentPublishedMinor: Int
trustCenterVisibility: TrustCenterVisibility!
@@ -2583,7 +2582,6 @@ type EmployeeDocument
id: ID!
title: String!
description: String
documentType: DocumentType!
signed: Boolean @goField(forceResolver: true)
approvalState: DocumentVersionApprovalDecisionState @goField(forceResolver: true)
@@ -2608,6 +2606,7 @@ type EmployeeDocumentVersion
minor: Int!
status: DocumentVersionStatus!
classification: DocumentClassification!
documentType: DocumentType!
signed: Boolean! @goField(forceResolver: true)
approvalDecision: DocumentVersionApprovalDecision @goField(forceResolver: true)
publishedAt: Datetime
@@ -4642,7 +4641,6 @@ input UpdateDocumentInput {
id: ID!
title: String
content: String
documentType: DocumentType
trustCenterVisibility: TrustCenterVisibility
}
@@ -5529,6 +5527,7 @@ type DocumentVersion implements Node {
changelog: String!
title: String!
classification: DocumentClassification!
documentType: DocumentType!
approvers(
first: Int
after: CursorKey
@@ -5900,6 +5899,7 @@ input UpdateDocumentVersionInput {
documentVersionId: ID!
content: String
classification: DocumentClassification
documentType: DocumentType
}
input CancelSignatureRequestInput {

View File

@@ -80,7 +80,6 @@ func NewDocument(document *coredata.Document) *Document {
Organization: &Organization{
ID: document.OrganizationID,
},
DocumentType: document.DocumentType,
CurrentPublishedMajor: document.CurrentPublishedMajor,
CurrentPublishedMinor: document.CurrentPublishedMinor,
TrustCenterVisibility: document.TrustCenterVisibility,

View File

@@ -82,6 +82,7 @@ func NewDocumentVersion(documentVersion *coredata.DocumentVersion) *DocumentVers
Content: documentVersion.Content,
Status: documentVersion.Status,
Classification: documentVersion.Classification,
DocumentType: documentVersion.DocumentType,
PublishedAt: documentVersion.PublishedAt,
Changelog: documentVersion.Changelog,
CreatedAt: documentVersion.CreatedAt,

View File

@@ -70,6 +70,7 @@ type (
Minor int
Status coredata.DocumentVersionStatus
Classification coredata.DocumentClassification
DocumentType coredata.DocumentType
PublishedAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time

View File

@@ -2168,6 +2168,7 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl
Minor: v.Minor,
Status: v.Status,
Classification: v.Classification,
DocumentType: v.DocumentType,
PublishedAt: v.PublishedAt,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
@@ -5142,10 +5143,10 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
ctx,
probo.CreateDocumentRequest{
OrganizationID: input.OrganizationID,
DocumentType: input.DocumentType,
Title: input.Title,
Content: content,
Classification: input.Classification,
DocumentType: input.DocumentType,
TrustCenterVisibility: input.TrustCenterVisibility,
},
)
@@ -5180,7 +5181,6 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
probo.UpdateDocumentRequest{
DocumentID: input.ID,
Title: input.Title,
DocumentType: input.DocumentType,
TrustCenterVisibility: input.TrustCenterVisibility,
},
)
@@ -5923,6 +5923,7 @@ func (r *mutationResolver) UpdateDocumentVersion(ctx context.Context, input type
ID: input.DocumentVersionID,
Content: input.Content,
Classification: input.Classification,
DocumentType: input.DocumentType,
},
)
if err != nil {

View File

@@ -2095,7 +2095,6 @@ func (r *Resolver) UpdateDocumentTool(ctx context.Context, req *mcp.CallToolRequ
probo.UpdateDocumentRequest{
DocumentID: input.ID,
Title: input.Title,
DocumentType: input.DocumentType,
TrustCenterVisibility: input.TrustCenterVisibility,
},
)
@@ -2201,6 +2200,7 @@ func (r *Resolver) UpdateDocumentVersionTool(ctx context.Context, req *mcp.CallT
ID: input.DocumentVersionID,
Content: content,
Classification: input.Classification,
DocumentType: input.DocumentType,
},
)
if err != nil {

View File

@@ -5207,7 +5207,6 @@ components:
- id
- organization_id
- title
- document_type
- trust_center_visibility
- status
- created_at
@@ -5222,9 +5221,6 @@ components:
title:
type: string
description: Document title
document_type:
$ref: "#/components/schemas/DocumentType"
description: Document type
current_published_major:
type:
- integer
@@ -5266,6 +5262,7 @@ components:
- major
- minor
- classification
- document_type
- content
- changelog
- status
@@ -5293,6 +5290,9 @@ components:
classification:
$ref: "#/components/schemas/DocumentClassification"
description: Document classification
document_type:
$ref: "#/components/schemas/DocumentType"
description: Document type
content:
type: string
description: Document content
@@ -5482,9 +5482,6 @@ components:
title:
type: string
description: Document title
document_type:
$ref: "#/components/schemas/DocumentType"
description: Document type
trust_center_visibility:
$ref: "#/components/schemas/TrustCenterVisibility"
description: Trust center visibility
@@ -5613,6 +5610,9 @@ components:
classification:
$ref: "#/components/schemas/DocumentClassification"
description: Document classification
document_type:
$ref: "#/components/schemas/DocumentType"
description: Document type
UpdateDocumentVersionOutput:
type: object

View File

@@ -24,7 +24,6 @@ func NewDocument(d *coredata.Document) *Document {
ID: d.ID,
OrganizationID: d.OrganizationID,
Title: d.Title,
DocumentType: d.DocumentType,
CurrentPublishedMajor: d.CurrentPublishedMajor,
CurrentPublishedMinor: d.CurrentPublishedMinor,
TrustCenterVisibility: d.TrustCenterVisibility,
@@ -87,6 +86,7 @@ func NewDocumentVersion(dv *coredata.DocumentVersion) *DocumentVersion {
Major: dv.Major,
Minor: dv.Minor,
Classification: dv.Classification,
DocumentType: dv.DocumentType,
Content: dv.Content,
Changelog: dv.Changelog,
Status: dv.Status,