Remove tenant service pattern
Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -17,6 +17,7 @@ package compliancepage
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/trust"
|
||||
)
|
||||
|
||||
@@ -37,7 +38,9 @@ func (h *Handler) HandleLLMsTxt(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
|
||||
if err := h.trustService.RenderCompliancePageMarkdown(r.Context(), w, tc.ID, tc.TenantID); err != nil {
|
||||
scope := coredata.NewScopeFromObjectID(tc.ID)
|
||||
|
||||
if err := h.trustService.RenderCompliancePageMarkdown(r.Context(), w, tc.ID, scope); err != nil {
|
||||
http.Error(w, "internal server error", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
@@ -77,7 +80,9 @@ func (h *Handler) HandleSitemap(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/xml; charset=utf-8")
|
||||
|
||||
if err := h.trustService.RenderSitemap(r.Context(), w, tc.ID, tc.TenantID, *baseURL); err != nil {
|
||||
scope := coredata.NewScopeFromObjectID(tc.ID)
|
||||
|
||||
if err := h.trustService.RenderSitemap(r.Context(), w, tc.ID, scope, *baseURL); err != nil {
|
||||
http.Error(w, "internal server error", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,9 +373,10 @@ func (r *accessSourceResolver) Connector(ctx context.Context, obj *types.AccessS
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
connector, err := prb.Connectors.Get(ctx, *obj.ConnectorID)
|
||||
connector, err := prb.Connectors.Get(ctx, scope, *obj.ConnectorID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -441,9 +442,10 @@ func (r *accessSourceResolver) NeedsConfiguration(ctx context.Context, obj *type
|
||||
return false, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
dbConnector, err := prb.Connectors.Get(ctx, *obj.ConnectorID)
|
||||
dbConnector, err := prb.Connectors.Get(ctx, scope, *obj.ConnectorID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return false, nil
|
||||
@@ -502,9 +504,10 @@ func (r *accessSourceResolver) SelectedOrganization(ctx context.Context, obj *ty
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
dbConnector, err := prb.Connectors.Get(ctx, *obj.ConnectorID)
|
||||
dbConnector, err := prb.Connectors.Get(ctx, scope, *obj.ConnectorID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
|
||||
@@ -51,7 +51,8 @@ func (r *assetResolver) ThirdParties(ctx context.Context, obj *types.Asset, firs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: coredata.ThirdPartyOrderFieldCreatedAt,
|
||||
@@ -66,7 +67,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -81,15 +82,16 @@ func (r *assetResolver) Organization(ctx context.Context, obj *types.Asset) (*ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
asset, err := prb.Assets.Get(ctx, obj.ID)
|
||||
asset, err := prb.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, asset.OrganizationID)
|
||||
org, err := prb.Organizations.Get(ctx, scope, asset.OrganizationID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -114,11 +116,12 @@ func (r *assetConnectionResolver) TotalCount(ctx context.Context, obj *types.Ass
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.Assets.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.Assets.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count assets", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -158,7 +161,8 @@ func (r *datumResolver) ThirdParties(ctx context.Context, obj *types.Datum, firs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: coredata.ThirdPartyOrderFieldCreatedAt,
|
||||
@@ -173,7 +177,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -215,11 +219,12 @@ func (r *datumConnectionResolver) TotalCount(ctx context.Context, obj *types.Dat
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.Data.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.Data.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count data", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -239,10 +244,11 @@ func (r *mutationResolver) CreateAsset(ctx context.Context, input types.CreateAs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
asset, err := prb.Assets.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateAssetRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -274,10 +280,11 @@ func (r *mutationResolver) UpdateAsset(ctx context.Context, input types.UpdateAs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
asset, err := prb.Assets.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateAssetRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -309,9 +316,10 @@ func (r *mutationResolver) DeleteAsset(ctx context.Context, input types.DeleteAs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.AssetID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.AssetID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Assets.Delete(ctx, input.AssetID)
|
||||
err := prb.Assets.Delete(ctx, scope, input.AssetID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete asset", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -328,10 +336,11 @@ func (r *mutationResolver) CreateDatum(ctx context.Context, input types.CreateDa
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
data, err := prb.Data.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateDatumRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -361,10 +370,11 @@ func (r *mutationResolver) UpdateDatum(ctx context.Context, input types.UpdateDa
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
datum, err := prb.Data.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateDatumRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -394,9 +404,10 @@ func (r *mutationResolver) DeleteDatum(ctx context.Context, input types.DeleteDa
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DatumID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DatumID)
|
||||
prb := r.probo
|
||||
|
||||
if err := prb.Data.Delete(ctx, input.DatumID); err != nil {
|
||||
if err := prb.Data.Delete(ctx, scope, input.DatumID); err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete datum", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
@@ -412,9 +423,10 @@ func (r *mutationResolver) PublishDataList(ctx context.Context, input types.Publ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishDataList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -441,9 +453,10 @@ func (r *mutationResolver) PublishAssetList(ctx context.Context, input types.Pub
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishAssetList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
|
||||
@@ -104,9 +104,10 @@ func (r *auditResolver) ReportURL(ctx context.Context, obj *types.Audit) (*strin
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
url, err := prb.Audits.GenerateReportURL(ctx, obj.ID, 15*time.Minute)
|
||||
url, err := prb.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)
|
||||
@@ -121,7 +122,8 @@ func (r *auditResolver) Controls(ctx context.Context, obj *types.Audit, first *i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -141,7 +143,7 @@ func (r *auditResolver) Controls(ctx context.Context, obj *types.Audit, first *i
|
||||
controlFilter = coredata.NewControlFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Controls.ListForAuditID(ctx, obj.ID, cursor, controlFilter)
|
||||
page, err := prb.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)
|
||||
@@ -156,7 +158,8 @@ func (r *auditResolver) Findings(ctx context.Context, obj *types.Audit, first *i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.FindingOrderField]{
|
||||
Field: coredata.FindingOrderFieldCreatedAt,
|
||||
@@ -186,7 +189,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, obj.ID, cursor, findingFilter)
|
||||
p, err := prb.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)
|
||||
@@ -206,11 +209,12 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.Audits.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.Audits.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -218,7 +222,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
|
||||
return count, nil
|
||||
case *findingResolver:
|
||||
count, err := prb.Audits.CountForFindingID(ctx, obj.ParentID)
|
||||
count, err := prb.Audits.CountForFindingID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -226,7 +230,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
|
||||
return count, nil
|
||||
case *controlResolver:
|
||||
count, err := prb.Audits.CountForControlID(ctx, obj.ParentID)
|
||||
count, err := prb.Audits.CountForControlID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -267,7 +271,8 @@ func (r *findingResolver) Audits(ctx context.Context, obj *types.Finding, first
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.AuditOrderField]{
|
||||
Field: coredata.AuditOrderFieldCreatedAt,
|
||||
@@ -282,7 +287,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, obj.ID, cursor)
|
||||
p, err := prb.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)
|
||||
@@ -354,7 +359,8 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
var (
|
||||
kind *coredata.FindingKind
|
||||
@@ -373,7 +379,7 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.Findings.CountForOrganizationID(ctx, obj.ParentID, findingFilter)
|
||||
count, err := prb.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)
|
||||
@@ -381,7 +387,7 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F
|
||||
|
||||
return count, nil
|
||||
case *auditResolver:
|
||||
count, err := prb.Findings.CountForAuditID(ctx, obj.ParentID, findingFilter)
|
||||
count, err := prb.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)
|
||||
@@ -401,7 +407,8 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateAuditRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -413,7 +420,7 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Create(ctx, &req)
|
||||
audit, err := prb.Audits.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -435,7 +442,7 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
},
|
||||
}
|
||||
|
||||
audit, err = prb.Audits.UploadReport(ctx, uploadReq)
|
||||
audit, err = prb.Audits.UploadReport(ctx, scope, uploadReq)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -458,7 +465,8 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateAuditRequest{
|
||||
ID: input.ID,
|
||||
@@ -469,7 +477,7 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Update(ctx, &req)
|
||||
audit, err := prb.Audits.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -491,9 +499,10 @@ func (r *mutationResolver) DeleteAudit(ctx context.Context, input types.DeleteAu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.AuditID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Audits.Delete(ctx, input.AuditID)
|
||||
err := prb.Audits.Delete(ctx, scope, input.AuditID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -510,7 +519,8 @@ func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.Up
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.AuditID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UploadAuditReportRequest{
|
||||
AuditID: input.AuditID,
|
||||
@@ -522,7 +532,7 @@ func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.Up
|
||||
},
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.UploadReport(ctx, req)
|
||||
audit, err := prb.Audits.UploadReport(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -544,9 +554,10 @@ func (r *mutationResolver) DeleteAuditReport(ctx context.Context, input types.De
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.AuditID)
|
||||
prb := r.probo
|
||||
|
||||
audit, err := prb.Audits.DeleteReport(ctx, input.AuditID)
|
||||
audit, err := prb.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)
|
||||
@@ -563,7 +574,8 @@ func (r *mutationResolver) CreateFinding(ctx context.Context, input types.Create
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateFindingRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -581,7 +593,7 @@ func (r *mutationResolver) CreateFinding(ctx context.Context, input types.Create
|
||||
EffectivenessCheck: input.EffectivenessCheck,
|
||||
}
|
||||
|
||||
finding, err := prb.Findings.Create(ctx, &req)
|
||||
finding, err := prb.Findings.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -603,7 +615,8 @@ func (r *mutationResolver) UpdateFinding(ctx context.Context, input types.Update
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateFindingRequest{
|
||||
ID: input.ID,
|
||||
@@ -620,7 +633,7 @@ func (r *mutationResolver) UpdateFinding(ctx context.Context, input types.Update
|
||||
EffectivenessCheck: gqlutils.UnwrapOmittable(input.EffectivenessCheck),
|
||||
}
|
||||
|
||||
finding, err := prb.Findings.Update(ctx, &req)
|
||||
finding, err := prb.Findings.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -642,9 +655,10 @@ func (r *mutationResolver) DeleteFinding(ctx context.Context, input types.Delete
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.FindingID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.FindingID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Findings.Delete(ctx, input.FindingID)
|
||||
err := prb.Findings.Delete(ctx, scope, input.FindingID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete finding", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -661,9 +675,10 @@ func (r *mutationResolver) CreateFindingAuditMapping(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.FindingID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.FindingID)
|
||||
prb := r.probo
|
||||
|
||||
finding, audit, err := prb.Findings.CreateAuditMapping(ctx, input.FindingID, input.AuditID, input.ReferenceID)
|
||||
finding, audit, err := prb.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)
|
||||
@@ -681,9 +696,10 @@ func (r *mutationResolver) DeleteFindingAuditMapping(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.FindingID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.FindingID)
|
||||
prb := r.probo
|
||||
|
||||
finding, audit, err := prb.Findings.DeleteAuditMapping(ctx, input.FindingID, input.AuditID)
|
||||
finding, audit, err := prb.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)
|
||||
@@ -701,9 +717,10 @@ func (r *mutationResolver) PublishFindingList(ctx context.Context, input types.P
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishFindingList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -730,9 +747,10 @@ func (r *reportResolver) DownloadURL(ctx context.Context, obj *types.Report) (*s
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
url, err := prb.Reports.GenerateDownloadURL(ctx, obj.ID, 15*time.Minute)
|
||||
url, err := prb.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)
|
||||
@@ -747,9 +765,10 @@ func (r *reportResolver) Audit(ctx context.Context, obj *types.Report) (*types.A
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
audit, err := prb.Audits.GetByReportID(ctx, obj.ID)
|
||||
audit, err := prb.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)
|
||||
|
||||
@@ -26,14 +26,15 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
var (
|
||||
loadNode func(ctx context.Context, id gid.GID) (types.Node, error)
|
||||
action string
|
||||
prb = r.ProboService(ctx, id.TenantID())
|
||||
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, id)
|
||||
organization, err := prb.Organizations.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -43,7 +44,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, id)
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -53,7 +54,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, id)
|
||||
framework, err := prb.Frameworks.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -63,7 +64,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, id)
|
||||
measure, err := prb.Measures.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -73,7 +74,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, id)
|
||||
task, err := prb.Tasks.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -83,7 +84,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, id)
|
||||
evidence, err := prb.Evidences.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -93,7 +94,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, id)
|
||||
document, err := prb.Documents.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -103,7 +104,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, id)
|
||||
control, err := prb.Controls.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -113,7 +114,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, id)
|
||||
risk, err := prb.Risks.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -195,7 +196,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, id)
|
||||
thirdPartyComplianceReport, err := prb.ThirdPartyComplianceReports.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -205,7 +206,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, id)
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -215,7 +216,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, id)
|
||||
thirdPartyService, err := prb.ThirdPartyServices.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -225,7 +226,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, id)
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -235,7 +236,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, id)
|
||||
documentVersionSignature, err := prb.Documents.GetVersionSignature(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -245,7 +246,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, id)
|
||||
asset, err := prb.Assets.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -255,7 +256,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, id)
|
||||
datum, err := prb.Data.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -265,7 +266,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, id)
|
||||
audit, err := prb.Audits.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -275,7 +276,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, id)
|
||||
finding, err := prb.Findings.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -285,7 +286,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, id)
|
||||
obligation, err := prb.Obligations.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -295,7 +296,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, id)
|
||||
report, err := prb.Reports.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -305,7 +306,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, id)
|
||||
processingActivity, err := prb.ProcessingActivities.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -316,7 +317,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, id)
|
||||
dpia, err := prb.DataProtectionImpactAssessments.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -327,7 +328,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, id)
|
||||
tia, err := prb.TransferImpactAssessments.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -337,14 +338,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, id)
|
||||
trustCenter, err := prb.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, *trustCenter.NonDisclosureAgreementFileID)
|
||||
file, err = prb.Files.Get(ctx, scope, *trustCenter.NonDisclosureAgreementFileID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get NDA file: %w", err)
|
||||
}
|
||||
@@ -355,7 +356,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, id)
|
||||
trustCenterAccess, err := prb.TrustCenterAccesses.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -365,7 +366,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, id)
|
||||
rightsRequest, err := prb.RightsRequests.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -375,7 +376,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, id)
|
||||
statementOfApplicability, err := prb.StatementsOfApplicability.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -385,7 +386,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, id)
|
||||
wc, err := prb.WebhookSubscriptions.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -83,13 +83,14 @@ func handleConnectorInitiate(
|
||||
}
|
||||
|
||||
requestedScopes := r.URL.Query()["scope"]
|
||||
prb := proboSvc.WithTenant(organizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(organizationID)
|
||||
prb := proboSvc
|
||||
|
||||
// Look up any existing connector so we can union its stored scopes
|
||||
// into the new auth request. Cross-org/provider/protocol mismatches
|
||||
// are caught inside Reconnect at callback time; this handler only
|
||||
// needs the scope set.
|
||||
existing, err := loadExistingConnector(r, prb, organizationID, provider)
|
||||
existing, err := loadExistingConnector(r, prb, scope, organizationID, provider)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
httpserver.RenderError(w, http.StatusBadRequest, fmt.Errorf("cannot reconnect: connector not found"))
|
||||
@@ -138,7 +139,8 @@ func handleConnectorInitiate(
|
||||
// from nil (no existing row — fresh install path).
|
||||
func loadExistingConnector(
|
||||
r *http.Request,
|
||||
prb *probo.TenantService,
|
||||
prb *probo.Service,
|
||||
scope coredata.Scoper,
|
||||
organizationID gid.GID,
|
||||
provider string,
|
||||
) (*coredata.Connector, error) {
|
||||
@@ -148,7 +150,7 @@ func loadExistingConnector(
|
||||
return nil, fmt.Errorf("%w: cannot parse connector id: %w", errInvalidReconnectConnector, err)
|
||||
}
|
||||
|
||||
found, err := prb.Connectors.GetWithConnection(r.Context(), parsedID)
|
||||
found, err := prb.Connectors.GetWithConnection(r.Context(), scope, parsedID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -158,6 +160,7 @@ func loadExistingConnector(
|
||||
|
||||
found, err := prb.Connectors.GetByOrganizationIDAndProvider(
|
||||
r.Context(),
|
||||
scope,
|
||||
organizationID,
|
||||
coredata.ConnectorProvider(provider),
|
||||
)
|
||||
|
||||
@@ -36,7 +36,8 @@ func (r *mutationResolver) CreateAPIKeyConnector(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateConnectorRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -75,7 +76,7 @@ func (r *mutationResolver) CreateAPIKeyConnector(ctx context.Context, input type
|
||||
}
|
||||
}
|
||||
|
||||
cnnctr, err := prb.Connectors.Create(ctx, req)
|
||||
cnnctr, err := prb.Connectors.Create(ctx, scope, req)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -95,7 +96,8 @@ func (r *mutationResolver) CreateClientCredentialsConnector(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
oauth2Conn := &connector.OAuth2Connection{
|
||||
GrantType: connector.OAuth2GrantTypeClientCredentials,
|
||||
@@ -121,7 +123,7 @@ func (r *mutationResolver) CreateClientCredentialsConnector(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
cnnctr, err := prb.Connectors.Create(ctx, req)
|
||||
cnnctr, err := prb.Connectors.Create(ctx, scope, req)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -141,9 +143,10 @@ func (r *mutationResolver) DeleteConnector(ctx context.Context, input types.Dele
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ConnectorID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ConnectorID)
|
||||
prb := r.probo
|
||||
|
||||
if err := prb.Connectors.Delete(ctx, input.ConnectorID); err != nil {
|
||||
if err := prb.Connectors.Delete(ctx, scope, input.ConnectorID); err != nil {
|
||||
panic(fmt.Errorf("cannot delete connector: %w", err))
|
||||
}
|
||||
|
||||
@@ -158,9 +161,10 @@ func (r *mutationResolver) DeleteSlackConnection(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.SlackConnectionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.SlackConnectionID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Connectors.Delete(ctx, input.SlackConnectionID)
|
||||
err := prb.Connectors.Delete(ctx, scope, input.SlackConnectionID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete slack connection", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
|
||||
@@ -28,9 +28,10 @@ func (r *applicabilityStatementResolver) StatementOfApplicability(ctx context.Co
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.StatementOfApplicability.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.StatementOfApplicability.ID)
|
||||
prb := r.probo
|
||||
|
||||
soa, err := prb.StatementsOfApplicability.Get(ctx, obj.StatementOfApplicability.ID)
|
||||
soa, err := prb.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)
|
||||
@@ -72,11 +73,12 @@ func (r *applicabilityStatementConnectionResolver) TotalCount(ctx context.Contex
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *statementOfApplicabilityResolver:
|
||||
count, err := prb.StatementsOfApplicability.CountApplicabilityStatements(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -114,9 +116,10 @@ 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) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
hasRegulatory, err := prb.Controls.HasRegulatoryObligation(ctx, obj.ID)
|
||||
hasRegulatory, err := prb.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)
|
||||
@@ -127,9 +130,10 @@ 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) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
hasContractual, err := prb.Controls.HasContractualObligation(ctx, obj.ID)
|
||||
hasContractual, err := prb.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)
|
||||
@@ -140,9 +144,10 @@ 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) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
hasRisk, err := prb.Controls.HasRiskAssessment(ctx, obj.ID)
|
||||
hasRisk, err := prb.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)
|
||||
@@ -179,7 +184,8 @@ func (r *controlResolver) Measures(ctx context.Context, obj *types.Control, firs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MeasureOrderField]{
|
||||
Field: coredata.MeasureOrderFieldCreatedAt,
|
||||
@@ -199,7 +205,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, obj.ID, cursor, measureFilter)
|
||||
page, err := prb.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)
|
||||
@@ -214,7 +220,8 @@ func (r *controlResolver) Documents(ctx context.Context, obj *types.Control, fir
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{
|
||||
Field: coredata.DocumentOrderFieldCreatedAt,
|
||||
@@ -237,7 +244,7 @@ func (r *controlResolver) Documents(ctx context.Context, obj *types.Control, fir
|
||||
WithClassifications(filter.Classifications)
|
||||
}
|
||||
|
||||
page, err := prb.Documents.ListForControlID(ctx, obj.ID, cursor, documentFilter)
|
||||
page, err := prb.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)
|
||||
@@ -252,7 +259,8 @@ func (r *controlResolver) Audits(ctx context.Context, obj *types.Control, first
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.AuditOrderField]{
|
||||
Field: coredata.AuditOrderFieldCreatedAt,
|
||||
@@ -267,7 +275,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -282,7 +290,8 @@ func (r *controlResolver) Obligations(ctx context.Context, obj *types.Control, f
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ObligationOrderField]{
|
||||
Field: coredata.ObligationOrderFieldCreatedAt,
|
||||
@@ -297,7 +306,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -317,11 +326,12 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.Controls.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -329,7 +339,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
|
||||
return count, nil
|
||||
case *frameworkResolver:
|
||||
count, err := prb.Controls.CountForFrameworkID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -337,7 +347,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
|
||||
return count, nil
|
||||
case *documentResolver:
|
||||
count, err := prb.Controls.CountForDocumentID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -345,7 +355,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
|
||||
return count, nil
|
||||
case *measureResolver:
|
||||
count, err := prb.Controls.CountForMeasureID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -353,7 +363,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Controls.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -361,7 +371,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
|
||||
return count, nil
|
||||
case *statementOfApplicabilityResolver:
|
||||
count, err := prb.Controls.CountForStatementOfApplicabilityID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -381,10 +391,11 @@ func (r *mutationResolver) CreateControl(ctx context.Context, input types.Create
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.FrameworkID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.FrameworkID)
|
||||
prb := r.probo
|
||||
|
||||
control, err := prb.Controls.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateControlRequest{
|
||||
FrameworkID: input.FrameworkID,
|
||||
Name: input.Name,
|
||||
@@ -420,10 +431,11 @@ func (r *mutationResolver) UpdateControl(ctx context.Context, input types.Update
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
control, err := prb.Controls.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateControlRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -459,9 +471,10 @@ func (r *mutationResolver) DeleteControl(ctx context.Context, input types.Delete
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ControlID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ControlID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Controls.Delete(ctx, input.ControlID)
|
||||
err := prb.Controls.Delete(ctx, scope, input.ControlID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete control", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -478,9 +491,10 @@ func (r *mutationResolver) CreateControlMeasureMapping(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.MeasureID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.MeasureID)
|
||||
prb := r.probo
|
||||
|
||||
control, measure, err := prb.Controls.CreateMeasureMapping(ctx, input.ControlID, input.MeasureID)
|
||||
control, measure, err := prb.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)
|
||||
@@ -498,9 +512,10 @@ func (r *mutationResolver) CreateControlDocumentMapping(ctx context.Context, inp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
control, document, err := prb.Controls.CreateDocumentMapping(ctx, input.ControlID, input.DocumentID)
|
||||
control, document, err := prb.Controls.CreateDocumentMapping(ctx, scope, input.ControlID, input.DocumentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -523,9 +538,10 @@ func (r *mutationResolver) DeleteControlMeasureMapping(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.MeasureID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.MeasureID)
|
||||
prb := r.probo
|
||||
|
||||
control, measure, err := prb.Controls.DeleteMeasureMapping(ctx, input.ControlID, input.MeasureID)
|
||||
control, measure, err := prb.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)
|
||||
@@ -543,9 +559,10 @@ func (r *mutationResolver) DeleteControlDocumentMapping(ctx context.Context, inp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
control, document, err := prb.Controls.DeleteDocumentMapping(ctx, input.ControlID, input.DocumentID)
|
||||
control, document, err := prb.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)
|
||||
@@ -563,9 +580,10 @@ func (r *mutationResolver) CreateApplicabilityStatement(ctx context.Context, inp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.StatementOfApplicabilityID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.StatementOfApplicabilityID)
|
||||
prb := r.probo
|
||||
|
||||
applicabilityStatement, err := prb.StatementsOfApplicability.CreateApplicabilityStatement(ctx, input.StatementOfApplicabilityID, input.ControlID, input.Applicability, input.Justification)
|
||||
applicabilityStatement, err := prb.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)
|
||||
@@ -582,9 +600,10 @@ func (r *mutationResolver) UpdateApplicabilityStatement(ctx context.Context, inp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ApplicabilityStatementID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ApplicabilityStatementID)
|
||||
prb := r.probo
|
||||
|
||||
applicabilityStatement, err := prb.StatementsOfApplicability.UpdateApplicabilityStatement(ctx, input.ApplicabilityStatementID, input.Applicability, input.Justification)
|
||||
applicabilityStatement, err := prb.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)
|
||||
@@ -601,9 +620,10 @@ func (r *mutationResolver) DeleteApplicabilityStatement(ctx context.Context, inp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ApplicabilityStatementID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ApplicabilityStatementID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.StatementsOfApplicability.DeleteApplicabilityStatement(ctx, input.ApplicabilityStatementID)
|
||||
err := prb.StatementsOfApplicability.DeleteApplicabilityStatement(ctx, scope, input.ApplicabilityStatementID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete applicability statement", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -620,9 +640,10 @@ func (r *mutationResolver) CreateControlAuditMapping(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.AuditID)
|
||||
prb := r.probo
|
||||
|
||||
control, audit, err := prb.Controls.CreateAuditMapping(ctx, input.ControlID, input.AuditID)
|
||||
control, audit, err := prb.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)
|
||||
@@ -640,9 +661,10 @@ func (r *mutationResolver) DeleteControlAuditMapping(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.AuditID)
|
||||
prb := r.probo
|
||||
|
||||
control, audit, err := prb.Controls.DeleteAuditMapping(ctx, input.ControlID, input.AuditID)
|
||||
control, audit, err := prb.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)
|
||||
@@ -660,9 +682,10 @@ func (r *mutationResolver) CreateControlObligationMapping(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ObligationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ObligationID)
|
||||
prb := r.probo
|
||||
|
||||
control, obligation, err := prb.Controls.CreateObligationMapping(ctx, input.ControlID, input.ObligationID)
|
||||
control, obligation, err := prb.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)
|
||||
@@ -680,9 +703,10 @@ func (r *mutationResolver) DeleteControlObligationMapping(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ObligationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ObligationID)
|
||||
prb := r.probo
|
||||
|
||||
control, obligation, err := prb.Controls.DeleteObligationMapping(ctx, input.ControlID, input.ObligationID)
|
||||
control, obligation, err := prb.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)
|
||||
@@ -700,10 +724,11 @@ func (r *mutationResolver) CreateStatementOfApplicability(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
statementOfApplicability, err := prb.StatementsOfApplicability.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateStatementOfApplicabilityRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -734,7 +759,8 @@ func (r *mutationResolver) UpdateStatementOfApplicability(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
var name *string
|
||||
if input.Name != nil {
|
||||
@@ -742,7 +768,7 @@ func (r *mutationResolver) UpdateStatementOfApplicability(ctx context.Context, i
|
||||
}
|
||||
|
||||
statementOfApplicability, err := prb.StatementsOfApplicability.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateStatementOfApplicabilityRequest{
|
||||
StatementOfApplicabilityID: input.ID,
|
||||
Name: name,
|
||||
@@ -773,9 +799,10 @@ func (r *mutationResolver) DeleteStatementOfApplicability(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.StatementOfApplicabilityID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.StatementOfApplicabilityID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.StatementsOfApplicability.Delete(ctx, input.StatementOfApplicabilityID)
|
||||
err := prb.StatementsOfApplicability.Delete(ctx, scope, input.StatementOfApplicabilityID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete statement_of_applicability", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -792,9 +819,10 @@ func (r *mutationResolver) PublishStatementOfApplicability(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.StatementOfApplicabilityID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.StatementOfApplicabilityID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishStatementOfApplicability(ctx, input.StatementOfApplicabilityID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -825,9 +853,10 @@ func (r *statementOfApplicabilityResolver) Document(ctx context.Context, obj *ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.Document.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.Document.ID)
|
||||
prb := r.probo
|
||||
|
||||
document, err := prb.Documents.Get(ctx, obj.Document.ID)
|
||||
document, err := prb.Documents.Get(ctx, scope, obj.Document.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -869,7 +898,8 @@ func (r *statementOfApplicabilityResolver) ApplicabilityStatements(ctx context.C
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ApplicabilityStatementOrderField]{
|
||||
Field: coredata.ApplicabilityStatementOrderFieldCreatedAt,
|
||||
@@ -884,7 +914,7 @@ func (r *statementOfApplicabilityResolver) ApplicabilityStatements(ctx context.C
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
p, err := prb.StatementsOfApplicability.ListApplicabilityStatements(ctx, obj.ID, cursor)
|
||||
p, err := prb.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)
|
||||
@@ -900,11 +930,12 @@ 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) {
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.StatementsOfApplicability.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -26,15 +26,16 @@ func (r *dataProtectionImpactAssessmentResolver) ProcessingActivity(ctx context.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
dpia, err := prb.DataProtectionImpactAssessments.Get(ctx, obj.ID)
|
||||
dpia, err := prb.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, dpia.ProcessingActivityID)
|
||||
processingActivity, err := prb.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)
|
||||
@@ -49,15 +50,16 @@ func (r *dataProtectionImpactAssessmentResolver) Organization(ctx context.Contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
dpia, err := prb.DataProtectionImpactAssessments.Get(ctx, obj.ID)
|
||||
dpia, err := prb.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, dpia.OrganizationID)
|
||||
organization, err := prb.Organizations.Get(ctx, scope, dpia.OrganizationID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -82,11 +84,12 @@ func (r *dataProtectionImpactAssessmentConnectionResolver) TotalCount(ctx contex
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.DataProtectionImpactAssessments.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -106,7 +109,8 @@ func (r *mutationResolver) CreateDataProtectionImpactAssessment(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ProcessingActivityID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ProcessingActivityID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateDataProtectionImpactAssessmentRequest{
|
||||
ProcessingActivityID: input.ProcessingActivityID,
|
||||
@@ -117,7 +121,7 @@ func (r *mutationResolver) CreateDataProtectionImpactAssessment(ctx context.Cont
|
||||
ResidualRisk: input.ResidualRisk,
|
||||
}
|
||||
|
||||
dpia, err := prb.DataProtectionImpactAssessments.Create(ctx, &req)
|
||||
dpia, err := prb.DataProtectionImpactAssessments.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -143,7 +147,8 @@ func (r *mutationResolver) UpdateDataProtectionImpactAssessment(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateDataProtectionImpactAssessmentRequest{
|
||||
ID: input.ID,
|
||||
@@ -154,7 +159,7 @@ func (r *mutationResolver) UpdateDataProtectionImpactAssessment(ctx context.Cont
|
||||
ResidualRisk: input.ResidualRisk,
|
||||
}
|
||||
|
||||
dpia, err := prb.DataProtectionImpactAssessments.Update(ctx, &req)
|
||||
dpia, err := prb.DataProtectionImpactAssessments.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -176,9 +181,10 @@ func (r *mutationResolver) DeleteDataProtectionImpactAssessment(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DataProtectionImpactAssessmentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DataProtectionImpactAssessmentID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.DataProtectionImpactAssessments.Delete(ctx, input.DataProtectionImpactAssessmentID)
|
||||
err := prb.DataProtectionImpactAssessments.Delete(ctx, scope, input.DataProtectionImpactAssessmentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete data protection impact assessment", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -195,7 +201,8 @@ func (r *mutationResolver) CreateTransferImpactAssessment(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ProcessingActivityID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ProcessingActivityID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateTransferImpactAssessmentRequest{
|
||||
ProcessingActivityID: input.ProcessingActivityID,
|
||||
@@ -206,7 +213,7 @@ func (r *mutationResolver) CreateTransferImpactAssessment(ctx context.Context, i
|
||||
SupplementaryMeasures: input.SupplementaryMeasures,
|
||||
}
|
||||
|
||||
tia, err := prb.TransferImpactAssessments.Create(ctx, &req)
|
||||
tia, err := prb.TransferImpactAssessments.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -232,7 +239,8 @@ func (r *mutationResolver) UpdateTransferImpactAssessment(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateTransferImpactAssessmentRequest{
|
||||
ID: input.ID,
|
||||
@@ -243,7 +251,7 @@ func (r *mutationResolver) UpdateTransferImpactAssessment(ctx context.Context, i
|
||||
SupplementaryMeasures: gqlutils.UnwrapOmittable(input.SupplementaryMeasures),
|
||||
}
|
||||
|
||||
tia, err := prb.TransferImpactAssessments.Update(ctx, &req)
|
||||
tia, err := prb.TransferImpactAssessments.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -265,9 +273,10 @@ func (r *mutationResolver) DeleteTransferImpactAssessment(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TransferImpactAssessmentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TransferImpactAssessmentID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.TransferImpactAssessments.Delete(ctx, input.TransferImpactAssessmentID)
|
||||
err := prb.TransferImpactAssessments.Delete(ctx, scope, input.TransferImpactAssessmentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete transfer impact assessment", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -284,9 +293,10 @@ func (r *mutationResolver) PublishDataProtectionImpactAssessmentList(ctx context
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishDataProtectionImpactAssessmentList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -313,9 +323,10 @@ func (r *mutationResolver) PublishTransferImpactAssessmentList(ctx context.Conte
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishTransferImpactAssessmentList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -342,9 +353,10 @@ func (r *transferImpactAssessmentResolver) ProcessingActivity(ctx context.Contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
processingActivity, err := prb.ProcessingActivities.Get(ctx, obj.ProcessingActivity.ID)
|
||||
processingActivity, err := prb.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)
|
||||
@@ -386,11 +398,12 @@ func (r *transferImpactAssessmentConnectionResolver) TotalCount(ctx context.Cont
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.TransferImpactAssessments.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -91,9 +91,9 @@ func (f *batchFetcher) newLoaders() *Loaders {
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchOrganizations(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Organization, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
orgs, err := tenantSvc.Organizations.GetByIDs(ctx, keys...)
|
||||
orgs, err := f.probo.Organizations.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load organizations: %w", err)
|
||||
}
|
||||
@@ -107,9 +107,9 @@ func (f *batchFetcher) fetchOrganizations(ctx context.Context, keys []gid.GID) (
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchFrameworks(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Framework, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
frameworks, err := tenantSvc.Frameworks.GetByIDs(ctx, keys...)
|
||||
frameworks, err := f.probo.Frameworks.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load frameworks: %w", err)
|
||||
}
|
||||
@@ -123,9 +123,9 @@ func (f *batchFetcher) fetchFrameworks(ctx context.Context, keys []gid.GID) (map
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchControls(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Control, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
controls, err := tenantSvc.Controls.GetByIDs(ctx, keys...)
|
||||
controls, err := f.probo.Controls.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load controls: %w", err)
|
||||
}
|
||||
@@ -139,9 +139,9 @@ func (f *batchFetcher) fetchControls(ctx context.Context, keys []gid.GID) (map[g
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchThirdParties(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.ThirdParty, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
thirdParties, err := tenantSvc.ThirdParties.GetByIDs(ctx, keys...)
|
||||
thirdParties, err := f.probo.ThirdParties.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load thirdParties: %w", err)
|
||||
}
|
||||
@@ -155,9 +155,9 @@ func (f *batchFetcher) fetchThirdParties(ctx context.Context, keys []gid.GID) (m
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchDocuments(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Document, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
documents, err := tenantSvc.Documents.GetByIDs(ctx, keys...)
|
||||
documents, err := f.probo.Documents.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load documents: %w", err)
|
||||
}
|
||||
@@ -187,9 +187,9 @@ func (f *batchFetcher) fetchProfiles(ctx context.Context, keys []gid.GID) (map[g
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchRisks(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Risk, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
risks, err := tenantSvc.Risks.GetByIDs(ctx, keys...)
|
||||
risks, err := f.probo.Risks.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load risks: %w", err)
|
||||
}
|
||||
@@ -203,9 +203,9 @@ func (f *batchFetcher) fetchRisks(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchMeasures(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Measure, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
measures, err := tenantSvc.Measures.GetByIDs(ctx, keys...)
|
||||
measures, err := f.probo.Measures.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load measures: %w", err)
|
||||
}
|
||||
@@ -219,9 +219,9 @@ func (f *batchFetcher) fetchMeasures(ctx context.Context, keys []gid.GID) (map[g
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchTasks(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Task, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
tasks, err := tenantSvc.Tasks.GetByIDs(ctx, keys...)
|
||||
tasks, err := f.probo.Tasks.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load tasks: %w", err)
|
||||
}
|
||||
@@ -235,9 +235,9 @@ func (f *batchFetcher) fetchTasks(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchFiles(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.File, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
files, err := tenantSvc.Files.GetByIDs(ctx, keys...)
|
||||
files, err := f.probo.Files.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load files: %w", err)
|
||||
}
|
||||
@@ -251,9 +251,9 @@ func (f *batchFetcher) fetchFiles(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
}
|
||||
|
||||
func (f *batchFetcher) fetchReports(ctx context.Context, keys []gid.GID) (map[gid.GID]*coredata.Report, error) {
|
||||
tenantSvc := f.probo.WithTenant(keys[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(keys[0])
|
||||
|
||||
reports, err := tenantSvc.Reports.GetByIDs(ctx, keys...)
|
||||
reports, err := f.probo.Reports.GetByIDs(ctx, scope, keys...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot batch load reports: %w", err)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ func (r *documentResolver) Versions(ctx context.Context, obj *types.Document, fi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionOrderField]{
|
||||
Field: coredata.DocumentVersionOrderFieldCreatedAt,
|
||||
@@ -75,7 +76,7 @@ func (r *documentResolver) Versions(ctx context.Context, obj *types.Document, fi
|
||||
versionFilter = versionFilter.WithStatuses(filter.Statuses...)
|
||||
}
|
||||
|
||||
page, err := prb.Documents.ListVersions(ctx, obj.ID, cursor, versionFilter)
|
||||
page, err := prb.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)
|
||||
@@ -90,7 +91,8 @@ func (r *documentResolver) Controls(ctx context.Context, obj *types.Document, fi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -110,7 +112,7 @@ func (r *documentResolver) Controls(ctx context.Context, obj *types.Document, fi
|
||||
controlFilter = coredata.NewControlFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Controls.ListForDocumentID(ctx, obj.ID, cursor, controlFilter)
|
||||
page, err := prb.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)
|
||||
@@ -125,9 +127,10 @@ func (r *documentResolver) DefaultApprovers(ctx context.Context, obj *types.Docu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
profiles, err := prb.Documents.GetDefaultApprovers(ctx, obj.ID)
|
||||
profiles, err := prb.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)
|
||||
@@ -152,11 +155,12 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *controlResolver:
|
||||
count, err := prb.Documents.CountForControlID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -164,7 +168,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Documents.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -172,7 +176,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Documents.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -180,7 +184,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
|
||||
return count, nil
|
||||
case *measureResolver:
|
||||
count, err := prb.Documents.CountForMeasureID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -229,7 +233,8 @@ func (r *documentVersionResolver) Approvers(ctx context.Context, obj *types.Docu
|
||||
}, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MembershipProfileOrderField]{
|
||||
Field: coredata.MembershipProfileOrderFieldCreatedAt,
|
||||
@@ -242,7 +247,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, obj.ID, c)
|
||||
p, err := prb.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)
|
||||
@@ -257,7 +262,8 @@ func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.Doc
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionSignatureOrderField]{
|
||||
Field: coredata.DocumentVersionSignatureOrderFieldCreatedAt,
|
||||
@@ -289,7 +295,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, obj.ID, cursor, signatureFilter)
|
||||
page, err := prb.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)
|
||||
@@ -304,7 +310,8 @@ func (r *documentVersionResolver) ApprovalQuorums(ctx context.Context, obj *type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionApprovalQuorumOrderField]{
|
||||
Field: coredata.DocumentVersionApprovalQuorumOrderFieldCreatedAt,
|
||||
@@ -319,7 +326,7 @@ func (r *documentVersionResolver) ApprovalQuorums(ctx context.Context, obj *type
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
p, err := prb.DocumentApprovals.ListQuorums(ctx, obj.ID, cursor)
|
||||
p, err := prb.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)
|
||||
@@ -336,9 +343,10 @@ func (r *documentVersionResolver) Signed(ctx context.Context, obj *types.Documen
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
signed, err := prb.Documents.IsVersionSignedByUserEmail(ctx, obj.ID, identity.EmailAddress)
|
||||
signed, err := prb.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)
|
||||
@@ -358,9 +366,10 @@ func (r *documentVersionApprovalDecisionResolver) Quorum(ctx context.Context, ob
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
quorum, err := prb.DocumentApprovals.GetQuorum(ctx, obj.Quorum.ID)
|
||||
quorum, err := prb.DocumentApprovals.GetQuorum(ctx, scope, obj.Quorum.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -380,9 +389,10 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
quorum, err := prb.DocumentApprovals.GetQuorum(ctx, obj.Quorum.ID)
|
||||
quorum, err := prb.DocumentApprovals.GetQuorum(ctx, scope, obj.Quorum.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -393,7 +403,7 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, quorum.VersionID)
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, scope, quorum.VersionID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -460,14 +470,15 @@ func (r *documentVersionApprovalDecisionConnectionResolver) TotalCount(ctx conte
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
filter := coredata.NewDocumentVersionApprovalDecisionFilter(nil)
|
||||
if obj.Filters != nil {
|
||||
filter = obj.Filters
|
||||
}
|
||||
|
||||
count, err := prb.DocumentApprovals.CountDecisions(ctx, obj.ParentID, filter)
|
||||
count, err := prb.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)
|
||||
@@ -482,9 +493,10 @@ func (r *documentVersionApprovalQuorumResolver) DocumentVersion(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, obj.DocumentVersion.ID)
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, scope, obj.DocumentVersion.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -504,7 +516,8 @@ func (r *documentVersionApprovalQuorumResolver) Decisions(ctx context.Context, o
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionApprovalDecisionOrderField]{
|
||||
Field: coredata.DocumentVersionApprovalDecisionOrderFieldCreatedAt,
|
||||
@@ -526,7 +539,7 @@ func (r *documentVersionApprovalQuorumResolver) Decisions(ctx context.Context, o
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
p, err := prb.DocumentApprovals.ListDecisions(ctx, obj.ID, cursor, approvalFilter)
|
||||
p, err := prb.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)
|
||||
@@ -546,9 +559,10 @@ func (r *documentVersionApprovalQuorumConnectionResolver) TotalCount(ctx context
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.DocumentApprovals.CountQuorums(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -563,7 +577,8 @@ func (r *documentVersionConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *documentResolver:
|
||||
@@ -572,7 +587,7 @@ func (r *documentVersionConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
filter = obj.Filters
|
||||
}
|
||||
|
||||
count, err := prb.Documents.CountVersionsForDocumentID(ctx, obj.ParentID, filter)
|
||||
count, err := prb.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)
|
||||
@@ -592,9 +607,10 @@ func (r *documentVersionSignatureResolver) DocumentVersion(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, obj.DocumentVersion.ID)
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, scope, obj.DocumentVersion.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -641,7 +657,8 @@ func (r *documentVersionSignatureConnectionResolver) TotalCount(ctx context.Cont
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *documentVersionResolver:
|
||||
@@ -650,7 +667,7 @@ func (r *documentVersionSignatureConnectionResolver) TotalCount(ctx context.Cont
|
||||
filter = obj.Filters
|
||||
}
|
||||
|
||||
count, err := prb.Documents.CountSignaturesForVersionID(ctx, obj.ParentID, filter)
|
||||
count, err := prb.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)
|
||||
@@ -672,9 +689,10 @@ func (r *employeeDocumentResolver) Signed(ctx context.Context, obj *types.Employ
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
signed, err := prb.Documents.IsSigned(ctx, obj.ID, identity.EmailAddress)
|
||||
signed, err := prb.Documents.IsSigned(ctx, scope, obj.ID, identity.EmailAddress)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -696,9 +714,10 @@ func (r *employeeDocumentResolver) ApprovalState(ctx context.Context, obj *types
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
state, err := prb.Documents.GetViewerApprovalState(ctx, obj.ID, identity.ID)
|
||||
state, err := prb.Documents.GetViewerApprovalState(ctx, scope, obj.ID, identity.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -718,7 +737,8 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentVersionOrderField]{
|
||||
Field: coredata.DocumentVersionOrderFieldCreatedAt,
|
||||
@@ -750,7 +770,7 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl
|
||||
versionFilter := coredata.NewDocumentVersionFilter().
|
||||
WithEmployeeIdentityID(&identity.ID, filterMode)
|
||||
|
||||
versionsPage, err := prb.Documents.ListVersions(ctx, obj.ID, cursor, versionFilter)
|
||||
versionsPage, err := prb.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)
|
||||
@@ -786,9 +806,10 @@ func (r *employeeDocumentVersionResolver) Signed(ctx context.Context, obj *types
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
signed, err := prb.Documents.IsVersionSignedByUserEmail(ctx, obj.ID, identity.EmailAddress)
|
||||
signed, err := prb.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)
|
||||
@@ -804,9 +825,10 @@ func (r *employeeDocumentVersionResolver) ApprovalDecision(ctx context.Context,
|
||||
}
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
decision, err := prb.DocumentApprovals.GetViewerDecision(ctx, obj.ID, identity.ID)
|
||||
decision, err := prb.DocumentApprovals.GetViewerDecision(ctx, scope, obj.ID, identity.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -826,7 +848,8 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
var content string
|
||||
if input.Content != nil {
|
||||
@@ -834,7 +857,7 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
}
|
||||
|
||||
document, documentVersion, err := prb.Documents.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateDocumentRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Title: input.Title,
|
||||
@@ -871,7 +894,8 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
var defaultApproverIDs *[]gid.GID
|
||||
if input.DefaultApproverIds != nil {
|
||||
@@ -879,7 +903,7 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
|
||||
}
|
||||
|
||||
document, documentVersion, draftCreated, err := prb.Documents.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateDocumentRequest{
|
||||
DocumentID: input.ID,
|
||||
Title: input.Title,
|
||||
@@ -936,9 +960,10 @@ func (r *mutationResolver) DeleteDocumentDraft(ctx context.Context, input types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
document, err := prb.Documents.DeleteDraft(ctx, input.DocumentID)
|
||||
document, err := prb.Documents.DeleteDraft(ctx, scope, input.DocumentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -968,9 +993,10 @@ func (r *mutationResolver) ArchiveDocument(ctx context.Context, input types.Arch
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
document, err := prb.Documents.Archive(ctx, input.DocumentID)
|
||||
document, err := prb.Documents.Archive(ctx, scope, input.DocumentID)
|
||||
if err != nil {
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
@@ -992,9 +1018,10 @@ func (r *mutationResolver) UnarchiveDocument(ctx context.Context, input types.Un
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
document, err := prb.Documents.Unarchive(ctx, input.DocumentID)
|
||||
document, err := prb.Documents.Unarchive(ctx, scope, input.DocumentID)
|
||||
if err != nil {
|
||||
if errNotArchived, ok := errors.AsType[*probo.ErrDocumentNotArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errNotArchived)
|
||||
@@ -1016,9 +1043,10 @@ func (r *mutationResolver) DeleteDocument(ctx context.Context, input types.Delet
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Documents.SoftDelete(ctx, input.DocumentID)
|
||||
err := prb.Documents.SoftDelete(ctx, scope, input.DocumentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot soft delete document", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -1040,9 +1068,10 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
result, err := prb.Documents.PublishVersion(ctx, probo.PublishDocumentRequest{
|
||||
result, err := prb.Documents.PublishVersion(ctx, scope, probo.PublishDocumentRequest{
|
||||
DocumentID: input.DocumentID,
|
||||
Minor: input.Minor,
|
||||
ApproverIDs: input.ApproverIds,
|
||||
@@ -1104,9 +1133,10 @@ func (r *mutationResolver) BulkPublishDocuments(ctx context.Context, input types
|
||||
}
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentIds[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentIds[0])
|
||||
prb := r.probo
|
||||
|
||||
versions, documents, err := prb.DocumentApprovals.BulkPublishVersions(ctx, probo.BulkPublishVersionsRequest{
|
||||
versions, documents, err := prb.DocumentApprovals.BulkPublishVersions(ctx, scope, probo.BulkPublishVersionsRequest{
|
||||
DocumentIDs: input.DocumentIds,
|
||||
Minor: input.Minor,
|
||||
Changelog: input.Changelog,
|
||||
@@ -1151,9 +1181,10 @@ func (r *mutationResolver) VoidDocumentVersionApproval(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionID)
|
||||
prb := r.probo
|
||||
|
||||
quorum, documentVersion, err := prb.DocumentApprovals.VoidApproval(ctx, input.DocumentVersionID)
|
||||
quorum, documentVersion, err := prb.DocumentApprovals.VoidApproval(ctx, scope, input.DocumentVersionID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -1192,9 +1223,10 @@ func (r *mutationResolver) BulkDeleteDocuments(ctx context.Context, input types.
|
||||
}
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentIds[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentIds[0])
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Documents.BulkSoftDelete(ctx, input.DocumentIds)
|
||||
err := prb.Documents.BulkSoftDelete(ctx, scope, input.DocumentIds)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot bulk delete documents", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -1219,9 +1251,10 @@ func (r *mutationResolver) BulkArchiveDocuments(ctx context.Context, input types
|
||||
}
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentIds[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentIds[0])
|
||||
prb := r.probo
|
||||
|
||||
if err := prb.Documents.BulkArchive(ctx, input.DocumentIds); err != nil {
|
||||
if err := prb.Documents.BulkArchive(ctx, scope, input.DocumentIds); err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot bulk archive documents", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
@@ -1245,9 +1278,10 @@ func (r *mutationResolver) BulkUnarchiveDocuments(ctx context.Context, input typ
|
||||
}
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentIds[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentIds[0])
|
||||
prb := r.probo
|
||||
|
||||
if err := prb.Documents.BulkUnarchive(ctx, input.DocumentIds); err != nil {
|
||||
if err := prb.Documents.BulkUnarchive(ctx, scope, input.DocumentIds); err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot bulk unarchive documents", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
@@ -1271,7 +1305,8 @@ func (r *mutationResolver) BulkExportDocuments(ctx context.Context, input types.
|
||||
}
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentIds[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentIds[0])
|
||||
prb := r.probo
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
@@ -1281,7 +1316,7 @@ func (r *mutationResolver) BulkExportDocuments(ctx context.Context, input types.
|
||||
WatermarkEmail: input.WatermarkEmail,
|
||||
}
|
||||
|
||||
documentExport, exportErr := prb.Documents.RequestExport(ctx, input.DocumentIds, identity.EmailAddress, identity.FullName, options)
|
||||
documentExport, exportErr := prb.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)
|
||||
@@ -1298,9 +1333,10 @@ func (r *mutationResolver) GenerateDocumentChangelog(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
prb := r.probo
|
||||
|
||||
changelog, err := prb.Documents.GenerateChangelog(ctx, input.DocumentID)
|
||||
changelog, err := prb.Documents.GenerateChangelog(ctx, scope, input.DocumentID)
|
||||
if err != nil {
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
@@ -1322,10 +1358,11 @@ func (r *mutationResolver) RequestSignature(ctx context.Context, input types.Req
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionID)
|
||||
prb := r.probo
|
||||
|
||||
documentVersionSignature, err := prb.Documents.RequestSignature(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.RequestSignatureRequest{
|
||||
DocumentVersionID: input.DocumentVersionID,
|
||||
Signatory: input.SignatoryID,
|
||||
@@ -1372,10 +1409,11 @@ func (r *mutationResolver) BulkRequestSignatures(ctx context.Context, input type
|
||||
}
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentIds[0].TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentIds[0])
|
||||
prb := r.probo
|
||||
|
||||
documentVersionSignatures, err := prb.Documents.BulkRequestSignatures(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.BulkRequestSignaturesRequest{
|
||||
DocumentIDs: input.DocumentIds,
|
||||
SignatoryIDs: input.SignatoryIds,
|
||||
@@ -1410,9 +1448,10 @@ func (r *mutationResolver) SendSigningNotifications(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Documents.SendSigningNotifications(ctx, input.OrganizationID)
|
||||
err := prb.Documents.SendSigningNotifications(ctx, scope, input.OrganizationID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot send signing notifications", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -1429,9 +1468,10 @@ func (r *mutationResolver) CancelSignatureRequest(ctx context.Context, input typ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentVersionSignatureID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionSignatureID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Documents.CancelSignatureRequest(ctx, input.DocumentVersionSignatureID)
|
||||
err := prb.Documents.CancelSignatureRequest(ctx, scope, input.DocumentVersionSignatureID)
|
||||
if err != nil {
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
@@ -1454,9 +1494,10 @@ func (r *mutationResolver) SignDocument(ctx context.Context, input types.SignDoc
|
||||
}
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionID)
|
||||
prb := r.probo
|
||||
|
||||
documentVersionSignature, err := prb.Documents.SignDocumentVersionByIdentity(ctx, input.DocumentVersionID, identity.ID)
|
||||
documentVersionSignature, err := prb.Documents.SignDocumentVersionByIdentity(ctx, scope, input.DocumentVersionID, identity.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -1486,9 +1527,10 @@ func (r *mutationResolver) ApproveDocumentVersion(ctx context.Context, input typ
|
||||
signerIP = httpReq.RemoteAddr
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionID)
|
||||
prb := r.probo
|
||||
|
||||
decision, err := prb.DocumentApprovals.Approve(ctx, probo.ApproveDocumentVersionRequest{
|
||||
decision, err := prb.DocumentApprovals.Approve(ctx, scope, probo.ApproveDocumentVersionRequest{
|
||||
DocumentVersionID: input.DocumentVersionID,
|
||||
IdentityID: identity.ID,
|
||||
Comment: input.Comment,
|
||||
@@ -1532,9 +1574,10 @@ func (r *mutationResolver) RejectDocumentVersion(ctx context.Context, input type
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionID)
|
||||
prb := r.probo
|
||||
|
||||
decision, err := prb.DocumentApprovals.Reject(ctx, probo.RejectDocumentVersionRequest{
|
||||
decision, err := prb.DocumentApprovals.Reject(ctx, scope, probo.RejectDocumentVersionRequest{
|
||||
DocumentVersionID: input.DocumentVersionID,
|
||||
IdentityID: identity.ID,
|
||||
Comment: input.Comment,
|
||||
@@ -1572,7 +1615,8 @@ func (r *mutationResolver) ExportDocumentVersionPDF(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionID)
|
||||
prb := r.probo
|
||||
|
||||
watermarkEmail := input.WatermarkEmail
|
||||
if input.WithWatermark && watermarkEmail == nil {
|
||||
@@ -1586,7 +1630,7 @@ func (r *mutationResolver) ExportDocumentVersionPDF(ctx context.Context, input t
|
||||
WatermarkEmail: watermarkEmail,
|
||||
}
|
||||
|
||||
pdf, err := prb.Documents.ExportPDF(ctx, input.DocumentVersionID, options)
|
||||
pdf, err := prb.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)
|
||||
@@ -1603,9 +1647,10 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentVersionID)
|
||||
prb := r.probo
|
||||
|
||||
documentVersion, err := prb.Documents.GetVersion(ctx, input.DocumentVersionID)
|
||||
documentVersion, err := prb.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)
|
||||
@@ -1618,7 +1663,7 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context,
|
||||
coredata.EmployeeFilterModeApproval,
|
||||
)
|
||||
|
||||
_, err = prb.Documents.GetWithFilter(ctx, documentVersion.DocumentID, documentFilter)
|
||||
_, err = prb.Documents.GetWithFilter(ctx, scope, documentVersion.DocumentID, documentFilter)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -1635,7 +1680,7 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context,
|
||||
WatermarkEmail: &identity.EmailAddress,
|
||||
}
|
||||
|
||||
pdf, err := prb.Documents.ExportPDF(ctx, input.DocumentVersionID, options)
|
||||
pdf, err := prb.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)
|
||||
|
||||
@@ -106,11 +106,12 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *measureResolver:
|
||||
count, err := prb.Evidences.CountForMeasureID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -118,7 +119,7 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
|
||||
return count, nil
|
||||
case *taskResolver:
|
||||
count, err := prb.Evidences.CountForTaskID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -138,9 +139,10 @@ func (r *mutationResolver) DeleteEvidence(ctx context.Context, input types.Delet
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.EvidenceID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.EvidenceID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Evidences.Delete(ctx, input.EvidenceID)
|
||||
err := prb.Evidences.Delete(ctx, scope, input.EvidenceID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete evidence", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -157,10 +159,11 @@ func (r *mutationResolver) UploadMeasureEvidence(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.MeasureID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.MeasureID)
|
||||
prb := r.probo
|
||||
|
||||
evidence, err := prb.Evidences.UploadMeasureEvidence(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UploadMeasureEvidenceRequest{
|
||||
MeasureID: input.MeasureID,
|
||||
File: probo.FileUpload{
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
|
||||
"go.probo.inc/probo/pkg/server/api/console/v1/types"
|
||||
@@ -22,9 +23,10 @@ func (r *fileResolver) DownloadURL(ctx context.Context, obj *types.File) (string
|
||||
return "", err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
downloadUrl, err := prb.Files.GenerateFileTempURL(ctx, obj.ID, 60*time.Second)
|
||||
downloadUrl, err := prb.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)
|
||||
|
||||
@@ -52,7 +52,8 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -72,7 +73,7 @@ func (r *frameworkResolver) Controls(ctx context.Context, obj *types.Framework,
|
||||
controlFilter = coredata.NewControlFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Controls.ListForFrameworkID(ctx, obj.ID, cursor, controlFilter)
|
||||
page, err := prb.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)
|
||||
@@ -87,9 +88,10 @@ func (r *frameworkResolver) LightLogoURL(ctx context.Context, obj *types.Framewo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
return prb.Frameworks.GenerateLightLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
return prb.Frameworks.GenerateLightLogoURL(ctx, scope, obj.ID, 1*time.Hour)
|
||||
}
|
||||
|
||||
// DarkLogoURL is the resolver for the darkLogoURL field.
|
||||
@@ -98,9 +100,10 @@ func (r *frameworkResolver) DarkLogoURL(ctx context.Context, obj *types.Framewor
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
return prb.Frameworks.GenerateDarkLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
return prb.Frameworks.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour)
|
||||
}
|
||||
|
||||
// Permission is the resolver for the permission field.
|
||||
@@ -116,9 +119,10 @@ func (r *frameworkConnectionResolver) TotalCount(ctx context.Context, obj *types
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.Frameworks.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.Frameworks.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count frameworks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -138,10 +142,11 @@ func (r *mutationResolver) CreateFramework(ctx context.Context, input types.Crea
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
framework, err := prb.Frameworks.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateFrameworkRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -168,10 +173,11 @@ func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.Upda
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
framework, err := prb.Frameworks.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateFrameworkRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -199,7 +205,8 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.ImportFrameworkRequest{}
|
||||
if err := json.NewDecoder(input.File.File).Decode(&req.Framework); err != nil {
|
||||
@@ -207,7 +214,7 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
framework, err := prb.Frameworks.Import(ctx, input.OrganizationID, req)
|
||||
framework, err := prb.Frameworks.Import(ctx, scope, input.OrganizationID, req)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -229,9 +236,10 @@ func (r *mutationResolver) DeleteFramework(ctx context.Context, input types.Dele
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.FrameworkID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.FrameworkID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Frameworks.Delete(ctx, input.FrameworkID)
|
||||
err := prb.Frameworks.Delete(ctx, scope, input.FrameworkID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete framework", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -248,11 +256,13 @@ func (r *mutationResolver) ExportFramework(ctx context.Context, input types.Expo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.FrameworkID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.FrameworkID)
|
||||
prb := r.probo
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
exportJob, exportErr := prb.Frameworks.RequestExport(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
input.FrameworkID,
|
||||
identity.EmailAddress,
|
||||
identity.FullName,
|
||||
|
||||
@@ -26,7 +26,8 @@ func (r *measureResolver) Evidences(ctx context.Context, obj *types.Measure, fir
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.EvidenceOrderField]{
|
||||
Field: coredata.EvidenceOrderFieldCreatedAt,
|
||||
@@ -41,7 +42,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -56,7 +57,8 @@ func (r *measureResolver) Tasks(ctx context.Context, obj *types.Measure, first *
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TaskOrderField]{
|
||||
Field: coredata.TaskOrderFieldCreatedAt,
|
||||
@@ -71,7 +73,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -86,7 +88,8 @@ func (r *measureResolver) Risks(ctx context.Context, obj *types.Measure, first *
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.RiskOrderField]{
|
||||
Field: coredata.RiskOrderFieldCreatedAt,
|
||||
@@ -106,7 +109,7 @@ func (r *measureResolver) Risks(ctx context.Context, obj *types.Measure, first *
|
||||
riskFilter = coredata.NewRiskFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Risks.ListForMeasureID(ctx, obj.ID, cursor, riskFilter)
|
||||
page, err := prb.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)
|
||||
@@ -121,7 +124,8 @@ func (r *measureResolver) Controls(ctx context.Context, obj *types.Measure, firs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -141,7 +145,7 @@ func (r *measureResolver) Controls(ctx context.Context, obj *types.Measure, firs
|
||||
controlFilter = coredata.NewControlFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Controls.ListForMeasureID(ctx, obj.ID, cursor, controlFilter)
|
||||
page, err := prb.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)
|
||||
@@ -156,7 +160,8 @@ func (r *measureResolver) Documents(ctx context.Context, obj *types.Measure, fir
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{
|
||||
Field: coredata.DocumentOrderFieldCreatedAt,
|
||||
@@ -179,7 +184,7 @@ func (r *measureResolver) Documents(ctx context.Context, obj *types.Measure, fir
|
||||
WithClassifications(filter.Classifications)
|
||||
}
|
||||
|
||||
pg, err := prb.Documents.ListForMeasureID(ctx, obj.ID, cursor, documentFilter)
|
||||
pg, err := prb.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)
|
||||
@@ -199,11 +204,12 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.Measures.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -211,7 +217,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
|
||||
return count, nil
|
||||
case *controlResolver:
|
||||
count, err := prb.Measures.CountForControlID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -219,7 +225,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Measures.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -239,10 +245,11 @@ func (r *mutationResolver) CreateMeasure(ctx context.Context, input types.Create
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
measure, err := prb.Measures.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateMeasureRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -275,10 +282,11 @@ func (r *mutationResolver) UpdateMeasure(ctx context.Context, input types.Update
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
measure, err := prb.Measures.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateMeasureRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -308,7 +316,8 @@ func (r *mutationResolver) ImportMeasure(ctx context.Context, input types.Import
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
var req probo.ImportMeasureRequest
|
||||
if err := json.NewDecoder(input.File.File).Decode(&req.Measures); err != nil {
|
||||
@@ -316,7 +325,7 @@ func (r *mutationResolver) ImportMeasure(ctx context.Context, input types.Import
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
measures, err := prb.Measures.Import(ctx, input.OrganizationID, req)
|
||||
measures, err := prb.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)
|
||||
@@ -338,9 +347,10 @@ func (r *mutationResolver) DeleteMeasure(ctx context.Context, input types.Delete
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.MeasureID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.MeasureID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Measures.Delete(ctx, input.MeasureID)
|
||||
err := prb.Measures.Delete(ctx, scope, input.MeasureID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete measure", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -357,9 +367,10 @@ func (r *mutationResolver) CreateMeasureDocumentMapping(ctx context.Context, inp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.MeasureID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.MeasureID)
|
||||
prb := r.probo
|
||||
|
||||
measure, document, err := prb.Measures.CreateDocumentMapping(ctx, input.MeasureID, input.DocumentID)
|
||||
measure, document, err := prb.Measures.CreateDocumentMapping(ctx, scope, input.MeasureID, input.DocumentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -382,9 +393,10 @@ func (r *mutationResolver) DeleteMeasureDocumentMapping(ctx context.Context, inp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.MeasureID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.MeasureID)
|
||||
prb := r.probo
|
||||
|
||||
measure, document, err := prb.Measures.DeleteDocumentMapping(ctx, input.MeasureID, input.DocumentID)
|
||||
measure, document, err := prb.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)
|
||||
|
||||
@@ -27,7 +27,8 @@ func (r *mutationResolver) CreateObligation(ctx context.Context, input types.Cre
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateObligationRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -43,7 +44,7 @@ func (r *mutationResolver) CreateObligation(ctx context.Context, input types.Cre
|
||||
Type: input.Type,
|
||||
}
|
||||
|
||||
obligation, err := prb.Obligations.Create(ctx, &req)
|
||||
obligation, err := prb.Obligations.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -65,7 +66,8 @@ func (r *mutationResolver) UpdateObligation(ctx context.Context, input types.Upd
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateObligationRequest{
|
||||
ID: input.ID,
|
||||
@@ -81,7 +83,7 @@ func (r *mutationResolver) UpdateObligation(ctx context.Context, input types.Upd
|
||||
Type: input.Type,
|
||||
}
|
||||
|
||||
obligation, err := prb.Obligations.Update(ctx, &req)
|
||||
obligation, err := prb.Obligations.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -103,9 +105,10 @@ func (r *mutationResolver) DeleteObligation(ctx context.Context, input types.Del
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ObligationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ObligationID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Obligations.Delete(ctx, input.ObligationID)
|
||||
err := prb.Obligations.Delete(ctx, scope, input.ObligationID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete obligation", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -122,9 +125,10 @@ func (r *mutationResolver) PublishObligationList(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishObligationList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -200,11 +204,12 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.Obligations.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.Obligations.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count obligations", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -212,7 +217,7 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Obligations.CountForRiskID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -32,7 +32,8 @@ func (r *mutationResolver) UpdateOrganizationContext(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateOrganizationContextRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -43,7 +44,7 @@ func (r *mutationResolver) UpdateOrganizationContext(ctx context.Context, input
|
||||
Customers: gqlutils.UnwrapOmittable(input.Customers),
|
||||
}
|
||||
|
||||
organizationContext, err := prb.Organizations.UpdateContext(ctx, req)
|
||||
organizationContext, err := prb.Organizations.UpdateContext(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -65,9 +66,10 @@ func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organizat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
logoURL, err := prb.Organizations.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
logoURL, err := prb.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)
|
||||
@@ -82,9 +84,10 @@ func (r *organizationResolver) HorizontalLogoURL(ctx context.Context, obj *types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
horizontalLogoURL, err := prb.Organizations.GenerateHorizontalLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
horizontalLogoURL, err := prb.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)
|
||||
@@ -99,9 +102,10 @@ func (r *organizationResolver) Context(ctx context.Context, obj *types.Organizat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
orgContext, err := prb.Organizations.GetContext(ctx, obj.ID)
|
||||
orgContext, err := prb.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)
|
||||
@@ -157,9 +161,10 @@ func (r *organizationResolver) MeasureCategories(ctx context.Context, obj *types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
categories, err := prb.Measures.ListDistinctCategoriesForOrganizationID(ctx, obj.ID)
|
||||
categories, err := prb.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)
|
||||
@@ -232,9 +237,10 @@ func (r *organizationResolver) AssetListDocument(ctx context.Context, obj *types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
assetDocumentID, err := prb.GeneratedDocuments.GetAssetListDocumentID(ctx, obj.ID)
|
||||
assetDocumentID, err := prb.GeneratedDocuments.GetAssetListDocumentID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get asset list document ID: %w", err)
|
||||
}
|
||||
@@ -243,7 +249,7 @@ func (r *organizationResolver) AssetListDocument(ctx context.Context, obj *types
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
doc, err := prb.Documents.Get(ctx, *assetDocumentID)
|
||||
doc, err := prb.Documents.Get(ctx, scope, *assetDocumentID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get asset list document: %w", err)
|
||||
}
|
||||
@@ -257,7 +263,8 @@ func (r *organizationResolver) Assets(ctx context.Context, obj *types.Organizati
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.AssetOrderField]{
|
||||
Field: coredata.AssetOrderFieldCreatedAt,
|
||||
@@ -272,7 +279,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -287,9 +294,10 @@ func (r *organizationResolver) DataListDocument(ctx context.Context, obj *types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
dataDocumentID, err := prb.GeneratedDocuments.GetDataListDocumentID(ctx, obj.ID)
|
||||
dataDocumentID, err := prb.GeneratedDocuments.GetDataListDocumentID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get data export document ID: %w", err)
|
||||
}
|
||||
@@ -298,7 +306,7 @@ func (r *organizationResolver) DataListDocument(ctx context.Context, obj *types.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
doc, err := prb.Documents.Get(ctx, *dataDocumentID)
|
||||
doc, err := prb.Documents.Get(ctx, scope, *dataDocumentID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get data export document: %w", err)
|
||||
}
|
||||
@@ -312,7 +320,8 @@ func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DatumOrderField]{
|
||||
Field: coredata.DatumOrderFieldCreatedAt,
|
||||
@@ -327,7 +336,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -342,7 +351,8 @@ func (r *organizationResolver) Audits(ctx context.Context, obj *types.Organizati
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.AuditOrderField]{
|
||||
Field: coredata.AuditOrderFieldCreatedAt,
|
||||
@@ -357,7 +367,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -372,9 +382,10 @@ func (r *organizationResolver) FindingsDocument(ctx context.Context, obj *types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
findingDocumentID, err := prb.GeneratedDocuments.GetFindingsDocumentID(ctx, obj.ID)
|
||||
findingDocumentID, err := prb.GeneratedDocuments.GetFindingsDocumentID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get finding list document ID: %w", err)
|
||||
}
|
||||
@@ -383,7 +394,7 @@ func (r *organizationResolver) FindingsDocument(ctx context.Context, obj *types.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
doc, err := prb.Documents.Get(ctx, *findingDocumentID)
|
||||
doc, err := prb.Documents.Get(ctx, scope, *findingDocumentID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get finding list document: %w", err)
|
||||
}
|
||||
@@ -397,7 +408,8 @@ func (r *organizationResolver) Findings(ctx context.Context, obj *types.Organiza
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.FindingOrderField]{
|
||||
Field: coredata.FindingOrderFieldCreatedAt,
|
||||
@@ -428,7 +440,7 @@ func (r *organizationResolver) Findings(ctx context.Context, obj *types.Organiza
|
||||
|
||||
findingFilter := coredata.NewFindingFilter(kind, status, priority, ownerID)
|
||||
|
||||
page, err := prb.Findings.ListForOrganizationID(ctx, obj.ID, cursor, findingFilter)
|
||||
page, err := prb.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)
|
||||
@@ -491,7 +503,8 @@ func (r *organizationResolver) SlackConnections(ctx context.Context, obj *types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
slackProvider := coredata.ConnectorProviderSlack
|
||||
filter := coredata.NewConnectorProviderFilter(&slackProvider)
|
||||
@@ -503,7 +516,7 @@ func (r *organizationResolver) SlackConnections(ctx context.Context, obj *types.
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.Connectors.ListForOrganizationID(ctx, obj.ID, cursor, filter)
|
||||
page, err := prb.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)
|
||||
@@ -523,9 +536,10 @@ func (r *organizationResolver) Connectors(ctx context.Context, obj *types.Organi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
connectors, err := prb.Connectors.ListAllForOrganizationID(ctx, obj.ID)
|
||||
connectors, err := prb.Connectors.ListAllForOrganizationID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization connectors: %w", err))
|
||||
}
|
||||
@@ -586,7 +600,8 @@ func (r *organizationResolver) Controls(ctx context.Context, obj *types.Organiza
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -606,7 +621,7 @@ func (r *organizationResolver) Controls(ctx context.Context, obj *types.Organiza
|
||||
controlFilter = coredata.NewControlFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Controls.ListForOrganizationID(ctx, obj.ID, cursor, controlFilter)
|
||||
page, err := prb.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)
|
||||
@@ -621,7 +636,8 @@ func (r *organizationResolver) StatementsOfApplicability(ctx context.Context, ob
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.StatementOfApplicabilityOrderField]{
|
||||
Field: coredata.StatementOfApplicabilityOrderFieldCreatedAt,
|
||||
@@ -636,7 +652,7 @@ func (r *organizationResolver) StatementsOfApplicability(ctx context.Context, ob
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.StatementsOfApplicability.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -651,7 +667,8 @@ func (r *organizationResolver) DataProtectionImpactAssessments(ctx context.Conte
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DataProtectionImpactAssessmentOrderField]{
|
||||
Field: coredata.DataProtectionImpactAssessmentOrderFieldCreatedAt,
|
||||
@@ -667,7 +684,7 @@ func (r *organizationResolver) DataProtectionImpactAssessments(ctx context.Conte
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.DataProtectionImpactAssessments.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -682,9 +699,10 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetDataProtectionImpactAssessmentsDocumentID(ctx, obj.ID)
|
||||
documentID, err := prb.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)
|
||||
@@ -694,7 +712,7 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
document, err := prb.Documents.Get(ctx, scope, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -714,7 +732,8 @@ func (r *organizationResolver) TransferImpactAssessments(ctx context.Context, ob
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TransferImpactAssessmentOrderField]{
|
||||
Field: coredata.TransferImpactAssessmentOrderFieldCreatedAt,
|
||||
@@ -730,7 +749,7 @@ func (r *organizationResolver) TransferImpactAssessments(ctx context.Context, ob
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.TransferImpactAssessments.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -745,9 +764,10 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetTransferImpactAssessmentsDocumentID(ctx, obj.ID)
|
||||
documentID, err := prb.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)
|
||||
@@ -757,7 +777,7 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
document, err := prb.Documents.Get(ctx, scope, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -777,7 +797,8 @@ func (r *organizationResolver) Documents(ctx context.Context, obj *types.Organiz
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{
|
||||
Field: coredata.DocumentOrderFieldTitle,
|
||||
@@ -801,7 +822,7 @@ func (r *organizationResolver) Documents(ctx context.Context, obj *types.Organiz
|
||||
WithStatus(filter.Status)
|
||||
}
|
||||
|
||||
page, err := prb.Documents.ListByOrganizationID(ctx, obj.ID, cursor, documentFilter)
|
||||
page, err := prb.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)
|
||||
@@ -821,7 +842,8 @@ func (r *organizationResolver) Frameworks(ctx context.Context, obj *types.Organi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.FrameworkOrderField]{
|
||||
Field: coredata.FrameworkOrderFieldCreatedAt,
|
||||
@@ -836,7 +858,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -851,7 +873,8 @@ func (r *organizationResolver) Measures(ctx context.Context, obj *types.Organiza
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MeasureOrderField]{
|
||||
Field: coredata.MeasureOrderFieldCreatedAt,
|
||||
@@ -871,7 +894,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, obj.ID, cursor, measureFilter)
|
||||
page, err := prb.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)
|
||||
@@ -886,9 +909,10 @@ func (r *organizationResolver) ObligationsDocument(ctx context.Context, obj *typ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
obligationDocumentID, err := prb.GeneratedDocuments.GetObligationsDocumentID(ctx, obj.ID)
|
||||
obligationDocumentID, err := prb.GeneratedDocuments.GetObligationsDocumentID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get obligation list document ID: %w", err)
|
||||
}
|
||||
@@ -897,7 +921,7 @@ func (r *organizationResolver) ObligationsDocument(ctx context.Context, obj *typ
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
doc, err := prb.Documents.Get(ctx, *obligationDocumentID)
|
||||
doc, err := prb.Documents.Get(ctx, scope, *obligationDocumentID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get obligation list document: %w", err)
|
||||
}
|
||||
@@ -911,7 +935,8 @@ func (r *organizationResolver) Obligations(ctx context.Context, obj *types.Organ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ObligationOrderField]{
|
||||
Field: coredata.ObligationOrderFieldCreatedAt,
|
||||
@@ -927,7 +952,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -942,7 +967,8 @@ func (r *organizationResolver) ProcessingActivities(ctx context.Context, obj *ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ProcessingActivityOrderField]{
|
||||
Field: coredata.ProcessingActivityOrderFieldCreatedAt,
|
||||
@@ -958,7 +984,7 @@ func (r *organizationResolver) ProcessingActivities(ctx context.Context, obj *ty
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.ProcessingActivities.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -973,9 +999,10 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetProcessingActivitiesDocumentID(ctx, obj.ID)
|
||||
documentID, err := prb.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)
|
||||
@@ -985,7 +1012,7 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context,
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
document, err := prb.Documents.Get(ctx, scope, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -1005,7 +1032,8 @@ func (r *organizationResolver) RightsRequests(ctx context.Context, obj *types.Or
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.RightsRequestOrderField]{
|
||||
Field: coredata.RightsRequestOrderFieldCreatedAt,
|
||||
@@ -1021,7 +1049,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -1036,7 +1064,8 @@ func (r *organizationResolver) Risks(ctx context.Context, obj *types.Organizatio
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.RiskOrderField]{
|
||||
Field: coredata.RiskOrderFieldCreatedAt,
|
||||
@@ -1056,7 +1085,7 @@ func (r *organizationResolver) Risks(ctx context.Context, obj *types.Organizatio
|
||||
riskFilter = coredata.NewRiskFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Risks.ListForOrganizationID(ctx, obj.ID, cursor, riskFilter)
|
||||
page, err := prb.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)
|
||||
@@ -1071,9 +1100,10 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetRisksDocumentID(ctx, obj.ID)
|
||||
documentID, err := prb.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)
|
||||
@@ -1083,7 +1113,7 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
document, err := prb.Documents.Get(ctx, scope, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -1163,7 +1193,8 @@ func (r *organizationResolver) Tasks(ctx context.Context, obj *types.Organizatio
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TaskOrderField]{
|
||||
Field: coredata.TaskOrderFieldCreatedAt,
|
||||
@@ -1178,7 +1209,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -1193,9 +1224,10 @@ func (r *organizationResolver) TrustCenter(ctx context.Context, obj *types.Organ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
trustCenter, err := prb.TrustCenters.GetByOrganizationID(ctx, obj.ID)
|
||||
trustCenter, err := prb.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)
|
||||
@@ -1203,7 +1235,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, *trustCenter.NonDisclosureAgreementFileID)
|
||||
file, err = prb.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)
|
||||
@@ -1219,9 +1251,10 @@ func (r *organizationResolver) CustomDomain(ctx context.Context, obj *types.Orga
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
domain, err := prb.CustomDomains.GetOrganizationCustomDomain(ctx, obj.ID)
|
||||
domain, err := prb.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)
|
||||
@@ -1240,7 +1273,8 @@ func (r *organizationResolver) TrustCenterFiles(ctx context.Context, obj *types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TrustCenterFileOrderField]{
|
||||
Field: coredata.TrustCenterFileOrderFieldCreatedAt,
|
||||
@@ -1255,7 +1289,7 @@ func (r *organizationResolver) TrustCenterFiles(ctx context.Context, obj *types.
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
pageResult, err := prb.TrustCenterFiles.ListForOrganizationID(ctx, obj.ID, cursor, &coredata.TrustCenterFileFilter{})
|
||||
pageResult, err := prb.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)
|
||||
@@ -1301,7 +1335,8 @@ func (r *organizationResolver) ThirdParties(ctx context.Context, obj *types.Orga
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: coredata.ThirdPartyOrderFieldCreatedAt,
|
||||
@@ -1318,7 +1353,7 @@ func (r *organizationResolver) ThirdParties(ctx context.Context, obj *types.Orga
|
||||
|
||||
thirdPartyFilter := coredata.NewThirdPartyFilter(nil)
|
||||
|
||||
page, err := prb.ThirdParties.ListForOrganizationID(ctx, obj.ID, cursor, thirdPartyFilter)
|
||||
page, err := prb.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)
|
||||
@@ -1333,9 +1368,10 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
documentID, err := prb.GeneratedDocuments.GetThirdPartiesDocumentID(ctx, obj.ID)
|
||||
documentID, err := prb.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)
|
||||
@@ -1345,7 +1381,7 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *documentID)
|
||||
document, err := prb.Documents.Get(ctx, scope, *documentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -1365,7 +1401,8 @@ func (r *organizationResolver) WebhookSubscriptions(ctx context.Context, obj *ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.WebhookSubscriptionOrderField]{
|
||||
Field: coredata.WebhookSubscriptionOrderFieldCreatedAt,
|
||||
@@ -1380,7 +1417,7 @@ func (r *organizationResolver) WebhookSubscriptions(ctx context.Context, obj *ty
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.WebhookSubscriptions.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -1415,9 +1452,10 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
|
||||
|
||||
return count, nil
|
||||
case *documentVersionResolver:
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.Documents.CountVersionApprovers(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -27,7 +27,8 @@ func (r *mutationResolver) CreateProcessingActivity(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateProcessingActivityRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -52,7 +53,7 @@ func (r *mutationResolver) CreateProcessingActivity(ctx context.Context, input t
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
}
|
||||
|
||||
activity, err := prb.ProcessingActivities.Create(ctx, &req)
|
||||
activity, err := prb.ProcessingActivities.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot create processing activity", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -69,7 +70,8 @@ func (r *mutationResolver) UpdateProcessingActivity(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateProcessingActivityRequest{
|
||||
ID: input.ID,
|
||||
@@ -94,7 +96,7 @@ func (r *mutationResolver) UpdateProcessingActivity(ctx context.Context, input t
|
||||
ThirdPartyIDs: &input.ThirdPartyIds,
|
||||
}
|
||||
|
||||
activity, err := prb.ProcessingActivities.Update(ctx, &req)
|
||||
activity, err := prb.ProcessingActivities.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot update processing activity", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -111,9 +113,10 @@ func (r *mutationResolver) DeleteProcessingActivity(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ProcessingActivityID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ProcessingActivityID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ProcessingActivities.Delete(ctx, input.ProcessingActivityID)
|
||||
err := prb.ProcessingActivities.Delete(ctx, scope, input.ProcessingActivityID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete processing activity", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -130,9 +133,10 @@ func (r *mutationResolver) PublishProcessingActivityList(ctx context.Context, in
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishProcessingActivityList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -207,7 +211,8 @@ func (r *processingActivityResolver) ThirdParties(ctx context.Context, obj *type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: coredata.ThirdPartyOrderFieldCreatedAt,
|
||||
@@ -222,7 +227,7 @@ func (r *processingActivityResolver) ThirdParties(ctx context.Context, obj *type
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.ThirdParties.ListForProcessingActivityID(ctx, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -237,9 +242,10 @@ func (r *processingActivityResolver) DataProtectionImpactAssessment(ctx context.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
dpia, err := prb.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||
dpia, err := prb.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -259,9 +265,10 @@ func (r *processingActivityResolver) TransferImpactAssessment(ctx context.Contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
tia, err := prb.TransferImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||
tia, err := prb.TransferImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -286,11 +293,12 @@ func (r *processingActivityConnectionResolver) TotalCount(ctx context.Context, o
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.ProcessingActivities.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -172,7 +172,8 @@ func handleConnectorComplete(
|
||||
return
|
||||
}
|
||||
|
||||
svc := proboSvc.WithTenant(organizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(organizationID)
|
||||
svc := proboSvc
|
||||
|
||||
var cnnctr *coredata.Connector
|
||||
|
||||
@@ -187,6 +188,7 @@ func handleConnectorComplete(
|
||||
|
||||
cnnctr, err = svc.Connectors.Reconnect(
|
||||
r.Context(),
|
||||
scope,
|
||||
probo.ReconnectConnectorRequest{
|
||||
ConnectorID: connectorID,
|
||||
OrganizationID: organizationID,
|
||||
@@ -263,7 +265,7 @@ func handleConnectorComplete(
|
||||
}
|
||||
}
|
||||
|
||||
cnnctr, err = svc.Connectors.Create(r.Context(), createReq)
|
||||
cnnctr, err = svc.Connectors.Create(r.Context(), scope, createReq)
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot create connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
@@ -357,10 +359,6 @@ func isValidPagerDutySubdomain(s string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *Resolver) ProboService(ctx context.Context, tenantID gid.TenantID) *probo.TenantService {
|
||||
return r.probo.WithTenant(tenantID)
|
||||
}
|
||||
|
||||
func (r *Resolver) Permission(ctx context.Context, obj types.Node, action string) (bool, error) {
|
||||
return r.authorize(ctx, obj.GetID(), action, authz.WithDryRun()) == nil, nil
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateRightsRequestRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -38,7 +39,7 @@ func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types.
|
||||
ActionTaken: input.ActionTaken,
|
||||
}
|
||||
|
||||
rightsRequest, err := prb.RightsRequests.Create(ctx, &req)
|
||||
rightsRequest, err := prb.RightsRequests.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -60,7 +61,8 @@ func (r *mutationResolver) UpdateRightsRequest(ctx context.Context, input types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateRightsRequestRequest{
|
||||
ID: input.ID,
|
||||
@@ -73,7 +75,7 @@ func (r *mutationResolver) UpdateRightsRequest(ctx context.Context, input types.
|
||||
ActionTaken: gqlutils.UnwrapOmittable(input.ActionTaken),
|
||||
}
|
||||
|
||||
rightsRequest, err := prb.RightsRequests.Update(ctx, &req)
|
||||
rightsRequest, err := prb.RightsRequests.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -95,9 +97,10 @@ func (r *mutationResolver) DeleteRightsRequest(ctx context.Context, input types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RightsRequestID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RightsRequestID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.RightsRequests.Delete(ctx, input.RightsRequestID)
|
||||
err := prb.RightsRequests.Delete(ctx, scope, input.RightsRequestID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete rights request", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -114,15 +117,16 @@ func (r *rightsRequestResolver) Organization(ctx context.Context, obj *types.Rig
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
rightsRequest, err := prb.RightsRequests.Get(ctx, obj.ID)
|
||||
rightsRequest, err := prb.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, rightsRequest.OrganizationID)
|
||||
organization, err := prb.Organizations.Get(ctx, scope, rightsRequest.OrganizationID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -147,11 +151,12 @@ func (r *rightsRequestConnectionResolver) TotalCount(ctx context.Context, obj *t
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.RightsRequests.CountByOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -28,10 +28,11 @@ func (r *mutationResolver) CreateRisk(ctx context.Context, input types.CreateRis
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
risk, err := prb.Risks.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateRiskRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -71,10 +72,11 @@ func (r *mutationResolver) UpdateRisk(ctx context.Context, input types.UpdateRis
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
risk, err := prb.Risks.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateRiskRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -110,9 +112,10 @@ func (r *mutationResolver) DeleteRisk(ctx context.Context, input types.DeleteRis
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RiskID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Risks.Delete(ctx, input.RiskID)
|
||||
err := prb.Risks.Delete(ctx, scope, input.RiskID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete risk", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -129,9 +132,10 @@ func (r *mutationResolver) CreateRiskMeasureMapping(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RiskID)
|
||||
prb := r.probo
|
||||
|
||||
risk, measure, err := prb.Risks.CreateMeasureMapping(ctx, input.RiskID, input.MeasureID)
|
||||
risk, measure, err := prb.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)
|
||||
@@ -149,9 +153,10 @@ func (r *mutationResolver) DeleteRiskMeasureMapping(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RiskID)
|
||||
prb := r.probo
|
||||
|
||||
risk, measure, err := prb.Risks.DeleteMeasureMapping(ctx, input.RiskID, input.MeasureID)
|
||||
risk, measure, err := prb.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)
|
||||
@@ -169,9 +174,10 @@ func (r *mutationResolver) CreateRiskDocumentMapping(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RiskID)
|
||||
prb := r.probo
|
||||
|
||||
risk, document, err := prb.Risks.CreateDocumentMapping(ctx, input.RiskID, input.DocumentID)
|
||||
risk, document, err := prb.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)
|
||||
@@ -189,9 +195,10 @@ func (r *mutationResolver) DeleteRiskDocumentMapping(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RiskID)
|
||||
prb := r.probo
|
||||
|
||||
risk, document, err := prb.Risks.DeleteDocumentMapping(ctx, input.RiskID, input.DocumentID)
|
||||
risk, document, err := prb.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)
|
||||
@@ -209,9 +216,10 @@ func (r *mutationResolver) CreateRiskObligationMapping(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RiskID)
|
||||
prb := r.probo
|
||||
|
||||
risk, obligation, err := prb.Risks.CreateObligationMapping(ctx, input.RiskID, input.ObligationID)
|
||||
risk, obligation, err := prb.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)
|
||||
@@ -229,9 +237,10 @@ func (r *mutationResolver) DeleteRiskObligationMapping(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.RiskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.RiskID)
|
||||
prb := r.probo
|
||||
|
||||
risk, obligation, err := prb.Risks.DeleteObligationMapping(ctx, input.RiskID, input.ObligationID)
|
||||
risk, obligation, err := prb.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)
|
||||
@@ -249,9 +258,10 @@ func (r *mutationResolver) PublishRiskList(ctx context.Context, input types.Publ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishRiskList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -326,7 +336,8 @@ func (r *riskResolver) Measures(ctx context.Context, obj *types.Risk, first *int
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MeasureOrderField]{
|
||||
Field: coredata.MeasureOrderFieldCreatedAt,
|
||||
@@ -346,7 +357,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, obj.ID, cursor, measureFilter)
|
||||
page, err := prb.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)
|
||||
@@ -361,7 +372,8 @@ func (r *riskResolver) Documents(ctx context.Context, obj *types.Risk, first *in
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{
|
||||
Field: coredata.DocumentOrderFieldCreatedAt,
|
||||
@@ -384,7 +396,7 @@ func (r *riskResolver) Documents(ctx context.Context, obj *types.Risk, first *in
|
||||
WithClassifications(filter.Classifications)
|
||||
}
|
||||
|
||||
page, err := prb.Documents.ListForRiskID(ctx, obj.ID, cursor, documentFilter)
|
||||
page, err := prb.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)
|
||||
@@ -399,7 +411,8 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ControlOrderField]{
|
||||
Field: coredata.ControlOrderFieldCreatedAt,
|
||||
@@ -419,7 +432,7 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int
|
||||
filters = coredata.NewControlFilter(filter.Query)
|
||||
}
|
||||
|
||||
page, err := prb.Controls.ListForRiskID(ctx, obj.ID, cursor, filters)
|
||||
page, err := prb.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)
|
||||
@@ -434,7 +447,8 @@ func (r *riskResolver) Obligations(ctx context.Context, obj *types.Risk, first *
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ObligationOrderField]{
|
||||
Field: coredata.ObligationOrderFieldCreatedAt,
|
||||
@@ -449,7 +463,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -496,11 +510,12 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *measureResolver:
|
||||
count, err := prb.Risks.CountForMeasureID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
@@ -508,7 +523,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Risks.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -28,10 +28,11 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTas
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
task, err := prb.Tasks.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateTaskRequest{
|
||||
MeasureID: input.MeasureID,
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -68,10 +69,11 @@ func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTas
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TaskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TaskID)
|
||||
prb := r.probo
|
||||
|
||||
task, err := prb.Tasks.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateTaskRequest{
|
||||
TaskID: input.TaskID,
|
||||
Name: input.Name,
|
||||
@@ -106,9 +108,10 @@ func (r *mutationResolver) DeleteTask(ctx context.Context, input types.DeleteTas
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TaskID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TaskID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.Tasks.Delete(ctx, input.TaskID)
|
||||
err := prb.Tasks.Delete(ctx, scope, input.TaskID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete task", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -199,7 +202,8 @@ func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *in
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.EvidenceOrderField]{
|
||||
Field: coredata.EvidenceOrderFieldCreatedAt,
|
||||
@@ -214,7 +218,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -234,11 +238,12 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *measureResolver:
|
||||
count, err := prb.Tasks.CountForMeasureID(ctx, obj.ParentID)
|
||||
count, err := prb.Tasks.CountForMeasureID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -246,7 +251,7 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Tasks.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.Tasks.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
|
||||
@@ -31,10 +31,11 @@ func (r *mutationResolver) CreateThirdParty(ctx context.Context, input types.Cre
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
thirdParty, err := prb.ThirdParties.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateThirdPartyRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -83,10 +84,11 @@ func (r *mutationResolver) UpdateThirdParty(ctx context.Context, input types.Upd
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
thirdParty, err := prb.ThirdParties.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateThirdPartyRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -132,9 +134,10 @@ func (r *mutationResolver) DeleteThirdParty(ctx context.Context, input types.Del
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ThirdParties.Delete(ctx, input.ThirdPartyID)
|
||||
err := prb.ThirdParties.Delete(ctx, scope, input.ThirdPartyID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete thirdParty", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -151,7 +154,8 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateThirdPartyContactRequest{
|
||||
ThirdPartyID: input.ThirdPartyID,
|
||||
@@ -161,7 +165,7 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty
|
||||
Role: input.Role,
|
||||
}
|
||||
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Create(ctx, req)
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Create(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -183,7 +187,8 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateThirdPartyContactRequest{
|
||||
ID: input.ID,
|
||||
@@ -193,7 +198,7 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty
|
||||
Role: gqlutils.UnwrapOmittable(input.Role),
|
||||
}
|
||||
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Update(ctx, req)
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Update(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -215,9 +220,10 @@ func (r *mutationResolver) DeleteThirdPartyContact(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyContactID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyContactID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ThirdPartyContacts.Delete(ctx, input.ThirdPartyContactID)
|
||||
err := prb.ThirdPartyContacts.Delete(ctx, scope, input.ThirdPartyContactID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete thirdParty contact", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -234,7 +240,8 @@ func (r *mutationResolver) CreateThirdPartyService(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateThirdPartyServiceRequest{
|
||||
ThirdPartyID: input.ThirdPartyID,
|
||||
@@ -242,7 +249,7 @@ func (r *mutationResolver) CreateThirdPartyService(ctx context.Context, input ty
|
||||
Description: input.Description,
|
||||
}
|
||||
|
||||
thirdPartyService, err := prb.ThirdPartyServices.Create(ctx, req)
|
||||
thirdPartyService, err := prb.ThirdPartyServices.Create(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -264,7 +271,8 @@ func (r *mutationResolver) UpdateThirdPartyService(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateThirdPartyServiceRequest{
|
||||
ID: input.ID,
|
||||
@@ -272,7 +280,7 @@ func (r *mutationResolver) UpdateThirdPartyService(ctx context.Context, input ty
|
||||
Description: gqlutils.UnwrapOmittable(input.Description),
|
||||
}
|
||||
|
||||
thirdPartyService, err := prb.ThirdPartyServices.Update(ctx, req)
|
||||
thirdPartyService, err := prb.ThirdPartyServices.Update(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -294,9 +302,10 @@ func (r *mutationResolver) DeleteThirdPartyService(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyServiceID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyServiceID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ThirdPartyServices.Delete(ctx, input.ThirdPartyServiceID)
|
||||
err := prb.ThirdPartyServices.Delete(ctx, scope, input.ThirdPartyServiceID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete thirdParty service", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -313,10 +322,11 @@ func (r *mutationResolver) UploadThirdPartyComplianceReport(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyComplianceReport, err := prb.ThirdPartyComplianceReports.Upload(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
input.ThirdPartyID,
|
||||
&probo.ThirdPartyComplianceReportCreateRequest{
|
||||
File: probo.FileUpload{Filename: input.File.Filename, Size: input.File.Size, Content: input.File.File, ContentType: input.File.ContentType},
|
||||
@@ -346,9 +356,10 @@ func (r *mutationResolver) DeleteThirdPartyComplianceReport(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ReportID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ReportID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ThirdPartyComplianceReports.Delete(ctx, input.ReportID)
|
||||
err := prb.ThirdPartyComplianceReports.Delete(ctx, scope, input.ReportID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete thirdParty compliance report", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -365,10 +376,11 @@ func (r *mutationResolver) UploadThirdPartyBusinessAssociateAgreement(ctx contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.Upload(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
input.ThirdPartyID,
|
||||
&probo.ThirdPartyBusinessAssociateAgreementCreateRequest{
|
||||
File: input.File.File,
|
||||
@@ -398,10 +410,11 @@ func (r *mutationResolver) UpdateThirdPartyBusinessAssociateAgreement(ctx contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
input.ThirdPartyID,
|
||||
&probo.ThirdPartyBusinessAssociateAgreementUpdateRequest{
|
||||
ValidFrom: gqlutils.UnwrapOmittable(input.ValidFrom),
|
||||
@@ -429,9 +442,10 @@ func (r *mutationResolver) DeleteThirdPartyBusinessAssociateAgreement(ctx contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ThirdPartyBusinessAssociateAgreements.DeleteByThirdPartyID(ctx, input.ThirdPartyID)
|
||||
err := prb.ThirdPartyBusinessAssociateAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete thirdParty business associate agreement", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -448,10 +462,11 @@ func (r *mutationResolver) UploadThirdPartyDataPrivacyAgreement(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.Upload(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
input.ThirdPartyID,
|
||||
&probo.ThirdPartyDataPrivacyAgreementCreateRequest{
|
||||
File: input.File.File,
|
||||
@@ -481,10 +496,11 @@ func (r *mutationResolver) UpdateThirdPartyDataPrivacyAgreement(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
input.ThirdPartyID,
|
||||
&probo.ThirdPartyDataPrivacyAgreementUpdateRequest{
|
||||
ValidFrom: gqlutils.UnwrapOmittable(input.ValidFrom),
|
||||
@@ -512,9 +528,10 @@ func (r *mutationResolver) DeleteThirdPartyDataPrivacyAgreement(ctx context.Cont
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ThirdPartyDataPrivacyAgreements.DeleteByThirdPartyID(ctx, input.ThirdPartyID)
|
||||
err := prb.ThirdPartyDataPrivacyAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete thirdParty data privacy agreement", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -531,10 +548,11 @@ func (r *mutationResolver) CreateThirdPartyRiskAssessment(ctx context.Context, i
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ThirdPartyID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyRiskAssessment, err := prb.ThirdParties.CreateRiskAssessment(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateThirdPartyRiskAssessmentRequest{
|
||||
ThirdPartyID: input.ThirdPartyID,
|
||||
ExpiresAt: input.ExpiresAt,
|
||||
@@ -564,10 +582,11 @@ func (r *mutationResolver) AssessThirdParty(ctx context.Context, input types.Ass
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
result, err := prb.ThirdParties.Assess(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.AssessThirdPartyRequest{
|
||||
ID: input.ID,
|
||||
WebsiteURL: input.WebsiteURL,
|
||||
@@ -597,9 +616,10 @@ func (r *mutationResolver) PublishThirdPartyList(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishThirdPartyList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.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)
|
||||
@@ -648,7 +668,8 @@ func (r *thirdPartyResolver) ComplianceReports(ctx context.Context, obj *types.T
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyComplianceReportOrderField]{
|
||||
Field: coredata.ThirdPartyComplianceReportOrderFieldReportDate,
|
||||
@@ -663,7 +684,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -678,9 +699,10 @@ func (r *thirdPartyResolver) BusinessAssociateAgreement(ctx context.Context, obj
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.GetByThirdPartyID(ctx, obj.ID)
|
||||
thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.GetByThirdPartyID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, nil
|
||||
@@ -700,9 +722,10 @@ func (r *thirdPartyResolver) DataPrivacyAgreement(ctx context.Context, obj *type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.GetByThirdPartyID(ctx, obj.ID)
|
||||
thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.GetByThirdPartyID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, nil
|
||||
@@ -722,7 +745,8 @@ func (r *thirdPartyResolver) Contacts(ctx context.Context, obj *types.ThirdParty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyContactOrderField]{
|
||||
Field: coredata.ThirdPartyContactOrderFieldCreatedAt,
|
||||
@@ -737,7 +761,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -752,7 +776,8 @@ func (r *thirdPartyResolver) Services(ctx context.Context, obj *types.ThirdParty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyServiceOrderField]{
|
||||
Field: coredata.ThirdPartyServiceOrderFieldCreatedAt,
|
||||
@@ -767,7 +792,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -782,7 +807,8 @@ func (r *thirdPartyResolver) RiskAssessments(ctx context.Context, obj *types.Thi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyRiskAssessmentOrderField]{
|
||||
Field: coredata.ThirdPartyRiskAssessmentOrderFieldCreatedAt,
|
||||
@@ -797,7 +823,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -869,9 +895,10 @@ func (r *thirdPartyBusinessAssociateAgreementResolver) ThirdParty(ctx context.Co
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, obj.ID)
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -889,9 +916,10 @@ func (r *thirdPartyBusinessAssociateAgreementResolver) FileURL(ctx context.Conte
|
||||
return "", err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
fileURL, err := prb.ThirdPartyBusinessAssociateAgreements.GenerateFileURL(ctx, obj.ID, 1*time.Hour)
|
||||
fileURL, err := prb.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)
|
||||
@@ -911,9 +939,10 @@ func (r *thirdPartyComplianceReportResolver) ThirdParty(ctx context.Context, obj
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, obj.ID)
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -933,9 +962,10 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
evidence, err := prb.ThirdPartyComplianceReports.Get(ctx, obj.ID)
|
||||
evidence, err := prb.ThirdPartyComplianceReports.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load evidence", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -945,7 +975,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
file, err := prb.Files.Get(ctx, *evidence.ReportFileId)
|
||||
file, err := prb.Files.Get(ctx, scope, *evidence.ReportFileId)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -970,11 +1000,12 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.ThirdParties.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.ThirdParties.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -982,7 +1013,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
|
||||
return count, nil
|
||||
case *assetResolver:
|
||||
count, err := prb.ThirdParties.CountForAssetID(ctx, obj.ParentID)
|
||||
count, err := prb.ThirdParties.CountForAssetID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -990,7 +1021,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
|
||||
return count, nil
|
||||
case *datumResolver:
|
||||
count, err := prb.ThirdParties.CountForDatumID(ctx, obj.ParentID)
|
||||
count, err := prb.ThirdParties.CountForDatumID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -1010,16 +1041,17 @@ func (r *thirdPartyContactResolver) ThirdParty(ctx context.Context, obj *types.T
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
// Get the thirdParty contact to access the ThirdPartyID
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Get(ctx, obj.ID)
|
||||
thirdPartyContact, err := prb.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, thirdPartyContact.ThirdPartyID)
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, scope, thirdPartyContact.ThirdPartyID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -1044,9 +1076,10 @@ func (r *thirdPartyDataPrivacyAgreementResolver) ThirdParty(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, obj.ID)
|
||||
thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -1066,9 +1099,10 @@ func (r *thirdPartyDataPrivacyAgreementResolver) FileURL(ctx context.Context, ob
|
||||
return "", err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
fileURL, err := prb.ThirdPartyDataPrivacyAgreements.GenerateFileURL(ctx, obj.ID, 1*time.Hour)
|
||||
fileURL, err := prb.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)
|
||||
@@ -1088,9 +1122,10 @@ func (r *thirdPartyRiskAssessmentResolver) ThirdParty(ctx context.Context, obj *
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
thirdParty, err := prb.ThirdParties.GetByRiskAssessmentID(ctx, obj.ID)
|
||||
thirdParty, err := prb.ThirdParties.GetByRiskAssessmentID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
|
||||
@@ -62,10 +62,11 @@ func (r *mutationResolver) UpdateTrustCenter(ctx context.Context, input types.Up
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TrustCenterID)
|
||||
prb := r.probo
|
||||
|
||||
trustCenter, file, err := prb.TrustCenters.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.UpdateTrustCenterRequest{
|
||||
ID: input.TrustCenterID,
|
||||
Active: input.Active,
|
||||
@@ -93,10 +94,11 @@ func (r *mutationResolver) UploadTrustCenterNda(ctx context.Context, input types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TrustCenterID)
|
||||
prb := r.probo
|
||||
|
||||
trustCenter, file, err := prb.TrustCenters.UploadNDA(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.UploadTrustCenterNDARequest{
|
||||
TrustCenterID: input.TrustCenterID,
|
||||
File: input.File.File,
|
||||
@@ -124,9 +126,10 @@ func (r *mutationResolver) DeleteTrustCenterNda(ctx context.Context, input types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TrustCenterID)
|
||||
prb := r.probo
|
||||
|
||||
trustCenter, file, err := prb.TrustCenters.DeleteNDA(ctx, input.TrustCenterID)
|
||||
trustCenter, file, err := prb.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)
|
||||
@@ -143,7 +146,8 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TrustCenterID)
|
||||
prb := r.probo
|
||||
|
||||
req := &probo.UpdateTrustCenterBrandRequest{
|
||||
TrustCenterID: input.TrustCenterID,
|
||||
@@ -183,7 +187,7 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
}
|
||||
}
|
||||
|
||||
trustCenter, file, err := prb.TrustCenters.UpdateTrustCenterBrand(ctx, req)
|
||||
trustCenter, file, err := prb.TrustCenters.UpdateTrustCenterBrand(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -205,7 +209,8 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
var (
|
||||
documentAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
@@ -235,7 +240,7 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
|
||||
}
|
||||
|
||||
access, err := prb.TrustCenterAccesses.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.UpdateTrustCenterAccessRequest{
|
||||
ID: input.ID,
|
||||
DocumentAccesses: documentAccesses,
|
||||
@@ -264,9 +269,10 @@ func (r *mutationResolver) DeleteTrustCenterAccess(ctx context.Context, input ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.TrustCenterAccesses.Delete(ctx, input.ID)
|
||||
err := prb.TrustCenterAccesses.Delete(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete trust center access", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -283,10 +289,11 @@ func (r *mutationResolver) CreateTrustCenterReference(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TrustCenterID)
|
||||
prb := r.probo
|
||||
|
||||
reference, err := prb.TrustCenterReferences.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.CreateTrustCenterReferenceRequest{
|
||||
TrustCenterID: input.TrustCenterID,
|
||||
Name: input.Name,
|
||||
@@ -321,7 +328,8 @@ func (r *mutationResolver) UpdateTrustCenterReference(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := &probo.UpdateTrustCenterReferenceRequest{
|
||||
ID: input.ID,
|
||||
@@ -340,7 +348,7 @@ func (r *mutationResolver) UpdateTrustCenterReference(ctx context.Context, input
|
||||
}
|
||||
}
|
||||
|
||||
reference, err := prb.TrustCenterReferences.Update(ctx, req)
|
||||
reference, err := prb.TrustCenterReferences.Update(ctx, scope, req)
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
@@ -362,9 +370,10 @@ func (r *mutationResolver) DeleteTrustCenterReference(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.TrustCenterReferences.Delete(ctx, input.ID)
|
||||
err := prb.TrustCenterReferences.Delete(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete trust center reference", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -381,10 +390,11 @@ func (r *mutationResolver) CreateComplianceFramework(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TrustCenterID)
|
||||
prb := r.probo
|
||||
|
||||
cf, err := prb.ComplianceFrameworks.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.CreateComplianceFrameworkRequest{
|
||||
TrustCenterID: input.TrustCenterID,
|
||||
FrameworkID: input.FrameworkID,
|
||||
@@ -411,9 +421,10 @@ func (r *mutationResolver) UpdateComplianceFramework(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
cf, err := prb.ComplianceFrameworks.Update(ctx, &probo.UpdateComplianceFrameworkRequest{
|
||||
cf, err := prb.ComplianceFrameworks.Update(ctx, scope, &probo.UpdateComplianceFrameworkRequest{
|
||||
ID: input.ID,
|
||||
Rank: input.Rank,
|
||||
})
|
||||
@@ -438,10 +449,11 @@ func (r *mutationResolver) DeleteComplianceFramework(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ComplianceFrameworks.Delete(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.DeleteComplianceFrameworkRequest{
|
||||
ID: input.ID,
|
||||
},
|
||||
@@ -467,10 +479,11 @@ func (r *mutationResolver) CreateComplianceExternalURL(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.TrustCenterID)
|
||||
prb := r.probo
|
||||
|
||||
item, err := prb.ComplianceExternalURLs.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.CreateComplianceExternalURLRequest{
|
||||
TrustCenterID: input.TrustCenterID,
|
||||
Name: input.Name,
|
||||
@@ -498,9 +511,10 @@ func (r *mutationResolver) UpdateComplianceExternalURL(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
item, err := prb.ComplianceExternalURLs.Update(ctx, &probo.UpdateComplianceExternalURLRequest{
|
||||
item, err := prb.ComplianceExternalURLs.Update(ctx, scope, &probo.UpdateComplianceExternalURLRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
URL: input.URL,
|
||||
@@ -527,9 +541,10 @@ func (r *mutationResolver) DeleteComplianceExternalURL(ctx context.Context, inpu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
if err := prb.ComplianceExternalURLs.Delete(ctx, &probo.DeleteComplianceExternalURLRequest{ID: input.ID}); err != nil {
|
||||
if err := prb.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)
|
||||
}
|
||||
@@ -550,10 +565,11 @@ func (r *mutationResolver) CreateTrustCenterFile(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
file, err := prb.TrustCenterFiles.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.CreateTrustCenterFileRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
@@ -588,10 +604,11 @@ func (r *mutationResolver) UpdateTrustCenterFile(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
file, err := prb.TrustCenterFiles.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&probo.UpdateTrustCenterFileRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
@@ -620,9 +637,10 @@ func (r *mutationResolver) GetTrustCenterFile(ctx context.Context, input types.G
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
file, err := prb.TrustCenterFiles.Get(ctx, input.ID)
|
||||
file, err := prb.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)
|
||||
@@ -639,9 +657,10 @@ func (r *mutationResolver) DeleteTrustCenterFile(ctx context.Context, input type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.TrustCenterFiles.Delete(ctx, input.ID)
|
||||
err := prb.TrustCenterFiles.Delete(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete trust center file", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -658,10 +677,11 @@ func (r *mutationResolver) CreateCustomDomain(ctx context.Context, input types.C
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
domain, err := prb.CustomDomains.CreateCustomDomain(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateCustomDomainRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Domain: input.Domain,
|
||||
@@ -688,11 +708,12 @@ func (r *mutationResolver) DeleteCustomDomain(ctx context.Context, input types.D
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
// TODO Drop this wierd logic
|
||||
// Get the current custom domain ID before deleting
|
||||
domain, err := prb.CustomDomains.GetOrganizationCustomDomain(ctx, input.OrganizationID)
|
||||
domain, err := prb.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)
|
||||
@@ -704,7 +725,7 @@ func (r *mutationResolver) DeleteCustomDomain(ctx context.Context, input types.D
|
||||
|
||||
deletedDomainID := domain.ID
|
||||
|
||||
if err := prb.CustomDomains.DeleteCustomDomain(ctx, input.OrganizationID); err != nil {
|
||||
if err := prb.CustomDomains.DeleteCustomDomain(ctx, scope, input.OrganizationID); err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete custom domain", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
@@ -720,9 +741,10 @@ func (r *trustCenterResolver) LogoFileURL(ctx context.Context, obj *types.TrustC
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
logoURL, err := prb.TrustCenters.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
logoURL, err := prb.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)
|
||||
@@ -737,9 +759,10 @@ func (r *trustCenterResolver) DarkLogoFileURL(ctx context.Context, obj *types.Tr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
logoURL, err := prb.TrustCenters.GenerateDarkLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
logoURL, err := prb.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)
|
||||
@@ -760,9 +783,10 @@ func (r *trustCenterResolver) NdaFileURL(ctx context.Context, obj *types.TrustCe
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
fileURL, err := prb.TrustCenters.GenerateNDAFileURL(ctx, obj.ID, 15*time.Minute)
|
||||
fileURL, err := prb.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)
|
||||
@@ -777,15 +801,16 @@ func (r *trustCenterResolver) Organization(ctx context.Context, obj *types.Trust
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
trustCenter, err := prb.TrustCenters.Get(ctx, obj.ID)
|
||||
trustCenter, err := prb.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, trustCenter.OrganizationID)
|
||||
organization, err := prb.Organizations.Get(ctx, scope, trustCenter.OrganizationID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -805,7 +830,8 @@ func (r *trustCenterResolver) Accesses(ctx context.Context, obj *types.TrustCent
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TrustCenterAccessOrderField]{
|
||||
Field: coredata.TrustCenterAccessOrderFieldCreatedAt,
|
||||
@@ -820,7 +846,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, obj.ID, cursor)
|
||||
result, err := prb.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)
|
||||
@@ -835,7 +861,8 @@ func (r *trustCenterResolver) References(ctx context.Context, obj *types.TrustCe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TrustCenterReferenceOrderField]{
|
||||
Field: coredata.TrustCenterReferenceOrderFieldRank,
|
||||
@@ -850,7 +877,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, obj.ID, cursor)
|
||||
result, err := prb.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)
|
||||
@@ -865,7 +892,8 @@ func (r *trustCenterResolver) ComplianceFrameworks(ctx context.Context, obj *typ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ComplianceFrameworkOrderField]{
|
||||
Field: coredata.ComplianceFrameworkOrderFieldRank,
|
||||
@@ -880,7 +908,7 @@ func (r *trustCenterResolver) ComplianceFrameworks(ctx context.Context, obj *typ
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
result, err := prb.ComplianceFrameworks.ListWithHiddenForTrustCenterID(ctx, obj.ID, cursor)
|
||||
result, err := prb.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)
|
||||
@@ -895,7 +923,8 @@ func (r *trustCenterResolver) ExternalUrls(ctx context.Context, obj *types.Trust
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ComplianceExternalURLOrderField]{
|
||||
Field: coredata.ComplianceExternalURLOrderFieldRank,
|
||||
@@ -910,7 +939,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, obj.ID, cursor)
|
||||
result, err := prb.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)
|
||||
@@ -929,9 +958,10 @@ func (r *trustCenterResolver) MailingList(ctx context.Context, obj *types.TrustC
|
||||
return obj.MailingList, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
ml, err := prb.TrustCenters.GetMailingList(ctx, obj.ID)
|
||||
ml, err := prb.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)
|
||||
@@ -955,9 +985,10 @@ func (r *trustCenterAccessResolver) NdaSignature(ctx context.Context, obj *types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
access, err := prb.TrustCenterAccesses.Get(ctx, obj.ID)
|
||||
access, err := prb.TrustCenterAccesses.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load trust center access: %w", err)
|
||||
}
|
||||
@@ -980,9 +1011,10 @@ func (r *trustCenterAccessResolver) PendingRequestCount(ctx context.Context, obj
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.TrustCenterAccesses.CountPendingRequestDocumentAccesses(ctx, obj.ID)
|
||||
count, err := prb.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)
|
||||
@@ -997,9 +1029,10 @@ func (r *trustCenterAccessResolver) ActiveCount(ctx context.Context, obj *types.
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.TrustCenterAccesses.CountActiveDocumentAccesses(ctx, obj.ID)
|
||||
count, err := prb.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)
|
||||
@@ -1034,7 +1067,8 @@ func (r *trustCenterAccessResolver) AvailableDocumentAccesses(ctx context.Contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TrustCenterDocumentAccessOrderField]{
|
||||
Field: coredata.TrustCenterDocumentAccessOrderFieldCreatedAt,
|
||||
@@ -1049,7 +1083,7 @@ func (r *trustCenterAccessResolver) AvailableDocumentAccesses(ctx context.Contex
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
result, err := prb.TrustCenterAccesses.ListAvailableDocumentAccesses(ctx, obj.ID, cursor)
|
||||
result, err := prb.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)
|
||||
@@ -1073,9 +1107,10 @@ func (r *trustCenterDocumentAccessResolver) Document(ctx context.Context, obj *t
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.TrustCenterAccessID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.TrustCenterAccessID)
|
||||
prb := r.probo
|
||||
|
||||
document, err := prb.Documents.Get(ctx, *obj.DocumentID)
|
||||
document, err := prb.Documents.Get(ctx, scope, *obj.DocumentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -1099,9 +1134,10 @@ func (r *trustCenterDocumentAccessResolver) Report(ctx context.Context, obj *typ
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.TrustCenterAccessID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.TrustCenterAccessID)
|
||||
prb := r.probo
|
||||
|
||||
report, err := prb.Reports.Get(ctx, *obj.ReportID)
|
||||
report, err := prb.Reports.Get(ctx, scope, *obj.ReportID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load report", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -1120,9 +1156,10 @@ func (r *trustCenterDocumentAccessResolver) TrustCenterFile(ctx context.Context,
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.TrustCenterAccessID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.TrustCenterAccessID)
|
||||
prb := r.probo
|
||||
|
||||
trustCenterFile, err := prb.TrustCenterFiles.Get(ctx, *obj.TrustCenterFileID)
|
||||
trustCenterFile, err := prb.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)
|
||||
@@ -1137,9 +1174,10 @@ func (r *trustCenterDocumentAccessConnectionResolver) TotalCount(ctx context.Con
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.TrustCenterAccesses.CountDocumentAccesses(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -1154,9 +1192,10 @@ func (r *trustCenterFileResolver) FileURL(ctx context.Context, obj *types.TrustC
|
||||
return "", err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
fileURL, err := prb.TrustCenterFiles.GenerateFileURL(ctx, obj.ID, 1*time.Hour)
|
||||
fileURL, err := prb.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)
|
||||
@@ -1171,15 +1210,16 @@ func (r *trustCenterFileResolver) Organization(ctx context.Context, obj *types.T
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
trustCenterFile, err := prb.TrustCenterFiles.Get(ctx, obj.ID)
|
||||
trustCenterFile, err := prb.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, trustCenterFile.OrganizationID)
|
||||
organization, err := prb.Organizations.Get(ctx, scope, trustCenterFile.OrganizationID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -1204,9 +1244,10 @@ func (r *trustCenterFileConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.TrustCenterFiles.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -1221,9 +1262,10 @@ func (r *trustCenterReferenceResolver) LogoURL(ctx context.Context, obj *types.T
|
||||
return "", err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
fileURL, err := prb.TrustCenterReferences.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
fileURL, err := prb.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)
|
||||
@@ -1243,9 +1285,10 @@ func (r *trustCenterReferenceConnectionResolver) TotalCount(ctx context.Context,
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.TrustCenterReferences.CountForTrustCenterID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
@@ -26,7 +26,8 @@ func (r *viewerResolver) SignableDocuments(ctx context.Context, obj *types.Viewe
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, organizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(organizationID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{
|
||||
Field: coredata.DocumentOrderFieldCreatedAt,
|
||||
@@ -45,7 +46,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, organizationID, cursor, documentFilter)
|
||||
documentsPage, err := prb.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)
|
||||
@@ -74,13 +75,14 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, id.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
prb := r.probo
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeSignature)
|
||||
|
||||
document, err := prb.Documents.GetWithFilter(ctx, id, documentFilter)
|
||||
document, err := prb.Documents.GetWithFilter(ctx, scope, id, documentFilter)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
@@ -107,7 +109,8 @@ func (r *viewerResolver) ApprovableDocuments(ctx context.Context, obj *types.Vie
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, organizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(organizationID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{
|
||||
Field: coredata.DocumentOrderFieldCreatedAt,
|
||||
@@ -126,7 +129,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, organizationID, cursor, documentFilter)
|
||||
documentsPage, err := prb.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)
|
||||
@@ -155,13 +158,14 @@ func (r *viewerResolver) ApprovableDocument(ctx context.Context, obj *types.View
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, id.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
prb := r.probo
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeApproval)
|
||||
|
||||
document, err := prb.Documents.GetWithFilter(ctx, id, documentFilter)
|
||||
document, err := prb.Documents.GetWithFilter(ctx, scope, id, documentFilter)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
|
||||
@@ -28,10 +28,11 @@ func (r *mutationResolver) CreateWebhookSubscription(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
wc, err := prb.WebhookSubscriptions.Create(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.CreateWebhookSubscriptionRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
EndpointURL: input.EndpointURL,
|
||||
@@ -59,10 +60,11 @@ func (r *mutationResolver) UpdateWebhookSubscription(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
wc, err := prb.WebhookSubscriptions.Update(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
probo.UpdateWebhookSubscriptionRequest{
|
||||
WebhookSubscriptionID: input.ID,
|
||||
EndpointURL: input.EndpointURL,
|
||||
@@ -90,9 +92,10 @@ func (r *mutationResolver) DeleteWebhookSubscription(ctx context.Context, input
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.WebhookSubscriptionID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.WebhookSubscriptionID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.WebhookSubscriptions.Delete(ctx, input.WebhookSubscriptionID)
|
||||
err := prb.WebhookSubscriptions.Delete(ctx, scope, input.WebhookSubscriptionID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete webhook subscription", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -109,9 +112,10 @@ func (r *webhookEventConnectionResolver) TotalCount(ctx context.Context, obj *ty
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
count, err := prb.WebhookSubscriptions.CountEventsForSubscriptionID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
@@ -148,9 +152,10 @@ func (r *webhookSubscriptionResolver) SigningSecret(ctx context.Context, obj *ty
|
||||
return "", err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
signingSecret, err := prb.WebhookSubscriptions.GetSigningSecret(ctx, obj.ID)
|
||||
signingSecret, err := prb.WebhookSubscriptions.GetSigningSecret(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get signing secret", log.Error(err))
|
||||
return "", gqlutils.Internal(ctx)
|
||||
@@ -165,7 +170,8 @@ func (r *webhookSubscriptionResolver) Events(ctx context.Context, obj *types.Web
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.WebhookEventOrderField]{
|
||||
Field: coredata.WebhookEventOrderFieldCreatedAt,
|
||||
@@ -180,7 +186,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, obj.ID, cursor)
|
||||
page, err := prb.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)
|
||||
@@ -200,11 +206,12 @@ func (r *webhookSubscriptionConnectionResolver) TotalCount(ctx context.Context,
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.WebhookSubscriptions.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.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)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,6 @@
|
||||
package mcp_v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
@@ -24,7 +23,6 @@ import (
|
||||
mcpgenmcp "go.probo.inc/mcpgen/mcp"
|
||||
"go.probo.inc/probo/pkg/accessreview"
|
||||
"go.probo.inc/probo/pkg/cookiebanner"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/server/api/authn"
|
||||
@@ -32,10 +30,6 @@ import (
|
||||
"go.probo.inc/probo/pkg/server/api/mcp/v1/server"
|
||||
)
|
||||
|
||||
func (r *Resolver) ProboService(ctx context.Context, objectID gid.GID) *probo.TenantService {
|
||||
return r.proboSvc.WithTenant(objectID.TenantID())
|
||||
}
|
||||
|
||||
func NewMux(logger *log.Logger, proboSvc *probo.Service, iamSvc *iam.Service, accessReviewSvc *accessreview.Service, cookieBannerSvc *cookiebanner.Service, tokenSecret string) *chi.Mux {
|
||||
logger = logger.Named("mcp.v1")
|
||||
|
||||
|
||||
@@ -159,8 +159,7 @@ func SlackHandler(slackSvc *slack.Service, slackSigningSecret string, logger *lo
|
||||
}
|
||||
|
||||
requesterEmail := *initialSlackMessage.RequesterEmail
|
||||
|
||||
tenantSvc := trustSvc.WithTenant(initialSlackMessage.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(initialSlackMessage.OrganizationID)
|
||||
|
||||
var (
|
||||
documentIDs []gid.GID
|
||||
@@ -169,8 +168,6 @@ func SlackHandler(slackSvc *slack.Service, slackSigningSecret string, logger *lo
|
||||
statusAction string
|
||||
)
|
||||
|
||||
tenantSlackSvc := slackSvc.WithTenant(initialSlackMessage.OrganizationID.TenantID())
|
||||
|
||||
// accept_all, reject_all
|
||||
if strings.HasSuffix(action.ActionID, "_all") {
|
||||
currentMessageId, err := gid.ParseGID(action.Value)
|
||||
@@ -179,7 +176,7 @@ func SlackHandler(slackSvc *slack.Service, slackSigningSecret string, logger *lo
|
||||
return
|
||||
}
|
||||
|
||||
documentIDs, reportIDs, fileIDs, err = tenantSlackSvc.SlackMessages.GetSlackMessageDocumentIDs(ctx, currentMessageId)
|
||||
documentIDs, reportIDs, fileIDs, err = slackSvc.GetSlackMessageDocumentIDs(ctx, scope, currentMessageId)
|
||||
if err != nil {
|
||||
logger.ErrorCtx(ctx, "cannot load slack message document ids", log.Error(err))
|
||||
httpserver.RenderJSON(w, http.StatusInternalServerError, SlackInteractiveResponse{Success: false, Message: "internal server error"})
|
||||
@@ -244,8 +241,9 @@ func SlackHandler(slackSvc *slack.Service, slackSigningSecret string, logger *lo
|
||||
|
||||
switch statusAction {
|
||||
case StatusAccept:
|
||||
if err := tenantSvc.TrustCenterAccesses.GrantByIDs(
|
||||
if err := trustSvc.TrustCenterAccesses.GrantByIDs(
|
||||
ctx,
|
||||
scope,
|
||||
initialSlackMessage.OrganizationID,
|
||||
requesterEmail,
|
||||
documentIDs,
|
||||
@@ -258,8 +256,9 @@ func SlackHandler(slackSvc *slack.Service, slackSigningSecret string, logger *lo
|
||||
return
|
||||
}
|
||||
case StatusReject:
|
||||
if err := tenantSvc.TrustCenterAccesses.RejectOrRevokeByIDs(
|
||||
if err := trustSvc.TrustCenterAccesses.RejectOrRevokeByIDs(
|
||||
ctx,
|
||||
scope,
|
||||
initialSlackMessage.OrganizationID,
|
||||
requesterEmail,
|
||||
documentIDs,
|
||||
@@ -278,8 +277,9 @@ func SlackHandler(slackSvc *slack.Service, slackSigningSecret string, logger *lo
|
||||
return
|
||||
}
|
||||
|
||||
if err := tenantSlackSvc.SlackMessages.UpdateSlackAccessMessage(
|
||||
if err := slackSvc.UpdateSlackAccessMessage(
|
||||
ctx,
|
||||
scope,
|
||||
initialSlackMessage.ID,
|
||||
slackPayload.ResponseURL,
|
||||
requesterEmail,
|
||||
|
||||
@@ -41,11 +41,12 @@ func (r *queryResolver) Viewer(ctx context.Context) (*types.Identity, error) {
|
||||
|
||||
// Node is the resolver for the node field.
|
||||
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
trustService := r.TrustService(ctx, id.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
trustService := r.trust
|
||||
|
||||
switch id.EntityType() {
|
||||
case coredata.OrganizationEntityType:
|
||||
organization, err := trustService.Organizations.Get(ctx, id)
|
||||
organization, err := trustService.Organizations.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -56,7 +57,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
case coredata.DocumentEntityType:
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
document, err := trustService.Documents.Get(ctx, trustCenter.OrganizationID, id)
|
||||
document, err := trustService.Documents.Get(ctx, scope, trustCenter.OrganizationID, id)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "node %q not found", id)
|
||||
@@ -74,7 +75,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
return types.NewDocument(document), nil
|
||||
|
||||
case coredata.FrameworkEntityType:
|
||||
framework, err := trustService.Frameworks.Get(ctx, id)
|
||||
framework, err := trustService.Frameworks.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get framework", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -85,7 +86,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
case coredata.ReportEntityType:
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
report, err := trustService.Reports.Get(ctx, trustCenter.OrganizationID, id)
|
||||
report, err := trustService.Reports.Get(ctx, scope, trustCenter.OrganizationID, id)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrReportNotFound) || errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "node %q not found", id)
|
||||
@@ -99,7 +100,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
return types.NewReport(report), nil
|
||||
|
||||
case coredata.AuditEntityType:
|
||||
audit, err := trustService.Audits.Get(ctx, id)
|
||||
audit, err := trustService.Audits.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -108,7 +109,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
return types.NewAudit(audit), nil
|
||||
|
||||
case coredata.ThirdPartyEntityType:
|
||||
thirdParty, err := trustService.ThirdParties.Get(ctx, id)
|
||||
thirdParty, err := trustService.ThirdParties.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -117,7 +118,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
return types.NewSubprocessor(thirdParty), nil
|
||||
|
||||
case coredata.TrustCenterEntityType:
|
||||
trustCenter, err := trustService.TrustCenters.Get(ctx, id)
|
||||
trustCenter, err := trustService.TrustCenters.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get trust center", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -126,7 +127,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
return types.NewTrustCenter(trustCenter), nil
|
||||
|
||||
case coredata.TrustCenterReferenceEntityType:
|
||||
reference, err := trustService.TrustCenterReferences.Get(ctx, id)
|
||||
reference, err := trustService.TrustCenterReferences.Get(ctx, scope, id)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get trust center reference", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -137,7 +138,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
case coredata.TrustCenterFileEntityType:
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, trustCenter.OrganizationID, id)
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, scope, trustCenter.OrganizationID, id)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "node %q not found", id)
|
||||
@@ -159,15 +160,16 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
func (r *queryResolver) CurrentTrustCenter(ctx context.Context) (*types.TrustCenter, error) {
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
org, err := trustService.Organizations.Get(ctx, trustCenter.OrganizationID)
|
||||
org, err := trustService.Organizations.Get(ctx, scope, trustCenter.OrganizationID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
trustCenter, err = trustService.TrustCenters.Get(ctx, trustCenter.ID)
|
||||
trustCenter, err = trustService.TrustCenters.Get(ctx, scope, trustCenter.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get trust center", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
|
||||
@@ -87,9 +87,10 @@ func (r *nonDisclosureAgreementResolver) FileURL(ctx context.Context, obj *types
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
if identity := authn.IdentityFromContext(ctx); identity != nil && r.esign != nil {
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
access, err := trustService.TrustCenterAccesses.GetAccess(ctx, trustCenter.ID, identity.ID)
|
||||
access, err := trustService.TrustCenterAccesses.GetAccess(ctx, scope, trustCenter.ID, identity.ID)
|
||||
if err == nil && access.ElectronicSignatureID != nil {
|
||||
fileURL, err := r.esign.GenerateSignatureFileURL(ctx, *access.ElectronicSignatureID, 15*time.Minute)
|
||||
if err == nil {
|
||||
@@ -100,9 +101,10 @@ func (r *nonDisclosureAgreementResolver) FileURL(ctx context.Context, obj *types
|
||||
}
|
||||
}
|
||||
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
fileURL, err := trustService.TrustCenters.GenerateNDAFileURL(ctx, trustCenter.ID, 15*time.Minute)
|
||||
fileURL, err := trustService.TrustCenters.GenerateNDAFileURL(ctx, scope, trustCenter.ID, 15*time.Minute)
|
||||
if err != nil {
|
||||
return "", gqlutils.Internal(ctx)
|
||||
}
|
||||
@@ -118,9 +120,10 @@ func (r *nonDisclosureAgreementResolver) ViewerSignature(ctx context.Context, ob
|
||||
}
|
||||
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
access, err := trustService.TrustCenterAccesses.GetAccess(ctx, trustCenter.ID, identity.ID)
|
||||
access, err := trustService.TrustCenterAccesses.GetAccess(ctx, scope, trustCenter.ID, identity.ID)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -9,15 +9,17 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/server/api/trust/v1/schema"
|
||||
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
|
||||
)
|
||||
|
||||
// LogoURL is the resolver for the logoUrl field.
|
||||
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
return trustService.Organizations.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
return trustService.Organizations.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour)
|
||||
}
|
||||
|
||||
// Organization returns schema.OrganizationResolver implementation.
|
||||
|
||||
@@ -39,7 +39,6 @@ import (
|
||||
"go.gearno.de/kit/log"
|
||||
"go.probo.inc/probo/pkg/baseurl"
|
||||
"go.probo.inc/probo/pkg/esign"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/mailman"
|
||||
"go.probo.inc/probo/pkg/securecookie"
|
||||
@@ -108,7 +107,3 @@ func NewMux(
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Resolver) TrustService(ctx context.Context, tenantID gid.TenantID) *trust.TenantService {
|
||||
return r.trust.WithTenant(tenantID)
|
||||
}
|
||||
|
||||
@@ -26,15 +26,16 @@ import (
|
||||
|
||||
// Framework is the resolver for the framework field.
|
||||
func (r *auditResolver) Framework(ctx context.Context, obj *types.Audit) (*types.Framework, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
audit, err := trustService.Audits.Get(ctx, obj.ID)
|
||||
audit, err := trustService.Audits.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
framework, err := trustService.Frameworks.Get(ctx, audit.FrameworkID)
|
||||
framework, err := trustService.Frameworks.Get(ctx, scope, audit.FrameworkID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -45,9 +46,10 @@ func (r *auditResolver) Framework(ctx context.Context, obj *types.Audit) (*types
|
||||
|
||||
// Report is the resolver for the report field.
|
||||
func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Report, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
audit, err := trustService.Audits.Get(ctx, obj.ID)
|
||||
audit, err := trustService.Audits.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -59,7 +61,7 @@ func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Re
|
||||
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
report, err := trustService.Reports.Get(ctx, trustCenter.OrganizationID, *audit.ReportID)
|
||||
report, err := trustService.Reports.Get(ctx, scope, trustCenter.OrganizationID, *audit.ReportID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load report", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -70,9 +72,10 @@ func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Re
|
||||
|
||||
// Framework is the resolver for the framework field on ComplianceFramework.
|
||||
func (r *complianceFrameworkResolver) Framework(ctx context.Context, obj *types.ComplianceFramework) (*types.Framework, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
framework, err := trustService.Frameworks.Get(ctx, obj.FrameworkID)
|
||||
framework, err := trustService.Frameworks.Get(ctx, scope, obj.FrameworkID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -83,10 +86,11 @@ func (r *complianceFrameworkResolver) Framework(ctx context.Context, obj *types.
|
||||
|
||||
// IsUserAuthorized is the resolver for the isUserAuthorized field.
|
||||
func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Document) (bool, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
document, err := trustService.Documents.Get(ctx, trustCenter.OrganizationID, obj.ID)
|
||||
document, err := trustService.Documents.Get(ctx, scope, trustCenter.OrganizationID, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return false, gqlutils.NotFoundf(ctx, "document %q not found", obj.ID)
|
||||
@@ -111,7 +115,7 @@ func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Docu
|
||||
}
|
||||
|
||||
documentAccess, err := trustService.TrustCenterAccesses.GetDocumentAccess(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
obj.ID,
|
||||
@@ -134,7 +138,8 @@ func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Docu
|
||||
|
||||
// Access is the resolver for the access field.
|
||||
func (r *documentResolver) Access(ctx context.Context, obj *types.Document) (*types.DocumentAccess, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
@@ -143,7 +148,7 @@ func (r *documentResolver) Access(ctx context.Context, obj *types.Document) (*ty
|
||||
}
|
||||
|
||||
access, err := trustService.TrustCenterAccesses.GetDocumentAccess(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
obj.ID,
|
||||
@@ -172,22 +177,25 @@ func (r *documentResolver) Access(ctx context.Context, obj *types.Document) (*ty
|
||||
|
||||
// LightLogoURL is the resolver for the lightLogoURL field.
|
||||
func (r *frameworkResolver) LightLogoURL(ctx context.Context, obj *types.Framework) (*string, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
return trustService.Frameworks.GenerateLightLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
return trustService.Frameworks.GenerateLightLogoURL(ctx, scope, obj.ID, 1*time.Hour)
|
||||
}
|
||||
|
||||
// DarkLogoURL is the resolver for the darkLogoURL field.
|
||||
func (r *frameworkResolver) DarkLogoURL(ctx context.Context, obj *types.Framework) (*string, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
return trustService.Frameworks.GenerateDarkLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
return trustService.Frameworks.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour)
|
||||
}
|
||||
|
||||
// RequestAllAccesses is the resolver for the requestAllAccesses field.
|
||||
func (r *mutationResolver) RequestAllAccesses(ctx context.Context) (*types.RequestAccessesPayload, error) {
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
if identity == nil {
|
||||
@@ -195,7 +203,7 @@ func (r *mutationResolver) RequestAllAccesses(ctx context.Context) (*types.Reque
|
||||
}
|
||||
|
||||
access, err := trustService.TrustCenterAccesses.Request(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&trust.TrustCenterAccessRequest{
|
||||
TrustCenterID: trustCenter.ID,
|
||||
IdentityID: identity.ID,
|
||||
@@ -219,10 +227,11 @@ func (r *mutationResolver) RequestAllAccesses(ctx context.Context) (*types.Reque
|
||||
|
||||
// ExportDocumentPDF is the resolver for the exportDocumentPDF field.
|
||||
func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.ExportDocumentPDFInput) (*types.ExportDocumentPDFPayload, error) {
|
||||
trustService := r.TrustService(ctx, input.DocumentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.DocumentID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
document, err := trustService.Documents.Get(ctx, trustCenter.OrganizationID, input.DocumentID)
|
||||
document, err := trustService.Documents.Get(ctx, scope, trustCenter.OrganizationID, input.DocumentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "document %q not found", input.DocumentID)
|
||||
@@ -238,7 +247,7 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
pdf, err := trustService.Documents.ExportPDFWithoutWatermark(ctx, input.DocumentID)
|
||||
pdf, err := trustService.Documents.ExportPDFWithoutWatermark(ctx, scope, input.DocumentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot export document PDF", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -255,7 +264,7 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
}
|
||||
|
||||
documentAccess, err := trustService.TrustCenterAccesses.GetDocumentAccess(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
input.DocumentID,
|
||||
@@ -268,7 +277,7 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
return nil, gqlutils.Forbiddenf(ctx, "access denied: no permission to access this document")
|
||||
}
|
||||
|
||||
pdf, err := trustService.Documents.ExportPDF(ctx, input.DocumentID, identity.EmailAddress)
|
||||
pdf, err := trustService.Documents.ExportPDF(ctx, scope, input.DocumentID, identity.EmailAddress)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot export document PDF", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -281,18 +290,18 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
|
||||
// ExportReportPDF is the resolver for the exportReportPDF field.
|
||||
func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.ExportReportPDFInput) (*types.ExportReportPDFPayload, error) {
|
||||
trustService := r.TrustService(ctx, input.ReportID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(input.ReportID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
audit, err := trustService.Audits.GetByReportID(ctx, input.ReportID)
|
||||
audit, err := trustService.Audits.GetByReportID(ctx, scope, input.ReportID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
pdf, err := trustService.Reports.ExportPDFWithoutWatermark(ctx, input.ReportID)
|
||||
pdf, err := trustService.Reports.ExportPDFWithoutWatermark(ctx, scope, input.ReportID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot export report PDF", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -309,7 +318,7 @@ func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.Expo
|
||||
}
|
||||
|
||||
reportAccess, err := trustService.TrustCenterAccesses.GetReportAccess(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
input.ReportID,
|
||||
@@ -322,7 +331,7 @@ func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.Expo
|
||||
return nil, gqlutils.Forbiddenf(ctx, "access denied: no permission to access this report")
|
||||
}
|
||||
|
||||
pdf, err := trustService.Reports.ExportPDF(ctx, input.ReportID, identity.EmailAddress)
|
||||
pdf, err := trustService.Reports.ExportPDF(ctx, scope, input.ReportID, identity.EmailAddress)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot export report PDF", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -336,9 +345,10 @@ func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.Expo
|
||||
// ExportTrustCenterFile is the resolver for the exportTrustCenterFile field.
|
||||
func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input types.ExportTrustCenterFileInput) (*types.ExportTrustCenterFilePayload, error) {
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, trustCenter.OrganizationID, input.TrustCenterFileID)
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, scope, trustCenter.OrganizationID, input.TrustCenterFileID)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "trust center file %q not found", input.TrustCenterFileID)
|
||||
@@ -350,7 +360,7 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
|
||||
}
|
||||
|
||||
if trustCenterFile.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
fileData, mimeType, err := trustService.TrustCenterFiles.ExportFileWithoutWatermark(ctx, input.TrustCenterFileID)
|
||||
fileData, mimeType, err := trustService.TrustCenterFiles.ExportFileWithoutWatermark(ctx, scope, input.TrustCenterFileID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot export trust center file", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -366,7 +376,7 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
|
||||
return nil, gqlutils.Unauthenticatedf(ctx, "unauthenticated")
|
||||
}
|
||||
|
||||
fileAccess, err := trustService.TrustCenterAccesses.GetTrustCenterFileAccess(ctx,
|
||||
fileAccess, err := trustService.TrustCenterAccesses.GetTrustCenterFileAccess(ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
input.TrustCenterFileID,
|
||||
@@ -379,7 +389,7 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
|
||||
return nil, gqlutils.Forbiddenf(ctx, "access denied: no permission to access this file")
|
||||
}
|
||||
|
||||
fileData, mimeType, err := trustService.TrustCenterFiles.ExportFile(ctx, input.TrustCenterFileID, identity.EmailAddress)
|
||||
fileData, mimeType, err := trustService.TrustCenterFiles.ExportFile(ctx, scope, input.TrustCenterFileID, identity.EmailAddress)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot export trust center file", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -393,9 +403,10 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
|
||||
// RequestDocumentAccess is the resolver for the requestDocumentAccess field.
|
||||
func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input types.RequestDocumentAccessInput) (*types.RequestDocumentAccessPayload, error) {
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
document, err := trustService.Documents.Get(ctx, trustCenter.OrganizationID, input.DocumentID)
|
||||
document, err := trustService.Documents.Get(ctx, scope, trustCenter.OrganizationID, input.DocumentID)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrDocumentNotFound) || errors.Is(err, trust.ErrDocumentNotVisible) || errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "document %q not found", input.DocumentID)
|
||||
@@ -423,7 +434,7 @@ func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input type
|
||||
}
|
||||
|
||||
if _, err := trustService.TrustCenterAccesses.Request(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&trust.TrustCenterAccessRequest{
|
||||
TrustCenterID: trustCenter.ID,
|
||||
IdentityID: identity.ID,
|
||||
@@ -444,9 +455,10 @@ func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input type
|
||||
// RequestReportAccess is the resolver for the requestReportAccess field.
|
||||
func (r *mutationResolver) RequestReportAccess(ctx context.Context, input types.RequestReportAccessInput) (*types.RequestReportAccessPayload, error) {
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
audit, err := trustService.Audits.GetByReportID(ctx, input.ReportID)
|
||||
audit, err := trustService.Audits.GetByReportID(ctx, scope, input.ReportID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -465,7 +477,7 @@ func (r *mutationResolver) RequestReportAccess(ctx context.Context, input types.
|
||||
}
|
||||
|
||||
if _, err := trustService.TrustCenterAccesses.Request(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&trust.TrustCenterAccessRequest{
|
||||
TrustCenterID: trustCenter.ID,
|
||||
IdentityID: identity.ID,
|
||||
@@ -486,9 +498,10 @@ func (r *mutationResolver) RequestReportAccess(ctx context.Context, input types.
|
||||
// RequestTrustCenterFileAccess is the resolver for the requestTrustCenterFileAccess field.
|
||||
func (r *mutationResolver) RequestTrustCenterFileAccess(ctx context.Context, input types.RequestTrustCenterFileAccessInput) (*types.RequestFileAccessPayload, error) {
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
trustService := r.TrustService(ctx, trustCenter.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(trustCenter.ID)
|
||||
trustService := r.trust
|
||||
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, trustCenter.OrganizationID, input.TrustCenterFileID)
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, scope, trustCenter.OrganizationID, input.TrustCenterFileID)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "trust center file %q not found", input.TrustCenterFileID)
|
||||
@@ -512,7 +525,7 @@ func (r *mutationResolver) RequestTrustCenterFileAccess(ctx context.Context, inp
|
||||
}
|
||||
|
||||
if _, err := trustService.TrustCenterAccesses.Request(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
&trust.TrustCenterAccessRequest{
|
||||
TrustCenterID: trustCenter.ID,
|
||||
IdentityID: identity.ID,
|
||||
@@ -532,11 +545,11 @@ func (r *mutationResolver) RequestTrustCenterFileAccess(ctx context.Context, inp
|
||||
|
||||
// IsUserAuthorized is the resolver for the isUserAuthorized field.
|
||||
func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report) (bool, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
audit, err := trustService.Audits.GetByReportID(ctx, obj.ID)
|
||||
audit, err := trustService.Audits.GetByReportID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
|
||||
return false, gqlutils.Internal(ctx)
|
||||
@@ -551,7 +564,7 @@ func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report
|
||||
return false, nil
|
||||
}
|
||||
|
||||
reportAccess, err := trustService.TrustCenterAccesses.GetReportAccess(ctx,
|
||||
reportAccess, err := trustService.TrustCenterAccesses.GetReportAccess(ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
obj.ID,
|
||||
@@ -574,7 +587,8 @@ func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report
|
||||
|
||||
// Access is the resolver for the access field.
|
||||
func (r *reportResolver) Access(ctx context.Context, obj *types.Report) (*types.DocumentAccess, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
@@ -583,7 +597,7 @@ func (r *reportResolver) Access(ctx context.Context, obj *types.Report) (*types.
|
||||
}
|
||||
|
||||
access, err := trustService.TrustCenterAccesses.GetReportAccess(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
obj.ID,
|
||||
@@ -612,11 +626,12 @@ func (r *reportResolver) Access(ctx context.Context, obj *types.Report) (*types.
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *subprocessorConnectionResolver) TotalCount(ctx context.Context, obj *types.SubprocessorConnection) (int, error) {
|
||||
trustService := r.TrustService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
trustService := r.trust
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *trustCenterResolver:
|
||||
count, err := trustService.ThirdParties.CountForTrustCenterId(ctx, obj.ParentID)
|
||||
count, err := trustService.ThirdParties.CountForTrustCenterId(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count subprocessors", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
@@ -632,16 +647,18 @@ func (r *subprocessorConnectionResolver) TotalCount(ctx context.Context, obj *ty
|
||||
|
||||
// LogoFileURL is the resolver for the logoFileUrl field.
|
||||
func (r *trustCenterResolver) LogoFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
return trustService.TrustCenters.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
return trustService.TrustCenters.GenerateLogoURL(ctx, scope, obj.ID, 1*time.Hour)
|
||||
}
|
||||
|
||||
// DarkLogoFileURL is the resolver for the darkLogoFileUrl field.
|
||||
func (r *trustCenterResolver) DarkLogoFileURL(ctx context.Context, obj *types.TrustCenter) (*string, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
return trustService.TrustCenters.GenerateDarkLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
return trustService.TrustCenters.GenerateDarkLogoURL(ctx, scope, obj.ID, 1*time.Hour)
|
||||
}
|
||||
|
||||
// NonDisclosureAgreement is the resolver for the nonDisclosureAgreement field.
|
||||
@@ -651,9 +668,10 @@ func (r *trustCenterResolver) NonDisclosureAgreement(ctx context.Context, obj *t
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
file, err := trustService.TrustCenters.GetNDAFile(ctx, obj.ID)
|
||||
file, err := trustService.TrustCenters.GetNDAFile(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load NDA file", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -698,15 +716,15 @@ func (r *trustCenterResolver) Organization(ctx context.Context, obj *types.Trust
|
||||
|
||||
// Documents is the resolver for the documents field.
|
||||
func (r *trustCenterResolver) Documents(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.DocumentConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
pageOrderBy := page.OrderBy[coredata.DocumentOrderField]{
|
||||
Field: coredata.DocumentOrderFieldTitle,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
}
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
documentPage, err := trustService.Documents.ListForOrganizationId(ctx, obj.Organization.ID, cursor)
|
||||
documentPage, err := trustService.Documents.ListForOrganizationId(ctx, scope, obj.Organization.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list public documents", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -717,15 +735,15 @@ func (r *trustCenterResolver) Documents(ctx context.Context, obj *types.TrustCen
|
||||
|
||||
// Audits is the resolver for the audits field.
|
||||
func (r *trustCenterResolver) Audits(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.AuditConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
pageOrderBy := page.OrderBy[coredata.AuditOrderField]{
|
||||
Field: coredata.AuditOrderFieldValidFrom,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
auditPage, err := trustService.Audits.ListForOrganizationId(ctx, obj.Organization.ID, cursor)
|
||||
auditPage, err := trustService.Audits.ListForOrganizationId(ctx, scope, obj.Organization.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list public audits", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -736,15 +754,15 @@ func (r *trustCenterResolver) Audits(ctx context.Context, obj *types.TrustCenter
|
||||
|
||||
// Subprocessors is the resolver for the subprocessors field.
|
||||
func (r *trustCenterResolver) Subprocessors(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.SubprocessorConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: coredata.ThirdPartyOrderFieldName,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
}
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
thirdPartyPage, err := trustService.ThirdParties.ListForOrganizationId(ctx, obj.Organization.ID, cursor)
|
||||
thirdPartyPage, err := trustService.ThirdParties.ListForOrganizationId(ctx, scope, obj.Organization.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list subprocessors", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -755,15 +773,15 @@ func (r *trustCenterResolver) Subprocessors(ctx context.Context, obj *types.Trus
|
||||
|
||||
// References is the resolver for the references field.
|
||||
func (r *trustCenterResolver) References(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TrustCenterReferenceConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
pageOrderBy := page.OrderBy[coredata.TrustCenterReferenceOrderField]{
|
||||
Field: coredata.TrustCenterReferenceOrderFieldRank,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
}
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
referencePage, err := trustService.TrustCenterReferences.ListForTrustCenterID(ctx, obj.ID, cursor)
|
||||
referencePage, err := trustService.TrustCenterReferences.ListForTrustCenterID(ctx, scope, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list public trust center references", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -774,8 +792,8 @@ func (r *trustCenterResolver) References(ctx context.Context, obj *types.TrustCe
|
||||
|
||||
// TrustCenterFiles is the resolver for the trustCenterFiles field.
|
||||
func (r *trustCenterResolver) TrustCenterFiles(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TrustCenterFileConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
pageOrderBy := page.OrderBy[coredata.TrustCenterFileOrderField]{
|
||||
Field: coredata.TrustCenterFileOrderFieldName,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
@@ -789,7 +807,7 @@ func (r *trustCenterResolver) TrustCenterFiles(ctx context.Context, obj *types.T
|
||||
),
|
||||
)
|
||||
|
||||
trustCenterFilePage, err := trustService.TrustCenterFiles.ListForOrganizationId(ctx, obj.Organization.ID, cursor, filter)
|
||||
trustCenterFilePage, err := trustService.TrustCenterFiles.ListForOrganizationId(ctx, scope, obj.Organization.ID, cursor, filter)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list public trust center files", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -800,15 +818,15 @@ func (r *trustCenterResolver) TrustCenterFiles(ctx context.Context, obj *types.T
|
||||
|
||||
// ComplianceFrameworks is the resolver for the complianceFrameworks field.
|
||||
func (r *trustCenterResolver) ComplianceFrameworks(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ComplianceFrameworkConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
pageOrderBy := page.OrderBy[coredata.ComplianceFrameworkOrderField]{
|
||||
Field: coredata.ComplianceFrameworkOrderFieldRank,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
}
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
cfPage, err := trustService.ComplianceFrameworks.ListByTrustCenterID(ctx, obj.ID, cursor)
|
||||
cfPage, err := trustService.ComplianceFrameworks.ListByTrustCenterID(ctx, scope, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list compliance frameworks", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -819,15 +837,15 @@ func (r *trustCenterResolver) ComplianceFrameworks(ctx context.Context, obj *typ
|
||||
|
||||
// ExternalUrls is the resolver for the externalUrls field.
|
||||
func (r *trustCenterResolver) ExternalUrls(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ComplianceExternalURLConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
pageOrderBy := page.OrderBy[coredata.ComplianceExternalURLOrderField]{
|
||||
Field: coredata.ComplianceExternalURLOrderFieldRank,
|
||||
Direction: page.OrderDirectionAsc,
|
||||
}
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
result, err := trustService.ComplianceExternalURLs.ListForTrustCenterID(ctx, obj.ID, cursor)
|
||||
result, err := trustService.ComplianceExternalURLs.ListForTrustCenterID(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)
|
||||
@@ -838,9 +856,10 @@ func (r *trustCenterResolver) ExternalUrls(ctx context.Context, obj *types.Trust
|
||||
|
||||
// Updates is the resolver for the updates field.
|
||||
func (r *trustCenterResolver) Updates(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.MailingListUpdateConnection, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
tc, err := trustService.TrustCenters.Get(ctx, obj.ID)
|
||||
tc, err := trustService.TrustCenters.Get(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load trust center", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -867,11 +886,11 @@ func (r *trustCenterResolver) Updates(ctx context.Context, obj *types.TrustCente
|
||||
|
||||
// IsUserAuthorized is the resolver for the isUserAuthorized field.
|
||||
func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *types.TrustCenterFile) (bool, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, trustCenter.OrganizationID, obj.ID)
|
||||
trustCenterFile, err := trustService.TrustCenterFiles.Get(ctx, scope, trustCenter.OrganizationID, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, trust.ErrTrustCenterFileNotFound) || errors.Is(err, trust.ErrTrustCenterFileNotVisible) {
|
||||
return false, gqlutils.NotFoundf(ctx, "trust center file %q not found", obj.ID)
|
||||
@@ -891,7 +910,7 @@ func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *typ
|
||||
return false, nil
|
||||
}
|
||||
|
||||
fileAccess, err := trustService.TrustCenterAccesses.GetTrustCenterFileAccess(ctx,
|
||||
fileAccess, err := trustService.TrustCenterAccesses.GetTrustCenterFileAccess(ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
obj.ID,
|
||||
@@ -914,7 +933,8 @@ func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *typ
|
||||
|
||||
// Access is the resolver for the access field.
|
||||
func (r *trustCenterFileResolver) Access(ctx context.Context, obj *types.TrustCenterFile) (*types.DocumentAccess, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
trustCenter := compliancepage.CompliancePageFromContext(ctx)
|
||||
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
@@ -923,7 +943,7 @@ func (r *trustCenterFileResolver) Access(ctx context.Context, obj *types.TrustCe
|
||||
}
|
||||
|
||||
access, err := trustService.TrustCenterAccesses.GetTrustCenterFileAccess(
|
||||
ctx,
|
||||
ctx, scope,
|
||||
trustCenter.ID,
|
||||
identity.ID,
|
||||
obj.ID,
|
||||
@@ -952,9 +972,10 @@ func (r *trustCenterFileResolver) Access(ctx context.Context, obj *types.TrustCe
|
||||
|
||||
// LogoURL is the resolver for the logoUrl field.
|
||||
func (r *trustCenterReferenceResolver) LogoURL(ctx context.Context, obj *types.TrustCenterReference) (string, error) {
|
||||
trustService := r.TrustService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
trustService := r.trust
|
||||
|
||||
logoURL, err := trustService.TrustCenterReferences.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
logoURL, err := trustService.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)
|
||||
|
||||
Reference in New Issue
Block a user