Add processing activity, DPIA and TIA publish to document system
Replace the old PDF/snapshot-based exports for processing activities, Data Protection Impact Assessments and Transfer Impact Assessments with the publish document system. Includes GraphQL mutations, MCP tools, CLI commands, n8n operations, frontend publish dialogs, e2e tests, and prosemirror register templates that mirror the previous PDF layouts. Each register lives as a generated DocumentTypeRegister document on the organization, reused across publishes (the major version bumps on every republish). Approvers can be passed in to create a draft pending approval; otherwise the version is published immediately. The frontend ProcessingActivities page exposes a Publish dropdown per register and a Document link button per active tab, pre-fills the previous default approvers, and navigates to the published document on success. Remove snapshot mode entirely from these three entities: drop snapshotId and sourceId from GraphQL schemas, types, filters, resolvers, MCP spec, frontend routes and pages; remove SnapshotsTypeProcessingActivities from the snapshot registry and delete the ProcessingActivities.Snapshot, ProcessingActivitySnapshotter interface and *.InsertProcessingActivitySnapshots methods. The snapshot_id columns remain in the database but are now filtered out with snapshot_id IS NULL. Add Get/Upsert/Clear GeneratedDocumentID methods on each entity type (ProcessingActivity, DataProtectionImpactAssessment, TransferImpactAssessment) backed by new columns in the generated_documents table, matching the Finding/Obligation pattern. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -7,14 +7,11 @@ package console_v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/vikstrous/dataloadgen"
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/dataloader"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
|
||||
@@ -87,7 +84,7 @@ func (r *dataProtectionImpactAssessmentConnectionResolver) TotalCount(ctx contex
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.DataProtectionImpactAssessments.CountForOrganizationID(ctx, obj.ParentID, obj.Filter)
|
||||
count, err := prb.DataProtectionImpactAssessments.CountForOrganizationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization data protection impact assessments", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -269,59 +266,49 @@ func (r *mutationResolver) DeleteTransferImpactAssessment(ctx context.Context, i
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ExportDataProtectionImpactAssessmentsPDF is the resolver for the exportDataProtectionImpactAssessmentsPDF field.
|
||||
func (r *mutationResolver) ExportDataProtectionImpactAssessmentsPDF(ctx context.Context, input types.ExportDataProtectionImpactAssessmentsPDFInput) (*types.ExportDataProtectionImpactAssessmentsPDFPayload, error) {
|
||||
if err := r.authorize(ctx, input.OrganizationID, probo.ActionDataProtectionImpactAssessmentExport); err != nil {
|
||||
// PublishDataProtectionImpactAssessmentList is the resolver for the publishDataProtectionImpactAssessmentList field.
|
||||
func (r *mutationResolver) PublishDataProtectionImpactAssessmentList(ctx context.Context, input types.PublishDataProtectionImpactAssessmentListInput) (*types.PublishDataProtectionImpactAssessmentListPayload, error) {
|
||||
if err := r.authorize(ctx, input.OrganizationID, probo.ActionDataProtectionImpactAssessmentPublish); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
var snapshotIDPtr *gid.GID
|
||||
if input.Filter != nil {
|
||||
snapshotIDPtr = input.Filter.SnapshotID
|
||||
}
|
||||
dpiaFilter := coredata.NewDataProtectionImpactAssessmentFilter(&snapshotIDPtr)
|
||||
|
||||
pdf, err := prb.DataProtectionImpactAssessments.ExportPDF(ctx, input.OrganizationID, dpiaFilter)
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishDataProtectionImpactAssessmentList(ctx, input.OrganizationID, input.ApproverIds)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
r.logger.ErrorCtx(ctx, "cannot export data protection impact assessments PDF", log.Error(err))
|
||||
r.logger.ErrorCtx(ctx, "cannot publish data protection impact assessment list", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &types.ExportDataProtectionImpactAssessmentsPDFPayload{
|
||||
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
|
||||
return &types.PublishDataProtectionImpactAssessmentListPayload{
|
||||
DocumentEdge: types.NewDocumentEdge(document, coredata.DocumentOrderFieldCreatedAt),
|
||||
DocumentVersionEdge: types.NewDocumentVersionEdge(documentVersion, coredata.DocumentVersionOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ExportTransferImpactAssessmentsPDF is the resolver for the exportTransferImpactAssessmentsPDF field.
|
||||
func (r *mutationResolver) ExportTransferImpactAssessmentsPDF(ctx context.Context, input types.ExportTransferImpactAssessmentsPDFInput) (*types.ExportTransferImpactAssessmentsPDFPayload, error) {
|
||||
if err := r.authorize(ctx, input.OrganizationID, probo.ActionTransferImpactAssessmentExport); err != nil {
|
||||
// PublishTransferImpactAssessmentList is the resolver for the publishTransferImpactAssessmentList field.
|
||||
func (r *mutationResolver) PublishTransferImpactAssessmentList(ctx context.Context, input types.PublishTransferImpactAssessmentListInput) (*types.PublishTransferImpactAssessmentListPayload, error) {
|
||||
if err := r.authorize(ctx, input.OrganizationID, probo.ActionTransferImpactAssessmentPublish); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
var snapshotIDPtr *gid.GID
|
||||
if input.Filter != nil {
|
||||
snapshotIDPtr = input.Filter.SnapshotID
|
||||
}
|
||||
tiaFilter := coredata.NewTransferImpactAssessmentFilter(&snapshotIDPtr)
|
||||
|
||||
pdf, err := prb.TransferImpactAssessments.ExportPDF(ctx, input.OrganizationID, tiaFilter)
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishTransferImpactAssessmentList(ctx, input.OrganizationID, input.ApproverIds)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
r.logger.ErrorCtx(ctx, "cannot export transfer impact assessments PDF", log.Error(err))
|
||||
r.logger.ErrorCtx(ctx, "cannot publish transfer impact assessment list", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &types.ExportTransferImpactAssessmentsPDFPayload{
|
||||
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
|
||||
return &types.PublishTransferImpactAssessmentListPayload{
|
||||
DocumentEdge: types.NewDocumentEdge(document, coredata.DocumentOrderFieldCreatedAt),
|
||||
DocumentVersionEdge: types.NewDocumentVersionEdge(documentVersion, coredata.DocumentVersionOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -378,7 +365,7 @@ func (r *transferImpactAssessmentConnectionResolver) TotalCount(ctx context.Cont
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.TransferImpactAssessments.CountForOrganizationID(ctx, obj.ParentID, obj.Filter)
|
||||
count, err := prb.TransferImpactAssessments.CountForOrganizationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization transfer impact assessments", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
|
||||
@@ -52,14 +52,6 @@ input TransferImpactAssessmentOrder
|
||||
field: TransferImpactAssessmentOrderField!
|
||||
}
|
||||
|
||||
input DataProtectionImpactAssessmentFilter {
|
||||
snapshotId: ID
|
||||
}
|
||||
|
||||
input TransferImpactAssessmentFilter {
|
||||
snapshotId: ID
|
||||
}
|
||||
|
||||
type DataProtectionImpactAssessment implements Node {
|
||||
id: ID!
|
||||
processingActivity: ProcessingActivity! @goField(forceResolver: true)
|
||||
@@ -137,12 +129,12 @@ extend type Mutation {
|
||||
deleteTransferImpactAssessment(
|
||||
input: DeleteTransferImpactAssessmentInput!
|
||||
): DeleteTransferImpactAssessmentPayload!
|
||||
exportDataProtectionImpactAssessmentsPDF(
|
||||
input: ExportDataProtectionImpactAssessmentsPDFInput!
|
||||
): ExportDataProtectionImpactAssessmentsPDFPayload!
|
||||
exportTransferImpactAssessmentsPDF(
|
||||
input: ExportTransferImpactAssessmentsPDFInput!
|
||||
): ExportTransferImpactAssessmentsPDFPayload!
|
||||
publishDataProtectionImpactAssessmentList(
|
||||
input: PublishDataProtectionImpactAssessmentListInput!
|
||||
): PublishDataProtectionImpactAssessmentListPayload!
|
||||
publishTransferImpactAssessmentList(
|
||||
input: PublishTransferImpactAssessmentListInput!
|
||||
): PublishTransferImpactAssessmentListPayload!
|
||||
}
|
||||
|
||||
input CreateDataProtectionImpactAssessmentInput {
|
||||
@@ -189,14 +181,14 @@ input DeleteTransferImpactAssessmentInput {
|
||||
transferImpactAssessmentId: ID!
|
||||
}
|
||||
|
||||
input ExportDataProtectionImpactAssessmentsPDFInput {
|
||||
input PublishDataProtectionImpactAssessmentListInput {
|
||||
organizationId: ID!
|
||||
filter: DataProtectionImpactAssessmentFilter
|
||||
approverIds: [ID!]
|
||||
}
|
||||
|
||||
input ExportTransferImpactAssessmentsPDFInput {
|
||||
input PublishTransferImpactAssessmentListInput {
|
||||
organizationId: ID!
|
||||
filter: TransferImpactAssessmentFilter
|
||||
approverIds: [ID!]
|
||||
}
|
||||
|
||||
type CreateDataProtectionImpactAssessmentPayload {
|
||||
@@ -223,10 +215,12 @@ type DeleteTransferImpactAssessmentPayload {
|
||||
deletedTransferImpactAssessmentId: ID!
|
||||
}
|
||||
|
||||
type ExportDataProtectionImpactAssessmentsPDFPayload {
|
||||
data: String!
|
||||
type PublishDataProtectionImpactAssessmentListPayload {
|
||||
documentEdge: DocumentEdge!
|
||||
documentVersionEdge: DocumentVersionEdge!
|
||||
}
|
||||
|
||||
type ExportTransferImpactAssessmentsPDFPayload {
|
||||
data: String!
|
||||
type PublishTransferImpactAssessmentListPayload {
|
||||
documentEdge: DocumentEdge!
|
||||
documentVersionEdge: DocumentVersionEdge!
|
||||
}
|
||||
|
||||
@@ -203,18 +203,21 @@ type Organization implements Node {
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: DataProtectionImpactAssessmentOrder
|
||||
filter: DataProtectionImpactAssessmentFilter = { snapshotId: null }
|
||||
): DataProtectionImpactAssessmentConnection! @goField(forceResolver: true)
|
||||
|
||||
dataProtectionImpactAssessmentsDocument: Document
|
||||
@goField(forceResolver: true)
|
||||
|
||||
transferImpactAssessments(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: TransferImpactAssessmentOrder
|
||||
filter: TransferImpactAssessmentFilter = { snapshotId: null }
|
||||
): TransferImpactAssessmentConnection! @goField(forceResolver: true)
|
||||
|
||||
transferImpactAssessmentsDocument: Document @goField(forceResolver: true)
|
||||
|
||||
documents(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
@@ -265,9 +268,10 @@ type Organization implements Node {
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: ProcessingActivityOrder
|
||||
filter: ProcessingActivityFilter = { snapshotId: null }
|
||||
): ProcessingActivityConnection! @goField(forceResolver: true)
|
||||
|
||||
processingActivitiesDocument: Document @goField(forceResolver: true)
|
||||
|
||||
rightsRequests(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
|
||||
@@ -138,14 +138,8 @@ input ProcessingActivityOrder
|
||||
field: ProcessingActivityOrderField!
|
||||
}
|
||||
|
||||
input ProcessingActivityFilter {
|
||||
snapshotId: ID
|
||||
}
|
||||
|
||||
type ProcessingActivity implements Node {
|
||||
id: ID!
|
||||
snapshotId: ID
|
||||
sourceId: ID
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
name: String!
|
||||
purpose: String
|
||||
@@ -207,9 +201,9 @@ extend type Mutation {
|
||||
deleteProcessingActivity(
|
||||
input: DeleteProcessingActivityInput!
|
||||
): DeleteProcessingActivityPayload!
|
||||
exportProcessingActivitiesPDF(
|
||||
input: ExportProcessingActivitiesPDFInput!
|
||||
): ExportProcessingActivitiesPDFPayload!
|
||||
publishProcessingActivityList(
|
||||
input: PublishProcessingActivityListInput!
|
||||
): PublishProcessingActivityListPayload!
|
||||
}
|
||||
|
||||
input CreateProcessingActivityInput {
|
||||
@@ -265,9 +259,9 @@ input DeleteProcessingActivityInput {
|
||||
processingActivityId: ID!
|
||||
}
|
||||
|
||||
input ExportProcessingActivitiesPDFInput {
|
||||
input PublishProcessingActivityListInput {
|
||||
organizationId: ID!
|
||||
filter: ProcessingActivityFilter
|
||||
approverIds: [ID!]
|
||||
}
|
||||
|
||||
type CreateProcessingActivityPayload {
|
||||
@@ -282,6 +276,7 @@ type DeleteProcessingActivityPayload {
|
||||
deletedProcessingActivityId: ID!
|
||||
}
|
||||
|
||||
type ExportProcessingActivitiesPDFPayload {
|
||||
data: String!
|
||||
type PublishProcessingActivityListPayload {
|
||||
documentEdge: DocumentEdge!
|
||||
documentVersionEdge: DocumentVersionEdge!
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ func (r *organizationResolver) StatementsOfApplicability(ctx context.Context, ob
|
||||
}
|
||||
|
||||
// DataProtectionImpactAssessments is the resolver for the dataProtectionImpactAssessments field.
|
||||
func (r *organizationResolver) DataProtectionImpactAssessments(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DataProtectionImpactAssessmentOrderBy, filter *types.DataProtectionImpactAssessmentFilter) (*types.DataProtectionImpactAssessmentConnection, error) {
|
||||
func (r *organizationResolver) DataProtectionImpactAssessments(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DataProtectionImpactAssessmentOrderBy) (*types.DataProtectionImpactAssessmentConnection, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionDataProtectionImpactAssessmentList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -653,22 +653,46 @@ func (r *organizationResolver) DataProtectionImpactAssessments(ctx context.Conte
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
dpiaFilter := coredata.NewDataProtectionImpactAssessmentFilter(nil)
|
||||
if filter != nil {
|
||||
dpiaFilter = coredata.NewDataProtectionImpactAssessmentFilter(&filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.DataProtectionImpactAssessments.ListForOrganizationID(ctx, obj.ID, cursor, dpiaFilter)
|
||||
page, err := prb.DataProtectionImpactAssessments.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list organization data protection impact assessments", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewDataProtectionImpactAssessmentConnection(page, r, obj.ID, dpiaFilter), nil
|
||||
return types.NewDataProtectionImpactAssessmentConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// DataProtectionImpactAssessmentsDocument is the resolver for the dataProtectionImpactAssessmentsDocument field.
|
||||
func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx context.Context, obj *types.Organization) (*types.Document, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionDocumentGet); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetDataProtectionImpactAssessmentsDocumentID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get DPIA list document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
r.logger.ErrorCtx(ctx, "cannot load DPIA list document", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
|
||||
// TransferImpactAssessments is the resolver for the transferImpactAssessments field.
|
||||
func (r *organizationResolver) TransferImpactAssessments(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.TransferImpactAssessmentOrderBy, filter *types.TransferImpactAssessmentFilter) (*types.TransferImpactAssessmentConnection, error) {
|
||||
func (r *organizationResolver) TransferImpactAssessments(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.TransferImpactAssessmentOrderBy) (*types.TransferImpactAssessmentConnection, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionTransferImpactAssessmentList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -689,18 +713,42 @@ func (r *organizationResolver) TransferImpactAssessments(ctx context.Context, ob
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
tiaFilter := coredata.NewTransferImpactAssessmentFilter(nil)
|
||||
if filter != nil {
|
||||
tiaFilter = coredata.NewTransferImpactAssessmentFilter(&filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.TransferImpactAssessments.ListForOrganizationID(ctx, obj.ID, cursor, tiaFilter)
|
||||
page, err := prb.TransferImpactAssessments.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list organization transfer impact assessments", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewTransferImpactAssessmentConnection(page, r, obj.ID, tiaFilter), nil
|
||||
return types.NewTransferImpactAssessmentConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// TransferImpactAssessmentsDocument is the resolver for the transferImpactAssessmentsDocument field.
|
||||
func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Context, obj *types.Organization) (*types.Document, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionDocumentGet); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetTransferImpactAssessmentsDocumentID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get TIA list document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
r.logger.ErrorCtx(ctx, "cannot load TIA list document", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
|
||||
// Documents is the resolver for the documents field.
|
||||
@@ -868,7 +916,7 @@ func (r *organizationResolver) Obligations(ctx context.Context, obj *types.Organ
|
||||
}
|
||||
|
||||
// ProcessingActivities is the resolver for the processingActivities field.
|
||||
func (r *organizationResolver) ProcessingActivities(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProcessingActivityOrderBy, filter *types.ProcessingActivityFilter) (*types.ProcessingActivityConnection, error) {
|
||||
func (r *organizationResolver) ProcessingActivities(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProcessingActivityOrderBy) (*types.ProcessingActivityConnection, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionProcessingActivityList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -889,18 +937,42 @@ func (r *organizationResolver) ProcessingActivities(ctx context.Context, obj *ty
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
processingActivityFilter := coredata.NewProcessingActivityFilter(nil)
|
||||
if filter != nil {
|
||||
processingActivityFilter = coredata.NewProcessingActivityFilter(&filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.ProcessingActivities.ListForOrganizationID(ctx, obj.ID, cursor, processingActivityFilter)
|
||||
page, err := prb.ProcessingActivities.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list organization processing activities", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewProcessingActivityConnection(page, r, obj.ID, filter), nil
|
||||
return types.NewProcessingActivityConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// ProcessingActivitiesDocument is the resolver for the processingActivitiesDocument field.
|
||||
func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context, obj *types.Organization) (*types.Document, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionDocumentGet); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetProcessingActivitiesDocumentID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get processing activities document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
r.logger.ErrorCtx(ctx, "cannot load processing activities document", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
|
||||
// RightsRequests is the resolver for the rightsRequests field.
|
||||
|
||||
@@ -7,14 +7,11 @@ package console_v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/vikstrous/dataloadgen"
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
@@ -127,31 +124,26 @@ func (r *mutationResolver) DeleteProcessingActivity(ctx context.Context, input t
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ExportProcessingActivitiesPDF is the resolver for the exportProcessingActivitiesPDF field.
|
||||
func (r *mutationResolver) ExportProcessingActivitiesPDF(ctx context.Context, input types.ExportProcessingActivitiesPDFInput) (*types.ExportProcessingActivitiesPDFPayload, error) {
|
||||
if err := r.authorize(ctx, input.OrganizationID, probo.ActionProcessingActivityExport); err != nil {
|
||||
// PublishProcessingActivityList is the resolver for the publishProcessingActivityList field.
|
||||
func (r *mutationResolver) PublishProcessingActivityList(ctx context.Context, input types.PublishProcessingActivityListInput) (*types.PublishProcessingActivityListPayload, error) {
|
||||
if err := r.authorize(ctx, input.OrganizationID, probo.ActionProcessingActivityPublish); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
var snapshotIDPtr *gid.GID
|
||||
if input.Filter != nil {
|
||||
snapshotIDPtr = input.Filter.SnapshotID
|
||||
}
|
||||
processingActivityFilter := coredata.NewProcessingActivityFilter(&snapshotIDPtr)
|
||||
|
||||
pdf, err := prb.ProcessingActivities.ExportPDF(ctx, input.OrganizationID, processingActivityFilter)
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishProcessingActivityList(ctx, input.OrganizationID, input.ApproverIds)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
r.logger.ErrorCtx(ctx, "cannot export processing activities PDF", log.Error(err))
|
||||
r.logger.ErrorCtx(ctx, "cannot publish processing activity list", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &types.ExportProcessingActivitiesPDFPayload{
|
||||
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
|
||||
return &types.PublishProcessingActivityListPayload{
|
||||
DocumentEdge: types.NewDocumentEdge(document, coredata.DocumentOrderFieldCreatedAt),
|
||||
DocumentVersionEdge: types.NewDocumentVersionEdge(documentVersion, coredata.DocumentVersionOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -286,12 +278,7 @@ func (r *processingActivityConnectionResolver) TotalCount(ctx context.Context, o
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
processingActivityFilter := coredata.NewProcessingActivityFilter(nil)
|
||||
if obj.Filter != nil {
|
||||
processingActivityFilter = coredata.NewProcessingActivityFilter(&obj.Filter.SnapshotID)
|
||||
}
|
||||
|
||||
count, err := prb.ProcessingActivities.CountForOrganizationID(ctx, obj.ParentID, processingActivityFilter)
|
||||
count, err := prb.ProcessingActivities.CountForOrganizationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization processing activities", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
|
||||
@@ -30,7 +30,6 @@ type (
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
Filter *coredata.DataProtectionImpactAssessmentFilter
|
||||
}
|
||||
)
|
||||
|
||||
@@ -38,7 +37,6 @@ func NewDataProtectionImpactAssessmentConnection(
|
||||
p *page.Page[*coredata.DataProtectionImpactAssessment, coredata.DataProtectionImpactAssessmentOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
filter *coredata.DataProtectionImpactAssessmentFilter,
|
||||
) *DataProtectionImpactAssessmentConnection {
|
||||
edges := make([]*DataProtectionImpactAssessmentEdge, len(p.Data))
|
||||
for i, dpia := range p.Data {
|
||||
@@ -51,7 +49,6 @@ func NewDataProtectionImpactAssessmentConnection(
|
||||
|
||||
Resolver: parentType,
|
||||
ParentID: parentID,
|
||||
Filter: filter,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ type (
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
Filter *ProcessingActivityFilter
|
||||
}
|
||||
)
|
||||
|
||||
@@ -38,7 +37,6 @@ func NewProcessingActivityConnection(
|
||||
p *page.Page[*coredata.ProcessingActivity, coredata.ProcessingActivityOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
filter *ProcessingActivityFilter,
|
||||
) *ProcessingActivityConnection {
|
||||
edges := make([]*ProcessingActivityEdge, len(p.Data))
|
||||
for i, processingActivity := range p.Data {
|
||||
@@ -51,7 +49,6 @@ func NewProcessingActivityConnection(
|
||||
|
||||
Resolver: parentType,
|
||||
ParentID: parentID,
|
||||
Filter: filter,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +65,6 @@ func NewProcessingActivity(par *coredata.ProcessingActivity) *ProcessingActivity
|
||||
Organization: &Organization{
|
||||
ID: par.OrganizationID,
|
||||
},
|
||||
SnapshotID: par.SnapshotID,
|
||||
SourceID: par.SourceID,
|
||||
Name: par.Name,
|
||||
Purpose: par.Purpose,
|
||||
DataSubjectCategory: par.DataSubjectCategory,
|
||||
|
||||
@@ -30,7 +30,6 @@ type (
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
Filter *coredata.TransferImpactAssessmentFilter
|
||||
}
|
||||
)
|
||||
|
||||
@@ -38,7 +37,6 @@ func NewTransferImpactAssessmentConnection(
|
||||
p *page.Page[*coredata.TransferImpactAssessment, coredata.TransferImpactAssessmentOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
filter *coredata.TransferImpactAssessmentFilter,
|
||||
) *TransferImpactAssessmentConnection {
|
||||
edges := make([]*TransferImpactAssessmentEdge, len(p.Data))
|
||||
for i, tia := range p.Data {
|
||||
@@ -51,7 +49,6 @@ func NewTransferImpactAssessmentConnection(
|
||||
|
||||
Resolver: parentType,
|
||||
ParentID: parentID,
|
||||
Filter: filter,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -956,13 +956,7 @@ func (r *Resolver) ListProcessingActivitiesTool(ctx context.Context, req *mcp.Ca
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
noSnapshot := (*gid.GID)(nil)
|
||||
filter := coredata.NewProcessingActivityFilter(&noSnapshot)
|
||||
if input.Filter != nil {
|
||||
filter = coredata.NewProcessingActivityFilter(&input.Filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.ProcessingActivities.ListForOrganizationID(ctx, input.OrganizationID, cursor, filter)
|
||||
page, err := prb.ProcessingActivities.ListForOrganizationID(ctx, input.OrganizationID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization processing activities: %w", err))
|
||||
}
|
||||
@@ -1103,13 +1097,7 @@ func (r *Resolver) ListDataProtectionImpactAssessmentsTool(ctx context.Context,
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
noSnapshot := (*gid.GID)(nil)
|
||||
filter := coredata.NewDataProtectionImpactAssessmentFilter(&noSnapshot)
|
||||
if input.Filter != nil {
|
||||
filter = coredata.NewDataProtectionImpactAssessmentFilter(&input.Filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.DataProtectionImpactAssessments.ListForOrganizationID(ctx, input.OrganizationID, cursor, filter)
|
||||
page, err := prb.DataProtectionImpactAssessments.ListForOrganizationID(ctx, input.OrganizationID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization data protection impact assessments: %w", err))
|
||||
}
|
||||
@@ -1200,13 +1188,7 @@ func (r *Resolver) ListTransferImpactAssessmentsTool(ctx context.Context, req *m
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
noSnapshot := (*gid.GID)(nil)
|
||||
filter := coredata.NewTransferImpactAssessmentFilter(&noSnapshot)
|
||||
if input.Filter != nil {
|
||||
filter = coredata.NewTransferImpactAssessmentFilter(&input.Filter.SnapshotID)
|
||||
}
|
||||
|
||||
page, err := prb.TransferImpactAssessments.ListForOrganizationID(ctx, input.OrganizationID, cursor, filter)
|
||||
page, err := prb.TransferImpactAssessments.ListForOrganizationID(ctx, input.OrganizationID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization transfer impact assessments: %w", err))
|
||||
}
|
||||
@@ -4810,3 +4792,51 @@ func (r *Resolver) PublishObligationListTool(ctx context.Context, req *mcp.CallT
|
||||
DocumentVersionID: documentVersion.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) PublishProcessingActivityListTool(ctx context.Context, req *mcp.CallToolRequest, input *types.PublishProcessingActivityListInput) (*mcp.CallToolResult, types.PublishProcessingActivityListOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionProcessingActivityPublish)
|
||||
|
||||
svc := r.ProboService(ctx, input.OrganizationID)
|
||||
|
||||
document, documentVersion, err := svc.GeneratedDocuments.PublishProcessingActivityList(ctx, input.OrganizationID, input.ApproverIds)
|
||||
if err != nil {
|
||||
return nil, types.PublishProcessingActivityListOutput{}, fmt.Errorf("cannot publish processing activity list: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.PublishProcessingActivityListOutput{
|
||||
DocumentID: document.ID,
|
||||
DocumentVersionID: documentVersion.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) PublishDataProtectionImpactAssessmentListTool(ctx context.Context, req *mcp.CallToolRequest, input *types.PublishDataProtectionImpactAssessmentListInput) (*mcp.CallToolResult, types.PublishDataProtectionImpactAssessmentListOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionDataProtectionImpactAssessmentPublish)
|
||||
|
||||
svc := r.ProboService(ctx, input.OrganizationID)
|
||||
|
||||
document, documentVersion, err := svc.GeneratedDocuments.PublishDataProtectionImpactAssessmentList(ctx, input.OrganizationID, input.ApproverIds)
|
||||
if err != nil {
|
||||
return nil, types.PublishDataProtectionImpactAssessmentListOutput{}, fmt.Errorf("cannot publish DPIA list: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.PublishDataProtectionImpactAssessmentListOutput{
|
||||
DocumentID: document.ID,
|
||||
DocumentVersionID: documentVersion.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) PublishTransferImpactAssessmentListTool(ctx context.Context, req *mcp.CallToolRequest, input *types.PublishTransferImpactAssessmentListInput) (*mcp.CallToolResult, types.PublishTransferImpactAssessmentListOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionTransferImpactAssessmentPublish)
|
||||
|
||||
svc := r.ProboService(ctx, input.OrganizationID)
|
||||
|
||||
document, documentVersion, err := svc.GeneratedDocuments.PublishTransferImpactAssessmentList(ctx, input.OrganizationID, input.ApproverIds)
|
||||
if err != nil {
|
||||
return nil, types.PublishTransferImpactAssessmentListOutput{}, fmt.Errorf("cannot publish TIA list: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.PublishTransferImpactAssessmentListOutput{
|
||||
DocumentID: document.ID,
|
||||
DocumentVersionID: documentVersion.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -3709,15 +3709,6 @@ components:
|
||||
cursor:
|
||||
$ref: "#/components/schemas/CursorKey"
|
||||
description: Page cursor
|
||||
filter:
|
||||
type: object
|
||||
properties:
|
||||
snapshot_id:
|
||||
anyOf:
|
||||
- $ref: "#/components/schemas/GID"
|
||||
- type: "null"
|
||||
description: Filter by snapshot ID. Defaults to null, which returns only processing activities with no snapshot (current live data). Pass a specific snapshot ID to retrieve processing activities as they were at that snapshot.
|
||||
default: null
|
||||
|
||||
ListProcessingActivitiesOutput:
|
||||
type: object
|
||||
@@ -4016,15 +4007,6 @@ components:
|
||||
type: integer
|
||||
cursor:
|
||||
$ref: "#/components/schemas/CursorKey"
|
||||
filter:
|
||||
type: object
|
||||
properties:
|
||||
snapshot_id:
|
||||
anyOf:
|
||||
- $ref: "#/components/schemas/GID"
|
||||
- type: "null"
|
||||
description: Filter by snapshot ID. Defaults to null, which returns only DPIAs with no snapshot (current live data). Pass a specific snapshot ID to retrieve DPIAs as they were at that snapshot.
|
||||
default: null
|
||||
|
||||
ListDataProtectionImpactAssessmentsOutput:
|
||||
type: object
|
||||
@@ -4200,15 +4182,6 @@ components:
|
||||
type: integer
|
||||
cursor:
|
||||
$ref: "#/components/schemas/CursorKey"
|
||||
filter:
|
||||
type: object
|
||||
properties:
|
||||
snapshot_id:
|
||||
anyOf:
|
||||
- $ref: "#/components/schemas/GID"
|
||||
- type: "null"
|
||||
description: Filter by snapshot ID. Defaults to null, which returns only TIAs with no snapshot (current live data). Pass a specific snapshot ID to retrieve TIAs as they were at that snapshot.
|
||||
default: null
|
||||
|
||||
ListTransferImpactAssessmentsOutput:
|
||||
type: object
|
||||
@@ -7065,6 +7038,87 @@ components:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Created document version ID
|
||||
|
||||
PublishProcessingActivityListInput:
|
||||
type: object
|
||||
required:
|
||||
- organization_id
|
||||
properties:
|
||||
organization_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Organization ID
|
||||
approver_ids:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Optional approver profile IDs. If provided, creates a draft pending approval instead of publishing immediately.
|
||||
|
||||
PublishProcessingActivityListOutput:
|
||||
type: object
|
||||
required:
|
||||
- document_id
|
||||
- document_version_id
|
||||
properties:
|
||||
document_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Created or updated document ID
|
||||
document_version_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Created document version ID
|
||||
|
||||
PublishDataProtectionImpactAssessmentListInput:
|
||||
type: object
|
||||
required:
|
||||
- organization_id
|
||||
properties:
|
||||
organization_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Organization ID
|
||||
approver_ids:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Optional approver profile IDs. If provided, creates a draft pending approval instead of publishing immediately.
|
||||
|
||||
PublishDataProtectionImpactAssessmentListOutput:
|
||||
type: object
|
||||
required:
|
||||
- document_id
|
||||
- document_version_id
|
||||
properties:
|
||||
document_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Created or updated document ID
|
||||
document_version_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Created document version ID
|
||||
|
||||
PublishTransferImpactAssessmentListInput:
|
||||
type: object
|
||||
required:
|
||||
- organization_id
|
||||
properties:
|
||||
organization_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Organization ID
|
||||
approver_ids:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Optional approver profile IDs. If provided, creates a draft pending approval instead of publishing immediately.
|
||||
|
||||
PublishTransferImpactAssessmentListOutput:
|
||||
type: object
|
||||
required:
|
||||
- document_id
|
||||
- document_version_id
|
||||
properties:
|
||||
document_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Created or updated document ID
|
||||
document_version_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Created document version ID
|
||||
|
||||
PublishStatementOfApplicabilityInput:
|
||||
type: object
|
||||
required:
|
||||
@@ -10318,6 +10372,30 @@ tools:
|
||||
$ref: "#/components/schemas/PublishObligationListInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/PublishObligationListOutput"
|
||||
- name: publishProcessingActivityList
|
||||
description: Publish the processing activity register for an organization as a document. If a document already exists, a new version is created.
|
||||
hints:
|
||||
readonly: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/PublishProcessingActivityListInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/PublishProcessingActivityListOutput"
|
||||
- name: publishDataProtectionImpactAssessmentList
|
||||
description: Publish the Data Protection Impact Assessment register for an organization as a document. If a document already exists, a new version is created.
|
||||
hints:
|
||||
readonly: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/PublishDataProtectionImpactAssessmentListInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/PublishDataProtectionImpactAssessmentListOutput"
|
||||
- name: publishTransferImpactAssessmentList
|
||||
description: Publish the Transfer Impact Assessment register for an organization as a document. If a document already exists, a new version is created.
|
||||
hints:
|
||||
readonly: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/PublishTransferImpactAssessmentListInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/PublishTransferImpactAssessmentListOutput"
|
||||
- name: publishStatementOfApplicability
|
||||
description: Publish a statement of applicability as a document. If a document already exists, a new version is created.
|
||||
hints:
|
||||
|
||||
Reference in New Issue
Block a user