Add type to document
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -28,13 +28,14 @@ import (
|
||||
|
||||
type (
|
||||
Document struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
Title string `db:"title"`
|
||||
CurrentPublishedVersion *int `db:"current_published_version"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
Title string `db:"title"`
|
||||
DocumentType DocumentType `db:"document_type"`
|
||||
CurrentPublishedVersion *int `db:"current_published_version"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Documents []*Document
|
||||
@@ -63,6 +64,7 @@ SELECT
|
||||
organization_id,
|
||||
owner_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -107,6 +109,7 @@ SELECT
|
||||
organization_id,
|
||||
owner_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -152,6 +155,7 @@ INSERT INTO
|
||||
organization_id,
|
||||
owner_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -162,6 +166,7 @@ VALUES (
|
||||
@organization_id,
|
||||
@owner_id,
|
||||
@title,
|
||||
@document_type,
|
||||
@current_published_version,
|
||||
@created_at,
|
||||
@updated_at
|
||||
@@ -174,6 +179,7 @@ VALUES (
|
||||
"organization_id": p.OrganizationID,
|
||||
"owner_id": p.OwnerID,
|
||||
"title": p.Title,
|
||||
"document_type": p.DocumentType,
|
||||
"current_published_version": p.CurrentPublishedVersion,
|
||||
"created_at": p.CreatedAt,
|
||||
"updated_at": p.UpdatedAt,
|
||||
@@ -212,6 +218,7 @@ SET
|
||||
title = @title,
|
||||
current_published_version = @current_published_version,
|
||||
owner_id = @owner_id,
|
||||
document_type = @document_type,
|
||||
updated_at = @updated_at
|
||||
WHERE %s
|
||||
AND id = @document_id
|
||||
@@ -224,6 +231,7 @@ WHERE %s
|
||||
"title": p.Title,
|
||||
"current_published_version": p.CurrentPublishedVersion,
|
||||
"owner_id": p.OwnerID,
|
||||
"document_type": p.DocumentType,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -250,6 +258,7 @@ WITH plcs AS (
|
||||
p.organization_id,
|
||||
p.owner_id,
|
||||
p.title,
|
||||
p.document_type,
|
||||
p.current_published_version,
|
||||
p.created_at,
|
||||
p.updated_at
|
||||
@@ -265,6 +274,7 @@ SELECT
|
||||
organization_id,
|
||||
owner_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
created_at,
|
||||
updated_at
|
||||
@@ -309,6 +319,7 @@ WITH plcs AS (
|
||||
p.organization_id,
|
||||
p.owner_id,
|
||||
p.title,
|
||||
p.document_type,
|
||||
p.current_published_version,
|
||||
p.created_at,
|
||||
p.updated_at
|
||||
@@ -324,6 +335,7 @@ SELECT
|
||||
organization_id,
|
||||
owner_id,
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
created_at,
|
||||
updated_at
|
||||
|
||||
68
pkg/coredata/document_type.go
Normal file
68
pkg/coredata/document_type.go
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type (
|
||||
DocumentType string
|
||||
)
|
||||
|
||||
const (
|
||||
DocumentTypeOther DocumentType = "OTHER"
|
||||
DocumentTypeISMS DocumentType = "ISMS"
|
||||
DocumentTypePolicy DocumentType = "POLICY"
|
||||
)
|
||||
|
||||
func (dt DocumentType) MarshalText() ([]byte, error) {
|
||||
return []byte(dt.String()), nil
|
||||
}
|
||||
|
||||
func (dt *DocumentType) UnmarshalText(data []byte) error {
|
||||
val := string(data)
|
||||
|
||||
switch val {
|
||||
case DocumentTypeOther.String():
|
||||
*dt = DocumentTypeOther
|
||||
case DocumentTypeISMS.String():
|
||||
*dt = DocumentTypeISMS
|
||||
case DocumentTypePolicy.String():
|
||||
*dt = DocumentTypePolicy
|
||||
default:
|
||||
return fmt.Errorf("invalid DocumentType value: %q", val)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dt DocumentType) String() string {
|
||||
return string(dt)
|
||||
}
|
||||
|
||||
func (dt *DocumentType) Scan(value any) error {
|
||||
val, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid scan source for DocumentType, expected string got %T", value)
|
||||
}
|
||||
|
||||
return dt.UnmarshalText([]byte(val))
|
||||
}
|
||||
|
||||
func (dt DocumentType) Value() (driver.Value, error) {
|
||||
return dt.String(), nil
|
||||
}
|
||||
3
pkg/coredata/migrations/20250530T170253Z.sql
Normal file
3
pkg/coredata/migrations/20250530T170253Z.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
CREATE TYPE document_type AS ENUM ('OTHER', 'ISMS', 'POLICY');
|
||||
|
||||
ALTER TABLE documents ADD COLUMN document_type document_type NOT NULL DEFAULT 'POLICY';
|
||||
@@ -25,6 +25,7 @@ type (
|
||||
Content string
|
||||
OwnerID gid.GID
|
||||
CreatedBy gid.GID
|
||||
DocumentType coredata.DocumentType
|
||||
}
|
||||
|
||||
UpdateDocumentVersionRequest struct {
|
||||
@@ -131,10 +132,11 @@ func (s *DocumentService) Create(
|
||||
people := &coredata.People{}
|
||||
|
||||
document := &coredata.Document{
|
||||
ID: documentID,
|
||||
Title: req.Title,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
Title: req.Title,
|
||||
DocumentType: req.DocumentType,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
documentVersion := &coredata.DocumentVersion{
|
||||
@@ -632,3 +634,47 @@ func (s *DocumentService) ListForRiskID(
|
||||
|
||||
return page.NewPage(documents, cursor), nil
|
||||
}
|
||||
|
||||
func (s *DocumentService) Update(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
newOwnerID *gid.GID,
|
||||
documentType *coredata.DocumentType,
|
||||
) (*coredata.Document, error) {
|
||||
document := &coredata.Document{}
|
||||
people := &coredata.People{}
|
||||
now := time.Now()
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(tx pg.Conn) error {
|
||||
if err := document.LoadByID(ctx, tx, s.svc.scope, documentID); err != nil {
|
||||
return fmt.Errorf("cannot load document %q: %w", documentID, err)
|
||||
}
|
||||
|
||||
if newOwnerID != nil {
|
||||
if err := people.LoadByID(ctx, tx, s.svc.scope, *newOwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load new owner %q: %w", *newOwnerID, err)
|
||||
}
|
||||
document.OwnerID = *newOwnerID
|
||||
}
|
||||
|
||||
if documentType != nil {
|
||||
document.DocumentType = *documentType
|
||||
}
|
||||
document.UpdatedAt = now
|
||||
|
||||
if err := document.Update(ctx, tx, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot update document: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return document, nil
|
||||
}
|
||||
|
||||
@@ -337,6 +337,12 @@ enum VendorCategory @goModel(model: "github.com/getprobo/probo/pkg/coredata.Vend
|
||||
VERSION_CONTROL @goEnum(value: "github.com/getprobo/probo/pkg/coredata.VendorCategoryVersionControl")
|
||||
}
|
||||
|
||||
enum DocumentType @goModel(model: "github.com/getprobo/probo/pkg/coredata.DocumentType") {
|
||||
OTHER @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DocumentTypeOther")
|
||||
ISMS @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DocumentTypeISMS")
|
||||
POLICY @goEnum(value: "github.com/getprobo/probo/pkg/coredata.DocumentTypePolicy")
|
||||
}
|
||||
|
||||
# Order Input Types
|
||||
input UserOrder
|
||||
@goModel(
|
||||
@@ -752,6 +758,7 @@ type Document implements Node {
|
||||
id: ID!
|
||||
title: String!
|
||||
description: String!
|
||||
documentType: DocumentType!
|
||||
currentPublishedVersion: Int
|
||||
owner: People! @goField(forceResolver: true)
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
@@ -1096,6 +1103,7 @@ type Mutation {
|
||||
|
||||
# Document mutations
|
||||
createDocument(input: CreateDocumentInput!): CreateDocumentPayload!
|
||||
updateDocument(input: UpdateDocumentInput!): UpdateDocumentPayload!
|
||||
deleteDocument(input: DeleteDocumentInput!): DeleteDocumentPayload!
|
||||
publishDocumentVersion(
|
||||
input: PublishDocumentVersionInput!
|
||||
@@ -1396,6 +1404,7 @@ input CreateDocumentInput {
|
||||
title: String!
|
||||
content: String!
|
||||
ownerId: ID!
|
||||
documentType: DocumentType!
|
||||
}
|
||||
|
||||
input UpdateDocumentInput {
|
||||
@@ -1404,6 +1413,7 @@ input UpdateDocumentInput {
|
||||
content: String
|
||||
ownerId: ID
|
||||
createdBy: ID
|
||||
documentType: DocumentType
|
||||
}
|
||||
|
||||
input DeleteDocumentInput {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,7 @@ func NewDocument(document *coredata.Document) *Document {
|
||||
return &Document{
|
||||
ID: document.ID,
|
||||
Title: document.Title,
|
||||
DocumentType: document.DocumentType,
|
||||
CurrentPublishedVersion: document.CurrentPublishedVersion,
|
||||
CreatedAt: document.CreatedAt,
|
||||
UpdatedAt: document.UpdatedAt,
|
||||
|
||||
@@ -73,15 +73,15 @@ type ConnectorOrder struct {
|
||||
}
|
||||
|
||||
type Control struct {
|
||||
ID gid.GID `json:"id"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Framework *Framework `json:"framework"`
|
||||
Measures *MeasureConnection `json:"measures"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
ReferenceID string `json:"referenceId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Framework *Framework `json:"framework"`
|
||||
Measures *MeasureConnection `json:"measures"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Control) IsNode() {}
|
||||
@@ -97,6 +97,16 @@ type ControlEdge struct {
|
||||
Node *Control `json:"node"`
|
||||
}
|
||||
|
||||
type CreateControlDocumentMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
|
||||
type CreateControlDocumentMappingPayload struct {
|
||||
ControlEdge *ControlEdge `json:"controlEdge"`
|
||||
DocumentEdge *DocumentEdge `json:"documentEdge"`
|
||||
}
|
||||
|
||||
type CreateControlMeasureMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
MeasureID gid.GID `json:"measureId"`
|
||||
@@ -107,14 +117,17 @@ type CreateControlMeasureMappingPayload struct {
|
||||
MeasureEdge *MeasureEdge `json:"measureEdge"`
|
||||
}
|
||||
|
||||
type CreateControlDocumentMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
type CreateDocumentInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
}
|
||||
|
||||
type CreateControlDocumentMappingPayload struct {
|
||||
ControlEdge *ControlEdge `json:"controlEdge"`
|
||||
DocumentEdge *DocumentEdge `json:"documentEdge"`
|
||||
type CreateDocumentPayload struct {
|
||||
DocumentEdge *DocumentEdge `json:"documentEdge"`
|
||||
DocumentVersionEdge *DocumentVersionEdge `json:"documentVersionEdge"`
|
||||
}
|
||||
|
||||
type CreateDraftDocumentVersionInput struct {
|
||||
@@ -182,16 +195,14 @@ type CreatePeoplePayload struct {
|
||||
PeopleEdge *PeopleEdge `json:"peopleEdge"`
|
||||
}
|
||||
|
||||
type CreateDocumentInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
type CreateRiskDocumentMappingInput struct {
|
||||
RiskID gid.GID `json:"riskId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
|
||||
type CreateDocumentPayload struct {
|
||||
DocumentEdge *DocumentEdge `json:"documentEdge"`
|
||||
DocumentVersionEdge *DocumentVersionEdge `json:"documentVersionEdge"`
|
||||
type CreateRiskDocumentMappingPayload struct {
|
||||
RiskEdge *RiskEdge `json:"riskEdge"`
|
||||
DocumentEdge *DocumentEdge `json:"documentEdge"`
|
||||
}
|
||||
|
||||
type CreateRiskInput struct {
|
||||
@@ -222,16 +233,6 @@ type CreateRiskPayload struct {
|
||||
RiskEdge *RiskEdge `json:"riskEdge"`
|
||||
}
|
||||
|
||||
type CreateRiskDocumentMappingInput struct {
|
||||
RiskID gid.GID `json:"riskId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
|
||||
type CreateRiskDocumentMappingPayload struct {
|
||||
RiskEdge *RiskEdge `json:"riskEdge"`
|
||||
DocumentEdge *DocumentEdge `json:"documentEdge"`
|
||||
}
|
||||
|
||||
type CreateTaskInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
MeasureID *gid.GID `json:"measureId,omitempty"`
|
||||
@@ -284,6 +285,16 @@ type CreateVendorRiskAssessmentPayload struct {
|
||||
VendorRiskAssessmentEdge *VendorRiskAssessmentEdge `json:"vendorRiskAssessmentEdge"`
|
||||
}
|
||||
|
||||
type DeleteControlDocumentMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
|
||||
type DeleteControlDocumentMappingPayload struct {
|
||||
DeletedControlID gid.GID `json:"deletedControlId"`
|
||||
DeletedDocumentID gid.GID `json:"deletedDocumentId"`
|
||||
}
|
||||
|
||||
type DeleteControlMeasureMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
MeasureID gid.GID `json:"measureId"`
|
||||
@@ -294,14 +305,12 @@ type DeleteControlMeasureMappingPayload struct {
|
||||
DeletedMeasureID gid.GID `json:"deletedMeasureId"`
|
||||
}
|
||||
|
||||
type DeleteControlDocumentMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
type DeleteDocumentInput struct {
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
|
||||
type DeleteControlDocumentMappingPayload struct {
|
||||
DeletedControlID gid.GID `json:"deletedControlId"`
|
||||
DeletedDocumentID gid.GID `json:"deletedDocumentId"`
|
||||
type DeleteDocumentPayload struct {
|
||||
DeletedDocumentID gid.GID `json:"deletedDocumentId"`
|
||||
}
|
||||
|
||||
type DeleteEvidenceInput struct {
|
||||
@@ -344,11 +353,13 @@ type DeletePeoplePayload struct {
|
||||
DeletedPeopleID gid.GID `json:"deletedPeopleId"`
|
||||
}
|
||||
|
||||
type DeleteDocumentInput struct {
|
||||
type DeleteRiskDocumentMappingInput struct {
|
||||
RiskID gid.GID `json:"riskId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
|
||||
type DeleteDocumentPayload struct {
|
||||
type DeleteRiskDocumentMappingPayload struct {
|
||||
DeletedRiskID gid.GID `json:"deletedRiskId"`
|
||||
DeletedDocumentID gid.GID `json:"deletedDocumentId"`
|
||||
}
|
||||
|
||||
@@ -370,16 +381,6 @@ type DeleteRiskPayload struct {
|
||||
DeletedRiskID gid.GID `json:"deletedRiskId"`
|
||||
}
|
||||
|
||||
type DeleteRiskDocumentMappingInput struct {
|
||||
RiskID gid.GID `json:"riskId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
|
||||
type DeleteRiskDocumentMappingPayload struct {
|
||||
DeletedRiskID gid.GID `json:"deletedRiskId"`
|
||||
DeletedDocumentID gid.GID `json:"deletedDocumentId"`
|
||||
}
|
||||
|
||||
type DeleteTaskInput struct {
|
||||
TaskID gid.GID `json:"taskId"`
|
||||
}
|
||||
@@ -404,6 +405,94 @@ type DeleteVendorPayload struct {
|
||||
DeletedVendorID gid.GID `json:"deletedVendorId"`
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
CurrentPublishedVersion *int `json:"currentPublishedVersion,omitempty"`
|
||||
Owner *People `json:"owner"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Versions *DocumentVersionConnection `json:"versions"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Document) IsNode() {}
|
||||
func (this Document) GetID() gid.GID { return this.ID }
|
||||
|
||||
type DocumentConnection struct {
|
||||
Edges []*DocumentEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type DocumentEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *Document `json:"node"`
|
||||
}
|
||||
|
||||
type DocumentVersion struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Document *Document `json:"document"`
|
||||
Status coredata.DocumentStatus `json:"status"`
|
||||
Version int `json:"version"`
|
||||
Content string `json:"content"`
|
||||
Changelog string `json:"changelog"`
|
||||
Signatures *DocumentVersionSignatureConnection `json:"signatures"`
|
||||
PublishedBy *People `json:"publishedBy,omitempty"`
|
||||
PublishedAt *time.Time `json:"publishedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (DocumentVersion) IsNode() {}
|
||||
func (this DocumentVersion) GetID() gid.GID { return this.ID }
|
||||
|
||||
type DocumentVersionConnection struct {
|
||||
Edges []*DocumentVersionEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type DocumentVersionEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *DocumentVersion `json:"node"`
|
||||
}
|
||||
|
||||
type DocumentVersionFilter struct {
|
||||
Status *coredata.DocumentStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type DocumentVersionSignature struct {
|
||||
ID gid.GID `json:"id"`
|
||||
DocumentVersion *DocumentVersion `json:"documentVersion"`
|
||||
State coredata.DocumentVersionSignatureState `json:"state"`
|
||||
SignedBy *People `json:"signedBy"`
|
||||
SignedAt *time.Time `json:"signedAt,omitempty"`
|
||||
RequestedAt time.Time `json:"requestedAt"`
|
||||
RequestedBy *People `json:"requestedBy"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (DocumentVersionSignature) IsNode() {}
|
||||
func (this DocumentVersionSignature) GetID() gid.GID { return this.ID }
|
||||
|
||||
type DocumentVersionSignatureConnection struct {
|
||||
Edges []*DocumentVersionSignatureEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type DocumentVersionSignatureEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *DocumentVersionSignature `json:"node"`
|
||||
}
|
||||
|
||||
type DocumentVersionSignatureOrder struct {
|
||||
Field coredata.DocumentVersionSignatureOrderField `json:"field"`
|
||||
Direction page.OrderDirection `json:"direction"`
|
||||
}
|
||||
|
||||
type Evidence struct {
|
||||
ID gid.GID `json:"id"`
|
||||
FileURL *string `json:"fileUrl,omitempty"`
|
||||
@@ -542,7 +631,7 @@ type Organization struct {
|
||||
Frameworks *FrameworkConnection `json:"frameworks"`
|
||||
Vendors *VendorConnection `json:"vendors"`
|
||||
Peoples *PeopleConnection `json:"peoples"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Measures *MeasureConnection `json:"measures"`
|
||||
Risks *RiskConnection `json:"risks"`
|
||||
Tasks *TaskConnection `json:"tasks"`
|
||||
@@ -601,93 +690,6 @@ type PeopleEdge struct {
|
||||
Node *People `json:"node"`
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
CurrentPublishedVersion *int `json:"currentPublishedVersion,omitempty"`
|
||||
Owner *People `json:"owner"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Versions *DocumentVersionConnection `json:"versions"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Document) IsNode() {}
|
||||
func (this Document) GetID() gid.GID { return this.ID }
|
||||
|
||||
type DocumentConnection struct {
|
||||
Edges []*DocumentEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type DocumentEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *Document `json:"node"`
|
||||
}
|
||||
|
||||
type DocumentVersion struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Document *Document `json:"document"`
|
||||
Status coredata.DocumentStatus `json:"status"`
|
||||
Version int `json:"version"`
|
||||
Content string `json:"content"`
|
||||
Changelog string `json:"changelog"`
|
||||
Signatures *DocumentVersionSignatureConnection `json:"signatures"`
|
||||
PublishedBy *People `json:"publishedBy,omitempty"`
|
||||
PublishedAt *time.Time `json:"publishedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (DocumentVersion) IsNode() {}
|
||||
func (this DocumentVersion) GetID() gid.GID { return this.ID }
|
||||
|
||||
type DocumentVersionConnection struct {
|
||||
Edges []*DocumentVersionEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type DocumentVersionEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *DocumentVersion `json:"node"`
|
||||
}
|
||||
|
||||
type DocumentVersionFilter struct {
|
||||
Status *coredata.DocumentStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type DocumentVersionSignature struct {
|
||||
ID gid.GID `json:"id"`
|
||||
DocumentVersion *DocumentVersion `json:"documentVersion"`
|
||||
State coredata.DocumentVersionSignatureState `json:"state"`
|
||||
SignedBy *People `json:"signedBy"`
|
||||
SignedAt *time.Time `json:"signedAt,omitempty"`
|
||||
RequestedAt time.Time `json:"requestedAt"`
|
||||
RequestedBy *People `json:"requestedBy"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (DocumentVersionSignature) IsNode() {}
|
||||
func (this DocumentVersionSignature) GetID() gid.GID { return this.ID }
|
||||
|
||||
type DocumentVersionSignatureConnection struct {
|
||||
Edges []*DocumentVersionSignatureEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type DocumentVersionSignatureEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *DocumentVersionSignature `json:"node"`
|
||||
}
|
||||
|
||||
type DocumentVersionSignatureOrder struct {
|
||||
Field coredata.DocumentVersionSignatureOrderField `json:"field"`
|
||||
Direction page.OrderDirection `json:"direction"`
|
||||
}
|
||||
|
||||
type PublishDocumentVersionInput struct {
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
}
|
||||
@@ -722,7 +724,7 @@ type RequestEvidencePayload struct {
|
||||
|
||||
type RequestSignatureInput struct {
|
||||
DocumentVersionID gid.GID `json:"documentVersionId"`
|
||||
SignatoryID gid.GID `json:"signatoryId"`
|
||||
SignatoryID gid.GID `json:"signatoryId"`
|
||||
}
|
||||
|
||||
type RequestSignaturePayload struct {
|
||||
@@ -745,7 +747,7 @@ type Risk struct {
|
||||
Owner *People `json:"owner,omitempty"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Measures *MeasureConnection `json:"measures"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
@@ -812,6 +814,28 @@ type UnassignTaskPayload struct {
|
||||
Task *Task `json:"task"`
|
||||
}
|
||||
|
||||
type UpdateDocumentInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
CreatedBy *gid.GID `json:"createdBy,omitempty"`
|
||||
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateDocumentPayload struct {
|
||||
Document *Document `json:"document"`
|
||||
}
|
||||
|
||||
type UpdateDocumentVersionInput struct {
|
||||
DocumentVersionID gid.GID `json:"documentVersionId"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type UpdateDocumentVersionPayload struct {
|
||||
DocumentVersion *DocumentVersion `json:"documentVersion"`
|
||||
}
|
||||
|
||||
type UpdateFrameworkInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
@@ -859,27 +883,6 @@ type UpdatePeoplePayload struct {
|
||||
People *People `json:"people"`
|
||||
}
|
||||
|
||||
type UpdateDocumentInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
CreatedBy *gid.GID `json:"createdBy,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateDocumentPayload struct {
|
||||
Document *Document `json:"document"`
|
||||
}
|
||||
|
||||
type UpdateDocumentVersionInput struct {
|
||||
DocumentVersionID gid.GID `json:"documentVersionId"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type UpdateDocumentVersionPayload struct {
|
||||
DocumentVersion *DocumentVersion `json:"documentVersion"`
|
||||
}
|
||||
|
||||
type UpdateRiskInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
|
||||
@@ -87,6 +87,205 @@ func (r *controlResolver) Documents(ctx context.Context, obj *types.Control, fir
|
||||
return types.NewDocumentConnection(page), nil
|
||||
}
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *documentResolver) Owner(ctx context.Context, obj *types.Document) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
document, err := svc.Documents.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document: %w", err))
|
||||
}
|
||||
|
||||
// Get the owner
|
||||
owner, err := svc.Peoples.Get(ctx, document.OwnerID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get owner: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(owner), nil
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *documentResolver) Organization(ctx context.Context, obj *types.Document) (*types.Organization, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
document, err := svc.Documents.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document: %w", err))
|
||||
}
|
||||
|
||||
organization, err := svc.Organizations.Get(ctx, document.OrganizationID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get organization: %w", err))
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
// Versions is the resolver for the versions field.
|
||||
func (r *documentResolver) Versions(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionOrderBy, filter *types.DocumentVersionFilter) (*types.DocumentVersionConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionOrderField]{
|
||||
Field: coredata.DocumentVersionOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.DocumentVersionOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Documents.ListVersions(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list document versions: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocumentVersionConnection(page), nil
|
||||
}
|
||||
|
||||
// Controls is the resolver for the controls field.
|
||||
func (r *documentResolver) Controls(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Controls.ListForDocumentID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list document controls: %w", err))
|
||||
}
|
||||
|
||||
return types.NewControlConnection(page), nil
|
||||
}
|
||||
|
||||
// Document is the resolver for the document field.
|
||||
func (r *documentVersionResolver) Document(ctx context.Context, obj *types.DocumentVersion) (*types.Document, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersion, err := svc.Documents.GetVersion(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||
}
|
||||
|
||||
document, err := svc.Documents.Get(ctx, documentVersion.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
|
||||
// Signatures is the resolver for the signatures field.
|
||||
func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.DocumentVersion, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionSignatureOrder) (*types.DocumentVersionSignatureConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionSignatureOrderField]{
|
||||
Field: coredata.DocumentVersionSignatureOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.DocumentVersionSignatureOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Documents.ListSignatures(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list document version signatures: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocumentVersionSignatureConnection(page), nil
|
||||
}
|
||||
|
||||
// PublishedBy is the resolver for the publishedBy field.
|
||||
func (r *documentVersionResolver) PublishedBy(ctx context.Context, obj *types.DocumentVersion) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersion, err := svc.Documents.GetVersion(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||
}
|
||||
|
||||
if documentVersion.PublishedBy == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, *documentVersion.PublishedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// DocumentVersion is the resolver for the documentVersion field.
|
||||
func (r *documentVersionSignatureResolver) DocumentVersion(ctx context.Context, obj *types.DocumentVersionSignature) (*types.DocumentVersion, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersionSignature, err := svc.Documents.GetVersionSignature(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
||||
}
|
||||
|
||||
documentVersion, err := svc.Documents.GetVersion(ctx, documentVersionSignature.DocumentVersionID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocumentVersion(documentVersion), nil
|
||||
}
|
||||
|
||||
// SignedBy is the resolver for the signedBy field.
|
||||
func (r *documentVersionSignatureResolver) SignedBy(ctx context.Context, obj *types.DocumentVersionSignature) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersionSignature, err := svc.Documents.GetVersionSignature(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, documentVersionSignature.SignedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// RequestedBy is the resolver for the requestedBy field.
|
||||
func (r *documentVersionSignatureResolver) RequestedBy(ctx context.Context, obj *types.DocumentVersionSignature) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersionSignature, err := svc.Documents.GetVersionSignature(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, documentVersionSignature.RequestedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// FileURL is the resolver for the fileUrl field.
|
||||
func (r *evidenceResolver) FileURL(ctx context.Context, obj *types.Evidence) (*string, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
@@ -1153,6 +1352,7 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
ctx,
|
||||
probo.CreateDocumentRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
DocumentType: input.DocumentType,
|
||||
Title: input.Title,
|
||||
OwnerID: input.OwnerID,
|
||||
Content: input.Content,
|
||||
@@ -1169,6 +1369,26 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateDocument is the resolver for the updateDocument field.
|
||||
func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.UpdateDocumentInput) (*types.UpdateDocumentPayload, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.ID.TenantID())
|
||||
|
||||
document, err := svc.Documents.Update(
|
||||
ctx,
|
||||
input.ID,
|
||||
input.OwnerID,
|
||||
input.DocumentType,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot update document: %w", err)
|
||||
}
|
||||
|
||||
return &types.UpdateDocumentPayload{
|
||||
Document: types.NewDocument(document),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteDocument is the resolver for the deleteDocument field.
|
||||
func (r *mutationResolver) DeleteDocument(ctx context.Context, input types.DeleteDocumentInput) (*types.DeleteDocumentPayload, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, input.DocumentID.TenantID())
|
||||
@@ -1567,205 +1787,6 @@ func (r *organizationResolver) Tasks(ctx context.Context, obj *types.Organizatio
|
||||
return types.NewTaskConnection(page), nil
|
||||
}
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *documentResolver) Owner(ctx context.Context, obj *types.Document) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
document, err := svc.Documents.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document: %w", err))
|
||||
}
|
||||
|
||||
// Get the owner
|
||||
owner, err := svc.Peoples.Get(ctx, document.OwnerID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get owner: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(owner), nil
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *documentResolver) Organization(ctx context.Context, obj *types.Document) (*types.Organization, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
document, err := svc.Documents.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document: %w", err))
|
||||
}
|
||||
|
||||
organization, err := svc.Organizations.Get(ctx, document.OrganizationID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get organization: %w", err))
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
// Versions is the resolver for the versions field.
|
||||
func (r *documentResolver) Versions(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionOrderBy, filter *types.DocumentVersionFilter) (*types.DocumentVersionConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionOrderField]{
|
||||
Field: coredata.DocumentVersionOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.DocumentVersionOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Documents.ListVersions(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list document versions: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocumentVersionConnection(page), nil
|
||||
}
|
||||
|
||||
// Controls is the resolver for the controls field.
|
||||
func (r *documentResolver) Controls(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy) (*types.ControlConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Controls.ListForDocumentID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list document controls: %w", err))
|
||||
}
|
||||
|
||||
return types.NewControlConnection(page), nil
|
||||
}
|
||||
|
||||
// Document is the resolver for the document field.
|
||||
func (r *documentVersionResolver) Document(ctx context.Context, obj *types.DocumentVersion) (*types.Document, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersion, err := svc.Documents.GetVersion(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||
}
|
||||
|
||||
document, err := svc.Documents.Get(ctx, documentVersion.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
|
||||
// Signatures is the resolver for the signatures field.
|
||||
func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.DocumentVersion, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionSignatureOrder) (*types.DocumentVersionSignatureConnection, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionSignatureOrderField]{
|
||||
Field: coredata.DocumentVersionSignatureOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.DocumentVersionSignatureOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.Documents.ListSignatures(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list document version signatures: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocumentVersionSignatureConnection(page), nil
|
||||
}
|
||||
|
||||
// PublishedBy is the resolver for the publishedBy field.
|
||||
func (r *documentVersionResolver) PublishedBy(ctx context.Context, obj *types.DocumentVersion) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersion, err := svc.Documents.GetVersion(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||
}
|
||||
|
||||
if documentVersion.PublishedBy == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, *documentVersion.PublishedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// DocumentVersion is the resolver for the documentVersion field.
|
||||
func (r *documentVersionSignatureResolver) DocumentVersion(ctx context.Context, obj *types.DocumentVersionSignature) (*types.DocumentVersion, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersionSignature, err := svc.Documents.GetVersionSignature(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
||||
}
|
||||
|
||||
documentVersion, err := svc.Documents.GetVersion(ctx, documentVersionSignature.DocumentVersionID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version: %w", err))
|
||||
}
|
||||
|
||||
return types.NewDocumentVersion(documentVersion), nil
|
||||
}
|
||||
|
||||
// SignedBy is the resolver for the signedBy field.
|
||||
func (r *documentVersionSignatureResolver) SignedBy(ctx context.Context, obj *types.DocumentVersionSignature) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersionSignature, err := svc.Documents.GetVersionSignature(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, documentVersionSignature.SignedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// RequestedBy is the resolver for the requestedBy field.
|
||||
func (r *documentVersionSignatureResolver) RequestedBy(ctx context.Context, obj *types.DocumentVersionSignature) (*types.People, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, obj.ID.TenantID())
|
||||
|
||||
documentVersionSignature, err := svc.Documents.GetVersionSignature(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get document version signature: %w", err))
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, documentVersionSignature.RequestedBy)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get people: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// Node is the resolver for the node field.
|
||||
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
svc := GetTenantService(ctx, r.proboSvc, id.TenantID())
|
||||
@@ -2268,6 +2289,19 @@ func (r *viewerResolver) Organizations(ctx context.Context, obj *types.Viewer, f
|
||||
// Control returns schema.ControlResolver implementation.
|
||||
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
||||
|
||||
// Document returns schema.DocumentResolver implementation.
|
||||
func (r *Resolver) Document() schema.DocumentResolver { return &documentResolver{r} }
|
||||
|
||||
// DocumentVersion returns schema.DocumentVersionResolver implementation.
|
||||
func (r *Resolver) DocumentVersion() schema.DocumentVersionResolver {
|
||||
return &documentVersionResolver{r}
|
||||
}
|
||||
|
||||
// DocumentVersionSignature returns schema.DocumentVersionSignatureResolver implementation.
|
||||
func (r *Resolver) DocumentVersionSignature() schema.DocumentVersionSignatureResolver {
|
||||
return &documentVersionSignatureResolver{r}
|
||||
}
|
||||
|
||||
// Evidence returns schema.EvidenceResolver implementation.
|
||||
func (r *Resolver) Evidence() schema.EvidenceResolver { return &evidenceResolver{r} }
|
||||
|
||||
@@ -2283,19 +2317,6 @@ func (r *Resolver) Mutation() schema.MutationResolver { return &mutationResolver
|
||||
// Organization returns schema.OrganizationResolver implementation.
|
||||
func (r *Resolver) Organization() schema.OrganizationResolver { return &organizationResolver{r} }
|
||||
|
||||
// Document returns schema.DocumentResolver implementation.
|
||||
func (r *Resolver) Document() schema.DocumentResolver { return &documentResolver{r} }
|
||||
|
||||
// DocumentVersion returns schema.DocumentVersionResolver implementation.
|
||||
func (r *Resolver) DocumentVersion() schema.DocumentVersionResolver {
|
||||
return &documentVersionResolver{r}
|
||||
}
|
||||
|
||||
// DocumentVersionSignature returns schema.DocumentVersionSignatureResolver implementation.
|
||||
func (r *Resolver) DocumentVersionSignature() schema.DocumentVersionSignatureResolver {
|
||||
return &documentVersionSignatureResolver{r}
|
||||
}
|
||||
|
||||
// Query returns schema.QueryResolver implementation.
|
||||
func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} }
|
||||
|
||||
@@ -2325,14 +2346,14 @@ func (r *Resolver) VendorRiskAssessment() schema.VendorRiskAssessmentResolver {
|
||||
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
||||
|
||||
type controlResolver struct{ *Resolver }
|
||||
type documentResolver struct{ *Resolver }
|
||||
type documentVersionResolver struct{ *Resolver }
|
||||
type documentVersionSignatureResolver struct{ *Resolver }
|
||||
type evidenceResolver struct{ *Resolver }
|
||||
type frameworkResolver struct{ *Resolver }
|
||||
type measureResolver struct{ *Resolver }
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type organizationResolver struct{ *Resolver }
|
||||
type documentResolver struct{ *Resolver }
|
||||
type documentVersionResolver struct{ *Resolver }
|
||||
type documentVersionSignatureResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
||||
type riskResolver struct{ *Resolver }
|
||||
type taskResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user