From 8bf7be0c0daa35bce83d9cbae30d04af5943913b Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Wed, 20 May 2026 18:18:39 -0700 Subject: [PATCH] Style Signed-off-by: Bryan Frimin --- .../v1/access_review_campaign_resolvers.go | 12 +- pkg/server/api/console/v1/asset_resolvers.go | 54 ++--- pkg/server/api/console/v1/audit_resolvers.go | 84 +++----- pkg/server/api/console/v1/base_resolvers.go | 59 +++--- .../api/console/v1/connector_resolvers.go | 16 +- .../api/console/v1/control_resolvers.go | 134 ++++-------- ..._protection_impact_assessment_resolvers.go | 56 ++--- .../api/console/v1/document_resolvers.go | 192 +++++------------- .../api/console/v1/evidence_resolvers.go | 14 +- pkg/server/api/console/v1/file_resolvers.go | 4 +- .../api/console/v1/framework_resolvers.go | 36 +--- .../api/console/v1/measure_resolvers.go | 52 ++--- .../api/console/v1/obligation_resolvers.go | 22 +- .../api/console/v1/organization_resolvers.go | 172 +++++----------- .../v1/processing_activity_resolvers.go | 32 +-- .../console/v1/rights_request_resolvers.go | 22 +- pkg/server/api/console/v1/risk_resolvers.go | 62 ++---- pkg/server/api/console/v1/task_resolvers.go | 22 +- .../api/console/v1/third_party_resolvers.go | 148 ++++---------- .../api/console/v1/trust_center_resolvers.go | 178 +++++----------- pkg/server/api/console/v1/viewer_resolvers.go | 16 +- .../api/console/v1/webhook_resolvers.go | 28 +-- 22 files changed, 389 insertions(+), 1026 deletions(-) diff --git a/pkg/server/api/console/v1/access_review_campaign_resolvers.go b/pkg/server/api/console/v1/access_review_campaign_resolvers.go index 137780db7..8b5044dab 100644 --- a/pkg/server/api/console/v1/access_review_campaign_resolvers.go +++ b/pkg/server/api/console/v1/access_review_campaign_resolvers.go @@ -362,9 +362,7 @@ func (r *accessSourceResolver) Connector(ctx context.Context, obj *types.AccessS } scope := coredata.NewScopeFromObjectID(obj.ID) - prb := r.probo - - connector, err := prb.Connectors.Get(ctx, scope, *obj.ConnectorID) + connector, err := r.probo.Connectors.Get(ctx, scope, *obj.ConnectorID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -430,9 +428,7 @@ func (r *accessSourceResolver) NeedsConfiguration(ctx context.Context, obj *type return false, nil } - prb := r.probo - - dbConnector, err := prb.Connectors.Get(ctx, scope, *obj.ConnectorID) + dbConnector, err := r.probo.Connectors.Get(ctx, scope, *obj.ConnectorID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return false, nil @@ -492,9 +488,7 @@ func (r *accessSourceResolver) SelectedOrganization(ctx context.Context, obj *ty return nil, nil } - prb := r.probo - - dbConnector, err := prb.Connectors.Get(ctx, scope, *obj.ConnectorID) + dbConnector, err := r.probo.Connectors.Get(ctx, scope, *obj.ConnectorID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil diff --git a/pkg/server/api/console/v1/asset_resolvers.go b/pkg/server/api/console/v1/asset_resolvers.go index 0a1b986ce..a0c658792 100644 --- a/pkg/server/api/console/v1/asset_resolvers.go +++ b/pkg/server/api/console/v1/asset_resolvers.go @@ -52,8 +52,6 @@ func (r *assetResolver) ThirdParties(ctx context.Context, obj *types.Asset, firs return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{ Field: coredata.ThirdPartyOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -67,7 +65,7 @@ func (r *assetResolver) ThirdParties(ctx context.Context, obj *types.Asset, firs cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.ThirdParties.ListForAssetID(ctx, scope, obj.ID, cursor) + page, err := r.probo.ThirdParties.ListForAssetID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list asset thirdParties", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -83,15 +81,13 @@ func (r *assetResolver) Organization(ctx context.Context, obj *types.Asset) (*ty return nil, err } - prb := r.probo - - asset, err := prb.Assets.Get(ctx, scope, obj.ID) + asset, err := r.probo.Assets.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot load audit", log.Error(err)) return nil, gqlutils.Internal(ctx) } - org, err := prb.Organizations.Get(ctx, scope, asset.OrganizationID) + org, err := r.probo.Organizations.Get(ctx, scope, asset.OrganizationID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -117,11 +113,9 @@ func (r *assetConnectionResolver) TotalCount(ctx context.Context, obj *types.Ass return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.Assets.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.Assets.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count assets", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -162,8 +156,6 @@ func (r *datumResolver) ThirdParties(ctx context.Context, obj *types.Datum, firs return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{ Field: coredata.ThirdPartyOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -177,7 +169,7 @@ func (r *datumResolver) ThirdParties(ctx context.Context, obj *types.Datum, firs cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Data.ListThirdParties(ctx, scope, obj.ID, cursor) + page, err := r.probo.Data.ListThirdParties(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list data thirdParties", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -220,11 +212,9 @@ func (r *datumConnectionResolver) TotalCount(ctx context.Context, obj *types.Dat return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.Data.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.Data.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count data", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -245,9 +235,7 @@ func (r *mutationResolver) CreateAsset(ctx context.Context, input types.CreateAs return nil, err } - prb := r.probo - - asset, err := prb.Assets.Create( + asset, err := r.probo.Assets.Create( ctx, scope, probo.CreateAssetRequest{ OrganizationID: input.OrganizationID, @@ -281,9 +269,7 @@ func (r *mutationResolver) UpdateAsset(ctx context.Context, input types.UpdateAs return nil, err } - prb := r.probo - - asset, err := prb.Assets.Update( + asset, err := r.probo.Assets.Update( ctx, scope, probo.UpdateAssetRequest{ ID: input.ID, @@ -317,9 +303,7 @@ func (r *mutationResolver) DeleteAsset(ctx context.Context, input types.DeleteAs return nil, err } - prb := r.probo - - if err := prb.Assets.Delete(ctx, scope, input.AssetID); err != nil { + if err := r.probo.Assets.Delete(ctx, scope, input.AssetID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete asset", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -336,9 +320,7 @@ func (r *mutationResolver) CreateDatum(ctx context.Context, input types.CreateDa return nil, err } - prb := r.probo - - data, err := prb.Data.Create( + data, err := r.probo.Data.Create( ctx, scope, probo.CreateDatumRequest{ OrganizationID: input.OrganizationID, @@ -370,9 +352,7 @@ func (r *mutationResolver) UpdateDatum(ctx context.Context, input types.UpdateDa return nil, err } - prb := r.probo - - datum, err := prb.Data.Update( + datum, err := r.probo.Data.Update( ctx, scope, probo.UpdateDatumRequest{ ID: input.ID, @@ -404,9 +384,7 @@ func (r *mutationResolver) DeleteDatum(ctx context.Context, input types.DeleteDa return nil, err } - prb := r.probo - - if err := prb.Data.Delete(ctx, scope, input.DatumID); err != nil { + if err := r.probo.Data.Delete(ctx, scope, input.DatumID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete datum", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -423,9 +401,7 @@ func (r *mutationResolver) PublishDataList(ctx context.Context, input types.Publ return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishDataList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishDataList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -453,9 +429,7 @@ func (r *mutationResolver) PublishAssetList(ctx context.Context, input types.Pub return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishAssetList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishAssetList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) diff --git a/pkg/server/api/console/v1/audit_resolvers.go b/pkg/server/api/console/v1/audit_resolvers.go index c58172f6c..550a152c2 100644 --- a/pkg/server/api/console/v1/audit_resolvers.go +++ b/pkg/server/api/console/v1/audit_resolvers.go @@ -105,9 +105,7 @@ func (r *auditResolver) ReportURL(ctx context.Context, obj *types.Audit) (*strin return nil, nil } - prb := r.probo - - url, err := prb.Audits.GenerateReportURL(ctx, scope, obj.ID, 15*time.Minute) + url, err := r.probo.Audits.GenerateReportURL(ctx, scope, obj.ID, 15*time.Minute) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate report URL", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -123,8 +121,6 @@ func (r *auditResolver) Controls(ctx context.Context, obj *types.Audit, first *i return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ Field: coredata.ControlOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -143,7 +139,7 @@ func (r *auditResolver) Controls(ctx context.Context, obj *types.Audit, first *i controlFilter = coredata.NewControlFilter(filter.Query) } - page, err := prb.Controls.ListForAuditID(ctx, scope, obj.ID, cursor, controlFilter) + page, err := r.probo.Controls.ListForAuditID(ctx, scope, obj.ID, cursor, controlFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list audit controls", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -159,8 +155,6 @@ func (r *auditResolver) Findings(ctx context.Context, obj *types.Audit, first *i return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.FindingOrderField]{ Field: coredata.FindingOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -189,7 +183,7 @@ func (r *auditResolver) Findings(ctx context.Context, obj *types.Audit, first *i findingFilter := coredata.NewFindingFilter(kind, status, priority, ownerID) - p, err := prb.Findings.ListForAuditID(ctx, scope, obj.ID, cursor, findingFilter) + p, err := r.probo.Findings.ListForAuditID(ctx, scope, obj.ID, cursor, findingFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list audit findings", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -210,11 +204,9 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.Audits.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.Audits.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -222,7 +214,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud return count, nil case *findingResolver: - count, err := prb.Audits.CountForFindingID(ctx, scope, obj.ParentID) + count, err := r.probo.Audits.CountForFindingID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -230,7 +222,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud return count, nil case *controlResolver: - count, err := prb.Audits.CountForControlID(ctx, scope, obj.ParentID) + count, err := r.probo.Audits.CountForControlID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -272,8 +264,6 @@ func (r *findingResolver) Audits(ctx context.Context, obj *types.Finding, first return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.AuditOrderField]{ Field: coredata.AuditOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -287,7 +277,7 @@ func (r *findingResolver) Audits(ctx context.Context, obj *types.Finding, first cursor := types.NewCursor(first, after, last, before, pageOrderBy) - p, err := prb.Audits.ListForFindingID(ctx, scope, obj.ID, cursor) + p, err := r.probo.Audits.ListForFindingID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list finding audits", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -360,8 +350,6 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F return 0, err } - prb := r.probo - var ( kind *coredata.FindingKind status *coredata.FindingStatus @@ -379,7 +367,7 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.Findings.CountForOrganizationID(ctx, scope, obj.ParentID, findingFilter) + count, err := r.probo.Findings.CountForOrganizationID(ctx, scope, obj.ParentID, findingFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot count findings", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -387,7 +375,7 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F return count, nil case *auditResolver: - count, err := prb.Findings.CountForAuditID(ctx, scope, obj.ParentID, findingFilter) + count, err := r.probo.Findings.CountForAuditID(ctx, scope, obj.ParentID, findingFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot count findings", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -408,8 +396,6 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu return nil, err } - prb := r.probo - req := probo.CreateAuditRequest{ OrganizationID: input.OrganizationID, FrameworkID: input.FrameworkID, @@ -420,7 +406,7 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu TrustCenterVisibility: input.TrustCenterVisibility, } - audit, err := prb.Audits.Create(ctx, scope, &req) + audit, err := r.probo.Audits.Create(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -442,7 +428,7 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu }, } - audit, err = prb.Audits.UploadReport(ctx, scope, uploadReq) + audit, err = r.probo.Audits.UploadReport(ctx, scope, uploadReq) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -466,8 +452,6 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu return nil, err } - prb := r.probo - req := probo.UpdateAuditRequest{ ID: input.ID, Name: gqlutils.UnwrapOmittable(input.Name), @@ -477,7 +461,7 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu TrustCenterVisibility: input.TrustCenterVisibility, } - audit, err := prb.Audits.Update(ctx, scope, &req) + audit, err := r.probo.Audits.Update(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -500,9 +484,7 @@ func (r *mutationResolver) DeleteAudit(ctx context.Context, input types.DeleteAu return nil, err } - prb := r.probo - - if err := prb.Audits.Delete(ctx, scope, input.AuditID); err != nil { + if err := r.probo.Audits.Delete(ctx, scope, input.AuditID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete audit", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -519,8 +501,6 @@ func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.Up return nil, err } - prb := r.probo - req := probo.UploadAuditReportRequest{ AuditID: input.AuditID, File: probo.File{ @@ -531,7 +511,7 @@ func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.Up }, } - audit, err := prb.Audits.UploadReport(ctx, scope, req) + audit, err := r.probo.Audits.UploadReport(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -554,9 +534,7 @@ func (r *mutationResolver) DeleteAuditReport(ctx context.Context, input types.De return nil, err } - prb := r.probo - - audit, err := prb.Audits.DeleteReport(ctx, scope, input.AuditID) + audit, err := r.probo.Audits.DeleteReport(ctx, scope, input.AuditID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete audit report", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -574,8 +552,6 @@ func (r *mutationResolver) CreateFinding(ctx context.Context, input types.Create return nil, err } - prb := r.probo - req := probo.CreateFindingRequest{ OrganizationID: input.OrganizationID, Kind: input.Kind, @@ -592,7 +568,7 @@ func (r *mutationResolver) CreateFinding(ctx context.Context, input types.Create EffectivenessCheck: input.EffectivenessCheck, } - finding, err := prb.Findings.Create(ctx, scope, &req) + finding, err := r.probo.Findings.Create(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -615,8 +591,6 @@ func (r *mutationResolver) UpdateFinding(ctx context.Context, input types.Update return nil, err } - prb := r.probo - req := probo.UpdateFindingRequest{ ID: input.ID, Description: gqlutils.UnwrapOmittable(input.Description), @@ -632,7 +606,7 @@ func (r *mutationResolver) UpdateFinding(ctx context.Context, input types.Update EffectivenessCheck: gqlutils.UnwrapOmittable(input.EffectivenessCheck), } - finding, err := prb.Findings.Update(ctx, scope, &req) + finding, err := r.probo.Findings.Update(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -655,9 +629,7 @@ func (r *mutationResolver) DeleteFinding(ctx context.Context, input types.Delete return nil, err } - prb := r.probo - - if err := prb.Findings.Delete(ctx, scope, input.FindingID); err != nil { + if err := r.probo.Findings.Delete(ctx, scope, input.FindingID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete finding", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -674,9 +646,7 @@ func (r *mutationResolver) CreateFindingAuditMapping(ctx context.Context, input return nil, err } - prb := r.probo - - finding, audit, err := prb.Findings.CreateAuditMapping(ctx, scope, input.FindingID, input.AuditID, input.ReferenceID) + finding, audit, err := r.probo.Findings.CreateAuditMapping(ctx, scope, input.FindingID, input.AuditID, input.ReferenceID) if err != nil { r.logger.ErrorCtx(ctx, "cannot create finding audit mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -695,9 +665,7 @@ func (r *mutationResolver) DeleteFindingAuditMapping(ctx context.Context, input return nil, err } - prb := r.probo - - finding, audit, err := prb.Findings.DeleteAuditMapping(ctx, scope, input.FindingID, input.AuditID) + finding, audit, err := r.probo.Findings.DeleteAuditMapping(ctx, scope, input.FindingID, input.AuditID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete finding audit mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -716,9 +684,7 @@ func (r *mutationResolver) PublishFindingList(ctx context.Context, input types.P return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishFindingList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishFindingList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -746,9 +712,7 @@ func (r *reportResolver) DownloadURL(ctx context.Context, obj *types.Report) (*s return nil, err } - prb := r.probo - - url, err := prb.Reports.GenerateDownloadURL(ctx, scope, obj.ID, 15*time.Minute) + url, err := r.probo.Reports.GenerateDownloadURL(ctx, scope, obj.ID, 15*time.Minute) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate download URL", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -764,9 +728,7 @@ func (r *reportResolver) Audit(ctx context.Context, obj *types.Report) (*types.A return nil, err } - prb := r.probo - - audit, err := prb.Audits.GetByReportID(ctx, scope, obj.ID) + audit, err := r.probo.Audits.GetByReportID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot load audit for report", log.Error(err)) return nil, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/base_resolvers.go b/pkg/server/api/console/v1/base_resolvers.go index 41915fe55..3576c8e67 100644 --- a/pkg/server/api/console/v1/base_resolvers.go +++ b/pkg/server/api/console/v1/base_resolvers.go @@ -27,14 +27,13 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error loadNode func(ctx context.Context, id gid.GID) (types.Node, error) action string scope = coredata.NewScopeFromObjectID(id) - prb = r.probo ) switch id.EntityType() { case coredata.OrganizationEntityType: action = iam.ActionOrganizationGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - organization, err := prb.Organizations.Get(ctx, scope, id) + organization, err := r.probo.Organizations.Get(ctx, scope, id) if err != nil { return nil, err } @@ -44,7 +43,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ThirdPartyEntityType: action = probo.ActionThirdPartyGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - thirdParty, err := prb.ThirdParties.Get(ctx, scope, id) + thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, id) if err != nil { return nil, err } @@ -54,7 +53,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.FrameworkEntityType: action = probo.ActionFrameworkGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - framework, err := prb.Frameworks.Get(ctx, scope, id) + framework, err := r.probo.Frameworks.Get(ctx, scope, id) if err != nil { return nil, err } @@ -64,7 +63,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.MeasureEntityType: action = probo.ActionMeasureGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - measure, err := prb.Measures.Get(ctx, scope, id) + measure, err := r.probo.Measures.Get(ctx, scope, id) if err != nil { return nil, err } @@ -74,7 +73,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.TaskEntityType: action = probo.ActionTaskGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - task, err := prb.Tasks.Get(ctx, scope, id) + task, err := r.probo.Tasks.Get(ctx, scope, id) if err != nil { return nil, err } @@ -84,7 +83,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.EvidenceEntityType: action = probo.ActionEvidenceList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - evidence, err := prb.Evidences.Get(ctx, scope, id) + evidence, err := r.probo.Evidences.Get(ctx, scope, id) if err != nil { return nil, err } @@ -94,7 +93,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.DocumentEntityType: action = probo.ActionDocumentGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - document, err := prb.Documents.Get(ctx, scope, id) + document, err := r.probo.Documents.Get(ctx, scope, id) if err != nil { return nil, err } @@ -104,7 +103,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ControlEntityType: action = probo.ActionControlList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - control, err := prb.Controls.Get(ctx, scope, id) + control, err := r.probo.Controls.Get(ctx, scope, id) if err != nil { return nil, err } @@ -114,7 +113,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.RiskEntityType: action = probo.ActionRiskGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - risk, err := prb.Risks.Get(ctx, scope, id) + risk, err := r.probo.Risks.Get(ctx, scope, id) if err != nil { return nil, err } @@ -196,7 +195,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ThirdPartyComplianceReportEntityType: action = probo.ActionThirdPartyComplianceReportGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - thirdPartyComplianceReport, err := prb.ThirdPartyComplianceReports.Get(ctx, scope, id) + thirdPartyComplianceReport, err := r.probo.ThirdPartyComplianceReports.Get(ctx, scope, id) if err != nil { return nil, err } @@ -206,7 +205,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ThirdPartyContactEntityType: action = probo.ActionThirdPartyContactGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - thirdPartyContact, err := prb.ThirdPartyContacts.Get(ctx, scope, id) + thirdPartyContact, err := r.probo.ThirdPartyContacts.Get(ctx, scope, id) if err != nil { return nil, err } @@ -216,7 +215,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ThirdPartyServiceEntityType: action = probo.ActionThirdPartyServiceGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - thirdPartyService, err := prb.ThirdPartyServices.Get(ctx, scope, id) + thirdPartyService, err := r.probo.ThirdPartyServices.Get(ctx, scope, id) if err != nil { return nil, err } @@ -226,7 +225,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.DocumentVersionEntityType: action = probo.ActionDocumentVersionList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - documentVersion, err := prb.Documents.GetVersion(ctx, scope, id) + documentVersion, err := r.probo.Documents.GetVersion(ctx, scope, id) if err != nil { return nil, err } @@ -236,7 +235,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.DocumentVersionSignatureEntityType: action = probo.ActionDocumentVersionSignatureList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - documentVersionSignature, err := prb.Documents.GetVersionSignature(ctx, scope, id) + documentVersionSignature, err := r.probo.Documents.GetVersionSignature(ctx, scope, id) if err != nil { return nil, err } @@ -246,7 +245,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.AssetEntityType: action = probo.ActionAssetList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - asset, err := prb.Assets.Get(ctx, scope, id) + asset, err := r.probo.Assets.Get(ctx, scope, id) if err != nil { return nil, err } @@ -256,7 +255,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.DatumEntityType: action = probo.ActionDatumList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - datum, err := prb.Data.Get(ctx, scope, id) + datum, err := r.probo.Data.Get(ctx, scope, id) if err != nil { return nil, err } @@ -266,7 +265,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.AuditEntityType: action = probo.ActionAuditList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - audit, err := prb.Audits.Get(ctx, scope, id) + audit, err := r.probo.Audits.Get(ctx, scope, id) if err != nil { return nil, err } @@ -276,7 +275,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.FindingEntityType: action = probo.ActionFindingList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - finding, err := prb.Findings.Get(ctx, scope, id) + finding, err := r.probo.Findings.Get(ctx, scope, id) if err != nil { return nil, err } @@ -286,7 +285,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ObligationEntityType: action = probo.ActionObligationList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - obligation, err := prb.Obligations.Get(ctx, scope, id) + obligation, err := r.probo.Obligations.Get(ctx, scope, id) if err != nil { return nil, err } @@ -296,7 +295,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ReportEntityType: action = probo.ActionReportGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - report, err := prb.Reports.Get(ctx, scope, id) + report, err := r.probo.Reports.Get(ctx, scope, id) if err != nil { return nil, err } @@ -306,7 +305,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.ProcessingActivityEntityType: action = probo.ActionProcessingActivityList loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - processingActivity, err := prb.ProcessingActivities.Get(ctx, scope, id) + processingActivity, err := r.probo.ProcessingActivities.Get(ctx, scope, id) if err != nil { return nil, err } @@ -317,7 +316,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error // TODO: add action // action = probo.ActionDataProtectionImpactAssessmentGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - dpia, err := prb.DataProtectionImpactAssessments.Get(ctx, scope, id) + dpia, err := r.probo.DataProtectionImpactAssessments.Get(ctx, scope, id) if err != nil { return nil, err } @@ -328,7 +327,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error // TODO: add action //action = probo.ActionTransferImpactAssessmentGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - tia, err := prb.TransferImpactAssessments.Get(ctx, scope, id) + tia, err := r.probo.TransferImpactAssessments.Get(ctx, scope, id) if err != nil { return nil, err } @@ -338,14 +337,14 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.TrustCenterEntityType: action = probo.ActionTrustCenterGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - trustCenter, err := prb.TrustCenters.Get(ctx, scope, id) + trustCenter, err := r.probo.TrustCenters.Get(ctx, scope, id) if err != nil { return nil, err } var file *coredata.File if trustCenter.NonDisclosureAgreementFileID != nil { - file, err = prb.Files.Get(ctx, scope, *trustCenter.NonDisclosureAgreementFileID) + file, err = r.probo.Files.Get(ctx, scope, *trustCenter.NonDisclosureAgreementFileID) if err != nil { return nil, fmt.Errorf("cannot get NDA file: %w", err) } @@ -356,7 +355,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.TrustCenterAccessEntityType: action = probo.ActionTrustCenterAccessGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - trustCenterAccess, err := prb.TrustCenterAccesses.Get(ctx, scope, id) + trustCenterAccess, err := r.probo.TrustCenterAccesses.Get(ctx, scope, id) if err != nil { return nil, err } @@ -366,7 +365,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.RightsRequestEntityType: action = probo.ActionRightsRequestGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - rightsRequest, err := prb.RightsRequests.Get(ctx, scope, id) + rightsRequest, err := r.probo.RightsRequests.Get(ctx, scope, id) if err != nil { return nil, err } @@ -376,7 +375,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.StatementOfApplicabilityEntityType: action = probo.ActionStatementOfApplicabilityGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - statementOfApplicability, err := prb.StatementsOfApplicability.Get(ctx, scope, id) + statementOfApplicability, err := r.probo.StatementsOfApplicability.Get(ctx, scope, id) if err != nil { return nil, err } @@ -386,7 +385,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error case coredata.WebhookSubscriptionEntityType: action = probo.ActionWebhookSubscriptionGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - wc, err := prb.WebhookSubscriptions.Get(ctx, scope, id) + wc, err := r.probo.WebhookSubscriptions.Get(ctx, scope, id) if err != nil { return nil, err } diff --git a/pkg/server/api/console/v1/connector_resolvers.go b/pkg/server/api/console/v1/connector_resolvers.go index 31717711b..a82aad6da 100644 --- a/pkg/server/api/console/v1/connector_resolvers.go +++ b/pkg/server/api/console/v1/connector_resolvers.go @@ -37,8 +37,6 @@ func (r *mutationResolver) CreateAPIKeyConnector(ctx context.Context, input type return nil, err } - prb := r.probo - req := probo.CreateConnectorRequest{ OrganizationID: input.OrganizationID, Provider: input.Provider, @@ -76,7 +74,7 @@ func (r *mutationResolver) CreateAPIKeyConnector(ctx context.Context, input type } } - cnnctr, err := prb.Connectors.Create(ctx, scope, req) + cnnctr, err := r.probo.Connectors.Create(ctx, scope, req) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -97,8 +95,6 @@ func (r *mutationResolver) CreateClientCredentialsConnector(ctx context.Context, return nil, err } - prb := r.probo - oauth2Conn := &connector.OAuth2Connection{ GrantType: connector.OAuth2GrantTypeClientCredentials, ClientID: input.ClientID, @@ -123,7 +119,7 @@ func (r *mutationResolver) CreateClientCredentialsConnector(ctx context.Context, } } - cnnctr, err := prb.Connectors.Create(ctx, scope, req) + cnnctr, err := r.probo.Connectors.Create(ctx, scope, req) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -144,9 +140,7 @@ func (r *mutationResolver) DeleteConnector(ctx context.Context, input types.Dele return nil, err } - prb := r.probo - - if err := prb.Connectors.Delete(ctx, scope, input.ConnectorID); err != nil { + if err := r.probo.Connectors.Delete(ctx, scope, input.ConnectorID); err != nil { panic(fmt.Errorf("cannot delete connector: %w", err)) } @@ -162,9 +156,7 @@ func (r *mutationResolver) DeleteSlackConnection(ctx context.Context, input type return nil, err } - prb := r.probo - - if err := prb.Connectors.Delete(ctx, scope, input.SlackConnectionID); err != nil { + if err := r.probo.Connectors.Delete(ctx, scope, input.SlackConnectionID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete slack connection", log.Error(err)) return nil, gqlutils.Internal(ctx) } diff --git a/pkg/server/api/console/v1/control_resolvers.go b/pkg/server/api/console/v1/control_resolvers.go index d0e54169b..97543c09d 100644 --- a/pkg/server/api/console/v1/control_resolvers.go +++ b/pkg/server/api/console/v1/control_resolvers.go @@ -29,9 +29,7 @@ func (r *applicabilityStatementResolver) StatementOfApplicability(ctx context.Co return nil, err } - prb := r.probo - - soa, err := prb.StatementsOfApplicability.Get(ctx, scope, obj.StatementOfApplicability.ID) + soa, err := r.probo.StatementsOfApplicability.Get(ctx, scope, obj.StatementOfApplicability.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get statement of applicability", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -74,11 +72,9 @@ func (r *applicabilityStatementConnectionResolver) TotalCount(ctx context.Contex return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *statementOfApplicabilityResolver: - count, err := prb.StatementsOfApplicability.CountApplicabilityStatements(ctx, scope, obj.ParentID) + count, err := r.probo.StatementsOfApplicability.CountApplicabilityStatements(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count applicability statements", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -117,9 +113,7 @@ func (r *controlResolver) Organization(ctx context.Context, obj *types.Control) // Regulatory is the resolver for the regulatory field. func (r *controlResolver) Regulatory(ctx context.Context, obj *types.Control) (bool, error) { scope := coredata.NewScopeFromObjectID(obj.ID) - prb := r.probo - - hasRegulatory, err := prb.Controls.HasRegulatoryObligation(ctx, scope, obj.ID) + hasRegulatory, err := r.probo.Controls.HasRegulatoryObligation(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot check regulatory obligation", log.Error(err)) return false, gqlutils.Internal(ctx) @@ -131,9 +125,7 @@ func (r *controlResolver) Regulatory(ctx context.Context, obj *types.Control) (b // Contractual is the resolver for the contractual field. func (r *controlResolver) Contractual(ctx context.Context, obj *types.Control) (bool, error) { scope := coredata.NewScopeFromObjectID(obj.ID) - prb := r.probo - - hasContractual, err := prb.Controls.HasContractualObligation(ctx, scope, obj.ID) + hasContractual, err := r.probo.Controls.HasContractualObligation(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot check contractual obligation", log.Error(err)) return false, gqlutils.Internal(ctx) @@ -145,9 +137,7 @@ func (r *controlResolver) Contractual(ctx context.Context, obj *types.Control) ( // RiskAssessment is the resolver for the riskAssessment field. func (r *controlResolver) RiskAssessment(ctx context.Context, obj *types.Control) (bool, error) { scope := coredata.NewScopeFromObjectID(obj.ID) - prb := r.probo - - hasRisk, err := prb.Controls.HasRiskAssessment(ctx, scope, obj.ID) + hasRisk, err := r.probo.Controls.HasRiskAssessment(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot check risk assessment", log.Error(err)) return false, gqlutils.Internal(ctx) @@ -185,8 +175,6 @@ func (r *controlResolver) Measures(ctx context.Context, obj *types.Control, firs return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.MeasureOrderField]{ Field: coredata.MeasureOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -205,7 +193,7 @@ func (r *controlResolver) Measures(ctx context.Context, obj *types.Control, firs measureFilter = coredata.NewMeasureFilter(filter.Query, filter.State, filter.Category) } - page, err := prb.Measures.ListForControlID(ctx, scope, obj.ID, cursor, measureFilter) + page, err := r.probo.Measures.ListForControlID(ctx, scope, obj.ID, cursor, measureFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list measures", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -221,8 +209,6 @@ func (r *controlResolver) Documents(ctx context.Context, obj *types.Control, fir return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{ Field: coredata.DocumentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -244,7 +230,7 @@ func (r *controlResolver) Documents(ctx context.Context, obj *types.Control, fir WithClassifications(filter.Classifications) } - page, err := prb.Documents.ListForControlID(ctx, scope, obj.ID, cursor, documentFilter) + page, err := r.probo.Documents.ListForControlID(ctx, scope, obj.ID, cursor, documentFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list documents", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -260,8 +246,6 @@ func (r *controlResolver) Audits(ctx context.Context, obj *types.Control, first return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.AuditOrderField]{ Field: coredata.AuditOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -275,7 +259,7 @@ func (r *controlResolver) Audits(ctx context.Context, obj *types.Control, first cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Audits.ListForControlID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Audits.ListForControlID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list control audits", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -291,8 +275,6 @@ func (r *controlResolver) Obligations(ctx context.Context, obj *types.Control, f return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ObligationOrderField]{ Field: coredata.ObligationOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -306,7 +288,7 @@ func (r *controlResolver) Obligations(ctx context.Context, obj *types.Control, f cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Obligations.ListForControlID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Obligations.ListForControlID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list control obligations", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -327,11 +309,9 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.Controls.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Controls.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -339,7 +319,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C return count, nil case *frameworkResolver: - count, err := prb.Controls.CountForFrameworkID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Controls.CountForFrameworkID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -347,7 +327,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C return count, nil case *documentResolver: - count, err := prb.Controls.CountForDocumentID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Controls.CountForDocumentID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -355,7 +335,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C return count, nil case *measureResolver: - count, err := prb.Controls.CountForMeasureID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Controls.CountForMeasureID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -363,7 +343,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C return count, nil case *riskResolver: - count, err := prb.Controls.CountForRiskID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Controls.CountForRiskID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -371,7 +351,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C return count, nil case *statementOfApplicabilityResolver: - count, err := prb.Controls.CountForStatementOfApplicabilityID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Controls.CountForStatementOfApplicabilityID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -392,9 +372,7 @@ func (r *mutationResolver) CreateControl(ctx context.Context, input types.Create return nil, err } - prb := r.probo - - control, err := prb.Controls.Create( + control, err := r.probo.Controls.Create( ctx, scope, probo.CreateControlRequest{ FrameworkID: input.FrameworkID, @@ -432,9 +410,7 @@ func (r *mutationResolver) UpdateControl(ctx context.Context, input types.Update return nil, err } - prb := r.probo - - control, err := prb.Controls.Update( + control, err := r.probo.Controls.Update( ctx, scope, probo.UpdateControlRequest{ ID: input.ID, @@ -472,9 +448,7 @@ func (r *mutationResolver) DeleteControl(ctx context.Context, input types.Delete return nil, err } - prb := r.probo - - if err := prb.Controls.Delete(ctx, scope, input.ControlID); err != nil { + if err := r.probo.Controls.Delete(ctx, scope, input.ControlID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete control", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -491,9 +465,7 @@ func (r *mutationResolver) CreateControlMeasureMapping(ctx context.Context, inpu return nil, err } - prb := r.probo - - control, measure, err := prb.Controls.CreateMeasureMapping(ctx, scope, input.ControlID, input.MeasureID) + control, measure, err := r.probo.Controls.CreateMeasureMapping(ctx, scope, input.ControlID, input.MeasureID) if err != nil { r.logger.ErrorCtx(ctx, "cannot create control measure mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -512,9 +484,7 @@ func (r *mutationResolver) CreateControlDocumentMapping(ctx context.Context, inp return nil, err } - prb := r.probo - - control, document, err := prb.Controls.CreateDocumentMapping(ctx, scope, input.ControlID, input.DocumentID) + control, document, err := r.probo.Controls.CreateDocumentMapping(ctx, scope, input.ControlID, input.DocumentID) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -538,9 +508,7 @@ func (r *mutationResolver) DeleteControlMeasureMapping(ctx context.Context, inpu return nil, err } - prb := r.probo - - control, measure, err := prb.Controls.DeleteMeasureMapping(ctx, scope, input.ControlID, input.MeasureID) + control, measure, err := r.probo.Controls.DeleteMeasureMapping(ctx, scope, input.ControlID, input.MeasureID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete control measure mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -559,9 +527,7 @@ func (r *mutationResolver) DeleteControlDocumentMapping(ctx context.Context, inp return nil, err } - prb := r.probo - - control, document, err := prb.Controls.DeleteDocumentMapping(ctx, scope, input.ControlID, input.DocumentID) + control, document, err := r.probo.Controls.DeleteDocumentMapping(ctx, scope, input.ControlID, input.DocumentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete control document mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -580,9 +546,7 @@ func (r *mutationResolver) CreateApplicabilityStatement(ctx context.Context, inp return nil, err } - prb := r.probo - - applicabilityStatement, err := prb.StatementsOfApplicability.CreateApplicabilityStatement(ctx, scope, input.StatementOfApplicabilityID, input.ControlID, input.Applicability, input.Justification) + applicabilityStatement, err := r.probo.StatementsOfApplicability.CreateApplicabilityStatement(ctx, scope, input.StatementOfApplicabilityID, input.ControlID, input.Applicability, input.Justification) if err != nil { r.logger.ErrorCtx(ctx, "cannot create applicability statement", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -600,9 +564,7 @@ func (r *mutationResolver) UpdateApplicabilityStatement(ctx context.Context, inp return nil, err } - prb := r.probo - - applicabilityStatement, err := prb.StatementsOfApplicability.UpdateApplicabilityStatement(ctx, scope, input.ApplicabilityStatementID, input.Applicability, input.Justification) + applicabilityStatement, err := r.probo.StatementsOfApplicability.UpdateApplicabilityStatement(ctx, scope, input.ApplicabilityStatementID, input.Applicability, input.Justification) if err != nil { r.logger.ErrorCtx(ctx, "cannot update applicability statement", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -620,9 +582,7 @@ func (r *mutationResolver) DeleteApplicabilityStatement(ctx context.Context, inp return nil, err } - prb := r.probo - - if err := prb.StatementsOfApplicability.DeleteApplicabilityStatement(ctx, scope, input.ApplicabilityStatementID); err != nil { + if err := r.probo.StatementsOfApplicability.DeleteApplicabilityStatement(ctx, scope, input.ApplicabilityStatementID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete applicability statement", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -639,9 +599,7 @@ func (r *mutationResolver) CreateControlAuditMapping(ctx context.Context, input return nil, err } - prb := r.probo - - control, audit, err := prb.Controls.CreateAuditMapping(ctx, scope, input.ControlID, input.AuditID) + control, audit, err := r.probo.Controls.CreateAuditMapping(ctx, scope, input.ControlID, input.AuditID) if err != nil { r.logger.ErrorCtx(ctx, "cannot create control audit mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -660,9 +618,7 @@ func (r *mutationResolver) DeleteControlAuditMapping(ctx context.Context, input return nil, err } - prb := r.probo - - control, audit, err := prb.Controls.DeleteAuditMapping(ctx, scope, input.ControlID, input.AuditID) + control, audit, err := r.probo.Controls.DeleteAuditMapping(ctx, scope, input.ControlID, input.AuditID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete control audit mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -681,9 +637,7 @@ func (r *mutationResolver) CreateControlObligationMapping(ctx context.Context, i return nil, err } - prb := r.probo - - control, obligation, err := prb.Controls.CreateObligationMapping(ctx, scope, input.ControlID, input.ObligationID) + control, obligation, err := r.probo.Controls.CreateObligationMapping(ctx, scope, input.ControlID, input.ObligationID) if err != nil { r.logger.ErrorCtx(ctx, "cannot create control obligation mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -702,9 +656,7 @@ func (r *mutationResolver) DeleteControlObligationMapping(ctx context.Context, i return nil, err } - prb := r.probo - - control, obligation, err := prb.Controls.DeleteObligationMapping(ctx, scope, input.ControlID, input.ObligationID) + control, obligation, err := r.probo.Controls.DeleteObligationMapping(ctx, scope, input.ControlID, input.ObligationID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete control obligation mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -723,9 +675,7 @@ func (r *mutationResolver) CreateStatementOfApplicability(ctx context.Context, i return nil, err } - prb := r.probo - - statementOfApplicability, err := prb.StatementsOfApplicability.Create( + statementOfApplicability, err := r.probo.StatementsOfApplicability.Create( ctx, scope, probo.CreateStatementOfApplicabilityRequest{ OrganizationID: input.OrganizationID, @@ -758,14 +708,12 @@ func (r *mutationResolver) UpdateStatementOfApplicability(ctx context.Context, i return nil, err } - prb := r.probo - var name *string if input.Name != nil { name = input.Name } - statementOfApplicability, err := prb.StatementsOfApplicability.Update( + statementOfApplicability, err := r.probo.StatementsOfApplicability.Update( ctx, scope, probo.UpdateStatementOfApplicabilityRequest{ StatementOfApplicabilityID: input.ID, @@ -798,9 +746,7 @@ func (r *mutationResolver) DeleteStatementOfApplicability(ctx context.Context, i return nil, err } - prb := r.probo - - if err := prb.StatementsOfApplicability.Delete(ctx, scope, input.StatementOfApplicabilityID); err != nil { + if err := r.probo.StatementsOfApplicability.Delete(ctx, scope, input.StatementOfApplicabilityID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete statement_of_applicability", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -817,9 +763,7 @@ func (r *mutationResolver) PublishStatementOfApplicability(ctx context.Context, return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishStatementOfApplicability(ctx, scope, input.StatementOfApplicabilityID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishStatementOfApplicability(ctx, scope, input.StatementOfApplicabilityID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -851,9 +795,7 @@ func (r *statementOfApplicabilityResolver) Document(ctx context.Context, obj *ty return nil, err } - prb := r.probo - - document, err := prb.Documents.Get(ctx, scope, obj.Document.ID) + document, err := r.probo.Documents.Get(ctx, scope, obj.Document.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -896,8 +838,6 @@ func (r *statementOfApplicabilityResolver) ApplicabilityStatements(ctx context.C return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ApplicabilityStatementOrderField]{ Field: coredata.ApplicabilityStatementOrderFieldCreatedAt, Direction: page.OrderDirectionAsc, @@ -911,7 +851,7 @@ func (r *statementOfApplicabilityResolver) ApplicabilityStatements(ctx context.C cursor := types.NewCursor(first, after, last, before, pageOrderBy) - p, err := prb.StatementsOfApplicability.ListApplicabilityStatements(ctx, scope, obj.ID, cursor) + p, err := r.probo.StatementsOfApplicability.ListApplicabilityStatements(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list applicability statements", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -928,11 +868,9 @@ func (r *statementOfApplicabilityResolver) Permission(ctx context.Context, obj * // TotalCount is the resolver for the totalCount field. func (r *statementOfApplicabilityConnectionResolver) TotalCount(ctx context.Context, obj *types.StatementOfApplicabilityConnection) (int, error) { scope := coredata.NewScopeFromObjectID(obj.ParentID) - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.StatementsOfApplicability.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.StatementsOfApplicability.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count statements_of_applicability", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/data_protection_impact_assessment_resolvers.go b/pkg/server/api/console/v1/data_protection_impact_assessment_resolvers.go index 692d52299..9ff108f4e 100644 --- a/pkg/server/api/console/v1/data_protection_impact_assessment_resolvers.go +++ b/pkg/server/api/console/v1/data_protection_impact_assessment_resolvers.go @@ -27,15 +27,13 @@ func (r *dataProtectionImpactAssessmentResolver) ProcessingActivity(ctx context. return nil, err } - prb := r.probo - - dpia, err := prb.DataProtectionImpactAssessments.Get(ctx, scope, obj.ID) + dpia, err := r.probo.DataProtectionImpactAssessments.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get processing activity dpia", log.Error(err)) return nil, gqlutils.Internal(ctx) } - processingActivity, err := prb.ProcessingActivities.Get(ctx, scope, dpia.ProcessingActivityID) + processingActivity, err := r.probo.ProcessingActivities.Get(ctx, scope, dpia.ProcessingActivityID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get processing activity", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -51,15 +49,13 @@ func (r *dataProtectionImpactAssessmentResolver) Organization(ctx context.Contex return nil, err } - prb := r.probo - - dpia, err := prb.DataProtectionImpactAssessments.Get(ctx, scope, obj.ID) + dpia, err := r.probo.DataProtectionImpactAssessments.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get processing activity dpia", log.Error(err)) return nil, gqlutils.Internal(ctx) } - organization, err := prb.Organizations.Get(ctx, scope, dpia.OrganizationID) + organization, err := r.probo.Organizations.Get(ctx, scope, dpia.OrganizationID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -85,11 +81,9 @@ func (r *dataProtectionImpactAssessmentConnectionResolver) TotalCount(ctx contex return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.DataProtectionImpactAssessments.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.DataProtectionImpactAssessments.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count organization data protection impact assessments", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -110,8 +104,6 @@ func (r *mutationResolver) CreateDataProtectionImpactAssessment(ctx context.Cont return nil, err } - prb := r.probo - req := probo.CreateDataProtectionImpactAssessmentRequest{ ProcessingActivityID: input.ProcessingActivityID, Description: input.Description, @@ -121,7 +113,7 @@ func (r *mutationResolver) CreateDataProtectionImpactAssessment(ctx context.Cont ResidualRisk: input.ResidualRisk, } - dpia, err := prb.DataProtectionImpactAssessments.Create(ctx, scope, &req) + dpia, err := r.probo.DataProtectionImpactAssessments.Create(ctx, scope, &req) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -148,8 +140,6 @@ func (r *mutationResolver) UpdateDataProtectionImpactAssessment(ctx context.Cont return nil, err } - prb := r.probo - req := probo.UpdateDataProtectionImpactAssessmentRequest{ ID: input.ID, Description: gqlutils.UnwrapOmittable(input.Description), @@ -159,7 +149,7 @@ func (r *mutationResolver) UpdateDataProtectionImpactAssessment(ctx context.Cont ResidualRisk: input.ResidualRisk, } - dpia, err := prb.DataProtectionImpactAssessments.Update(ctx, scope, &req) + dpia, err := r.probo.DataProtectionImpactAssessments.Update(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -182,9 +172,7 @@ func (r *mutationResolver) DeleteDataProtectionImpactAssessment(ctx context.Cont return nil, err } - prb := r.probo - - if err := prb.DataProtectionImpactAssessments.Delete(ctx, scope, input.DataProtectionImpactAssessmentID); err != nil { + if err := r.probo.DataProtectionImpactAssessments.Delete(ctx, scope, input.DataProtectionImpactAssessmentID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete data protection impact assessment", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -201,8 +189,6 @@ func (r *mutationResolver) CreateTransferImpactAssessment(ctx context.Context, i return nil, err } - prb := r.probo - req := probo.CreateTransferImpactAssessmentRequest{ ProcessingActivityID: input.ProcessingActivityID, DataSubjects: input.DataSubjects, @@ -212,7 +198,7 @@ func (r *mutationResolver) CreateTransferImpactAssessment(ctx context.Context, i SupplementaryMeasures: input.SupplementaryMeasures, } - tia, err := prb.TransferImpactAssessments.Create(ctx, scope, &req) + tia, err := r.probo.TransferImpactAssessments.Create(ctx, scope, &req) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -239,8 +225,6 @@ func (r *mutationResolver) UpdateTransferImpactAssessment(ctx context.Context, i return nil, err } - prb := r.probo - req := probo.UpdateTransferImpactAssessmentRequest{ ID: input.ID, DataSubjects: gqlutils.UnwrapOmittable(input.DataSubjects), @@ -250,7 +234,7 @@ func (r *mutationResolver) UpdateTransferImpactAssessment(ctx context.Context, i SupplementaryMeasures: gqlutils.UnwrapOmittable(input.SupplementaryMeasures), } - tia, err := prb.TransferImpactAssessments.Update(ctx, scope, &req) + tia, err := r.probo.TransferImpactAssessments.Update(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -273,9 +257,7 @@ func (r *mutationResolver) DeleteTransferImpactAssessment(ctx context.Context, i return nil, err } - prb := r.probo - - if err := prb.TransferImpactAssessments.Delete(ctx, scope, input.TransferImpactAssessmentID); err != nil { + if err := r.probo.TransferImpactAssessments.Delete(ctx, scope, input.TransferImpactAssessmentID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete transfer impact assessment", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -292,9 +274,7 @@ func (r *mutationResolver) PublishDataProtectionImpactAssessmentList(ctx context return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishDataProtectionImpactAssessmentList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishDataProtectionImpactAssessmentList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -322,9 +302,7 @@ func (r *mutationResolver) PublishTransferImpactAssessmentList(ctx context.Conte return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishTransferImpactAssessmentList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishTransferImpactAssessmentList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -352,9 +330,7 @@ func (r *transferImpactAssessmentResolver) ProcessingActivity(ctx context.Contex return nil, err } - prb := r.probo - - processingActivity, err := prb.ProcessingActivities.Get(ctx, scope, obj.ProcessingActivity.ID) + processingActivity, err := r.probo.ProcessingActivities.Get(ctx, scope, obj.ProcessingActivity.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get processing activity", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -397,11 +373,9 @@ func (r *transferImpactAssessmentConnectionResolver) TotalCount(ctx context.Cont return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.TransferImpactAssessments.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.TransferImpactAssessments.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count organization transfer impact assessments", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/document_resolvers.go b/pkg/server/api/console/v1/document_resolvers.go index 10b80ddef..63ed5b214 100644 --- a/pkg/server/api/console/v1/document_resolvers.go +++ b/pkg/server/api/console/v1/document_resolvers.go @@ -56,8 +56,6 @@ func (r *documentResolver) Versions(ctx context.Context, obj *types.Document, fi return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentVersionOrderField]{ Field: coredata.DocumentVersionOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -76,7 +74,7 @@ func (r *documentResolver) Versions(ctx context.Context, obj *types.Document, fi versionFilter = versionFilter.WithStatuses(filter.Statuses...) } - page, err := prb.Documents.ListVersions(ctx, scope, obj.ID, cursor, versionFilter) + page, err := r.probo.Documents.ListVersions(ctx, scope, obj.ID, cursor, versionFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list document versions", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -92,8 +90,6 @@ func (r *documentResolver) Controls(ctx context.Context, obj *types.Document, fi return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ Field: coredata.ControlOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -112,7 +108,7 @@ func (r *documentResolver) Controls(ctx context.Context, obj *types.Document, fi controlFilter = coredata.NewControlFilter(filter.Query) } - page, err := prb.Controls.ListForDocumentID(ctx, scope, obj.ID, cursor, controlFilter) + page, err := r.probo.Controls.ListForDocumentID(ctx, scope, obj.ID, cursor, controlFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list document controls", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -128,9 +124,7 @@ func (r *documentResolver) DefaultApprovers(ctx context.Context, obj *types.Docu return nil, err } - prb := r.probo - - profiles, err := prb.Documents.GetDefaultApprovers(ctx, scope, obj.ID) + profiles, err := r.probo.Documents.GetDefaultApprovers(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get default approvers", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -156,11 +150,9 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types. return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *controlResolver: - count, err := prb.Documents.CountForControlID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Documents.CountForControlID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -168,7 +160,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types. return count, nil case *organizationResolver: - count, err := prb.Documents.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Documents.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count documents", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -176,7 +168,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types. return count, nil case *riskResolver: - count, err := prb.Documents.CountForRiskID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Documents.CountForRiskID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -184,7 +176,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types. return count, nil case *measureResolver: - count, err := prb.Documents.CountForMeasureID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Documents.CountForMeasureID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count documents", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -234,8 +226,6 @@ func (r *documentVersionResolver) Approvers(ctx context.Context, obj *types.Docu }, nil } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.MembershipProfileOrderField]{ Field: coredata.MembershipProfileOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -247,7 +237,7 @@ func (r *documentVersionResolver) Approvers(ctx context.Context, obj *types.Docu c := types.NewCursor(first, after, last, before, pageOrderBy) - p, err := prb.Documents.ListVersionApprovers(ctx, scope, obj.ID, c) + p, err := r.probo.Documents.ListVersionApprovers(ctx, scope, obj.ID, c) if err != nil { r.logger.ErrorCtx(ctx, "cannot list document version approvers", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -263,8 +253,6 @@ func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.Doc return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentVersionSignatureOrderField]{ Field: coredata.DocumentVersionSignatureOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -300,7 +288,7 @@ func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.Doc cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Documents.ListSignatures(ctx, scope, obj.ID, cursor, signatureFilter) + page, err := r.probo.Documents.ListSignatures(ctx, scope, obj.ID, cursor, signatureFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list document version signatures", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -316,8 +304,6 @@ func (r *documentVersionResolver) ApprovalQuorums(ctx context.Context, obj *type return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentVersionApprovalQuorumOrderField]{ Field: coredata.DocumentVersionApprovalQuorumOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -331,7 +317,7 @@ func (r *documentVersionResolver) ApprovalQuorums(ctx context.Context, obj *type cursor := types.NewCursor(first, after, last, before, pageOrderBy) - p, err := prb.DocumentApprovals.ListQuorums(ctx, scope, obj.ID, cursor) + p, err := r.probo.DocumentApprovals.ListQuorums(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list approval quorums", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -348,9 +334,7 @@ func (r *documentVersionResolver) Signed(ctx context.Context, obj *types.Documen } identity := authn.IdentityFromContext(ctx) - prb := r.probo - - signed, err := prb.Documents.IsVersionSignedByUserEmail(ctx, scope, obj.ID, identity.EmailAddress) + signed, err := r.probo.Documents.IsVersionSignedByUserEmail(ctx, scope, obj.ID, identity.EmailAddress) if err != nil { r.logger.ErrorCtx(ctx, "cannot check if document version is signed", log.Error(err)) return false, gqlutils.Internal(ctx) @@ -371,9 +355,7 @@ func (r *documentVersionApprovalDecisionResolver) Quorum(ctx context.Context, ob return nil, err } - prb := r.probo - - quorum, err := prb.DocumentApprovals.GetQuorum(ctx, scope, obj.Quorum.ID) + quorum, err := r.probo.DocumentApprovals.GetQuorum(ctx, scope, obj.Quorum.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -394,9 +376,7 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co return nil, err } - prb := r.probo - - quorum, err := prb.DocumentApprovals.GetQuorum(ctx, scope, obj.Quorum.ID) + quorum, err := r.probo.DocumentApprovals.GetQuorum(ctx, scope, obj.Quorum.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -407,7 +387,7 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co return nil, gqlutils.Internal(ctx) } - documentVersion, err := prb.Documents.GetVersion(ctx, scope, quorum.VersionID) + documentVersion, err := r.probo.Documents.GetVersion(ctx, scope, quorum.VersionID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -475,14 +455,12 @@ func (r *documentVersionApprovalDecisionConnectionResolver) TotalCount(ctx conte return 0, err } - prb := r.probo - filter := coredata.NewDocumentVersionApprovalDecisionFilter(nil) if obj.Filters != nil { filter = obj.Filters } - count, err := prb.DocumentApprovals.CountDecisions(ctx, scope, obj.ParentID, filter) + count, err := r.probo.DocumentApprovals.CountDecisions(ctx, scope, obj.ParentID, filter) if err != nil { r.logger.ErrorCtx(ctx, "cannot count approval decisions", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -498,9 +476,7 @@ func (r *documentVersionApprovalQuorumResolver) DocumentVersion(ctx context.Cont return nil, err } - prb := r.probo - - documentVersion, err := prb.Documents.GetVersion(ctx, scope, obj.DocumentVersion.ID) + documentVersion, err := r.probo.Documents.GetVersion(ctx, scope, obj.DocumentVersion.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -521,8 +497,6 @@ func (r *documentVersionApprovalQuorumResolver) Decisions(ctx context.Context, o return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentVersionApprovalDecisionOrderField]{ Field: coredata.DocumentVersionApprovalDecisionOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -543,7 +517,7 @@ func (r *documentVersionApprovalQuorumResolver) Decisions(ctx context.Context, o cursor := types.NewCursor(first, after, last, before, pageOrderBy) - p, err := prb.DocumentApprovals.ListDecisions(ctx, scope, obj.ID, cursor, approvalFilter) + p, err := r.probo.DocumentApprovals.ListDecisions(ctx, scope, obj.ID, cursor, approvalFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list approval decisions", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -564,9 +538,7 @@ func (r *documentVersionApprovalQuorumConnectionResolver) TotalCount(ctx context return 0, err } - prb := r.probo - - count, err := prb.DocumentApprovals.CountQuorums(ctx, scope, obj.ParentID) + count, err := r.probo.DocumentApprovals.CountQuorums(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count approval quorums", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -582,8 +554,6 @@ func (r *documentVersionConnectionResolver) TotalCount(ctx context.Context, obj return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *documentResolver: filter := &coredata.DocumentVersionFilter{} @@ -591,7 +561,7 @@ func (r *documentVersionConnectionResolver) TotalCount(ctx context.Context, obj filter = obj.Filters } - count, err := prb.Documents.CountVersionsForDocumentID(ctx, scope, obj.ParentID, filter) + count, err := r.probo.Documents.CountVersionsForDocumentID(ctx, scope, obj.ParentID, filter) if err != nil { r.logger.ErrorCtx(ctx, "cannot count document versions", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -612,9 +582,7 @@ func (r *documentVersionSignatureResolver) DocumentVersion(ctx context.Context, return nil, err } - prb := r.probo - - documentVersion, err := prb.Documents.GetVersion(ctx, scope, obj.DocumentVersion.ID) + documentVersion, err := r.probo.Documents.GetVersion(ctx, scope, obj.DocumentVersion.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -662,8 +630,6 @@ func (r *documentVersionSignatureConnectionResolver) TotalCount(ctx context.Cont return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *documentVersionResolver: filter := &coredata.DocumentVersionSignatureFilter{} @@ -671,7 +637,7 @@ func (r *documentVersionSignatureConnectionResolver) TotalCount(ctx context.Cont filter = obj.Filters } - count, err := prb.Documents.CountSignaturesForVersionID(ctx, scope, obj.ParentID, filter) + count, err := r.probo.Documents.CountSignaturesForVersionID(ctx, scope, obj.ParentID, filter) if err != nil { r.logger.ErrorCtx(ctx, "cannot count signatures", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -693,9 +659,7 @@ func (r *employeeDocumentResolver) Signed(ctx context.Context, obj *types.Employ } identity := authn.IdentityFromContext(ctx) - prb := r.probo - - signed, err := prb.Documents.IsSigned(ctx, scope, obj.ID, identity.EmailAddress) + signed, err := r.probo.Documents.IsSigned(ctx, scope, obj.ID, identity.EmailAddress) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -718,9 +682,7 @@ func (r *employeeDocumentResolver) ApprovalState(ctx context.Context, obj *types identity := authn.IdentityFromContext(ctx) scope := coredata.NewScopeFromObjectID(obj.ID) - prb := r.probo - - state, err := prb.Documents.GetViewerApprovalState(ctx, scope, obj.ID, identity.ID) + state, err := r.probo.Documents.GetViewerApprovalState(ctx, scope, obj.ID, identity.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -741,8 +703,6 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentVersionOrderField]{ Field: coredata.DocumentVersionOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -773,7 +733,7 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl versionFilter := coredata.NewDocumentVersionFilter(). WithEmployeeIdentityID(&identity.ID, filterMode) - versionsPage, err := prb.Documents.ListVersions(ctx, scope, obj.ID, cursor, versionFilter) + versionsPage, err := r.probo.Documents.ListVersions(ctx, scope, obj.ID, cursor, versionFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list employee document versions", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -809,9 +769,7 @@ func (r *employeeDocumentVersionResolver) Signed(ctx context.Context, obj *types } identity := authn.IdentityFromContext(ctx) - prb := r.probo - - signed, err := prb.Documents.IsVersionSignedByUserEmail(ctx, scope, obj.ID, identity.EmailAddress) + signed, err := r.probo.Documents.IsVersionSignedByUserEmail(ctx, scope, obj.ID, identity.EmailAddress) if err != nil { r.logger.ErrorCtx(ctx, "cannot check if version is signed", log.Error(err)) return false, gqlutils.Internal(ctx) @@ -828,9 +786,7 @@ func (r *employeeDocumentVersionResolver) ApprovalDecision(ctx context.Context, identity := authn.IdentityFromContext(ctx) scope := coredata.NewScopeFromObjectID(obj.ID) - prb := r.probo - - decision, err := prb.DocumentApprovals.GetViewerDecision(ctx, scope, obj.ID, identity.ID) + decision, err := r.probo.DocumentApprovals.GetViewerDecision(ctx, scope, obj.ID, identity.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -851,14 +807,12 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat return nil, err } - prb := r.probo - var content string if input.Content != nil { content = *input.Content } - document, documentVersion, err := prb.Documents.Create( + document, documentVersion, err := r.probo.Documents.Create( ctx, scope, probo.CreateDocumentRequest{ OrganizationID: input.OrganizationID, @@ -897,14 +851,12 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat return nil, err } - prb := r.probo - var defaultApproverIDs *[]gid.GID if input.DefaultApproverIds != nil { defaultApproverIDs = &input.DefaultApproverIds } - document, documentVersion, draftCreated, err := prb.Documents.Update( + document, documentVersion, draftCreated, err := r.probo.Documents.Update( ctx, scope, probo.UpdateDocumentRequest{ DocumentID: input.ID, @@ -963,9 +915,7 @@ func (r *mutationResolver) DeleteDocumentDraft(ctx context.Context, input types. return nil, err } - prb := r.probo - - document, err := prb.Documents.DeleteDraft(ctx, scope, input.DocumentID) + document, err := r.probo.Documents.DeleteDraft(ctx, scope, input.DocumentID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -996,9 +946,7 @@ func (r *mutationResolver) ArchiveDocument(ctx context.Context, input types.Arch return nil, err } - prb := r.probo - - document, err := prb.Documents.Archive(ctx, scope, input.DocumentID) + document, err := r.probo.Documents.Archive(ctx, scope, input.DocumentID) if err != nil { if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok { return nil, gqlutils.Conflict(ctx, errArchived) @@ -1021,9 +969,7 @@ func (r *mutationResolver) UnarchiveDocument(ctx context.Context, input types.Un return nil, err } - prb := r.probo - - document, err := prb.Documents.Unarchive(ctx, scope, input.DocumentID) + document, err := r.probo.Documents.Unarchive(ctx, scope, input.DocumentID) if err != nil { if errNotArchived, ok := errors.AsType[*probo.ErrDocumentNotArchived](err); ok { return nil, gqlutils.Conflict(ctx, errNotArchived) @@ -1046,9 +992,7 @@ func (r *mutationResolver) DeleteDocument(ctx context.Context, input types.Delet return nil, err } - prb := r.probo - - if err := prb.Documents.SoftDelete(ctx, scope, input.DocumentID); err != nil { + if err := r.probo.Documents.SoftDelete(ctx, scope, input.DocumentID); err != nil { r.logger.ErrorCtx(ctx, "cannot soft delete document", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -1070,9 +1014,7 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ return nil, err } - prb := r.probo - - result, err := prb.Documents.PublishVersion(ctx, scope, probo.PublishDocumentRequest{ + result, err := r.probo.Documents.PublishVersion(ctx, scope, probo.PublishDocumentRequest{ DocumentID: input.DocumentID, Minor: input.Minor, ApproverIDs: input.ApproverIds, @@ -1135,9 +1077,7 @@ func (r *mutationResolver) BulkPublishDocuments(ctx context.Context, input types } scope := coredata.NewScopeFromObjectID(input.DocumentIds[0]) - prb := r.probo - - versions, documents, err := prb.DocumentApprovals.BulkPublishVersions(ctx, scope, probo.BulkPublishVersionsRequest{ + versions, documents, err := r.probo.DocumentApprovals.BulkPublishVersions(ctx, scope, probo.BulkPublishVersionsRequest{ DocumentIDs: input.DocumentIds, Minor: input.Minor, Changelog: input.Changelog, @@ -1183,9 +1123,7 @@ func (r *mutationResolver) VoidDocumentVersionApproval(ctx context.Context, inpu return nil, err } - prb := r.probo - - quorum, documentVersion, err := prb.DocumentApprovals.VoidApproval(ctx, scope, input.DocumentVersionID) + quorum, documentVersion, err := r.probo.DocumentApprovals.VoidApproval(ctx, scope, input.DocumentVersionID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -1225,9 +1163,7 @@ func (r *mutationResolver) BulkDeleteDocuments(ctx context.Context, input types. } scope := coredata.NewScopeFromObjectID(input.DocumentIds[0]) - prb := r.probo - - if err := prb.Documents.BulkSoftDelete(ctx, scope, input.DocumentIds); err != nil { + if err := r.probo.Documents.BulkSoftDelete(ctx, scope, input.DocumentIds); err != nil { r.logger.ErrorCtx(ctx, "cannot bulk delete documents", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -1252,9 +1188,7 @@ func (r *mutationResolver) BulkArchiveDocuments(ctx context.Context, input types } scope := coredata.NewScopeFromObjectID(input.DocumentIds[0]) - prb := r.probo - - if err := prb.Documents.BulkArchive(ctx, scope, input.DocumentIds); err != nil { + if err := r.probo.Documents.BulkArchive(ctx, scope, input.DocumentIds); err != nil { r.logger.ErrorCtx(ctx, "cannot bulk archive documents", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -1279,9 +1213,7 @@ func (r *mutationResolver) BulkUnarchiveDocuments(ctx context.Context, input typ } scope := coredata.NewScopeFromObjectID(input.DocumentIds[0]) - prb := r.probo - - if err := prb.Documents.BulkUnarchive(ctx, scope, input.DocumentIds); err != nil { + if err := r.probo.Documents.BulkUnarchive(ctx, scope, input.DocumentIds); err != nil { r.logger.ErrorCtx(ctx, "cannot bulk unarchive documents", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -1306,8 +1238,6 @@ func (r *mutationResolver) BulkExportDocuments(ctx context.Context, input types. } scope := coredata.NewScopeFromObjectID(input.DocumentIds[0]) - prb := r.probo - identity := authn.IdentityFromContext(ctx) options := probo.ExportPDFOptions{ @@ -1316,7 +1246,7 @@ func (r *mutationResolver) BulkExportDocuments(ctx context.Context, input types. WatermarkEmail: input.WatermarkEmail, } - documentExport, exportErr := prb.Documents.RequestExport(ctx, scope, input.DocumentIds, identity.EmailAddress, identity.FullName, options) + documentExport, exportErr := r.probo.Documents.RequestExport(ctx, scope, input.DocumentIds, identity.EmailAddress, identity.FullName, options) if exportErr != nil { r.logger.ErrorCtx(ctx, "cannot request document export", log.Error(exportErr)) return nil, gqlutils.Internal(ctx) @@ -1334,9 +1264,7 @@ func (r *mutationResolver) GenerateDocumentChangelog(ctx context.Context, input return nil, err } - prb := r.probo - - changelog, err := prb.Documents.GenerateChangelog(ctx, scope, input.DocumentID) + changelog, err := r.probo.Documents.GenerateChangelog(ctx, scope, input.DocumentID) if err != nil { if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok { return nil, gqlutils.Conflict(ctx, errArchived) @@ -1359,9 +1287,7 @@ func (r *mutationResolver) RequestSignature(ctx context.Context, input types.Req return nil, err } - prb := r.probo - - documentVersionSignature, err := prb.Documents.RequestSignature( + documentVersionSignature, err := r.probo.Documents.RequestSignature( ctx, scope, probo.RequestSignatureRequest{ DocumentVersionID: input.DocumentVersionID, @@ -1410,9 +1336,7 @@ func (r *mutationResolver) BulkRequestSignatures(ctx context.Context, input type } scope := coredata.NewScopeFromObjectID(input.DocumentIds[0]) - prb := r.probo - - documentVersionSignatures, err := prb.Documents.BulkRequestSignatures( + documentVersionSignatures, err := r.probo.Documents.BulkRequestSignatures( ctx, scope, probo.BulkRequestSignaturesRequest{ DocumentIDs: input.DocumentIds, @@ -1449,9 +1373,7 @@ func (r *mutationResolver) SendSigningNotifications(ctx context.Context, input t return nil, err } - prb := r.probo - - if err := prb.Documents.SendSigningNotifications(ctx, scope, input.OrganizationID); err != nil { + if err := r.probo.Documents.SendSigningNotifications(ctx, scope, input.OrganizationID); err != nil { r.logger.ErrorCtx(ctx, "cannot send signing notifications", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -1468,9 +1390,7 @@ func (r *mutationResolver) CancelSignatureRequest(ctx context.Context, input typ return nil, err } - prb := r.probo - - if err := prb.Documents.CancelSignatureRequest(ctx, scope, input.DocumentVersionSignatureID); err != nil { + if err := r.probo.Documents.CancelSignatureRequest(ctx, scope, input.DocumentVersionSignatureID); err != nil { if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok { return nil, gqlutils.Conflict(ctx, errArchived) } @@ -1493,9 +1413,7 @@ func (r *mutationResolver) SignDocument(ctx context.Context, input types.SignDoc } identity := authn.IdentityFromContext(ctx) - prb := r.probo - - documentVersionSignature, err := prb.Documents.SignDocumentVersionByIdentity(ctx, scope, input.DocumentVersionID, identity.ID) + documentVersionSignature, err := r.probo.Documents.SignDocumentVersionByIdentity(ctx, scope, input.DocumentVersionID, identity.ID) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -1526,9 +1444,7 @@ func (r *mutationResolver) ApproveDocumentVersion(ctx context.Context, input typ signerIP = httpReq.RemoteAddr } - prb := r.probo - - decision, err := prb.DocumentApprovals.Approve(ctx, scope, probo.ApproveDocumentVersionRequest{ + decision, err := r.probo.DocumentApprovals.Approve(ctx, scope, probo.ApproveDocumentVersionRequest{ DocumentVersionID: input.DocumentVersionID, IdentityID: identity.ID, Comment: input.Comment, @@ -1572,9 +1488,7 @@ func (r *mutationResolver) RejectDocumentVersion(ctx context.Context, input type } identity := authn.IdentityFromContext(ctx) - prb := r.probo - - decision, err := prb.DocumentApprovals.Reject(ctx, scope, probo.RejectDocumentVersionRequest{ + decision, err := r.probo.DocumentApprovals.Reject(ctx, scope, probo.RejectDocumentVersionRequest{ DocumentVersionID: input.DocumentVersionID, IdentityID: identity.ID, Comment: input.Comment, @@ -1613,8 +1527,6 @@ func (r *mutationResolver) ExportDocumentVersionPDF(ctx context.Context, input t return nil, err } - prb := r.probo - watermarkEmail := input.WatermarkEmail if input.WithWatermark && watermarkEmail == nil { identity := authn.IdentityFromContext(ctx) @@ -1627,7 +1539,7 @@ func (r *mutationResolver) ExportDocumentVersionPDF(ctx context.Context, input t WatermarkEmail: watermarkEmail, } - pdf, err := prb.Documents.ExportPDF(ctx, scope, input.DocumentVersionID, options) + pdf, err := r.probo.Documents.ExportPDF(ctx, scope, input.DocumentVersionID, options) if err != nil { r.logger.ErrorCtx(ctx, "cannot export document version PDF", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1645,9 +1557,7 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context, return nil, err } - prb := r.probo - - documentVersion, err := prb.Documents.GetVersion(ctx, scope, input.DocumentVersionID) + documentVersion, err := r.probo.Documents.GetVersion(ctx, scope, input.DocumentVersionID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get document version", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1660,7 +1570,7 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context, coredata.EmployeeFilterModeApproval, ) - _, err = prb.Documents.GetWithFilter(ctx, scope, documentVersion.DocumentID, documentFilter) + _, err = r.probo.Documents.GetWithFilter(ctx, scope, documentVersion.DocumentID, documentFilter) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -1677,7 +1587,7 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context, WatermarkEmail: &identity.EmailAddress, } - pdf, err := prb.Documents.ExportPDF(ctx, scope, input.DocumentVersionID, options) + pdf, err := r.probo.Documents.ExportPDF(ctx, scope, input.DocumentVersionID, options) if err != nil { r.logger.ErrorCtx(ctx, "cannot export employee document PDF", log.Error(err)) return nil, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/evidence_resolvers.go b/pkg/server/api/console/v1/evidence_resolvers.go index 4fee9b2a2..008741261 100644 --- a/pkg/server/api/console/v1/evidence_resolvers.go +++ b/pkg/server/api/console/v1/evidence_resolvers.go @@ -107,11 +107,9 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types. return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *measureResolver: - count, err := prb.Evidences.CountForMeasureID(ctx, scope, obj.ParentID) + count, err := r.probo.Evidences.CountForMeasureID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count measure evidence", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -119,7 +117,7 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types. return count, nil case *taskResolver: - count, err := prb.Evidences.CountForTaskID(ctx, scope, obj.ParentID) + count, err := r.probo.Evidences.CountForTaskID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count task evidence", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -140,9 +138,7 @@ func (r *mutationResolver) DeleteEvidence(ctx context.Context, input types.Delet return nil, err } - prb := r.probo - - if err := prb.Evidences.Delete(ctx, scope, input.EvidenceID); err != nil { + if err := r.probo.Evidences.Delete(ctx, scope, input.EvidenceID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete evidence", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -159,9 +155,7 @@ func (r *mutationResolver) UploadMeasureEvidence(ctx context.Context, input type return nil, err } - prb := r.probo - - evidence, err := prb.Evidences.UploadMeasureEvidence( + evidence, err := r.probo.Evidences.UploadMeasureEvidence( ctx, scope, probo.UploadMeasureEvidenceRequest{ MeasureID: input.MeasureID, diff --git a/pkg/server/api/console/v1/file_resolvers.go b/pkg/server/api/console/v1/file_resolvers.go index 02757be62..4e330ca5b 100644 --- a/pkg/server/api/console/v1/file_resolvers.go +++ b/pkg/server/api/console/v1/file_resolvers.go @@ -23,9 +23,7 @@ func (r *fileResolver) DownloadURL(ctx context.Context, obj *types.File) (string return "", err } - prb := r.probo - - downloadUrl, err := prb.Files.GenerateFileTempURL(ctx, scope, obj.ID, 60*time.Second) + downloadUrl, err := r.probo.Files.GenerateFileTempURL(ctx, scope, obj.ID, 60*time.Second) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate download URL", log.Error(err)) return "", gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/framework_resolvers.go b/pkg/server/api/console/v1/framework_resolvers.go index 251be4e30..1656640ec 100644 --- a/pkg/server/api/console/v1/framework_resolvers.go +++ b/pkg/server/api/console/v1/framework_resolvers.go @@ -53,8 +53,6 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework, return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ Field: coredata.ControlOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -73,7 +71,7 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework, controlFilter = coredata.NewControlFilter(filter.Query) } - page, err := prb.Controls.ListForFrameworkID(ctx, scope, obj.ID, cursor, controlFilter) + page, err := r.probo.Controls.ListForFrameworkID(ctx, scope, obj.ID, cursor, controlFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list controls", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -89,9 +87,7 @@ func (r *frameworkResolver) LightLogoURL(ctx context.Context, obj *types.Framewo return nil, err } - prb := r.probo - - return prb.Frameworks.GenerateLightLogoURL(ctx, scope, obj.ID, 1*time.Hour) + return r.probo.Frameworks.GenerateLightLogoURL(ctx, scope, obj.ID, 1*time.Hour) } // DarkLogoURL is the resolver for the darkLogoURL field. @@ -101,9 +97,7 @@ func (r *frameworkResolver) DarkLogoURL(ctx context.Context, obj *types.Framewor return nil, err } - prb := r.probo - - return prb.Frameworks.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour) + return r.probo.Frameworks.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour) } // Permission is the resolver for the permission field. @@ -120,9 +114,7 @@ func (r *frameworkConnectionResolver) TotalCount(ctx context.Context, obj *types switch obj.Resolver.(type) { case *organizationResolver: - prb := r.probo - - count, err := prb.Frameworks.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.Frameworks.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count frameworks", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -143,9 +135,7 @@ func (r *mutationResolver) CreateFramework(ctx context.Context, input types.Crea return nil, err } - prb := r.probo - - framework, err := prb.Frameworks.Create( + framework, err := r.probo.Frameworks.Create( ctx, scope, probo.CreateFrameworkRequest{ OrganizationID: input.OrganizationID, @@ -174,9 +164,7 @@ func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.Upda return nil, err } - prb := r.probo - - framework, err := prb.Frameworks.Update( + framework, err := r.probo.Frameworks.Update( ctx, scope, probo.UpdateFrameworkRequest{ ID: input.ID, @@ -206,15 +194,13 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo return nil, err } - prb := r.probo - req := probo.ImportFrameworkRequest{} if err := json.NewDecoder(input.File.File).Decode(&req.Framework); err != nil { r.logger.ErrorCtx(ctx, "cannot decode framework", log.Error(err)) return nil, gqlutils.Internal(ctx) } - framework, err := prb.Frameworks.Import(ctx, scope, input.OrganizationID, req) + framework, err := r.probo.Frameworks.Import(ctx, scope, input.OrganizationID, req) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -237,9 +223,7 @@ func (r *mutationResolver) DeleteFramework(ctx context.Context, input types.Dele return nil, err } - prb := r.probo - - if err := prb.Frameworks.Delete(ctx, scope, input.FrameworkID); err != nil { + if err := r.probo.Frameworks.Delete(ctx, scope, input.FrameworkID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete framework", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -256,11 +240,9 @@ func (r *mutationResolver) ExportFramework(ctx context.Context, input types.Expo return nil, err } - prb := r.probo - identity := authn.IdentityFromContext(ctx) - exportJob, exportErr := prb.Frameworks.RequestExport( + exportJob, exportErr := r.probo.Frameworks.RequestExport( ctx, scope, input.FrameworkID, identity.EmailAddress, diff --git a/pkg/server/api/console/v1/measure_resolvers.go b/pkg/server/api/console/v1/measure_resolvers.go index ba4f059d1..4535ae24f 100644 --- a/pkg/server/api/console/v1/measure_resolvers.go +++ b/pkg/server/api/console/v1/measure_resolvers.go @@ -27,8 +27,6 @@ func (r *measureResolver) Evidences(ctx context.Context, obj *types.Measure, fir return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.EvidenceOrderField]{ Field: coredata.EvidenceOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -42,7 +40,7 @@ func (r *measureResolver) Evidences(ctx context.Context, obj *types.Measure, fir cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Evidences.ListForMeasureID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Evidences.ListForMeasureID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list measure evidences", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -58,8 +56,6 @@ func (r *measureResolver) Tasks(ctx context.Context, obj *types.Measure, first * return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.TaskOrderField]{ Field: coredata.TaskOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -73,7 +69,7 @@ func (r *measureResolver) Tasks(ctx context.Context, obj *types.Measure, first * cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Tasks.ListForMeasureID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Tasks.ListForMeasureID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list measure tasks", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -89,8 +85,6 @@ func (r *measureResolver) Risks(ctx context.Context, obj *types.Measure, first * return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.RiskOrderField]{ Field: coredata.RiskOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -109,7 +103,7 @@ func (r *measureResolver) Risks(ctx context.Context, obj *types.Measure, first * riskFilter = coredata.NewRiskFilter(filter.Query) } - page, err := prb.Risks.ListForMeasureID(ctx, scope, obj.ID, cursor, riskFilter) + page, err := r.probo.Risks.ListForMeasureID(ctx, scope, obj.ID, cursor, riskFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list measure risks", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -125,8 +119,6 @@ func (r *measureResolver) Controls(ctx context.Context, obj *types.Measure, firs return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ Field: coredata.ControlOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -145,7 +137,7 @@ func (r *measureResolver) Controls(ctx context.Context, obj *types.Measure, firs controlFilter = coredata.NewControlFilter(filter.Query) } - page, err := prb.Controls.ListForMeasureID(ctx, scope, obj.ID, cursor, controlFilter) + page, err := r.probo.Controls.ListForMeasureID(ctx, scope, obj.ID, cursor, controlFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list measure controls", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -161,8 +153,6 @@ func (r *measureResolver) Documents(ctx context.Context, obj *types.Measure, fir return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{ Field: coredata.DocumentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -184,7 +174,7 @@ func (r *measureResolver) Documents(ctx context.Context, obj *types.Measure, fir WithClassifications(filter.Classifications) } - pg, err := prb.Documents.ListForMeasureID(ctx, scope, obj.ID, cursor, documentFilter) + pg, err := r.probo.Documents.ListForMeasureID(ctx, scope, obj.ID, cursor, documentFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list documents", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -205,11 +195,9 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.Measures.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Measures.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -217,7 +205,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M return count, nil case *controlResolver: - count, err := prb.Measures.CountForControlID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Measures.CountForControlID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -225,7 +213,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M return count, nil case *riskResolver: - count, err := prb.Measures.CountForRiskID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Measures.CountForRiskID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -246,9 +234,7 @@ func (r *mutationResolver) CreateMeasure(ctx context.Context, input types.Create return nil, err } - prb := r.probo - - measure, err := prb.Measures.Create( + measure, err := r.probo.Measures.Create( ctx, scope, probo.CreateMeasureRequest{ OrganizationID: input.OrganizationID, @@ -283,9 +269,7 @@ func (r *mutationResolver) UpdateMeasure(ctx context.Context, input types.Update return nil, err } - prb := r.probo - - measure, err := prb.Measures.Update( + measure, err := r.probo.Measures.Update( ctx, scope, probo.UpdateMeasureRequest{ ID: input.ID, @@ -317,15 +301,13 @@ func (r *mutationResolver) ImportMeasure(ctx context.Context, input types.Import return nil, err } - prb := r.probo - var req probo.ImportMeasureRequest if err := json.NewDecoder(input.File.File).Decode(&req.Measures); err != nil { r.logger.ErrorCtx(ctx, "cannot unmarshal measure", log.Error(err)) return nil, gqlutils.Internal(ctx) } - measures, err := prb.Measures.Import(ctx, scope, input.OrganizationID, req) + measures, err := r.probo.Measures.Import(ctx, scope, input.OrganizationID, req) if err != nil { r.logger.ErrorCtx(ctx, "cannot import measure", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -348,9 +330,7 @@ func (r *mutationResolver) DeleteMeasure(ctx context.Context, input types.Delete return nil, err } - prb := r.probo - - if err := prb.Measures.Delete(ctx, scope, input.MeasureID); err != nil { + if err := r.probo.Measures.Delete(ctx, scope, input.MeasureID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete measure", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -367,9 +347,7 @@ func (r *mutationResolver) CreateMeasureDocumentMapping(ctx context.Context, inp return nil, err } - prb := r.probo - - measure, document, err := prb.Measures.CreateDocumentMapping(ctx, scope, input.MeasureID, input.DocumentID) + measure, document, err := r.probo.Measures.CreateDocumentMapping(ctx, scope, input.MeasureID, input.DocumentID) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -393,9 +371,7 @@ func (r *mutationResolver) DeleteMeasureDocumentMapping(ctx context.Context, inp return nil, err } - prb := r.probo - - measure, document, err := prb.Measures.DeleteDocumentMapping(ctx, scope, input.MeasureID, input.DocumentID) + measure, document, err := r.probo.Measures.DeleteDocumentMapping(ctx, scope, input.MeasureID, input.DocumentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete measure document mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/obligation_resolvers.go b/pkg/server/api/console/v1/obligation_resolvers.go index 86789bee1..33de920b0 100644 --- a/pkg/server/api/console/v1/obligation_resolvers.go +++ b/pkg/server/api/console/v1/obligation_resolvers.go @@ -28,8 +28,6 @@ func (r *mutationResolver) CreateObligation(ctx context.Context, input types.Cre return nil, err } - prb := r.probo - req := probo.CreateObligationRequest{ OrganizationID: input.OrganizationID, Area: input.Area, @@ -44,7 +42,7 @@ func (r *mutationResolver) CreateObligation(ctx context.Context, input types.Cre Type: input.Type, } - obligation, err := prb.Obligations.Create(ctx, scope, &req) + obligation, err := r.probo.Obligations.Create(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -67,8 +65,6 @@ func (r *mutationResolver) UpdateObligation(ctx context.Context, input types.Upd return nil, err } - prb := r.probo - req := probo.UpdateObligationRequest{ ID: input.ID, Area: gqlutils.UnwrapOmittable(input.Area), @@ -83,7 +79,7 @@ func (r *mutationResolver) UpdateObligation(ctx context.Context, input types.Upd Type: input.Type, } - obligation, err := prb.Obligations.Update(ctx, scope, &req) + obligation, err := r.probo.Obligations.Update(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -106,9 +102,7 @@ func (r *mutationResolver) DeleteObligation(ctx context.Context, input types.Del return nil, err } - prb := r.probo - - if err := prb.Obligations.Delete(ctx, scope, input.ObligationID); err != nil { + if err := r.probo.Obligations.Delete(ctx, scope, input.ObligationID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete obligation", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -125,9 +119,7 @@ func (r *mutationResolver) PublishObligationList(ctx context.Context, input type return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishObligationList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishObligationList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -204,11 +196,9 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.Obligations.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.Obligations.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count obligations", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -216,7 +206,7 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type return count, nil case *riskResolver: - count, err := prb.Obligations.CountForRiskID(ctx, scope, obj.ParentID) + count, err := r.probo.Obligations.CountForRiskID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count risk obligations", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/organization_resolvers.go b/pkg/server/api/console/v1/organization_resolvers.go index 27a49d272..20a17dfbd 100644 --- a/pkg/server/api/console/v1/organization_resolvers.go +++ b/pkg/server/api/console/v1/organization_resolvers.go @@ -33,8 +33,6 @@ func (r *mutationResolver) UpdateOrganizationContext(ctx context.Context, input return nil, err } - prb := r.probo - req := probo.UpdateOrganizationContextRequest{ OrganizationID: input.OrganizationID, Product: gqlutils.UnwrapOmittable(input.Product), @@ -44,7 +42,7 @@ func (r *mutationResolver) UpdateOrganizationContext(ctx context.Context, input Customers: gqlutils.UnwrapOmittable(input.Customers), } - organizationContext, err := prb.Organizations.UpdateContext(ctx, scope, req) + organizationContext, err := r.probo.Organizations.UpdateContext(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -67,9 +65,7 @@ func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organizat return nil, err } - prb := r.probo - - logoURL, err := prb.Organizations.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour) + logoURL, err := r.probo.Organizations.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate logo url", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -85,9 +81,7 @@ func (r *organizationResolver) HorizontalLogoURL(ctx context.Context, obj *types return nil, err } - prb := r.probo - - horizontalLogoURL, err := prb.Organizations.GenerateHorizontalLogoURL(ctx, scope, obj.ID, 1*time.Hour) + horizontalLogoURL, err := r.probo.Organizations.GenerateHorizontalLogoURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate horizontal logo url", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -103,9 +97,7 @@ func (r *organizationResolver) Context(ctx context.Context, obj *types.Organizat return nil, err } - prb := r.probo - - orgContext, err := prb.Organizations.GetContext(ctx, scope, obj.ID) + orgContext, err := r.probo.Organizations.GetContext(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot load organization context", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -162,9 +154,7 @@ func (r *organizationResolver) MeasureCategories(ctx context.Context, obj *types return nil, err } - prb := r.probo - - categories, err := prb.Measures.ListDistinctCategoriesForOrganizationID(ctx, scope, obj.ID) + categories, err := r.probo.Measures.ListDistinctCategoriesForOrganizationID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot list measure categories", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -236,9 +226,7 @@ func (r *organizationResolver) AssetListDocument(ctx context.Context, obj *types return nil, err } - prb := r.probo - - assetDocumentID, err := prb.GeneratedDocuments.GetAssetListDocumentID(ctx, scope, obj.ID) + assetDocumentID, err := r.probo.GeneratedDocuments.GetAssetListDocumentID(ctx, scope, obj.ID) if err != nil { return nil, fmt.Errorf("cannot get asset list document ID: %w", err) } @@ -247,7 +235,7 @@ func (r *organizationResolver) AssetListDocument(ctx context.Context, obj *types return nil, nil } - doc, err := prb.Documents.Get(ctx, scope, *assetDocumentID) + doc, err := r.probo.Documents.Get(ctx, scope, *assetDocumentID) if err != nil { return nil, fmt.Errorf("cannot get asset list document: %w", err) } @@ -262,8 +250,6 @@ func (r *organizationResolver) Assets(ctx context.Context, obj *types.Organizati return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.AssetOrderField]{ Field: coredata.AssetOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -277,7 +263,7 @@ func (r *organizationResolver) Assets(ctx context.Context, obj *types.Organizati cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Assets.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Assets.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization assets", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -293,9 +279,7 @@ func (r *organizationResolver) DataListDocument(ctx context.Context, obj *types. return nil, err } - prb := r.probo - - dataDocumentID, err := prb.GeneratedDocuments.GetDataListDocumentID(ctx, scope, obj.ID) + dataDocumentID, err := r.probo.GeneratedDocuments.GetDataListDocumentID(ctx, scope, obj.ID) if err != nil { return nil, fmt.Errorf("cannot get data export document ID: %w", err) } @@ -304,7 +288,7 @@ func (r *organizationResolver) DataListDocument(ctx context.Context, obj *types. return nil, nil } - doc, err := prb.Documents.Get(ctx, scope, *dataDocumentID) + doc, err := r.probo.Documents.Get(ctx, scope, *dataDocumentID) if err != nil { return nil, fmt.Errorf("cannot get data export document: %w", err) } @@ -319,8 +303,6 @@ func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DatumOrderField]{ Field: coredata.DatumOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -334,7 +316,7 @@ func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Data.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Data.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization data", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -350,8 +332,6 @@ func (r *organizationResolver) Audits(ctx context.Context, obj *types.Organizati return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.AuditOrderField]{ Field: coredata.AuditOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -365,7 +345,7 @@ func (r *organizationResolver) Audits(ctx context.Context, obj *types.Organizati cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Audits.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Audits.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization audits", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -381,9 +361,7 @@ func (r *organizationResolver) FindingsDocument(ctx context.Context, obj *types. return nil, err } - prb := r.probo - - findingDocumentID, err := prb.GeneratedDocuments.GetFindingsDocumentID(ctx, scope, obj.ID) + findingDocumentID, err := r.probo.GeneratedDocuments.GetFindingsDocumentID(ctx, scope, obj.ID) if err != nil { return nil, fmt.Errorf("cannot get finding list document ID: %w", err) } @@ -392,7 +370,7 @@ func (r *organizationResolver) FindingsDocument(ctx context.Context, obj *types. return nil, nil } - doc, err := prb.Documents.Get(ctx, scope, *findingDocumentID) + doc, err := r.probo.Documents.Get(ctx, scope, *findingDocumentID) if err != nil { return nil, fmt.Errorf("cannot get finding list document: %w", err) } @@ -407,8 +385,6 @@ func (r *organizationResolver) Findings(ctx context.Context, obj *types.Organiza return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.FindingOrderField]{ Field: coredata.FindingOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -438,7 +414,7 @@ func (r *organizationResolver) Findings(ctx context.Context, obj *types.Organiza findingFilter := coredata.NewFindingFilter(kind, status, priority, ownerID) - page, err := prb.Findings.ListForOrganizationID(ctx, scope, obj.ID, cursor, findingFilter) + page, err := r.probo.Findings.ListForOrganizationID(ctx, scope, obj.ID, cursor, findingFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization findings", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -502,8 +478,6 @@ func (r *organizationResolver) SlackConnections(ctx context.Context, obj *types. return nil, err } - prb := r.probo - slackProvider := coredata.ConnectorProviderSlack filter := coredata.NewConnectorProviderFilter(&slackProvider) @@ -514,7 +488,7 @@ func (r *organizationResolver) SlackConnections(ctx context.Context, obj *types. cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Connectors.ListForOrganizationID(ctx, scope, obj.ID, cursor, filter) + page, err := r.probo.Connectors.ListForOrganizationID(ctx, scope, obj.ID, cursor, filter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization slack connections", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -535,9 +509,7 @@ func (r *organizationResolver) Connectors(ctx context.Context, obj *types.Organi return nil, err } - prb := r.probo - - connectors, err := prb.Connectors.ListAllForOrganizationID(ctx, scope, obj.ID) + connectors, err := r.probo.Connectors.ListAllForOrganizationID(ctx, scope, obj.ID) if err != nil { panic(fmt.Errorf("cannot list organization connectors: %w", err)) } @@ -599,8 +571,6 @@ func (r *organizationResolver) Controls(ctx context.Context, obj *types.Organiza return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ Field: coredata.ControlOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -619,7 +589,7 @@ func (r *organizationResolver) Controls(ctx context.Context, obj *types.Organiza controlFilter = coredata.NewControlFilter(filter.Query) } - page, err := prb.Controls.ListForOrganizationID(ctx, scope, obj.ID, cursor, controlFilter) + page, err := r.probo.Controls.ListForOrganizationID(ctx, scope, obj.ID, cursor, controlFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list controls", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -635,8 +605,6 @@ func (r *organizationResolver) StatementsOfApplicability(ctx context.Context, ob return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.StatementOfApplicabilityOrderField]{ Field: coredata.StatementOfApplicabilityOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -650,7 +618,7 @@ func (r *organizationResolver) StatementsOfApplicability(ctx context.Context, ob cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.StatementsOfApplicability.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.StatementsOfApplicability.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization statements_of_applicability", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -666,8 +634,6 @@ func (r *organizationResolver) DataProtectionImpactAssessments(ctx context.Conte return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DataProtectionImpactAssessmentOrderField]{ Field: coredata.DataProtectionImpactAssessmentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -682,7 +648,7 @@ func (r *organizationResolver) DataProtectionImpactAssessments(ctx context.Conte cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.DataProtectionImpactAssessments.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.DataProtectionImpactAssessments.ListForOrganizationID(ctx, scope, 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) @@ -698,9 +664,7 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte return nil, err } - prb := r.probo - - documentID, err := prb.GeneratedDocuments.GetDataProtectionImpactAssessmentsDocumentID(ctx, scope, obj.ID) + documentID, err := r.probo.GeneratedDocuments.GetDataProtectionImpactAssessmentsDocumentID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get DPIA list document ID", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -710,7 +674,7 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte return nil, nil } - document, err := prb.Documents.Get(ctx, scope, *documentID) + document, err := r.probo.Documents.Get(ctx, scope, *documentID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -731,8 +695,6 @@ func (r *organizationResolver) TransferImpactAssessments(ctx context.Context, ob return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.TransferImpactAssessmentOrderField]{ Field: coredata.TransferImpactAssessmentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -747,7 +709,7 @@ func (r *organizationResolver) TransferImpactAssessments(ctx context.Context, ob cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.TransferImpactAssessments.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.TransferImpactAssessments.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization transfer impact assessments", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -763,9 +725,7 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con return nil, err } - prb := r.probo - - documentID, err := prb.GeneratedDocuments.GetTransferImpactAssessmentsDocumentID(ctx, scope, obj.ID) + documentID, err := r.probo.GeneratedDocuments.GetTransferImpactAssessmentsDocumentID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get TIA list document ID", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -775,7 +735,7 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con return nil, nil } - document, err := prb.Documents.Get(ctx, scope, *documentID) + document, err := r.probo.Documents.Get(ctx, scope, *documentID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -796,8 +756,6 @@ func (r *organizationResolver) Documents(ctx context.Context, obj *types.Organiz return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{ Field: coredata.DocumentOrderFieldTitle, Direction: page.OrderDirectionDesc, @@ -820,7 +778,7 @@ func (r *organizationResolver) Documents(ctx context.Context, obj *types.Organiz WithStatus(filter.Status) } - page, err := prb.Documents.ListByOrganizationID(ctx, scope, obj.ID, cursor, documentFilter) + page, err := r.probo.Documents.ListByOrganizationID(ctx, scope, obj.ID, cursor, documentFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization documents", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -841,8 +799,6 @@ func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organi return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.FrameworkOrderField]{ Field: coredata.FrameworkOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -856,7 +812,7 @@ func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organi cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Frameworks.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Frameworks.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization frameworks", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -872,8 +828,6 @@ func (r *organizationResolver) Measures(ctx context.Context, obj *types.Organiza return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.MeasureOrderField]{ Field: coredata.MeasureOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -892,7 +846,7 @@ func (r *organizationResolver) Measures(ctx context.Context, obj *types.Organiza measureFilter = coredata.NewMeasureFilter(filter.Query, filter.State, filter.Category) } - page, err := prb.Measures.ListForOrganizationID(ctx, scope, obj.ID, cursor, measureFilter) + page, err := r.probo.Measures.ListForOrganizationID(ctx, scope, obj.ID, cursor, measureFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization measures", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -908,9 +862,7 @@ func (r *organizationResolver) ObligationsDocument(ctx context.Context, obj *typ return nil, err } - prb := r.probo - - obligationDocumentID, err := prb.GeneratedDocuments.GetObligationsDocumentID(ctx, scope, obj.ID) + obligationDocumentID, err := r.probo.GeneratedDocuments.GetObligationsDocumentID(ctx, scope, obj.ID) if err != nil { return nil, fmt.Errorf("cannot get obligation list document ID: %w", err) } @@ -919,7 +871,7 @@ func (r *organizationResolver) ObligationsDocument(ctx context.Context, obj *typ return nil, nil } - doc, err := prb.Documents.Get(ctx, scope, *obligationDocumentID) + doc, err := r.probo.Documents.Get(ctx, scope, *obligationDocumentID) if err != nil { return nil, fmt.Errorf("cannot get obligation list document: %w", err) } @@ -934,8 +886,6 @@ func (r *organizationResolver) Obligations(ctx context.Context, obj *types.Organ return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ObligationOrderField]{ Field: coredata.ObligationOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -950,7 +900,7 @@ func (r *organizationResolver) Obligations(ctx context.Context, obj *types.Organ cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Obligations.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Obligations.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization obligations", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -966,8 +916,6 @@ func (r *organizationResolver) ProcessingActivities(ctx context.Context, obj *ty return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ProcessingActivityOrderField]{ Field: coredata.ProcessingActivityOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -982,7 +930,7 @@ func (r *organizationResolver) ProcessingActivities(ctx context.Context, obj *ty cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.ProcessingActivities.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.ProcessingActivities.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization processing activities", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -998,9 +946,7 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context, return nil, err } - prb := r.probo - - documentID, err := prb.GeneratedDocuments.GetProcessingActivitiesDocumentID(ctx, scope, obj.ID) + documentID, err := r.probo.GeneratedDocuments.GetProcessingActivitiesDocumentID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get processing activities document ID", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1010,7 +956,7 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context, return nil, nil } - document, err := prb.Documents.Get(ctx, scope, *documentID) + document, err := r.probo.Documents.Get(ctx, scope, *documentID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -1031,8 +977,6 @@ func (r *organizationResolver) RightsRequests(ctx context.Context, obj *types.Or return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.RightsRequestOrderField]{ Field: coredata.RightsRequestOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -1047,7 +991,7 @@ func (r *organizationResolver) RightsRequests(ctx context.Context, obj *types.Or cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.RightsRequests.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.RightsRequests.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization rights requests", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1063,8 +1007,6 @@ func (r *organizationResolver) Risks(ctx context.Context, obj *types.Organizatio return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.RiskOrderField]{ Field: coredata.RiskOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -1083,7 +1025,7 @@ func (r *organizationResolver) Risks(ctx context.Context, obj *types.Organizatio riskFilter = coredata.NewRiskFilter(filter.Query) } - page, err := prb.Risks.ListForOrganizationID(ctx, scope, obj.ID, cursor, riskFilter) + page, err := r.probo.Risks.ListForOrganizationID(ctx, scope, obj.ID, cursor, riskFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization risks", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1099,9 +1041,7 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org return nil, err } - prb := r.probo - - documentID, err := prb.GeneratedDocuments.GetRisksDocumentID(ctx, scope, obj.ID) + documentID, err := r.probo.GeneratedDocuments.GetRisksDocumentID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get risks document ID", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1111,7 +1051,7 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org return nil, nil } - document, err := prb.Documents.Get(ctx, scope, *documentID) + document, err := r.probo.Documents.Get(ctx, scope, *documentID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -1190,8 +1130,6 @@ func (r *organizationResolver) Tasks(ctx context.Context, obj *types.Organizatio return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.TaskOrderField]{ Field: coredata.TaskOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -1205,7 +1143,7 @@ func (r *organizationResolver) Tasks(ctx context.Context, obj *types.Organizatio cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Tasks.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Tasks.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization tasks", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1221,9 +1159,7 @@ func (r *organizationResolver) TrustCenter(ctx context.Context, obj *types.Organ return nil, err } - prb := r.probo - - trustCenter, err := prb.TrustCenters.GetByOrganizationID(ctx, scope, obj.ID) + trustCenter, err := r.probo.TrustCenters.GetByOrganizationID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get trust center", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1231,7 +1167,7 @@ func (r *organizationResolver) TrustCenter(ctx context.Context, obj *types.Organ var file *coredata.File if trustCenter.NonDisclosureAgreementFileID != nil { - file, err = prb.Files.Get(ctx, scope, *trustCenter.NonDisclosureAgreementFileID) + file, err = r.probo.Files.Get(ctx, scope, *trustCenter.NonDisclosureAgreementFileID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get NDA file", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1248,9 +1184,7 @@ func (r *organizationResolver) CustomDomain(ctx context.Context, obj *types.Orga return nil, err } - prb := r.probo - - domain, err := prb.CustomDomains.GetOrganizationCustomDomain(ctx, scope, obj.ID) + domain, err := r.probo.CustomDomains.GetOrganizationCustomDomain(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get custom domain", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1270,8 +1204,6 @@ func (r *organizationResolver) TrustCenterFiles(ctx context.Context, obj *types. return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.TrustCenterFileOrderField]{ Field: coredata.TrustCenterFileOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -1285,7 +1217,7 @@ func (r *organizationResolver) TrustCenterFiles(ctx context.Context, obj *types. cursor := types.NewCursor(first, after, last, before, pageOrderBy) - pageResult, err := prb.TrustCenterFiles.ListForOrganizationID(ctx, scope, obj.ID, cursor, &coredata.TrustCenterFileFilter{}) + pageResult, err := r.probo.TrustCenterFiles.ListForOrganizationID(ctx, scope, obj.ID, cursor, &coredata.TrustCenterFileFilter{}) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization trust center files", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1332,8 +1264,6 @@ func (r *organizationResolver) ThirdParties(ctx context.Context, obj *types.Orga return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{ Field: coredata.ThirdPartyOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -1349,7 +1279,7 @@ func (r *organizationResolver) ThirdParties(ctx context.Context, obj *types.Orga thirdPartyFilter := coredata.NewThirdPartyFilter(nil) - page, err := prb.ThirdParties.ListForOrganizationID(ctx, scope, obj.ID, cursor, thirdPartyFilter) + page, err := r.probo.ThirdParties.ListForOrganizationID(ctx, scope, obj.ID, cursor, thirdPartyFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization thirdParties", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1365,9 +1295,7 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty return nil, err } - prb := r.probo - - documentID, err := prb.GeneratedDocuments.GetThirdPartiesDocumentID(ctx, scope, obj.ID) + documentID, err := r.probo.GeneratedDocuments.GetThirdPartiesDocumentID(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get thirdParties document ID", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1377,7 +1305,7 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty return nil, nil } - document, err := prb.Documents.Get(ctx, scope, *documentID) + document, err := r.probo.Documents.Get(ctx, scope, *documentID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -1398,8 +1326,6 @@ func (r *organizationResolver) WebhookSubscriptions(ctx context.Context, obj *ty return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.WebhookSubscriptionOrderField]{ Field: coredata.WebhookSubscriptionOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -1413,7 +1339,7 @@ func (r *organizationResolver) WebhookSubscriptions(ctx context.Context, obj *ty cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.WebhookSubscriptions.ListForOrganizationID(ctx, scope, obj.ID, cursor) + page, err := r.probo.WebhookSubscriptions.ListForOrganizationID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization webhook subscriptions", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1449,9 +1375,7 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P return count, nil case *documentVersionResolver: scope := coredata.NewScopeFromObjectID(obj.ParentID) - prb := r.probo - - count, err := prb.Documents.CountVersionApprovers(ctx, scope, obj.ParentID) + count, err := r.probo.Documents.CountVersionApprovers(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count document version approvers", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/processing_activity_resolvers.go b/pkg/server/api/console/v1/processing_activity_resolvers.go index a9ac31975..55164201e 100644 --- a/pkg/server/api/console/v1/processing_activity_resolvers.go +++ b/pkg/server/api/console/v1/processing_activity_resolvers.go @@ -28,8 +28,6 @@ func (r *mutationResolver) CreateProcessingActivity(ctx context.Context, input t return nil, err } - prb := r.probo - req := probo.CreateProcessingActivityRequest{ OrganizationID: input.OrganizationID, Name: input.Name, @@ -53,7 +51,7 @@ func (r *mutationResolver) CreateProcessingActivity(ctx context.Context, input t ThirdPartyIDs: input.ThirdPartyIds, } - activity, err := prb.ProcessingActivities.Create(ctx, scope, &req) + activity, err := r.probo.ProcessingActivities.Create(ctx, scope, &req) if err != nil { r.logger.ErrorCtx(ctx, "cannot create processing activity", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -71,8 +69,6 @@ func (r *mutationResolver) UpdateProcessingActivity(ctx context.Context, input t return nil, err } - prb := r.probo - req := probo.UpdateProcessingActivityRequest{ ID: input.ID, Name: input.Name, @@ -96,7 +92,7 @@ func (r *mutationResolver) UpdateProcessingActivity(ctx context.Context, input t ThirdPartyIDs: &input.ThirdPartyIds, } - activity, err := prb.ProcessingActivities.Update(ctx, scope, &req) + activity, err := r.probo.ProcessingActivities.Update(ctx, scope, &req) if err != nil { r.logger.ErrorCtx(ctx, "cannot update processing activity", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -114,9 +110,7 @@ func (r *mutationResolver) DeleteProcessingActivity(ctx context.Context, input t return nil, err } - prb := r.probo - - if err := prb.ProcessingActivities.Delete(ctx, scope, input.ProcessingActivityID); err != nil { + if err := r.probo.ProcessingActivities.Delete(ctx, scope, input.ProcessingActivityID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete processing activity", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -133,9 +127,7 @@ func (r *mutationResolver) PublishProcessingActivityList(ctx context.Context, in return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishProcessingActivityList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishProcessingActivityList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -211,8 +203,6 @@ func (r *processingActivityResolver) ThirdParties(ctx context.Context, obj *type return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{ Field: coredata.ThirdPartyOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -226,7 +216,7 @@ func (r *processingActivityResolver) ThirdParties(ctx context.Context, obj *type cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.ThirdParties.ListForProcessingActivityID(ctx, scope, obj.ID, cursor) + page, err := r.probo.ThirdParties.ListForProcessingActivityID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list processing activity thirdParties", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -242,9 +232,7 @@ func (r *processingActivityResolver) DataProtectionImpactAssessment(ctx context. return nil, err } - prb := r.probo - - dpia, err := prb.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID) + dpia, err := r.probo.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -265,9 +253,7 @@ func (r *processingActivityResolver) TransferImpactAssessment(ctx context.Contex return nil, err } - prb := r.probo - - tia, err := prb.TransferImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID) + tia, err := r.probo.TransferImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, nil @@ -293,11 +279,9 @@ func (r *processingActivityConnectionResolver) TotalCount(ctx context.Context, o return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.ProcessingActivities.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.ProcessingActivities.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count organization processing activities", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/rights_request_resolvers.go b/pkg/server/api/console/v1/rights_request_resolvers.go index 486a64e99..8f1cb26a1 100644 --- a/pkg/server/api/console/v1/rights_request_resolvers.go +++ b/pkg/server/api/console/v1/rights_request_resolvers.go @@ -26,8 +26,6 @@ func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types. return nil, err } - prb := r.probo - req := probo.CreateRightsRequestRequest{ OrganizationID: input.OrganizationID, RequestType: &input.RequestType, @@ -39,7 +37,7 @@ func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types. ActionTaken: input.ActionTaken, } - rightsRequest, err := prb.RightsRequests.Create(ctx, scope, &req) + rightsRequest, err := r.probo.RightsRequests.Create(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -62,8 +60,6 @@ func (r *mutationResolver) UpdateRightsRequest(ctx context.Context, input types. return nil, err } - prb := r.probo - req := probo.UpdateRightsRequestRequest{ ID: input.ID, RequestType: input.RequestType, @@ -75,7 +71,7 @@ func (r *mutationResolver) UpdateRightsRequest(ctx context.Context, input types. ActionTaken: gqlutils.UnwrapOmittable(input.ActionTaken), } - rightsRequest, err := prb.RightsRequests.Update(ctx, scope, &req) + rightsRequest, err := r.probo.RightsRequests.Update(ctx, scope, &req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -98,9 +94,7 @@ func (r *mutationResolver) DeleteRightsRequest(ctx context.Context, input types. return nil, err } - prb := r.probo - - if err := prb.RightsRequests.Delete(ctx, scope, input.RightsRequestID); err != nil { + if err := r.probo.RightsRequests.Delete(ctx, scope, input.RightsRequestID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete rights request", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -117,15 +111,13 @@ func (r *rightsRequestResolver) Organization(ctx context.Context, obj *types.Rig return nil, err } - prb := r.probo - - rightsRequest, err := prb.RightsRequests.Get(ctx, scope, obj.ID) + rightsRequest, err := r.probo.RightsRequests.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get rights request", log.Error(err)) return nil, gqlutils.Internal(ctx) } - organization, err := prb.Organizations.Get(ctx, scope, rightsRequest.OrganizationID) + organization, err := r.probo.Organizations.Get(ctx, scope, rightsRequest.OrganizationID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -151,11 +143,9 @@ func (r *rightsRequestConnectionResolver) TotalCount(ctx context.Context, obj *t return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.RightsRequests.CountByOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.RightsRequests.CountByOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count rights requests", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/risk_resolvers.go b/pkg/server/api/console/v1/risk_resolvers.go index aa750debf..a978db0bd 100644 --- a/pkg/server/api/console/v1/risk_resolvers.go +++ b/pkg/server/api/console/v1/risk_resolvers.go @@ -29,9 +29,7 @@ func (r *mutationResolver) CreateRisk(ctx context.Context, input types.CreateRis return nil, err } - prb := r.probo - - risk, err := prb.Risks.Create( + risk, err := r.probo.Risks.Create( ctx, scope, probo.CreateRiskRequest{ OrganizationID: input.OrganizationID, @@ -73,9 +71,7 @@ func (r *mutationResolver) UpdateRisk(ctx context.Context, input types.UpdateRis return nil, err } - prb := r.probo - - risk, err := prb.Risks.Update( + risk, err := r.probo.Risks.Update( ctx, scope, probo.UpdateRiskRequest{ ID: input.ID, @@ -113,9 +109,7 @@ func (r *mutationResolver) DeleteRisk(ctx context.Context, input types.DeleteRis return nil, err } - prb := r.probo - - if err := prb.Risks.Delete(ctx, scope, input.RiskID); err != nil { + if err := r.probo.Risks.Delete(ctx, scope, input.RiskID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete risk", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -132,9 +126,7 @@ func (r *mutationResolver) CreateRiskMeasureMapping(ctx context.Context, input t return nil, err } - prb := r.probo - - risk, measure, err := prb.Risks.CreateMeasureMapping(ctx, scope, input.RiskID, input.MeasureID) + risk, measure, err := r.probo.Risks.CreateMeasureMapping(ctx, scope, input.RiskID, input.MeasureID) if err != nil { r.logger.ErrorCtx(ctx, "cannot create risk measure mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -153,9 +145,7 @@ func (r *mutationResolver) DeleteRiskMeasureMapping(ctx context.Context, input t return nil, err } - prb := r.probo - - risk, measure, err := prb.Risks.DeleteMeasureMapping(ctx, scope, input.RiskID, input.MeasureID) + risk, measure, err := r.probo.Risks.DeleteMeasureMapping(ctx, scope, input.RiskID, input.MeasureID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete risk measure mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -174,9 +164,7 @@ func (r *mutationResolver) CreateRiskDocumentMapping(ctx context.Context, input return nil, err } - prb := r.probo - - risk, document, err := prb.Risks.CreateDocumentMapping(ctx, scope, input.RiskID, input.DocumentID) + risk, document, err := r.probo.Risks.CreateDocumentMapping(ctx, scope, input.RiskID, input.DocumentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot create risk document mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -195,9 +183,7 @@ func (r *mutationResolver) DeleteRiskDocumentMapping(ctx context.Context, input return nil, err } - prb := r.probo - - risk, document, err := prb.Risks.DeleteDocumentMapping(ctx, scope, input.RiskID, input.DocumentID) + risk, document, err := r.probo.Risks.DeleteDocumentMapping(ctx, scope, input.RiskID, input.DocumentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete risk document mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -216,9 +202,7 @@ func (r *mutationResolver) CreateRiskObligationMapping(ctx context.Context, inpu return nil, err } - prb := r.probo - - risk, obligation, err := prb.Risks.CreateObligationMapping(ctx, scope, input.RiskID, input.ObligationID) + risk, obligation, err := r.probo.Risks.CreateObligationMapping(ctx, scope, input.RiskID, input.ObligationID) if err != nil { r.logger.ErrorCtx(ctx, "cannot create risk obligation mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -237,9 +221,7 @@ func (r *mutationResolver) DeleteRiskObligationMapping(ctx context.Context, inpu return nil, err } - prb := r.probo - - risk, obligation, err := prb.Risks.DeleteObligationMapping(ctx, scope, input.RiskID, input.ObligationID) + risk, obligation, err := r.probo.Risks.DeleteObligationMapping(ctx, scope, input.RiskID, input.ObligationID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete risk obligation mapping", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -258,9 +240,7 @@ func (r *mutationResolver) PublishRiskList(ctx context.Context, input types.Publ return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishRiskList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishRiskList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -336,8 +316,6 @@ func (r *riskResolver) Measures(ctx context.Context, obj *types.Risk, first *int return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.MeasureOrderField]{ Field: coredata.MeasureOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -356,7 +334,7 @@ func (r *riskResolver) Measures(ctx context.Context, obj *types.Risk, first *int measureFilter = coredata.NewMeasureFilter(filter.Query, filter.State, filter.Category) } - page, err := prb.Measures.ListForRiskID(ctx, scope, obj.ID, cursor, measureFilter) + page, err := r.probo.Measures.ListForRiskID(ctx, scope, obj.ID, cursor, measureFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list risk measures", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -372,8 +350,6 @@ func (r *riskResolver) Documents(ctx context.Context, obj *types.Risk, first *in return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{ Field: coredata.DocumentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -395,7 +371,7 @@ func (r *riskResolver) Documents(ctx context.Context, obj *types.Risk, first *in WithClassifications(filter.Classifications) } - page, err := prb.Documents.ListForRiskID(ctx, scope, obj.ID, cursor, documentFilter) + page, err := r.probo.Documents.ListForRiskID(ctx, scope, obj.ID, cursor, documentFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list risk documents", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -411,8 +387,6 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ControlOrderField]{ Field: coredata.ControlOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -431,7 +405,7 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int filters = coredata.NewControlFilter(filter.Query) } - page, err := prb.Controls.ListForRiskID(ctx, scope, obj.ID, cursor, filters) + page, err := r.probo.Controls.ListForRiskID(ctx, scope, obj.ID, cursor, filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot list risk controls", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -447,8 +421,6 @@ func (r *riskResolver) Obligations(ctx context.Context, obj *types.Risk, first * return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ObligationOrderField]{ Field: coredata.ObligationOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -462,7 +434,7 @@ func (r *riskResolver) Obligations(ctx context.Context, obj *types.Risk, first * cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Obligations.ListForRiskID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Obligations.ListForRiskID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list risk obligations", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -509,11 +481,9 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *measureResolver: - count, err := prb.Risks.CountForMeasureID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Risks.CountForMeasureID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -521,7 +491,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk return count, nil case *organizationResolver: - count, err := prb.Risks.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) + count, err := r.probo.Risks.CountForOrganizationID(ctx, scope, obj.ParentID, obj.Filters) if err != nil { r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/task_resolvers.go b/pkg/server/api/console/v1/task_resolvers.go index 44d004b61..dce8a81bd 100644 --- a/pkg/server/api/console/v1/task_resolvers.go +++ b/pkg/server/api/console/v1/task_resolvers.go @@ -29,9 +29,7 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTas return nil, err } - prb := r.probo - - task, err := prb.Tasks.Create( + task, err := r.probo.Tasks.Create( ctx, scope, probo.CreateTaskRequest{ MeasureID: input.MeasureID, @@ -70,9 +68,7 @@ func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTas return nil, err } - prb := r.probo - - task, err := prb.Tasks.Update( + task, err := r.probo.Tasks.Update( ctx, scope, probo.UpdateTaskRequest{ TaskID: input.TaskID, @@ -109,9 +105,7 @@ func (r *mutationResolver) DeleteTask(ctx context.Context, input types.DeleteTas return nil, err } - prb := r.probo - - if err := prb.Tasks.Delete(ctx, scope, input.TaskID); err != nil { + if err := r.probo.Tasks.Delete(ctx, scope, input.TaskID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete task", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -202,8 +196,6 @@ func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *in return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.EvidenceOrderField]{ Field: coredata.EvidenceOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -217,7 +209,7 @@ func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *in cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.Evidences.ListForTaskID(ctx, scope, obj.ID, cursor) + page, err := r.probo.Evidences.ListForTaskID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list task evidences", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -238,11 +230,9 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *measureResolver: - count, err := prb.Tasks.CountForMeasureID(ctx, scope, obj.ParentID) + count, err := r.probo.Tasks.CountForMeasureID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -250,7 +240,7 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task return count, nil case *organizationResolver: - count, err := prb.Tasks.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.Tasks.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/third_party_resolvers.go b/pkg/server/api/console/v1/third_party_resolvers.go index 79c87f482..dd8939da2 100644 --- a/pkg/server/api/console/v1/third_party_resolvers.go +++ b/pkg/server/api/console/v1/third_party_resolvers.go @@ -32,9 +32,7 @@ func (r *mutationResolver) CreateThirdParty(ctx context.Context, input types.Cre return nil, err } - prb := r.probo - - thirdParty, err := prb.ThirdParties.Create( + thirdParty, err := r.probo.ThirdParties.Create( ctx, scope, probo.CreateThirdPartyRequest{ OrganizationID: input.OrganizationID, @@ -85,9 +83,7 @@ func (r *mutationResolver) UpdateThirdParty(ctx context.Context, input types.Upd return nil, err } - prb := r.probo - - thirdParty, err := prb.ThirdParties.Update( + thirdParty, err := r.probo.ThirdParties.Update( ctx, scope, probo.UpdateThirdPartyRequest{ ID: input.ID, @@ -135,9 +131,7 @@ func (r *mutationResolver) DeleteThirdParty(ctx context.Context, input types.Del return nil, err } - prb := r.probo - - if err := prb.ThirdParties.Delete(ctx, scope, input.ThirdPartyID); err != nil { + if err := r.probo.ThirdParties.Delete(ctx, scope, input.ThirdPartyID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete thirdParty", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -154,8 +148,6 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty return nil, err } - prb := r.probo - req := probo.CreateThirdPartyContactRequest{ ThirdPartyID: input.ThirdPartyID, FullName: input.FullName, @@ -164,7 +156,7 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty Role: input.Role, } - thirdPartyContact, err := prb.ThirdPartyContacts.Create(ctx, scope, req) + thirdPartyContact, err := r.probo.ThirdPartyContacts.Create(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -187,8 +179,6 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty return nil, err } - prb := r.probo - req := probo.UpdateThirdPartyContactRequest{ ID: input.ID, FullName: gqlutils.UnwrapOmittable(input.FullName), @@ -197,7 +187,7 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty Role: gqlutils.UnwrapOmittable(input.Role), } - thirdPartyContact, err := prb.ThirdPartyContacts.Update(ctx, scope, req) + thirdPartyContact, err := r.probo.ThirdPartyContacts.Update(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -220,9 +210,7 @@ func (r *mutationResolver) DeleteThirdPartyContact(ctx context.Context, input ty return nil, err } - prb := r.probo - - if err := prb.ThirdPartyContacts.Delete(ctx, scope, input.ThirdPartyContactID); err != nil { + if err := r.probo.ThirdPartyContacts.Delete(ctx, scope, input.ThirdPartyContactID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete thirdParty contact", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -239,15 +227,13 @@ func (r *mutationResolver) CreateThirdPartyService(ctx context.Context, input ty return nil, err } - prb := r.probo - req := probo.CreateThirdPartyServiceRequest{ ThirdPartyID: input.ThirdPartyID, Name: input.Name, Description: input.Description, } - thirdPartyService, err := prb.ThirdPartyServices.Create(ctx, scope, req) + thirdPartyService, err := r.probo.ThirdPartyServices.Create(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -270,15 +256,13 @@ func (r *mutationResolver) UpdateThirdPartyService(ctx context.Context, input ty return nil, err } - prb := r.probo - req := probo.UpdateThirdPartyServiceRequest{ ID: input.ID, Name: input.Name, Description: gqlutils.UnwrapOmittable(input.Description), } - thirdPartyService, err := prb.ThirdPartyServices.Update(ctx, scope, req) + thirdPartyService, err := r.probo.ThirdPartyServices.Update(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -301,9 +285,7 @@ func (r *mutationResolver) DeleteThirdPartyService(ctx context.Context, input ty return nil, err } - prb := r.probo - - if err := prb.ThirdPartyServices.Delete(ctx, scope, input.ThirdPartyServiceID); err != nil { + if err := r.probo.ThirdPartyServices.Delete(ctx, scope, input.ThirdPartyServiceID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete thirdParty service", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -320,9 +302,7 @@ func (r *mutationResolver) UploadThirdPartyComplianceReport(ctx context.Context, return nil, err } - prb := r.probo - - thirdPartyComplianceReport, err := prb.ThirdPartyComplianceReports.Upload( + thirdPartyComplianceReport, err := r.probo.ThirdPartyComplianceReports.Upload( ctx, scope, input.ThirdPartyID, &probo.ThirdPartyComplianceReportCreateRequest{ @@ -354,9 +334,7 @@ func (r *mutationResolver) DeleteThirdPartyComplianceReport(ctx context.Context, return nil, err } - prb := r.probo - - if err := prb.ThirdPartyComplianceReports.Delete(ctx, scope, input.ReportID); err != nil { + if err := r.probo.ThirdPartyComplianceReports.Delete(ctx, scope, input.ReportID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete thirdParty compliance report", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -373,9 +351,7 @@ func (r *mutationResolver) UploadThirdPartyBusinessAssociateAgreement(ctx contex return nil, err } - prb := r.probo - - thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.Upload( + thirdPartyBusinessAssociateAgreement, file, err := r.probo.ThirdPartyBusinessAssociateAgreements.Upload( ctx, scope, input.ThirdPartyID, &probo.ThirdPartyBusinessAssociateAgreementCreateRequest{ @@ -407,9 +383,7 @@ func (r *mutationResolver) UpdateThirdPartyBusinessAssociateAgreement(ctx contex return nil, err } - prb := r.probo - - thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.Update( + thirdPartyBusinessAssociateAgreement, file, err := r.probo.ThirdPartyBusinessAssociateAgreements.Update( ctx, scope, input.ThirdPartyID, &probo.ThirdPartyBusinessAssociateAgreementUpdateRequest{ @@ -439,9 +413,7 @@ func (r *mutationResolver) DeleteThirdPartyBusinessAssociateAgreement(ctx contex return nil, err } - prb := r.probo - - if err := prb.ThirdPartyBusinessAssociateAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil { + if err := r.probo.ThirdPartyBusinessAssociateAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete thirdParty business associate agreement", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -458,9 +430,7 @@ func (r *mutationResolver) UploadThirdPartyDataPrivacyAgreement(ctx context.Cont return nil, err } - prb := r.probo - - thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.Upload( + thirdPartyDataPrivacyAgreement, file, err := r.probo.ThirdPartyDataPrivacyAgreements.Upload( ctx, scope, input.ThirdPartyID, &probo.ThirdPartyDataPrivacyAgreementCreateRequest{ @@ -492,9 +462,7 @@ func (r *mutationResolver) UpdateThirdPartyDataPrivacyAgreement(ctx context.Cont return nil, err } - prb := r.probo - - thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.Update( + thirdPartyDataPrivacyAgreement, file, err := r.probo.ThirdPartyDataPrivacyAgreements.Update( ctx, scope, input.ThirdPartyID, &probo.ThirdPartyDataPrivacyAgreementUpdateRequest{ @@ -524,9 +492,7 @@ func (r *mutationResolver) DeleteThirdPartyDataPrivacyAgreement(ctx context.Cont return nil, err } - prb := r.probo - - if err := prb.ThirdPartyDataPrivacyAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil { + if err := r.probo.ThirdPartyDataPrivacyAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete thirdParty data privacy agreement", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -543,9 +509,7 @@ func (r *mutationResolver) CreateThirdPartyRiskAssessment(ctx context.Context, i return nil, err } - prb := r.probo - - thirdPartyRiskAssessment, err := prb.ThirdParties.CreateRiskAssessment( + thirdPartyRiskAssessment, err := r.probo.ThirdParties.CreateRiskAssessment( ctx, scope, probo.CreateThirdPartyRiskAssessmentRequest{ ThirdPartyID: input.ThirdPartyID, @@ -577,9 +541,7 @@ func (r *mutationResolver) AssessThirdParty(ctx context.Context, input types.Ass return nil, err } - prb := r.probo - - result, err := prb.ThirdParties.Assess( + result, err := r.probo.ThirdParties.Assess( ctx, scope, probo.AssessThirdPartyRequest{ ID: input.ID, @@ -611,9 +573,7 @@ func (r *mutationResolver) PublishThirdPartyList(ctx context.Context, input type return nil, err } - prb := r.probo - - document, documentVersion, err := prb.GeneratedDocuments.PublishThirdPartyList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) + document, documentVersion, err := r.probo.GeneratedDocuments.PublishThirdPartyList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor) if err != nil { if errors.Is(err, coredata.ErrResourceAlreadyExists) { return nil, gqlutils.Conflict(ctx, err) @@ -663,8 +623,6 @@ func (r *thirdPartyResolver) ComplianceReports(ctx context.Context, obj *types.T return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyComplianceReportOrderField]{ Field: coredata.ThirdPartyComplianceReportOrderFieldReportDate, Direction: page.OrderDirectionDesc, @@ -678,7 +636,7 @@ func (r *thirdPartyResolver) ComplianceReports(ctx context.Context, obj *types.T cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.ThirdPartyComplianceReports.ListForThirdPartyID(ctx, scope, obj.ID, cursor) + page, err := r.probo.ThirdPartyComplianceReports.ListForThirdPartyID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list thirdParty compliance reports", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -694,9 +652,7 @@ func (r *thirdPartyResolver) BusinessAssociateAgreement(ctx context.Context, obj return nil, err } - prb := r.probo - - thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.GetByThirdPartyID(ctx, scope, obj.ID) + thirdPartyBusinessAssociateAgreement, file, err := r.probo.ThirdPartyBusinessAssociateAgreements.GetByThirdPartyID(ctx, scope, obj.ID) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return nil, nil @@ -717,9 +673,7 @@ func (r *thirdPartyResolver) DataPrivacyAgreement(ctx context.Context, obj *type return nil, err } - prb := r.probo - - thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.GetByThirdPartyID(ctx, scope, obj.ID) + thirdPartyDataPrivacyAgreement, file, err := r.probo.ThirdPartyDataPrivacyAgreements.GetByThirdPartyID(ctx, scope, obj.ID) if err != nil { if errors.Is(err, pgx.ErrNoRows) { return nil, nil @@ -740,8 +694,6 @@ func (r *thirdPartyResolver) Contacts(ctx context.Context, obj *types.ThirdParty return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyContactOrderField]{ Field: coredata.ThirdPartyContactOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -755,7 +707,7 @@ func (r *thirdPartyResolver) Contacts(ctx context.Context, obj *types.ThirdParty cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.ThirdPartyContacts.List(ctx, scope, obj.ID, cursor) + page, err := r.probo.ThirdPartyContacts.List(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list thirdParty contacts", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -771,8 +723,6 @@ func (r *thirdPartyResolver) Services(ctx context.Context, obj *types.ThirdParty return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyServiceOrderField]{ Field: coredata.ThirdPartyServiceOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -786,7 +736,7 @@ func (r *thirdPartyResolver) Services(ctx context.Context, obj *types.ThirdParty cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.ThirdPartyServices.List(ctx, scope, obj.ID, cursor) + page, err := r.probo.ThirdPartyServices.List(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list thirdParty services", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -802,8 +752,6 @@ func (r *thirdPartyResolver) RiskAssessments(ctx context.Context, obj *types.Thi return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ThirdPartyRiskAssessmentOrderField]{ Field: coredata.ThirdPartyRiskAssessmentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -817,7 +765,7 @@ func (r *thirdPartyResolver) RiskAssessments(ctx context.Context, obj *types.Thi cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.ThirdParties.ListRiskAssessments(ctx, scope, obj.ID, cursor) + page, err := r.probo.ThirdParties.ListRiskAssessments(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list thirdParty risk assessments", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -890,9 +838,7 @@ func (r *thirdPartyBusinessAssociateAgreementResolver) ThirdParty(ctx context.Co return nil, err } - prb := r.probo - - thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID) + thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, obj.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -911,9 +857,7 @@ func (r *thirdPartyBusinessAssociateAgreementResolver) FileURL(ctx context.Conte return "", err } - prb := r.probo - - fileURL, err := prb.ThirdPartyBusinessAssociateAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour) + fileURL, err := r.probo.ThirdPartyBusinessAssociateAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate file URL", log.Error(err)) return "", gqlutils.Internal(ctx) @@ -934,9 +878,7 @@ func (r *thirdPartyComplianceReportResolver) ThirdParty(ctx context.Context, obj return nil, err } - prb := r.probo - - thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID) + thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, obj.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -957,9 +899,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type return nil, err } - prb := r.probo - - evidence, err := prb.ThirdPartyComplianceReports.Get(ctx, scope, obj.ID) + evidence, err := r.probo.ThirdPartyComplianceReports.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot load evidence", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -969,7 +909,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type return nil, nil } - file, err := prb.Files.Get(ctx, scope, *evidence.ReportFileId) + file, err := r.probo.Files.Get(ctx, scope, *evidence.ReportFileId) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -995,11 +935,9 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.ThirdParties.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.ThirdParties.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -1007,7 +945,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type return count, nil case *assetResolver: - count, err := prb.ThirdParties.CountForAssetID(ctx, scope, obj.ParentID) + count, err := r.probo.ThirdParties.CountForAssetID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -1015,7 +953,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type return count, nil case *datumResolver: - count, err := prb.ThirdParties.CountForDatumID(ctx, scope, obj.ParentID) + count, err := r.probo.ThirdParties.CountForDatumID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -1036,16 +974,14 @@ func (r *thirdPartyContactResolver) ThirdParty(ctx context.Context, obj *types.T return nil, err } - prb := r.probo - // Get the thirdParty contact to access the ThirdPartyID - thirdPartyContact, err := prb.ThirdPartyContacts.Get(ctx, scope, obj.ID) + thirdPartyContact, err := r.probo.ThirdPartyContacts.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get thirdParty contact", log.Error(err)) return nil, gqlutils.Internal(ctx) } - thirdParty, err := prb.ThirdParties.Get(ctx, scope, thirdPartyContact.ThirdPartyID) + thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, thirdPartyContact.ThirdPartyID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -1071,9 +1007,7 @@ func (r *thirdPartyDataPrivacyAgreementResolver) ThirdParty(ctx context.Context, return nil, err } - prb := r.probo - - thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID) + thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, obj.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -1094,9 +1028,7 @@ func (r *thirdPartyDataPrivacyAgreementResolver) FileURL(ctx context.Context, ob return "", err } - prb := r.probo - - fileURL, err := prb.ThirdPartyDataPrivacyAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour) + fileURL, err := r.probo.ThirdPartyDataPrivacyAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate file URL", log.Error(err)) return "", gqlutils.Internal(ctx) @@ -1117,9 +1049,7 @@ func (r *thirdPartyRiskAssessmentResolver) ThirdParty(ctx context.Context, obj * return nil, err } - prb := r.probo - - thirdParty, err := prb.ThirdParties.GetByRiskAssessmentID(ctx, scope, obj.ID) + thirdParty, err := r.probo.ThirdParties.GetByRiskAssessmentID(ctx, scope, obj.ID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) diff --git a/pkg/server/api/console/v1/trust_center_resolvers.go b/pkg/server/api/console/v1/trust_center_resolvers.go index 7377419ec..be148db08 100644 --- a/pkg/server/api/console/v1/trust_center_resolvers.go +++ b/pkg/server/api/console/v1/trust_center_resolvers.go @@ -63,9 +63,7 @@ func (r *mutationResolver) UpdateTrustCenter(ctx context.Context, input types.Up return nil, err } - prb := r.probo - - trustCenter, file, err := prb.TrustCenters.Update( + trustCenter, file, err := r.probo.TrustCenters.Update( ctx, scope, &probo.UpdateTrustCenterRequest{ ID: input.TrustCenterID, @@ -95,9 +93,7 @@ func (r *mutationResolver) UploadTrustCenterNda(ctx context.Context, input types return nil, err } - prb := r.probo - - trustCenter, file, err := prb.TrustCenters.UploadNDA( + trustCenter, file, err := r.probo.TrustCenters.UploadNDA( ctx, scope, &probo.UploadTrustCenterNDARequest{ TrustCenterID: input.TrustCenterID, @@ -127,9 +123,7 @@ func (r *mutationResolver) DeleteTrustCenterNda(ctx context.Context, input types return nil, err } - prb := r.probo - - trustCenter, file, err := prb.TrustCenters.DeleteNDA(ctx, scope, input.TrustCenterID) + trustCenter, file, err := r.probo.TrustCenters.DeleteNDA(ctx, scope, input.TrustCenterID) if err != nil { r.logger.ErrorCtx(ctx, "cannot delete trust center NDA", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -147,8 +141,6 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ return nil, err } - prb := r.probo - req := &probo.UpdateTrustCenterBrandRequest{ TrustCenterID: input.TrustCenterID, } @@ -187,7 +179,7 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ } } - trustCenter, file, err := prb.TrustCenters.UpdateTrustCenterBrand(ctx, scope, req) + trustCenter, file, err := r.probo.TrustCenters.UpdateTrustCenterBrand(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -210,8 +202,6 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty return nil, err } - prb := r.probo - var ( documentAccesses []probo.UpdateTrustCenterDocumentAccessRequest reportAccesses []probo.UpdateTrustCenterDocumentAccessRequest @@ -239,7 +229,7 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty }) } - access, err := prb.TrustCenterAccesses.Update( + access, err := r.probo.TrustCenterAccesses.Update( ctx, scope, &probo.UpdateTrustCenterAccessRequest{ ID: input.ID, @@ -270,9 +260,7 @@ func (r *mutationResolver) DeleteTrustCenterAccess(ctx context.Context, input ty return nil, err } - prb := r.probo - - if err := prb.TrustCenterAccesses.Delete(ctx, scope, input.ID); err != nil { + if err := r.probo.TrustCenterAccesses.Delete(ctx, scope, input.ID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete trust center access", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -289,9 +277,7 @@ func (r *mutationResolver) CreateTrustCenterReference(ctx context.Context, input return nil, err } - prb := r.probo - - reference, err := prb.TrustCenterReferences.Create( + reference, err := r.probo.TrustCenterReferences.Create( ctx, scope, &probo.CreateTrustCenterReferenceRequest{ TrustCenterID: input.TrustCenterID, @@ -328,8 +314,6 @@ func (r *mutationResolver) UpdateTrustCenterReference(ctx context.Context, input return nil, err } - prb := r.probo - req := &probo.UpdateTrustCenterReferenceRequest{ ID: input.ID, Name: input.Name, @@ -347,7 +331,7 @@ func (r *mutationResolver) UpdateTrustCenterReference(ctx context.Context, input } } - reference, err := prb.TrustCenterReferences.Update(ctx, scope, req) + reference, err := r.probo.TrustCenterReferences.Update(ctx, scope, req) if err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) @@ -370,9 +354,7 @@ func (r *mutationResolver) DeleteTrustCenterReference(ctx context.Context, input return nil, err } - prb := r.probo - - if err := prb.TrustCenterReferences.Delete(ctx, scope, input.ID); err != nil { + if err := r.probo.TrustCenterReferences.Delete(ctx, scope, input.ID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete trust center reference", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -389,9 +371,7 @@ func (r *mutationResolver) CreateComplianceFramework(ctx context.Context, input return nil, err } - prb := r.probo - - cf, err := prb.ComplianceFrameworks.Create( + cf, err := r.probo.ComplianceFrameworks.Create( ctx, scope, &probo.CreateComplianceFrameworkRequest{ TrustCenterID: input.TrustCenterID, @@ -420,9 +400,7 @@ func (r *mutationResolver) UpdateComplianceFramework(ctx context.Context, input return nil, err } - prb := r.probo - - cf, err := prb.ComplianceFrameworks.Update(ctx, scope, &probo.UpdateComplianceFrameworkRequest{ + cf, err := r.probo.ComplianceFrameworks.Update(ctx, scope, &probo.UpdateComplianceFrameworkRequest{ ID: input.ID, Rank: input.Rank, }) @@ -448,9 +426,7 @@ func (r *mutationResolver) DeleteComplianceFramework(ctx context.Context, input return nil, err } - prb := r.probo - - if err := prb.ComplianceFrameworks.Delete( + if err := r.probo.ComplianceFrameworks.Delete( ctx, scope, &probo.DeleteComplianceFrameworkRequest{ ID: input.ID, @@ -477,9 +453,7 @@ func (r *mutationResolver) CreateComplianceExternalURL(ctx context.Context, inpu return nil, err } - prb := r.probo - - item, err := prb.ComplianceExternalURLs.Create( + item, err := r.probo.ComplianceExternalURLs.Create( ctx, scope, &probo.CreateComplianceExternalURLRequest{ TrustCenterID: input.TrustCenterID, @@ -509,9 +483,7 @@ func (r *mutationResolver) UpdateComplianceExternalURL(ctx context.Context, inpu return nil, err } - prb := r.probo - - item, err := prb.ComplianceExternalURLs.Update(ctx, scope, &probo.UpdateComplianceExternalURLRequest{ + item, err := r.probo.ComplianceExternalURLs.Update(ctx, scope, &probo.UpdateComplianceExternalURLRequest{ ID: input.ID, Name: input.Name, URL: input.URL, @@ -539,9 +511,7 @@ func (r *mutationResolver) DeleteComplianceExternalURL(ctx context.Context, inpu return nil, err } - prb := r.probo - - if err := prb.ComplianceExternalURLs.Delete(ctx, scope, &probo.DeleteComplianceExternalURLRequest{ID: input.ID}); err != nil { + if err := r.probo.ComplianceExternalURLs.Delete(ctx, scope, &probo.DeleteComplianceExternalURLRequest{ID: input.ID}); err != nil { if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok { return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors) } @@ -563,9 +533,7 @@ func (r *mutationResolver) CreateTrustCenterFile(ctx context.Context, input type return nil, err } - prb := r.probo - - file, err := prb.TrustCenterFiles.Create( + file, err := r.probo.TrustCenterFiles.Create( ctx, scope, &probo.CreateTrustCenterFileRequest{ OrganizationID: input.OrganizationID, @@ -602,9 +570,7 @@ func (r *mutationResolver) UpdateTrustCenterFile(ctx context.Context, input type return nil, err } - prb := r.probo - - file, err := prb.TrustCenterFiles.Update( + file, err := r.probo.TrustCenterFiles.Update( ctx, scope, &probo.UpdateTrustCenterFileRequest{ ID: input.ID, @@ -635,9 +601,7 @@ func (r *mutationResolver) GetTrustCenterFile(ctx context.Context, input types.G return nil, err } - prb := r.probo - - file, err := prb.TrustCenterFiles.Get(ctx, scope, input.ID) + file, err := r.probo.TrustCenterFiles.Get(ctx, scope, input.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get trust center file", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -655,9 +619,7 @@ func (r *mutationResolver) DeleteTrustCenterFile(ctx context.Context, input type return nil, err } - prb := r.probo - - if err := prb.TrustCenterFiles.Delete(ctx, scope, input.ID); err != nil { + if err := r.probo.TrustCenterFiles.Delete(ctx, scope, input.ID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete trust center file", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -674,9 +636,7 @@ func (r *mutationResolver) CreateCustomDomain(ctx context.Context, input types.C return nil, err } - prb := r.probo - - domain, err := prb.CustomDomains.CreateCustomDomain( + domain, err := r.probo.CustomDomains.CreateCustomDomain( ctx, scope, probo.CreateCustomDomainRequest{ OrganizationID: input.OrganizationID, @@ -705,11 +665,9 @@ func (r *mutationResolver) DeleteCustomDomain(ctx context.Context, input types.D return nil, err } - prb := r.probo - // TODO Drop this wierd logic // Get the current custom domain ID before deleting - domain, err := prb.CustomDomains.GetOrganizationCustomDomain(ctx, scope, input.OrganizationID) + domain, err := r.probo.CustomDomains.GetOrganizationCustomDomain(ctx, scope, input.OrganizationID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get custom domain", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -721,7 +679,7 @@ func (r *mutationResolver) DeleteCustomDomain(ctx context.Context, input types.D deletedDomainID := domain.ID - if err := prb.CustomDomains.DeleteCustomDomain(ctx, scope, input.OrganizationID); err != nil { + if err := r.probo.CustomDomains.DeleteCustomDomain(ctx, scope, input.OrganizationID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete custom domain", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -738,9 +696,7 @@ func (r *trustCenterResolver) LogoFileURL(ctx context.Context, obj *types.TrustC return nil, err } - prb := r.probo - - logoURL, err := prb.TrustCenters.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour) + logoURL, err := r.probo.TrustCenters.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate logo url", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -756,9 +712,7 @@ func (r *trustCenterResolver) DarkLogoFileURL(ctx context.Context, obj *types.Tr return nil, err } - prb := r.probo - - logoURL, err := prb.TrustCenters.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour) + logoURL, err := r.probo.TrustCenters.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate logo url", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -780,9 +734,7 @@ func (r *trustCenterResolver) NdaFileURL(ctx context.Context, obj *types.TrustCe } scope := coredata.NewScopeFromObjectID(obj.ID) - prb := r.probo - - fileURL, err := prb.TrustCenters.GenerateNDAFileURL(ctx, scope, obj.ID, 15*time.Minute) + fileURL, err := r.probo.TrustCenters.GenerateNDAFileURL(ctx, scope, obj.ID, 15*time.Minute) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate NDA file URL", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -798,15 +750,13 @@ func (r *trustCenterResolver) Organization(ctx context.Context, obj *types.Trust return nil, err } - prb := r.probo - - trustCenter, err := prb.TrustCenters.Get(ctx, scope, obj.ID) + trustCenter, err := r.probo.TrustCenters.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get trust center", log.Error(err)) return nil, gqlutils.Internal(ctx) } - organization, err := prb.Organizations.Get(ctx, scope, trustCenter.OrganizationID) + organization, err := r.probo.Organizations.Get(ctx, scope, trustCenter.OrganizationID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -827,8 +777,6 @@ func (r *trustCenterResolver) Accesses(ctx context.Context, obj *types.TrustCent return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.TrustCenterAccessOrderField]{ Field: coredata.TrustCenterAccessOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -842,7 +790,7 @@ func (r *trustCenterResolver) Accesses(ctx context.Context, obj *types.TrustCent cursor := types.NewCursor(first, after, last, before, pageOrderBy) - result, err := prb.TrustCenterAccesses.ListForTrustCenterID(ctx, scope, obj.ID, cursor) + result, err := r.probo.TrustCenterAccesses.ListForTrustCenterID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list trust center accesses", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -858,8 +806,6 @@ func (r *trustCenterResolver) References(ctx context.Context, obj *types.TrustCe return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.TrustCenterReferenceOrderField]{ Field: coredata.TrustCenterReferenceOrderFieldRank, Direction: page.OrderDirectionAsc, @@ -873,7 +819,7 @@ func (r *trustCenterResolver) References(ctx context.Context, obj *types.TrustCe cursor := types.NewCursor(first, after, last, before, pageOrderBy) - result, err := prb.TrustCenterReferences.ListForTrustCenterID(ctx, scope, obj.ID, cursor) + result, err := r.probo.TrustCenterReferences.ListForTrustCenterID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list trust center references", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -889,8 +835,6 @@ func (r *trustCenterResolver) ComplianceFrameworks(ctx context.Context, obj *typ return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ComplianceFrameworkOrderField]{ Field: coredata.ComplianceFrameworkOrderFieldRank, Direction: page.OrderDirectionAsc, @@ -904,7 +848,7 @@ func (r *trustCenterResolver) ComplianceFrameworks(ctx context.Context, obj *typ cursor := types.NewCursor(first, after, last, before, pageOrderBy) - result, err := prb.ComplianceFrameworks.ListWithHiddenForTrustCenterID(ctx, scope, obj.ID, cursor) + result, err := r.probo.ComplianceFrameworks.ListWithHiddenForTrustCenterID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list compliance frameworks", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -920,8 +864,6 @@ func (r *trustCenterResolver) ExternalUrls(ctx context.Context, obj *types.Trust return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.ComplianceExternalURLOrderField]{ Field: coredata.ComplianceExternalURLOrderFieldRank, Direction: page.OrderDirectionAsc, @@ -935,7 +877,7 @@ func (r *trustCenterResolver) ExternalUrls(ctx context.Context, obj *types.Trust cursor := types.NewCursor(first, after, last, before, pageOrderBy) - result, err := prb.ComplianceExternalURLs.List(ctx, scope, obj.ID, cursor) + result, err := r.probo.ComplianceExternalURLs.List(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list compliance external URLs", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -955,9 +897,7 @@ func (r *trustCenterResolver) MailingList(ctx context.Context, obj *types.TrustC return obj.MailingList, nil } - prb := r.probo - - ml, err := prb.TrustCenters.GetMailingList(ctx, scope, obj.ID) + ml, err := r.probo.TrustCenters.GetMailingList(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get mailing list for trust center", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -982,9 +922,7 @@ func (r *trustCenterAccessResolver) NdaSignature(ctx context.Context, obj *types return nil, err } - prb := r.probo - - access, err := prb.TrustCenterAccesses.Get(ctx, scope, obj.ID) + access, err := r.probo.TrustCenterAccesses.Get(ctx, scope, obj.ID) if err != nil { return nil, fmt.Errorf("cannot load trust center access: %w", err) } @@ -1008,9 +946,7 @@ func (r *trustCenterAccessResolver) PendingRequestCount(ctx context.Context, obj return 0, err } - prb := r.probo - - count, err := prb.TrustCenterAccesses.CountPendingRequestDocumentAccesses(ctx, scope, obj.ID) + count, err := r.probo.TrustCenterAccesses.CountPendingRequestDocumentAccesses(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count pending request document accesses", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -1026,9 +962,7 @@ func (r *trustCenterAccessResolver) ActiveCount(ctx context.Context, obj *types. return 0, err } - prb := r.probo - - count, err := prb.TrustCenterAccesses.CountActiveDocumentAccesses(ctx, scope, obj.ID) + count, err := r.probo.TrustCenterAccesses.CountActiveDocumentAccesses(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count active document accesses", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -1064,8 +998,6 @@ func (r *trustCenterAccessResolver) AvailableDocumentAccesses(ctx context.Contex return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.TrustCenterDocumentAccessOrderField]{ Field: coredata.TrustCenterDocumentAccessOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -1079,7 +1011,7 @@ func (r *trustCenterAccessResolver) AvailableDocumentAccesses(ctx context.Contex cursor := types.NewCursor(first, after, last, before, pageOrderBy) - result, err := prb.TrustCenterAccesses.ListAvailableDocumentAccesses(ctx, scope, obj.ID, cursor) + result, err := r.probo.TrustCenterAccesses.ListAvailableDocumentAccesses(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list trust center document accesses", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1104,9 +1036,7 @@ func (r *trustCenterDocumentAccessResolver) Document(ctx context.Context, obj *t return nil, nil } - prb := r.probo - - document, err := prb.Documents.Get(ctx, scope, *obj.DocumentID) + document, err := r.probo.Documents.Get(ctx, scope, *obj.DocumentID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -1131,9 +1061,7 @@ func (r *trustCenterDocumentAccessResolver) Report(ctx context.Context, obj *typ return nil, nil } - prb := r.probo - - report, err := prb.Reports.Get(ctx, scope, *obj.ReportID) + report, err := r.probo.Reports.Get(ctx, scope, *obj.ReportID) if err != nil { r.logger.ErrorCtx(ctx, "cannot load report", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1153,9 +1081,7 @@ func (r *trustCenterDocumentAccessResolver) TrustCenterFile(ctx context.Context, return nil, nil } - prb := r.probo - - trustCenterFile, err := prb.TrustCenterFiles.Get(ctx, scope, *obj.TrustCenterFileID) + trustCenterFile, err := r.probo.TrustCenterFiles.Get(ctx, scope, *obj.TrustCenterFileID) if err != nil { r.logger.ErrorCtx(ctx, "cannot load trust center file", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -1171,9 +1097,7 @@ func (r *trustCenterDocumentAccessConnectionResolver) TotalCount(ctx context.Con return 0, err } - prb := r.probo - - count, err := prb.TrustCenterAccesses.CountDocumentAccesses(ctx, scope, obj.ParentID) + count, err := r.probo.TrustCenterAccesses.CountDocumentAccesses(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count trust center document accesses", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -1189,9 +1113,7 @@ func (r *trustCenterFileResolver) FileURL(ctx context.Context, obj *types.TrustC return "", err } - prb := r.probo - - fileURL, err := prb.TrustCenterFiles.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour) + fileURL, err := r.probo.TrustCenterFiles.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate file URL", log.Error(err)) return "", gqlutils.Internal(ctx) @@ -1207,15 +1129,13 @@ func (r *trustCenterFileResolver) Organization(ctx context.Context, obj *types.T return nil, err } - prb := r.probo - - trustCenterFile, err := prb.TrustCenterFiles.Get(ctx, scope, obj.ID) + trustCenterFile, err := r.probo.TrustCenterFiles.Get(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get trust center file", log.Error(err)) return nil, gqlutils.Internal(ctx) } - organization, err := prb.Organizations.Get(ctx, scope, trustCenterFile.OrganizationID) + organization, err := r.probo.Organizations.Get(ctx, scope, trustCenterFile.OrganizationID) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -1241,9 +1161,7 @@ func (r *trustCenterFileConnectionResolver) TotalCount(ctx context.Context, obj return 0, err } - prb := r.probo - - count, err := prb.TrustCenterFiles.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.TrustCenterFiles.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count trust center files", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -1259,9 +1177,7 @@ func (r *trustCenterReferenceResolver) LogoURL(ctx context.Context, obj *types.T return "", err } - prb := r.probo - - fileURL, err := prb.TrustCenterReferences.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour) + fileURL, err := r.probo.TrustCenterReferences.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour) if err != nil { r.logger.ErrorCtx(ctx, "cannot generate logo URL", log.Error(err)) return "", gqlutils.Internal(ctx) @@ -1282,9 +1198,7 @@ func (r *trustCenterReferenceConnectionResolver) TotalCount(ctx context.Context, return 0, err } - prb := r.probo - - count, err := prb.TrustCenterReferences.CountForTrustCenterID(ctx, scope, obj.ParentID) + count, err := r.probo.TrustCenterReferences.CountForTrustCenterID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count trust center references", log.Error(err)) return 0, gqlutils.Internal(ctx) diff --git a/pkg/server/api/console/v1/viewer_resolvers.go b/pkg/server/api/console/v1/viewer_resolvers.go index f0361bb70..3149c806f 100644 --- a/pkg/server/api/console/v1/viewer_resolvers.go +++ b/pkg/server/api/console/v1/viewer_resolvers.go @@ -27,8 +27,6 @@ func (r *viewerResolver) SignableDocuments(ctx context.Context, obj *types.Viewe return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{ Field: coredata.DocumentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -46,7 +44,7 @@ func (r *viewerResolver) SignableDocuments(ctx context.Context, obj *types.Viewe documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeSignature) - documentsPage, err := prb.Documents.ListByOrganizationID(ctx, scope, organizationID, cursor, documentFilter) + documentsPage, err := r.probo.Documents.ListByOrganizationID(ctx, scope, organizationID, cursor, documentFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization signable documents", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -76,13 +74,11 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer return nil, err } - prb := r.probo - identity := authn.IdentityFromContext(ctx) documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeSignature) - document, err := prb.Documents.GetWithFilter(ctx, scope, id, documentFilter) + document, err := r.probo.Documents.GetWithFilter(ctx, scope, id, documentFilter) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) @@ -110,8 +106,6 @@ func (r *viewerResolver) ApprovableDocuments(ctx context.Context, obj *types.Vie return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{ Field: coredata.DocumentOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -129,7 +123,7 @@ func (r *viewerResolver) ApprovableDocuments(ctx context.Context, obj *types.Vie documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeApproval) - documentsPage, err := prb.Documents.ListByOrganizationID(ctx, scope, organizationID, cursor, documentFilter) + documentsPage, err := r.probo.Documents.ListByOrganizationID(ctx, scope, organizationID, cursor, documentFilter) if err != nil { r.logger.ErrorCtx(ctx, "cannot list organization approvable documents", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -159,13 +153,11 @@ func (r *viewerResolver) ApprovableDocument(ctx context.Context, obj *types.View return nil, err } - prb := r.probo - identity := authn.IdentityFromContext(ctx) documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeApproval) - document, err := prb.Documents.GetWithFilter(ctx, scope, id, documentFilter) + document, err := r.probo.Documents.GetWithFilter(ctx, scope, id, documentFilter) if err != nil { if errors.Is(err, coredata.ErrResourceNotFound) { return nil, gqlutils.NotFound(ctx, err) diff --git a/pkg/server/api/console/v1/webhook_resolvers.go b/pkg/server/api/console/v1/webhook_resolvers.go index fac2c4f0b..94212dd71 100644 --- a/pkg/server/api/console/v1/webhook_resolvers.go +++ b/pkg/server/api/console/v1/webhook_resolvers.go @@ -29,9 +29,7 @@ func (r *mutationResolver) CreateWebhookSubscription(ctx context.Context, input return nil, err } - prb := r.probo - - wc, err := prb.WebhookSubscriptions.Create( + wc, err := r.probo.WebhookSubscriptions.Create( ctx, scope, probo.CreateWebhookSubscriptionRequest{ OrganizationID: input.OrganizationID, @@ -61,9 +59,7 @@ func (r *mutationResolver) UpdateWebhookSubscription(ctx context.Context, input return nil, err } - prb := r.probo - - wc, err := prb.WebhookSubscriptions.Update( + wc, err := r.probo.WebhookSubscriptions.Update( ctx, scope, probo.UpdateWebhookSubscriptionRequest{ WebhookSubscriptionID: input.ID, @@ -93,9 +89,7 @@ func (r *mutationResolver) DeleteWebhookSubscription(ctx context.Context, input return nil, err } - prb := r.probo - - if err := prb.WebhookSubscriptions.Delete(ctx, scope, input.WebhookSubscriptionID); err != nil { + if err := r.probo.WebhookSubscriptions.Delete(ctx, scope, input.WebhookSubscriptionID); err != nil { r.logger.ErrorCtx(ctx, "cannot delete webhook subscription", log.Error(err)) return nil, gqlutils.Internal(ctx) } @@ -112,9 +106,7 @@ func (r *webhookEventConnectionResolver) TotalCount(ctx context.Context, obj *ty return 0, err } - prb := r.probo - - count, err := prb.WebhookSubscriptions.CountEventsForSubscriptionID(ctx, scope, obj.ParentID) + count, err := r.probo.WebhookSubscriptions.CountEventsForSubscriptionID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count webhook events", log.Error(err)) return 0, gqlutils.Internal(ctx) @@ -152,9 +144,7 @@ func (r *webhookSubscriptionResolver) SigningSecret(ctx context.Context, obj *ty return "", err } - prb := r.probo - - signingSecret, err := prb.WebhookSubscriptions.GetSigningSecret(ctx, scope, obj.ID) + signingSecret, err := r.probo.WebhookSubscriptions.GetSigningSecret(ctx, scope, obj.ID) if err != nil { r.logger.ErrorCtx(ctx, "cannot get signing secret", log.Error(err)) return "", gqlutils.Internal(ctx) @@ -170,8 +160,6 @@ func (r *webhookSubscriptionResolver) Events(ctx context.Context, obj *types.Web return nil, err } - prb := r.probo - pageOrderBy := page.OrderBy[coredata.WebhookEventOrderField]{ Field: coredata.WebhookEventOrderFieldCreatedAt, Direction: page.OrderDirectionDesc, @@ -185,7 +173,7 @@ func (r *webhookSubscriptionResolver) Events(ctx context.Context, obj *types.Web cursor := types.NewCursor(first, after, last, before, pageOrderBy) - page, err := prb.WebhookSubscriptions.ListEventsForSubscriptionID(ctx, scope, obj.ID, cursor) + page, err := r.probo.WebhookSubscriptions.ListEventsForSubscriptionID(ctx, scope, obj.ID, cursor) if err != nil { r.logger.ErrorCtx(ctx, "cannot list webhook events", log.Error(err)) return nil, gqlutils.Internal(ctx) @@ -206,11 +194,9 @@ func (r *webhookSubscriptionConnectionResolver) TotalCount(ctx context.Context, return 0, err } - prb := r.probo - switch obj.Resolver.(type) { case *organizationResolver: - count, err := prb.WebhookSubscriptions.CountForOrganizationID(ctx, scope, obj.ParentID) + count, err := r.probo.WebhookSubscriptions.CountForOrganizationID(ctx, scope, obj.ParentID) if err != nil { r.logger.ErrorCtx(ctx, "cannot count webhook subscriptions", log.Error(err)) return 0, gqlutils.Internal(ctx)