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:
@@ -33,7 +33,6 @@ type (
|
||||
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"`
|
||||
@@ -41,6 +40,9 @@ type (
|
||||
ArchivedAt *time.Time `db:"archived_at"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
|
||||
// ordering only
|
||||
DocumentType DocumentType `db:"document_type"`
|
||||
}
|
||||
|
||||
Documents []*Document
|
||||
@@ -122,24 +124,30 @@ func (p *Document) LoadByID(
|
||||
documentID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_major,
|
||||
current_published_minor,
|
||||
trust_center_visibility,
|
||||
status,
|
||||
archived_at,
|
||||
created_at,
|
||||
updated_at
|
||||
documents.id,
|
||||
documents.organization_id,
|
||||
documents.title,
|
||||
documents.current_published_major,
|
||||
documents.current_published_minor,
|
||||
documents.trust_center_visibility,
|
||||
documents.status,
|
||||
documents.archived_at,
|
||||
documents.created_at,
|
||||
documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM
|
||||
documents
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = documents.id
|
||||
WHERE
|
||||
%s
|
||||
AND deleted_at IS NULL
|
||||
AND id = @document_id
|
||||
AND documents.deleted_at IS NULL
|
||||
AND documents.id = @document_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
@@ -175,24 +183,30 @@ func (p *Document) LoadByIDWithFilter(
|
||||
filter *DocumentFilter,
|
||||
) error {
|
||||
q := `
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_major,
|
||||
current_published_minor,
|
||||
trust_center_visibility,
|
||||
status,
|
||||
archived_at,
|
||||
created_at,
|
||||
updated_at
|
||||
documents.id,
|
||||
documents.organization_id,
|
||||
documents.title,
|
||||
documents.current_published_major,
|
||||
documents.current_published_minor,
|
||||
documents.trust_center_visibility,
|
||||
documents.status,
|
||||
documents.archived_at,
|
||||
documents.created_at,
|
||||
documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM
|
||||
documents
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = documents.id
|
||||
WHERE
|
||||
%s
|
||||
AND deleted_at IS NULL
|
||||
AND id = @document_id
|
||||
AND documents.deleted_at IS NULL
|
||||
AND documents.id = @document_id
|
||||
AND %s
|
||||
LIMIT 1;
|
||||
`
|
||||
@@ -229,24 +243,30 @@ func (p *Documents) LoadByIDs(
|
||||
documentIDs []gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_major,
|
||||
current_published_minor,
|
||||
trust_center_visibility,
|
||||
status,
|
||||
archived_at,
|
||||
created_at,
|
||||
updated_at
|
||||
documents.id,
|
||||
documents.organization_id,
|
||||
documents.title,
|
||||
documents.current_published_major,
|
||||
documents.current_published_minor,
|
||||
documents.trust_center_visibility,
|
||||
documents.status,
|
||||
documents.archived_at,
|
||||
documents.created_at,
|
||||
documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM
|
||||
documents
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = documents.id
|
||||
WHERE
|
||||
%s
|
||||
AND deleted_at IS NULL
|
||||
AND id = ANY(@document_ids)
|
||||
AND documents.deleted_at IS NULL
|
||||
AND documents.id = ANY(@document_ids)
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
@@ -312,24 +332,30 @@ func (p *Documents) LoadByOrganizationID(
|
||||
filter *DocumentFilter,
|
||||
) error {
|
||||
q := `
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_major,
|
||||
current_published_minor,
|
||||
trust_center_visibility,
|
||||
status,
|
||||
archived_at,
|
||||
created_at,
|
||||
updated_at
|
||||
documents.id,
|
||||
documents.organization_id,
|
||||
documents.title,
|
||||
documents.current_published_major,
|
||||
documents.current_published_minor,
|
||||
documents.trust_center_visibility,
|
||||
documents.status,
|
||||
documents.archived_at,
|
||||
documents.created_at,
|
||||
documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM
|
||||
documents
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = documents.id
|
||||
WHERE
|
||||
%s
|
||||
AND deleted_at IS NULL
|
||||
AND organization_id = @organization_id
|
||||
AND documents.deleted_at IS NULL
|
||||
AND documents.organization_id = @organization_id
|
||||
AND %s
|
||||
AND %s
|
||||
`
|
||||
@@ -364,24 +390,30 @@ func (p *Documents) LoadAllByOrganizationID(
|
||||
filter *DocumentFilter,
|
||||
) error {
|
||||
q := `
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_major,
|
||||
current_published_minor,
|
||||
trust_center_visibility,
|
||||
status,
|
||||
archived_at,
|
||||
created_at,
|
||||
updated_at
|
||||
documents.id,
|
||||
documents.organization_id,
|
||||
documents.title,
|
||||
documents.current_published_major,
|
||||
documents.current_published_minor,
|
||||
documents.trust_center_visibility,
|
||||
documents.status,
|
||||
documents.archived_at,
|
||||
documents.created_at,
|
||||
documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM
|
||||
documents
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = documents.id
|
||||
WHERE
|
||||
%s
|
||||
AND deleted_at IS NULL
|
||||
AND organization_id = @organization_id
|
||||
AND documents.deleted_at IS NULL
|
||||
AND documents.organization_id = @organization_id
|
||||
AND %s
|
||||
ORDER BY title ASC
|
||||
`
|
||||
@@ -416,7 +448,12 @@ func (p *Documents) LoadPublishedByOrganizationID(
|
||||
filter *DocumentFilter,
|
||||
) error {
|
||||
q := `
|
||||
WITH published_documents AS (
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
),
|
||||
published_documents AS (
|
||||
SELECT
|
||||
d.*,
|
||||
dv.title AS published_title
|
||||
@@ -431,19 +468,20 @@ WITH published_documents AS (
|
||||
AND d.organization_id = @organization_id
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
COALESCE(published_title, title) AS title,
|
||||
document_type,
|
||||
current_published_major,
|
||||
current_published_minor,
|
||||
trust_center_visibility,
|
||||
status,
|
||||
archived_at,
|
||||
created_at,
|
||||
updated_at
|
||||
documents.id,
|
||||
documents.organization_id,
|
||||
COALESCE(documents.published_title, documents.title) AS title,
|
||||
documents.current_published_major,
|
||||
documents.current_published_minor,
|
||||
documents.trust_center_visibility,
|
||||
documents.status,
|
||||
documents.archived_at,
|
||||
documents.created_at,
|
||||
documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM
|
||||
published_documents documents
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = documents.id
|
||||
WHERE
|
||||
%s
|
||||
AND %s
|
||||
@@ -483,7 +521,6 @@ INSERT INTO
|
||||
id,
|
||||
organization_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_major,
|
||||
current_published_minor,
|
||||
trust_center_visibility,
|
||||
@@ -497,7 +534,6 @@ VALUES (
|
||||
@document_id,
|
||||
@organization_id,
|
||||
@title,
|
||||
@document_type,
|
||||
@current_published_major,
|
||||
@current_published_minor,
|
||||
@trust_center_visibility,
|
||||
@@ -513,7 +549,6 @@ VALUES (
|
||||
"document_id": p.ID,
|
||||
"organization_id": p.OrganizationID,
|
||||
"title": p.Title,
|
||||
"document_type": p.DocumentType,
|
||||
"current_published_major": p.CurrentPublishedMajor,
|
||||
"current_published_minor": p.CurrentPublishedMinor,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
@@ -575,7 +610,6 @@ SET
|
||||
title = @title,
|
||||
current_published_major = @current_published_major,
|
||||
current_published_minor = @current_published_minor,
|
||||
document_type = @document_type,
|
||||
trust_center_visibility = @trust_center_visibility,
|
||||
status = @status,
|
||||
archived_at = @archived_at,
|
||||
@@ -593,7 +627,6 @@ WHERE
|
||||
"title": p.Title,
|
||||
"current_published_major": p.CurrentPublishedMajor,
|
||||
"current_published_minor": p.CurrentPublishedMinor,
|
||||
"document_type": p.DocumentType,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
"status": p.Status,
|
||||
"archived_at": p.ArchivedAt,
|
||||
@@ -653,7 +686,12 @@ func (p *Documents) LoadByControlID(
|
||||
filter *DocumentFilter,
|
||||
) error {
|
||||
q := `
|
||||
WITH scoped_documents AS (
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
),
|
||||
scoped_documents AS (
|
||||
SELECT *
|
||||
FROM documents
|
||||
WHERE %s
|
||||
@@ -665,16 +703,17 @@ SELECT
|
||||
scoped_documents.id,
|
||||
scoped_documents.organization_id,
|
||||
scoped_documents.title,
|
||||
scoped_documents.document_type,
|
||||
scoped_documents.current_published_major,
|
||||
scoped_documents.current_published_minor,
|
||||
scoped_documents.trust_center_visibility,
|
||||
scoped_documents.status,
|
||||
scoped_documents.archived_at,
|
||||
scoped_documents.created_at,
|
||||
scoped_documents.updated_at
|
||||
scoped_documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM scoped_documents
|
||||
INNER JOIN controls_documents cp ON scoped_documents.id = cp.document_id
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = scoped_documents.id
|
||||
WHERE cp.control_id = @control_id
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), filter.SQLFragment(), cursor.SQLFragment())
|
||||
@@ -744,7 +783,12 @@ func (p *Documents) LoadByRiskID(
|
||||
filter *DocumentFilter,
|
||||
) error {
|
||||
q := `
|
||||
WITH scoped_documents AS (
|
||||
WITH latest_versions AS (
|
||||
SELECT DISTINCT ON (document_id) document_id, document_type
|
||||
FROM document_versions
|
||||
ORDER BY document_id, major DESC, minor DESC
|
||||
),
|
||||
scoped_documents AS (
|
||||
SELECT *
|
||||
FROM documents
|
||||
WHERE %s
|
||||
@@ -756,16 +800,17 @@ SELECT
|
||||
scoped_documents.id,
|
||||
scoped_documents.organization_id,
|
||||
scoped_documents.title,
|
||||
scoped_documents.document_type,
|
||||
scoped_documents.current_published_major,
|
||||
scoped_documents.current_published_minor,
|
||||
scoped_documents.trust_center_visibility,
|
||||
scoped_documents.status,
|
||||
scoped_documents.archived_at,
|
||||
scoped_documents.created_at,
|
||||
scoped_documents.updated_at
|
||||
scoped_documents.updated_at,
|
||||
COALESCE(lv.document_type, 'OTHER') AS document_type
|
||||
FROM scoped_documents
|
||||
INNER JOIN risks_documents rp ON scoped_documents.id = rp.document_id
|
||||
LEFT JOIN latest_versions lv ON lv.document_id = scoped_documents.id
|
||||
WHERE rp.risk_id = @risk_id
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), filter.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
@@ -180,7 +180,13 @@ func (f *DocumentFilter) SQLFragment() string {
|
||||
AND
|
||||
CASE
|
||||
WHEN @document_types::document_type[] IS NOT NULL THEN
|
||||
document_type = ANY(@document_types::document_type[])
|
||||
(
|
||||
SELECT dv.document_type
|
||||
FROM document_versions dv
|
||||
WHERE dv.document_id = documents.id
|
||||
ORDER BY dv.major DESC, dv.minor DESC
|
||||
LIMIT 1
|
||||
) = ANY(@document_types::document_type[])
|
||||
ELSE TRUE
|
||||
END
|
||||
AND
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
|
||||
type (
|
||||
DocumentOrderField string
|
||||
)
|
||||
@@ -25,7 +27,25 @@ const (
|
||||
)
|
||||
|
||||
func (p DocumentOrderField) Column() string {
|
||||
return string(p)
|
||||
switch p {
|
||||
case DocumentOrderFieldCreatedAt:
|
||||
return "created_at"
|
||||
case DocumentOrderFieldTitle:
|
||||
return "title"
|
||||
case DocumentOrderFieldDocumentType:
|
||||
return "document_type"
|
||||
}
|
||||
panic(fmt.Sprintf("unsupported order by: %s", p))
|
||||
}
|
||||
|
||||
func (p DocumentOrderField) IsValid() bool {
|
||||
switch p {
|
||||
case DocumentOrderFieldCreatedAt,
|
||||
DocumentOrderFieldTitle,
|
||||
DocumentOrderFieldDocumentType:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (p DocumentOrderField) String() string {
|
||||
@@ -38,5 +58,8 @@ func (p DocumentOrderField) MarshalText() ([]byte, error) {
|
||||
|
||||
func (p *DocumentOrderField) UnmarshalText(text []byte) error {
|
||||
*p = DocumentOrderField(text)
|
||||
if !p.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid DocumentOrderField", string(text))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ type (
|
||||
Major int `db:"major"`
|
||||
Minor int `db:"minor"`
|
||||
Classification DocumentClassification `db:"classification"`
|
||||
DocumentType DocumentType `db:"document_type"`
|
||||
Content string `db:"content"`
|
||||
Changelog string `db:"changelog"`
|
||||
Status DocumentVersionStatus `db:"status"`
|
||||
@@ -120,6 +121,7 @@ SELECT
|
||||
major,
|
||||
minor,
|
||||
classification,
|
||||
document_type,
|
||||
content,
|
||||
changelog,
|
||||
status,
|
||||
@@ -182,6 +184,7 @@ SELECT
|
||||
major,
|
||||
minor,
|
||||
classification,
|
||||
document_type,
|
||||
content,
|
||||
changelog,
|
||||
status,
|
||||
@@ -233,6 +236,7 @@ INSERT INTO document_versions (
|
||||
major,
|
||||
minor,
|
||||
classification,
|
||||
document_type,
|
||||
content,
|
||||
changelog,
|
||||
status,
|
||||
@@ -248,6 +252,7 @@ VALUES (
|
||||
@major,
|
||||
@minor,
|
||||
@classification,
|
||||
@document_type,
|
||||
@content,
|
||||
@changelog,
|
||||
@status,
|
||||
@@ -264,6 +269,7 @@ VALUES (
|
||||
"major": dv.Major,
|
||||
"minor": dv.Minor,
|
||||
"classification": dv.Classification,
|
||||
"document_type": dv.DocumentType,
|
||||
"content": dv.Content,
|
||||
"changelog": dv.Changelog,
|
||||
"status": dv.Status,
|
||||
@@ -304,6 +310,7 @@ SELECT
|
||||
major,
|
||||
minor,
|
||||
classification,
|
||||
document_type,
|
||||
content,
|
||||
changelog,
|
||||
status,
|
||||
@@ -359,6 +366,7 @@ SELECT
|
||||
major,
|
||||
minor,
|
||||
classification,
|
||||
document_type,
|
||||
content,
|
||||
changelog,
|
||||
status,
|
||||
@@ -410,6 +418,7 @@ SELECT
|
||||
major,
|
||||
minor,
|
||||
classification,
|
||||
document_type,
|
||||
content,
|
||||
changelog,
|
||||
status,
|
||||
@@ -463,6 +472,7 @@ UPDATE document_versions SET
|
||||
content = @content,
|
||||
published_at = @published_at,
|
||||
classification = @classification,
|
||||
document_type = @document_type,
|
||||
updated_at = @updated_at
|
||||
WHERE %s
|
||||
AND id = @document_version_id
|
||||
@@ -480,6 +490,7 @@ WHERE %s
|
||||
"content": dv.Content,
|
||||
"published_at": dv.PublishedAt,
|
||||
"classification": dv.Classification,
|
||||
"document_type": dv.DocumentType,
|
||||
"updated_at": dv.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
12
pkg/coredata/migrations/20260331T120000Z.sql
Normal file
12
pkg/coredata/migrations/20260331T120000Z.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Add document_type column to document_versions, copying from parent document.
|
||||
ALTER TABLE document_versions ADD COLUMN document_type document_type NOT NULL DEFAULT 'OTHER';
|
||||
|
||||
UPDATE document_versions dv
|
||||
SET document_type = d.document_type
|
||||
FROM documents d
|
||||
WHERE dv.document_id = d.id;
|
||||
|
||||
ALTER TABLE document_versions ALTER COLUMN document_type DROP DEFAULT;
|
||||
|
||||
-- TODO: drop the document_type column from documents.
|
||||
ALTER TABLE documents ALTER COLUMN document_type SET DEFAULT 'OTHER';
|
||||
@@ -290,7 +290,7 @@ func (s *DocumentApprovalService) Approve(
|
||||
tx,
|
||||
&esign.CreateAndAcceptSignatureRequest{
|
||||
OrganizationID: documentVersion.OrganizationID,
|
||||
DocumentType: coredata.ElectronicSignatureDocumentTypeFromDocumentType(document.DocumentType),
|
||||
DocumentType: coredata.ElectronicSignatureDocumentTypeFromDocumentType(documentVersion.DocumentType),
|
||||
DocumentName: &document.Title,
|
||||
FileID: fileRecord.ID,
|
||||
SignerEmail: req.SignerEmail,
|
||||
|
||||
@@ -86,7 +86,6 @@ type (
|
||||
UpdateDocumentRequest struct {
|
||||
DocumentID gid.GID
|
||||
Title *string
|
||||
DocumentType *coredata.DocumentType
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
}
|
||||
|
||||
@@ -94,6 +93,7 @@ type (
|
||||
ID gid.GID
|
||||
Content *string
|
||||
Classification *coredata.DocumentClassification
|
||||
DocumentType *coredata.DocumentType
|
||||
}
|
||||
|
||||
RequestSignatureRequest struct {
|
||||
@@ -139,7 +139,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.DocumentType, "document_type", validator.OneOfSlice(coredata.DocumentTypes()))
|
||||
v.Check(udr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities()))
|
||||
|
||||
return v.Error()
|
||||
@@ -156,6 +155,7 @@ func (udvr *UpdateDocumentVersionRequest) Validate() error {
|
||||
validator.MaxLen(documentMaxLength),
|
||||
validator.ProseMirrorDocumentContent(),
|
||||
)
|
||||
v.Check(udvr.DocumentType, "document_type", validator.OneOfSlice(coredata.DocumentTypes()))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -518,7 +518,6 @@ func (s *DocumentService) Create(
|
||||
document := &coredata.Document{
|
||||
ID: documentID,
|
||||
Title: req.Title,
|
||||
DocumentType: req.DocumentType,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
Status: coredata.DocumentStatusActive,
|
||||
CreatedAt: now,
|
||||
@@ -547,6 +546,7 @@ func (s *DocumentService) Create(
|
||||
Content: content,
|
||||
Status: coredata.DocumentVersionStatusDraft,
|
||||
Classification: req.Classification,
|
||||
DocumentType: req.DocumentType,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
@@ -793,6 +793,9 @@ func (s *DocumentService) UpdateVersion(
|
||||
if req.Classification != nil {
|
||||
documentVersion.Classification = *req.Classification
|
||||
}
|
||||
if req.DocumentType != nil {
|
||||
documentVersion.DocumentType = *req.DocumentType
|
||||
}
|
||||
documentVersion.UpdatedAt = time.Now()
|
||||
|
||||
if err := documentVersion.Update(ctx, conn, s.svc.scope); err != nil {
|
||||
@@ -1031,6 +1034,7 @@ func (s *DocumentService) CreateDraft(
|
||||
draftVersion.Major = latestVersion.Major
|
||||
draftVersion.Minor = latestVersion.Minor + 1
|
||||
draftVersion.Classification = latestVersion.Classification
|
||||
draftVersion.DocumentType = latestVersion.DocumentType
|
||||
draftVersion.Content = latestVersion.Content
|
||||
draftVersion.Status = coredata.DocumentVersionStatusDraft
|
||||
draftVersion.CreatedAt = now
|
||||
@@ -1561,14 +1565,6 @@ func (s *DocumentService) Update(
|
||||
document.Title = *req.Title
|
||||
}
|
||||
|
||||
if req.DocumentType != nil {
|
||||
document.DocumentType = *req.DocumentType
|
||||
}
|
||||
|
||||
if req.DocumentType != nil {
|
||||
document.DocumentType = *req.DocumentType
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
document.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user