@@ -34,6 +34,7 @@ func (r *accessEntryResolver) Campaign(ctx context.Context, obj *types.AccessEnt
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get access review campaign: %w", err))
|
||||
}
|
||||
|
||||
@@ -53,6 +54,7 @@ func (r *accessEntryResolver) AccessSource(ctx context.Context, obj *types.Acces
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -96,12 +98,15 @@ func (r *accessEntryConnectionResolver) TotalCount(ctx context.Context, obj *typ
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access entries: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
count, err := r.accessReview.Entries(scope).CountForCampaignID(ctx, obj.ParentID, obj.Filter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access entries: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
@@ -248,6 +253,7 @@ func (r *accessReviewCampaignResolver) Entries(ctx context.Context, obj *types.A
|
||||
} else {
|
||||
p, err = r.accessReview.Entries(scope).ListForCampaignID(ctx, obj.ID, cursor, filter)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list access entries: %w", err))
|
||||
}
|
||||
@@ -302,6 +308,7 @@ func (r *accessReviewCampaignConnectionResolver) TotalCount(ctx context.Context,
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access review campaigns: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
@@ -335,6 +342,7 @@ func (r *accessReviewCampaignScopeSourceResolver) Entries(ctx context.Context, o
|
||||
}
|
||||
|
||||
sourceID := obj.ID
|
||||
|
||||
return types.NewAccessEntryConnection(p, r, obj.CampaignID, &sourceID, filter), nil
|
||||
}
|
||||
|
||||
@@ -372,6 +380,7 @@ func (r *accessSourceResolver) Connector(ctx context.Context, obj *types.AccessS
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get connector: %w", err))
|
||||
}
|
||||
|
||||
@@ -395,6 +404,7 @@ func (r *accessSourceResolver) ProviderOrganizations(ctx context.Context, obj *t
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return []*types.ProviderOrganization{}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("cannot get connector HTTP client: %w", err)
|
||||
}
|
||||
|
||||
@@ -412,6 +422,7 @@ func (r *accessSourceResolver) ProviderOrganizations(ctx context.Context, obj *t
|
||||
for i, o := range orgs {
|
||||
result[i] = &types.ProviderOrganization{Slug: o.Slug, DisplayName: o.DisplayName}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -437,6 +448,7 @@ func (r *accessSourceResolver) NeedsConfiguration(ctx context.Context, obj *type
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get connector: %w", err))
|
||||
}
|
||||
|
||||
@@ -444,6 +456,7 @@ func (r *accessSourceResolver) NeedsConfiguration(ctx context.Context, obj *type
|
||||
if !ok || !cfg.NeedsPicker {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return cfg.SelectedSlug(dbConnector) == "", nil
|
||||
}
|
||||
|
||||
@@ -460,6 +473,7 @@ func (r *accessSourceResolver) ConnectionStatus(ctx context.Context, obj *types.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return types.AccessSourceConnectionStatusNotApplicable, nil
|
||||
}
|
||||
|
||||
return types.AccessSourceConnectionStatusDisconnected, nil
|
||||
}
|
||||
|
||||
@@ -495,6 +509,7 @@ func (r *accessSourceResolver) SelectedOrganization(ctx context.Context, obj *ty
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot get connector: %w", err))
|
||||
}
|
||||
|
||||
@@ -502,10 +517,12 @@ func (r *accessSourceResolver) SelectedOrganization(ctx context.Context, obj *ty
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
slug := cfg.SelectedSlug(dbConnector)
|
||||
if slug == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &slug, nil
|
||||
}
|
||||
|
||||
@@ -524,6 +541,7 @@ func (r *accessSourceConnectionResolver) TotalCount(ctx context.Context, obj *ty
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot count access sources: %w", err))
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
@@ -568,9 +586,11 @@ func (r *mutationResolver) UpdateAccessSource(ctx context.Context, input types.U
|
||||
if input.Name.IsSet() {
|
||||
req.Name = input.Name.Value()
|
||||
}
|
||||
|
||||
if input.ConnectorID.IsSet() {
|
||||
req.ConnectorID = gqlutils.UnwrapOmittable(input.ConnectorID)
|
||||
}
|
||||
|
||||
if input.CSVData.IsSet() {
|
||||
req.CsvData = gqlutils.UnwrapOmittable(input.CSVData)
|
||||
}
|
||||
@@ -580,6 +600,7 @@ func (r *mutationResolver) UpdateAccessSource(ctx context.Context, input types.U
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot update access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -600,6 +621,7 @@ func (r *mutationResolver) DeleteAccessSource(ctx context.Context, input types.D
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot delete access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -627,6 +649,7 @@ func (r *mutationResolver) ConfigureAccessSource(ctx context.Context, input type
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot configure access source: %w", err))
|
||||
}
|
||||
|
||||
@@ -678,9 +701,11 @@ func (r *mutationResolver) UpdateAccessReviewCampaign(ctx context.Context, input
|
||||
if input.Name.IsSet() {
|
||||
req.Name = input.Name.Value()
|
||||
}
|
||||
|
||||
if input.Description.IsSet() {
|
||||
req.Description = input.Description.Value()
|
||||
}
|
||||
|
||||
if input.FrameworkControls.IsSet() {
|
||||
controls := input.FrameworkControls.Value()
|
||||
req.FrameworkControls = &controls
|
||||
@@ -691,6 +716,7 @@ func (r *mutationResolver) UpdateAccessReviewCampaign(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot update access review campaign: %w", err))
|
||||
}
|
||||
|
||||
@@ -711,6 +737,7 @@ func (r *mutationResolver) DeleteAccessReviewCampaign(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot delete access review campaign: %w", err))
|
||||
}
|
||||
|
||||
@@ -850,6 +877,7 @@ func (r *mutationResolver) RecordAccessEntryDecision(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot record access entry decision: %w", err))
|
||||
}
|
||||
|
||||
@@ -893,6 +921,7 @@ func (r *mutationResolver) RecordAccessEntryDecisions(ctx context.Context, input
|
||||
decisions := make([]accessreview.RecordAccessEntryDecisionRequest, len(input.Decisions))
|
||||
for i, d := range input.Decisions {
|
||||
var decidedByID *gid.GID
|
||||
|
||||
organizationID, err := r.accessReview.ResolveEntryOrganizationID(ctx, d.AccessEntryID)
|
||||
if err == nil {
|
||||
if cached, ok := profileCache[organizationID]; ok {
|
||||
@@ -902,6 +931,7 @@ func (r *mutationResolver) RecordAccessEntryDecisions(ctx context.Context, input
|
||||
if err == nil {
|
||||
decidedByID = &profile.ID
|
||||
}
|
||||
|
||||
profileCache[organizationID] = decidedByID
|
||||
}
|
||||
}
|
||||
@@ -919,6 +949,7 @@ func (r *mutationResolver) RecordAccessEntryDecisions(ctx context.Context, input
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot record access entry decisions: %w", err))
|
||||
}
|
||||
|
||||
@@ -949,6 +980,7 @@ func (r *mutationResolver) FlagAccessEntry(ctx context.Context, input types.Flag
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("cannot flag access entry: %w", err))
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ func (r *assetResolver) Owner(ctx context.Context, obj *types.Asset) (*types.Pro
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -84,7 +85,6 @@ func (r *assetResolver) Organization(ctx context.Context, obj *types.Asset) (*ty
|
||||
|
||||
asset, err := prb.Assets.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load audit", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
@@ -96,6 +96,7 @@ func (r *assetResolver) Organization(ctx context.Context, obj *types.Asset) (*ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -122,10 +123,12 @@ func (r *assetConnectionResolver) TotalCount(ctx context.Context, obj *types.Ass
|
||||
r.logger.ErrorCtx(ctx, "cannot count assets", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -194,6 +197,7 @@ func (r *datumResolver) Organization(ctx context.Context, obj *types.Datum) (*ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -220,10 +224,12 @@ func (r *datumConnectionResolver) TotalCount(ctx context.Context, obj *types.Dat
|
||||
r.logger.ErrorCtx(ctx, "cannot count data", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -247,12 +253,13 @@ func (r *mutationResolver) CreateAsset(ctx context.Context, input types.CreateAs
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create asset", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -285,7 +292,9 @@ func (r *mutationResolver) UpdateAsset(ctx context.Context, input types.UpdateAs
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update asset", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -331,12 +340,13 @@ func (r *mutationResolver) CreateDatum(ctx context.Context, input types.CreateDa
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create datum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -363,12 +373,13 @@ func (r *mutationResolver) UpdateDatum(ctx context.Context, input types.UpdateDa
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update datum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -408,10 +419,13 @@ func (r *mutationResolver) PublishDataList(ctx context.Context, input types.Publ
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish data list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -434,10 +448,13 @@ func (r *mutationResolver) PublishAssetList(ctx context.Context, input types.Pub
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish asset list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func (r *auditResolver) Organization(ctx context.Context, obj *types.Audit) (*ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -60,6 +61,7 @@ func (r *auditResolver) Framework(ctx context.Context, obj *types.Audit) (*types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -85,6 +87,7 @@ func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Re
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -212,6 +215,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *findingResolver:
|
||||
count, err := prb.Audits.CountForFindingID(ctx, obj.ParentID)
|
||||
@@ -219,6 +223,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *controlResolver:
|
||||
count, err := prb.Audits.CountForControlID(ctx, obj.ParentID)
|
||||
@@ -226,6 +231,7 @@ func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.Aud
|
||||
r.logger.ErrorCtx(ctx, "cannot count audits", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
default:
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
@@ -248,6 +254,7 @@ func (r *findingResolver) Organization(ctx context.Context, obj *types.Finding)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get finding organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -303,6 +310,7 @@ func (r *findingResolver) Owner(ctx context.Context, obj *types.Finding) (*types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get finding owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -328,6 +336,7 @@ func (r *findingResolver) Risk(ctx context.Context, obj *types.Finding) (*types.
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get finding risk", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -369,6 +378,7 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F
|
||||
r.logger.ErrorCtx(ctx, "cannot count findings", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *auditResolver:
|
||||
count, err := prb.Findings.CountForAuditID(ctx, obj.ParentID, findingFilter)
|
||||
@@ -376,10 +386,12 @@ func (r *findingConnectionResolver) TotalCount(ctx context.Context, obj *types.F
|
||||
r.logger.ErrorCtx(ctx, "cannot count findings", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver", log.Any("resolver", obj.Resolver))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -406,7 +418,9 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create audit", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -426,7 +440,9 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload audit report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
}
|
||||
@@ -458,7 +474,9 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update audit", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -509,7 +527,9 @@ func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.Up
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload audit report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -566,7 +586,9 @@ func (r *mutationResolver) CreateFinding(ctx context.Context, input types.Create
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create finding", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -603,7 +625,9 @@ func (r *mutationResolver) UpdateFinding(ctx context.Context, input types.Update
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update finding", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -684,10 +708,13 @@ func (r *mutationResolver) PublishFindingList(ctx context.Context, input types.P
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish finding list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
case coredata.ThirdPartyEntityType:
|
||||
@@ -46,6 +47,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdParty(thirdParty), nil
|
||||
}
|
||||
case coredata.FrameworkEntityType:
|
||||
@@ -55,6 +57,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewFramework(framework), nil
|
||||
}
|
||||
case coredata.MeasureEntityType:
|
||||
@@ -64,6 +67,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewMeasure(measure), nil
|
||||
}
|
||||
case coredata.TaskEntityType:
|
||||
@@ -73,6 +77,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewTask(task), nil
|
||||
}
|
||||
case coredata.EvidenceEntityType:
|
||||
@@ -82,6 +87,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewEvidence(evidence), nil
|
||||
}
|
||||
case coredata.DocumentEntityType:
|
||||
@@ -91,6 +97,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDocument(document), nil
|
||||
}
|
||||
case coredata.ControlEntityType:
|
||||
@@ -100,6 +107,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewControl(control), nil
|
||||
}
|
||||
case coredata.RiskEntityType:
|
||||
@@ -109,6 +117,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewRisk(risk), nil
|
||||
}
|
||||
case coredata.RiskAssessmentEntityType:
|
||||
@@ -178,6 +187,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdPartyComplianceReport(thirdPartyComplianceReport), nil
|
||||
}
|
||||
case coredata.ThirdPartyContactEntityType:
|
||||
@@ -187,6 +197,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdPartyContact(thirdPartyContact), nil
|
||||
}
|
||||
case coredata.ThirdPartyServiceEntityType:
|
||||
@@ -196,6 +207,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewThirdPartyService(thirdPartyService), nil
|
||||
}
|
||||
case coredata.DocumentVersionEntityType:
|
||||
@@ -205,6 +217,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDocumentVersion(documentVersion), nil
|
||||
}
|
||||
case coredata.DocumentVersionSignatureEntityType:
|
||||
@@ -214,6 +227,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDocumentVersionSignature(documentVersionSignature), nil
|
||||
}
|
||||
case coredata.AssetEntityType:
|
||||
@@ -223,6 +237,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAsset(asset), nil
|
||||
}
|
||||
case coredata.DatumEntityType:
|
||||
@@ -232,6 +247,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDatum(datum), nil
|
||||
}
|
||||
case coredata.AuditEntityType:
|
||||
@@ -241,6 +257,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAudit(audit), nil
|
||||
}
|
||||
case coredata.FindingEntityType:
|
||||
@@ -250,6 +267,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewFinding(finding), nil
|
||||
}
|
||||
case coredata.ObligationEntityType:
|
||||
@@ -259,6 +277,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewObligation(obligation), nil
|
||||
}
|
||||
case coredata.ReportEntityType:
|
||||
@@ -268,6 +287,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewReport(report), nil
|
||||
}
|
||||
case coredata.ProcessingActivityEntityType:
|
||||
@@ -277,6 +297,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewProcessingActivity(processingActivity), nil
|
||||
}
|
||||
case coredata.DataProtectionImpactAssessmentEntityType:
|
||||
@@ -287,6 +308,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewDataProtectionImpactAssessment(dpia), nil
|
||||
}
|
||||
case coredata.TransferImpactAssessmentEntityType:
|
||||
@@ -297,6 +319,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewTransferImpactAssessment(tia), nil
|
||||
}
|
||||
case coredata.TrustCenterEntityType:
|
||||
@@ -324,6 +347,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewTrustCenterAccess(trustCenterAccess), nil
|
||||
}
|
||||
case coredata.RightsRequestEntityType:
|
||||
@@ -333,6 +357,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewRightsRequest(rightsRequest), nil
|
||||
}
|
||||
case coredata.StatementOfApplicabilityEntityType:
|
||||
@@ -342,6 +367,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewStatementOfApplicability(statementOfApplicability), nil
|
||||
}
|
||||
case coredata.WebhookSubscriptionEntityType:
|
||||
@@ -351,76 +377,91 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewWebhookSubscription(wc), nil
|
||||
}
|
||||
case coredata.AccessReviewCampaignEntityType:
|
||||
action = probo.ActionAccessReviewCampaignGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
campaign, err := r.accessReview.Campaigns(scope).Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAccessReviewCampaign(campaign), nil
|
||||
}
|
||||
case coredata.AccessSourceEntityType:
|
||||
action = probo.ActionAccessSourceGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
source, err := r.accessReview.Sources(scope).Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAccessSource(source), nil
|
||||
}
|
||||
case coredata.AccessEntryEntityType:
|
||||
action = probo.ActionAccessEntryGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
entry, err := r.accessReview.Entries(scope).Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewAccessEntry(entry), nil
|
||||
}
|
||||
case coredata.CookieBannerEntityType:
|
||||
action = probo.ActionCookieBannerGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewCookieBanner(banner), nil
|
||||
}
|
||||
case coredata.CookieCategoryEntityType:
|
||||
action = probo.ActionCookieCategoryGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
category, err := r.cookieBanner.GetCookieCategory(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewCookieCategory(category), nil
|
||||
}
|
||||
case coredata.CookieConsentRecordEntityType:
|
||||
action = probo.ActionCookieConsentRecordList
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
record, err := r.cookieBanner.GetCookieConsentRecord(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewCookieConsentRecord(record), nil
|
||||
}
|
||||
case coredata.CookieBannerVersionEntityType:
|
||||
action = probo.ActionCookieBannerVersionGet
|
||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||
scope := coredata.NewScopeFromObjectID(id)
|
||||
|
||||
version, err := r.cookieBanner.GetCookieBannerVersion(ctx, scope, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.CookieBannerVersion{
|
||||
ID: version.ID,
|
||||
Version: version.Version,
|
||||
@@ -443,6 +484,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load node", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ func handleConnectorInitiate(
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("authentication required"))
|
||||
return
|
||||
}
|
||||
|
||||
session := authn.SessionFromContext(r.Context())
|
||||
if session == nil {
|
||||
httpserver.RenderError(w, http.StatusUnauthorized, fmt.Errorf("authentication required"))
|
||||
@@ -94,12 +95,15 @@ func handleConnectorInitiate(
|
||||
httpserver.RenderError(w, http.StatusBadRequest, fmt.Errorf("cannot reconnect: connector not found"))
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, errInvalidReconnectConnector) {
|
||||
httpserver.RenderError(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
logger.ErrorCtx(r.Context(), "cannot look up existing connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -118,6 +122,7 @@ func handleConnectorInitiate(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot initiate connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -147,6 +152,7 @@ func loadExistingConnector(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return found, nil
|
||||
}
|
||||
|
||||
@@ -158,5 +164,6 @@ func loadExistingConnector(
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return found, err
|
||||
}
|
||||
|
||||
@@ -75,5 +75,6 @@ func providerExtraSettings(provider coredata.ConnectorProvider) []*types.Connect
|
||||
if settings, ok := providerExtraSettingsMap[provider]; ok {
|
||||
return settings
|
||||
}
|
||||
|
||||
return []*types.ConnectorProviderSettingInfo{}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ func (r *connectorResolver) Oauth2Scopes(ctx context.Context, obj *types.Connect
|
||||
if scopes == nil {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
return scopes, nil
|
||||
}
|
||||
|
||||
@@ -49,26 +50,31 @@ func (r *mutationResolver) CreateAPIKeyConnector(ctx context.Context, input type
|
||||
OrganizationID: *input.TallyOrganizationID,
|
||||
}
|
||||
}
|
||||
|
||||
if input.SentryOrganizationSlug != nil {
|
||||
req.SentrySettings = &coredata.SentryConnectorSettings{
|
||||
OrganizationSlug: *input.SentryOrganizationSlug,
|
||||
}
|
||||
}
|
||||
|
||||
if input.SupabaseOrganizationSlug != nil {
|
||||
req.SupabaseSettings = &coredata.SupabaseConnectorSettings{
|
||||
OrganizationSlug: *input.SupabaseOrganizationSlug,
|
||||
}
|
||||
}
|
||||
|
||||
if input.GithubOrganization != nil {
|
||||
req.GitHubSettings = &coredata.GitHubConnectorSettings{
|
||||
Organization: *input.GithubOrganization,
|
||||
}
|
||||
}
|
||||
|
||||
if input.OnePasswordScimBridgeURL != nil {
|
||||
req.OnePasswordSettings = &coredata.OnePasswordConnectorSettings{
|
||||
SCIMBridgeURL: *input.OnePasswordScimBridgeURL,
|
||||
}
|
||||
}
|
||||
|
||||
cnnctr, err := prb.Connectors.Create(ctx, req)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
|
||||
@@ -54,6 +54,7 @@ func (r *applicabilityStatementResolver) Control(ctx context.Context, obj *types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get control", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -80,10 +81,12 @@ func (r *applicabilityStatementConnectionResolver) TotalCount(ctx context.Contex
|
||||
r.logger.ErrorCtx(ctx, "cannot count applicability statements", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for applicability statement connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -102,8 +105,10 @@ func (r *controlResolver) Organization(ctx context.Context, obj *types.Control)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
@@ -161,6 +166,7 @@ func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*t
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -320,6 +326,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *frameworkResolver:
|
||||
count, err := prb.Controls.CountForFrameworkID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -327,6 +334,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *documentResolver:
|
||||
count, err := prb.Controls.CountForDocumentID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -334,6 +342,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *measureResolver:
|
||||
count, err := prb.Controls.CountForMeasureID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -341,6 +350,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Controls.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -348,6 +358,7 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *statementOfApplicabilityResolver:
|
||||
count, err := prb.Controls.CountForStatementOfApplicabilityID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -355,10 +366,12 @@ func (r *controlConnectionResolver) TotalCount(ctx context.Context, obj *types.C
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -390,7 +403,9 @@ func (r *mutationResolver) CreateControl(ctx context.Context, input types.Create
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create control", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -419,7 +434,6 @@ func (r *mutationResolver) UpdateControl(ctx context.Context, input types.Update
|
||||
NotImplementedJustification: gqlutils.UnwrapOmittable(input.NotImplementedJustification),
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -428,7 +442,9 @@ func (r *mutationResolver) UpdateControl(ctx context.Context, input types.Update
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update control", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -491,6 +507,7 @@ func (r *mutationResolver) CreateControlDocumentMapping(ctx context.Context, inp
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create control document mapping", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -696,10 +713,13 @@ func (r *mutationResolver) CreateStatementOfApplicability(ctx context.Context, i
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create statement_of_applicability", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -732,10 +752,13 @@ func (r *mutationResolver) UpdateStatementOfApplicability(ctx context.Context, i
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update statement_of_applicability", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -776,10 +799,13 @@ func (r *mutationResolver) PublishStatementOfApplicability(ctx context.Context,
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish statement of applicability", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -806,7 +832,9 @@ func (r *statementOfApplicabilityResolver) Document(ctx context.Context, obj *ty
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -826,7 +854,9 @@ func (r *statementOfApplicabilityResolver) Organization(ctx context.Context, obj
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -879,10 +909,12 @@ func (r *statementOfApplicabilityConnectionResolver) TotalCount(ctx context.Cont
|
||||
r.logger.ErrorCtx(ctx, "cannot count statements_of_applicability", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@ func (r *cookieBannerResolver) Organization(ctx context.Context, obj *types.Cook
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -124,6 +126,7 @@ func (r *cookieBannerResolver) LatestVersion(ctx context.Context, obj *types.Coo
|
||||
}
|
||||
|
||||
v := versions[0]
|
||||
|
||||
return &types.CookieBannerVersion{
|
||||
ID: v.ID,
|
||||
Version: v.Version,
|
||||
@@ -331,7 +334,9 @@ func (r *cookieCategoryResolver) CookieBanner(ctx context.Context, obj *types.Co
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -446,10 +451,13 @@ func (r *mutationResolver) CreateCookieBanner(ctx context.Context, input types.C
|
||||
if errors.Is(err, cookiebanner.ErrOriginAlreadyInUse) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -482,10 +490,13 @@ func (r *mutationResolver) UpdateCookieBanner(ctx context.Context, input types.U
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -507,7 +518,9 @@ func (r *mutationResolver) DeleteCookieBanner(ctx context.Context, input types.D
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -529,13 +542,17 @@ func (r *mutationResolver) ActivateCookieBanner(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrBannerAlreadyActive) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrOriginAlreadyInUse) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot activate cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -557,10 +574,13 @@ func (r *mutationResolver) DeactivateCookieBanner(ctx context.Context, input typ
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrBannerAlreadyInactive) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot deactivate cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -582,7 +602,9 @@ func (r *mutationResolver) PublishCookieBannerVersion(ctx context.Context, input
|
||||
if errors.Is(err, cookiebanner.ErrNoDraftVersion) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish cookie banner version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -627,13 +649,17 @@ func (r *mutationResolver) CreateCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrCategorySlugAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -678,20 +704,26 @@ func (r *mutationResolver) UpdateCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrCategorySlugAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrPostHogConsentKindInvalid) {
|
||||
return nil, gqlutils.Invalid(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(category.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, category.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -717,7 +749,9 @@ func (r *mutationResolver) DeleteCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -728,14 +762,18 @@ func (r *mutationResolver) DeleteCookieCategory(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, cookiebanner.ErrCannotDeleteSystemCategory) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(bannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, bannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -768,10 +806,13 @@ func (r *mutationResolver) ReorderCookieCategory(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrCategoryNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot reorder cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -801,10 +842,13 @@ func (r *mutationResolver) UpsertCookieBannerTranslation(ctx context.Context, in
|
||||
if errors.Is(err, cookiebanner.ErrBannerNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upsert cookie banner translation", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -855,14 +899,18 @@ func (r *mutationResolver) CreateTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrPatternAlreadyExists) {
|
||||
return nil, gqlutils.Conflictf(ctx, "a pattern with this name already exists in this banner")
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(pattern.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, pattern.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -897,11 +945,14 @@ func (r *mutationResolver) UpdateTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrTrackerPatternNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(pattern.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, pattern.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -927,7 +978,9 @@ func (r *mutationResolver) DeleteTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrTrackerPatternNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -937,11 +990,14 @@ func (r *mutationResolver) DeleteTrackerPattern(ctx context.Context, input types
|
||||
if errors.Is(err, cookiebanner.ErrTrackerPatternNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete tracker pattern", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(bannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, bannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1023,14 +1079,18 @@ func (r *mutationResolver) CreateTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflictf(ctx, "a resource with this origin and path already exists in this banner")
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(resource.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, resource.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1065,14 +1125,18 @@ func (r *mutationResolver) UpdateTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrTrackerResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(resource.CookieBannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, resource.CookieBannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1098,7 +1162,9 @@ func (r *mutationResolver) DeleteTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrTrackerResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1108,11 +1174,14 @@ func (r *mutationResolver) DeleteTrackerResource(ctx context.Context, input type
|
||||
if errors.Is(err, cookiebanner.ErrTrackerResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete tracker resource", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
bannerScope := coredata.NewScopeFromObjectID(bannerID)
|
||||
|
||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, bannerScope, bannerID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
@@ -1180,7 +1249,9 @@ func (r *trackerPatternResolver) CookieCategory(ctx context.Context, obj *types.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1209,8 +1280,10 @@ func (r *trackerPatternResolver) Permission(ctx context.Context, obj *types.Trac
|
||||
func (r *trackerPatternConnectionResolver) TotalCount(ctx context.Context, obj *types.TrackerPatternConnection) (int, error) {
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
|
||||
var count int
|
||||
var err error
|
||||
var (
|
||||
count int
|
||||
err error
|
||||
)
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *cookieCategoryResolver:
|
||||
@@ -1220,6 +1293,7 @@ func (r *trackerPatternConnectionResolver) TotalCount(ctx context.Context, obj *
|
||||
if obj.Filter != nil {
|
||||
filter = filter.WithQuery(obj.Filter.Query).WithSource(obj.Filter.Source).WithTrackerType(obj.Filter.TrackerType)
|
||||
}
|
||||
|
||||
count, err = r.cookieBanner.CountUncategorisedTrackerPatterns(ctx, scope, obj.ParentID, filter)
|
||||
}
|
||||
|
||||
@@ -1244,7 +1318,9 @@ func (r *trackerResourceResolver) CookieCategory(ctx context.Context, obj *types
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie category", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1260,8 +1336,10 @@ func (r *trackerResourceResolver) Permission(ctx context.Context, obj *types.Tra
|
||||
func (r *trackerResourceConnectionResolver) TotalCount(ctx context.Context, obj *types.TrackerResourceConnection) (int, error) {
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
|
||||
var count int
|
||||
var err error
|
||||
var (
|
||||
count int
|
||||
err error
|
||||
)
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *cookieCategoryResolver:
|
||||
@@ -1271,6 +1349,7 @@ func (r *trackerResourceConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
if obj.Filter != nil {
|
||||
filter = filter.WithQuery(obj.Filter.Query).WithResourceType(obj.Filter.Type)
|
||||
}
|
||||
|
||||
count, err = r.cookieBanner.CountUncategorisedTrackerResources(ctx, scope, obj.ParentID, filter)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,9 @@ func (r *cookieConsentRecordResolver) CookieBanner(ctx context.Context, obj *typ
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -53,7 +55,9 @@ func (r *cookieConsentRecordResolver) CookieBannerVersion(ctx context.Context, o
|
||||
if errors.Is(err, cookiebanner.ErrVersionNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get cookie banner version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ func (r *dataProtectionImpactAssessmentResolver) Organization(ctx context.Contex
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -89,10 +91,12 @@ func (r *dataProtectionImpactAssessmentConnectionResolver) TotalCount(ctx contex
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization data protection impact assessments", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -122,7 +126,9 @@ func (r *mutationResolver) CreateDataProtectionImpactAssessment(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create data protection impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -153,7 +159,9 @@ func (r *mutationResolver) UpdateDataProtectionImpactAssessment(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update data protection impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -207,7 +215,9 @@ func (r *mutationResolver) CreateTransferImpactAssessment(ctx context.Context, i
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create transfer impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -238,7 +248,9 @@ func (r *mutationResolver) UpdateTransferImpactAssessment(ctx context.Context, i
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update transfer impact assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -279,10 +291,13 @@ func (r *mutationResolver) PublishDataProtectionImpactAssessmentList(ctx context
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish data protection impact assessment list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -305,10 +320,13 @@ func (r *mutationResolver) PublishTransferImpactAssessmentList(ctx context.Conte
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish transfer impact assessment list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -350,6 +368,7 @@ func (r *transferImpactAssessmentResolver) Organization(ctx context.Context, obj
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -376,10 +395,12 @@ func (r *transferImpactAssessmentConnectionResolver) TotalCount(ctx context.Cont
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization transfer impact assessments", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ func (f *batchFetcher) fetchOrganizations(ctx context.Context, keys []gid.GID) (
|
||||
for _, org := range orgs {
|
||||
result[org.ID] = org
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -117,6 +118,7 @@ func (f *batchFetcher) fetchFrameworks(ctx context.Context, keys []gid.GID) (map
|
||||
for _, v := range frameworks {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -132,6 +134,7 @@ func (f *batchFetcher) fetchControls(ctx context.Context, keys []gid.GID) (map[g
|
||||
for _, v := range controls {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -147,6 +150,7 @@ func (f *batchFetcher) fetchThirdParties(ctx context.Context, keys []gid.GID) (m
|
||||
for _, v := range thirdParties {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -162,6 +166,7 @@ func (f *batchFetcher) fetchDocuments(ctx context.Context, keys []gid.GID) (map[
|
||||
for _, v := range documents {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -177,6 +182,7 @@ func (f *batchFetcher) fetchProfiles(ctx context.Context, keys []gid.GID) (map[g
|
||||
for _, v := range profiles {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -192,6 +198,7 @@ func (f *batchFetcher) fetchRisks(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
for _, v := range risks {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -207,6 +214,7 @@ func (f *batchFetcher) fetchMeasures(ctx context.Context, keys []gid.GID) (map[g
|
||||
for _, v := range measures {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -222,6 +230,7 @@ func (f *batchFetcher) fetchTasks(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
for _, v := range tasks {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -237,6 +246,7 @@ func (f *batchFetcher) fetchFiles(ctx context.Context, keys []gid.GID) (map[gid.
|
||||
for _, v := range files {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -252,6 +262,7 @@ func (f *batchFetcher) fetchReports(ctx context.Context, keys []gid.GID) (map[gi
|
||||
for _, v := range reports {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -267,6 +278,7 @@ func (f *batchFetcher) fetchCookieBanners(ctx context.Context, keys []gid.GID) (
|
||||
for _, v := range banners {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -282,5 +294,6 @@ func (f *batchFetcher) fetchCookieCategories(ctx context.Context, keys []gid.GID
|
||||
for _, v := range categories {
|
||||
result[v.ID] = v
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ func (r *documentResolver) Organization(ctx context.Context, obj *types.Document
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -160,6 +161,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count controls", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Documents.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -167,6 +169,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count documents", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Documents.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -174,6 +177,7 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *measureResolver:
|
||||
count, err := prb.Documents.CountForMeasureID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -181,10 +185,12 @@ func (r *documentConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count documents", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -203,6 +209,7 @@ func (r *documentVersionResolver) Document(ctx context.Context, obj *types.Docum
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -263,16 +270,21 @@ func (r *documentVersionResolver) Signatures(ctx context.Context, obj *types.Doc
|
||||
}
|
||||
}
|
||||
|
||||
var signatureStates []coredata.DocumentVersionSignatureState
|
||||
var activeContract *bool
|
||||
var (
|
||||
signatureStates []coredata.DocumentVersionSignatureState
|
||||
activeContract *bool
|
||||
)
|
||||
|
||||
if filter != nil {
|
||||
if filter.States != nil {
|
||||
signatureStates = filter.States
|
||||
}
|
||||
|
||||
if filter.ActiveContract != nil {
|
||||
activeContract = filter.ActiveContract
|
||||
}
|
||||
}
|
||||
|
||||
signatureFilter := coredata.NewDocumentVersionSignatureFilter(signatureStates, activeContract)
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
@@ -355,6 +367,7 @@ func (r *documentVersionApprovalDecisionResolver) Quorum(ctx context.Context, ob
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approval quorum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -376,6 +389,7 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approval quorum", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -386,6 +400,7 @@ func (r *documentVersionApprovalDecisionResolver) DocumentVersion(ctx context.Co
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -405,6 +420,7 @@ func (r *documentVersionApprovalDecisionResolver) Approver(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approver profile", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -475,6 +491,7 @@ func (r *documentVersionApprovalQuorumResolver) DocumentVersion(ctx context.Cont
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -504,6 +521,7 @@ func (r *documentVersionApprovalQuorumResolver) Decisions(ctx context.Context, o
|
||||
if filter != nil && filter.States != nil {
|
||||
approvalStates = filter.States
|
||||
}
|
||||
|
||||
approvalFilter := coredata.NewDocumentVersionApprovalDecisionFilter(approvalStates)
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
@@ -553,15 +571,18 @@ func (r *documentVersionConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
if obj.Filters != nil {
|
||||
filter = obj.Filters
|
||||
}
|
||||
|
||||
count, err := prb.Documents.CountVersionsForDocumentID(ctx, obj.ParentID, filter)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count document versions", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -580,6 +601,7 @@ func (r *documentVersionSignatureResolver) DocumentVersion(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -601,6 +623,7 @@ func (r *documentVersionSignatureResolver) SignedBy(ctx context.Context, obj *ty
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get people", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -626,15 +649,18 @@ func (r *documentVersionSignatureConnectionResolver) TotalCount(ctx context.Cont
|
||||
if obj.Filters != nil {
|
||||
filter = obj.Filters
|
||||
}
|
||||
|
||||
count, err := prb.Documents.CountSignaturesForVersionID(ctx, obj.ParentID, filter)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count signatures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -653,7 +679,9 @@ func (r *employeeDocumentResolver) Signed(ctx context.Context, obj *types.Employ
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot check if document is signed", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -675,7 +703,9 @@ func (r *employeeDocumentResolver) ApprovalState(ctx context.Context, obj *types
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get viewer approval state", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -706,6 +736,7 @@ func (r *employeeDocumentResolver) Versions(ctx context.Context, obj *types.Empl
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
var filterMode coredata.EmployeeFilterMode
|
||||
|
||||
switch obj.FilterMode {
|
||||
case types.EmployeeDocumentFilterModeSignature:
|
||||
filterMode = coredata.EmployeeFilterModeSignature
|
||||
@@ -782,6 +813,7 @@ func (r *employeeDocumentVersionResolver) ApprovalDecision(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get viewer approval decision", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -821,7 +853,9 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -856,21 +890,25 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
|
||||
DefaultApproverIDs: defaultApproverIDs,
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
}
|
||||
|
||||
if errGenerated, ok := errors.AsType[*probo.ErrDocumentVersionGenerated](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errGenerated)
|
||||
}
|
||||
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -905,13 +943,17 @@ func (r *mutationResolver) DeleteDocumentDraft(ctx context.Context, input types.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errNotDeletable, ok := errors.AsType[*probo.ErrDocumentDraftNotDeletable](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errNotDeletable)
|
||||
}
|
||||
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete document draft", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -933,7 +975,9 @@ func (r *mutationResolver) ArchiveDocument(ctx context.Context, input types.Arch
|
||||
if errArchived, ok := errors.AsType[*probo.ErrDocumentArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errArchived)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot archive document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -955,7 +999,9 @@ func (r *mutationResolver) UnarchiveDocument(ctx context.Context, input types.Un
|
||||
if errNotArchived, ok := errors.AsType[*probo.ErrDocumentNotArchived](err); ok {
|
||||
return nil, gqlutils.Conflict(ctx, errNotArchived)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot unarchive document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -989,6 +1035,7 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
|
||||
if !input.Minor && len(input.ApproverIds) > 0 {
|
||||
action = probo.ActionDocumentVersionRequestApproval
|
||||
}
|
||||
|
||||
if err := r.authorize(ctx, input.DocumentID, action); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1027,6 +1074,7 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1037,6 +1085,7 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
|
||||
if result.Quorum != nil {
|
||||
payload.ApprovalQuorum = types.NewDocumentVersionApprovalQuorum(result.Quorum)
|
||||
}
|
||||
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
@@ -1076,6 +1125,7 @@ func (r *mutationResolver) BulkPublishDocuments(ctx context.Context, input types
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot bulk publish documents", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1118,6 +1168,7 @@ func (r *mutationResolver) VoidDocumentVersionApproval(ctx context.Context, inpu
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot void document version approval", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1256,6 +1307,7 @@ func (r *mutationResolver) GenerateDocumentChangelog(ctx context.Context, input
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot generate document changelog", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1297,6 +1349,7 @@ func (r *mutationResolver) RequestSignature(ctx context.Context, input types.Req
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot request signature", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1342,6 +1395,7 @@ func (r *mutationResolver) BulkRequestSignatures(ctx context.Context, input type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot bulk request signatures", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1384,6 +1438,7 @@ func (r *mutationResolver) CancelSignatureRequest(ctx context.Context, input typ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot cancel signature request", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1408,6 +1463,7 @@ func (r *mutationResolver) SignDocument(ctx context.Context, input types.SignDoc
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot sign document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1459,6 +1515,7 @@ func (r *mutationResolver) ApproveDocumentVersion(ctx context.Context, input typ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot approve document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1500,6 +1557,7 @@ func (r *mutationResolver) RejectDocumentVersion(ctx context.Context, input type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot reject document version", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1567,6 +1625,7 @@ func (r *mutationResolver) ExportEmployeeDocumentVersionPDF(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get employee document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func (r *evidenceResolver) File(ctx context.Context, obj *types.Evidence) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load evidence file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -65,6 +66,7 @@ func (r *evidenceResolver) Task(ctx context.Context, obj *types.Evidence) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load task", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -86,6 +88,7 @@ func (r *evidenceResolver) Measure(ctx context.Context, obj *types.Evidence) (*t
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -112,6 +115,7 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count measure evidence", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *taskResolver:
|
||||
count, err := prb.Evidences.CountForTaskID(ctx, obj.ParentID)
|
||||
@@ -119,10 +123,12 @@ func (r *evidenceConnectionResolver) TotalCount(ctx context.Context, obj *types.
|
||||
r.logger.ErrorCtx(ctx, "cannot count task evidence", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -169,7 +175,9 @@ func (r *mutationResolver) UploadMeasureEvidence(ctx context.Context, input type
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload measure evidence", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ func (r *frameworkResolver) Organization(ctx context.Context, obj *types.Framewo
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -122,10 +123,12 @@ func (r *frameworkConnectionResolver) TotalCount(ctx context.Context, obj *types
|
||||
r.logger.ErrorCtx(ctx, "cannot count frameworks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -148,7 +151,9 @@ func (r *mutationResolver) CreateFramework(ctx context.Context, input types.Crea
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -177,7 +182,9 @@ func (r *mutationResolver) UpdateFramework(ctx context.Context, input types.Upda
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -207,6 +214,7 @@ func (r *mutationResolver) ImportFramework(ctx context.Context, input types.Impo
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot import framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,5 +64,6 @@ func NewGraphQLHandler(
|
||||
|
||||
es := schema.NewExecutableSchema(config)
|
||||
gqlh := gqlutils.NewHandler(es, logger)
|
||||
|
||||
return gqlh
|
||||
}
|
||||
|
||||
@@ -78,10 +78,12 @@ func (r *mailingListSubscriberConnectionResolver) TotalCount(ctx context.Context
|
||||
r.logger.ErrorCtx(ctx, "cannot count mailing list subscribers", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for mailing list subscriber connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -118,7 +120,9 @@ func (r *mutationResolver) CreateMailingListUpdate(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create mailing list update", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -145,13 +149,17 @@ func (r *mutationResolver) UpdateMailingListUpdate(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateAlreadySent) {
|
||||
return nil, gqlutils.Conflictf(ctx, "mailing list update can only be edited when in draft")
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list update not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update mailing list update", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -171,10 +179,13 @@ func (r *mutationResolver) SendMailingListUpdate(ctx context.Context, input type
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateAlreadySent) {
|
||||
return nil, gqlutils.Conflictf(ctx, "mailing list update has already been queued for sending")
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list update not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot queue mailing list update for sending", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -193,7 +204,9 @@ func (r *mutationResolver) DeleteMailingListUpdate(ctx context.Context, input ty
|
||||
if errors.Is(err, mailman.ErrMailingListUpdateNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list update not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete mailing list update", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -238,10 +251,13 @@ func (r *mutationResolver) CreateMailingListSubscriber(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
if errors.Is(err, mailman.ErrSubscriberAlreadyExist) {
|
||||
return nil, gqlutils.Conflictf(ctx, "subscriber already exists in this mailing list")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create mailing list subscriber", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -260,7 +276,9 @@ func (r *mutationResolver) DeleteMailingListSubscriber(ctx context.Context, inpu
|
||||
if errors.Is(err, mailman.ErrSubscriberNotFound) {
|
||||
return nil, gqlutils.NotFoundf(ctx, "mailing list subscriber not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete mailing list subscriber", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *controlResolver:
|
||||
count, err := prb.Measures.CountForControlID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -215,6 +216,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Measures.CountForRiskID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -222,10 +224,12 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M
|
||||
r.logger.ErrorCtx(ctx, "cannot count measures", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -254,7 +258,9 @@ func (r *mutationResolver) CreateMeasure(ctx context.Context, input types.Create
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -285,7 +291,9 @@ func (r *mutationResolver) UpdateMeasure(ctx context.Context, input types.Update
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -358,6 +366,7 @@ func (r *mutationResolver) CreateMeasureDocumentMapping(ctx context.Context, inp
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create measure document mapping", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ func (r *mutationResolver) CreateObligation(ctx context.Context, input types.Cre
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create obligation", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -84,7 +86,9 @@ func (r *mutationResolver) UpdateObligation(ctx context.Context, input types.Upd
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update obligation", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -125,10 +129,13 @@ func (r *mutationResolver) PublishObligationList(ctx context.Context, input type
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish obligation list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -153,6 +160,7 @@ func (r *obligationResolver) Organization(ctx context.Context, obj *types.Obliga
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get obligation organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -174,6 +182,7 @@ func (r *obligationResolver) Owner(ctx context.Context, obj *types.Obligation) (
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get obligation owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -200,6 +209,7 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count obligations", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskResolver:
|
||||
count, err := prb.Obligations.CountForRiskID(ctx, obj.ParentID)
|
||||
@@ -207,10 +217,12 @@ func (r *obligationConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count risk obligations", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ func (r *mutationResolver) UpdateOrganizationContext(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update organization context", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -236,6 +238,7 @@ func (r *organizationResolver) AssetListDocument(ctx context.Context, obj *types
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get asset list document ID: %w", err)
|
||||
}
|
||||
|
||||
if assetDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -290,6 +293,7 @@ func (r *organizationResolver) DataListDocument(ctx context.Context, obj *types.
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get data export document ID: %w", err)
|
||||
}
|
||||
|
||||
if dataDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -374,6 +378,7 @@ func (r *organizationResolver) FindingsDocument(ctx context.Context, obj *types.
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get finding list document ID: %w", err)
|
||||
}
|
||||
|
||||
if findingDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -452,16 +457,20 @@ func (r *organizationResolver) AuditLogEntries(ctx context.Context, obj *types.O
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
coredataFilter := coredata.NewAuditLogEntryFilter()
|
||||
|
||||
if filter != nil {
|
||||
if filter.Action != nil {
|
||||
coredataFilter.WithAction(*filter.Action)
|
||||
}
|
||||
|
||||
if filter.ActorID != nil {
|
||||
coredataFilter.WithActorID(*filter.ActorID)
|
||||
}
|
||||
|
||||
if filter.ResourceType != nil {
|
||||
coredataFilter.WithResourceType(*filter.ResourceType)
|
||||
}
|
||||
|
||||
if filter.ResourceID != nil {
|
||||
coredataFilter.WithResourceID(*filter.ResourceID)
|
||||
}
|
||||
@@ -533,6 +542,7 @@ func (r *organizationResolver) Connectors(ctx context.Context, obj *types.Organi
|
||||
filtered = append(filtered, cnnctr)
|
||||
}
|
||||
}
|
||||
|
||||
connectors = filtered
|
||||
}
|
||||
|
||||
@@ -546,12 +556,15 @@ func (r *organizationResolver) ConnectorProviderInfos(ctx context.Context, obj *
|
||||
}
|
||||
|
||||
var infos []*types.ConnectorProviderInfo
|
||||
|
||||
for _, provider := range coredata.ConnectorProviders() {
|
||||
_, oauthErr := r.connectorRegistry.Get(string(provider))
|
||||
|
||||
scopes := drivers.ProviderOAuth2Scopes(provider)
|
||||
if scopes == nil {
|
||||
scopes = []string{}
|
||||
}
|
||||
|
||||
info := &types.ConnectorProviderInfo{
|
||||
Provider: provider,
|
||||
DisplayName: providerDisplayName(provider),
|
||||
@@ -563,6 +576,7 @@ func (r *organizationResolver) ConnectorProviderInfos(ctx context.Context, obj *
|
||||
}
|
||||
infos = append(infos, info)
|
||||
}
|
||||
|
||||
return infos, nil
|
||||
}
|
||||
|
||||
@@ -675,6 +689,7 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte
|
||||
r.logger.ErrorCtx(ctx, "cannot get DPIA list document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -684,7 +699,9 @@ func (r *organizationResolver) DataProtectionImpactAssessmentsDocument(ctx conte
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load DPIA list document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -735,6 +752,7 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con
|
||||
r.logger.ErrorCtx(ctx, "cannot get TIA list document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -744,7 +762,9 @@ func (r *organizationResolver) TransferImpactAssessmentsDocument(ctx context.Con
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load TIA list document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -872,6 +892,7 @@ func (r *organizationResolver) ObligationsDocument(ctx context.Context, obj *typ
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get obligation list document ID: %w", err)
|
||||
}
|
||||
|
||||
if obligationDocumentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -959,6 +980,7 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context,
|
||||
r.logger.ErrorCtx(ctx, "cannot get processing activities document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -968,7 +990,9 @@ func (r *organizationResolver) ProcessingActivitiesDocument(ctx context.Context,
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load processing activities document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1054,6 +1078,7 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org
|
||||
r.logger.ErrorCtx(ctx, "cannot get risks document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1063,7 +1088,9 @@ func (r *organizationResolver) RisksDocument(ctx context.Context, obj *types.Org
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load risks document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1313,6 +1340,7 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParties document ID", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if documentID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1322,7 +1350,9 @@ func (r *organizationResolver) ThirdPartiesDocument(ctx context.Context, obj *ty
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load thirdParties document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1382,18 +1412,22 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
|
||||
r.logger.ErrorCtx(ctx, "cannot count profiles", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *documentVersionResolver:
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
count, err := prb.Documents.CountVersionApprovers(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count document version approvers", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for profile connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -137,10 +137,13 @@ func (r *mutationResolver) PublishProcessingActivityList(ctx context.Context, in
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish processing activity list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -165,6 +168,7 @@ func (r *processingActivityResolver) Organization(ctx context.Context, obj *type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -190,6 +194,7 @@ func (r *processingActivityResolver) DataProtectionOfficer(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get data protection officer", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -239,7 +244,9 @@ func (r *processingActivityResolver) DataProtectionImpactAssessment(ctx context.
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get processing activity dpia", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -259,7 +266,9 @@ func (r *processingActivityResolver) TransferImpactAssessment(ctx context.Contex
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get processing activity tia", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -286,10 +295,12 @@ func (r *processingActivityConnectionResolver) TotalCount(ctx context.Context, o
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization processing activities", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,14 @@ func probeConnection(ctx context.Context, httpClient *http.Client, probeURL stri
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create probe request: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("probe request failed: %w", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
|
||||
@@ -162,6 +162,7 @@ func handleConnectorComplete(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot complete connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -196,6 +197,7 @@ func handleConnectorComplete(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot reconnect connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -218,6 +220,7 @@ func handleConnectorComplete(
|
||||
// token response body.
|
||||
subdomain = state.ProviderMetadata["subdomain"]
|
||||
}
|
||||
|
||||
// The subdomain comes from an attacker-influenceable
|
||||
// callback parameter; refuse anything that isn't a valid
|
||||
// DNS label so it cannot be smuggled into URLs or logs.
|
||||
@@ -225,8 +228,10 @@ func handleConnectorComplete(
|
||||
logger.WarnCtx(r.Context(), "rejecting invalid pagerduty subdomain",
|
||||
log.String("provider", string(connectorProvider)),
|
||||
)
|
||||
|
||||
subdomain = ""
|
||||
}
|
||||
|
||||
if subdomain != "" {
|
||||
createReq.PagerDutySettings = &coredata.PagerDutyConnectorSettings{
|
||||
Subdomain: subdomain,
|
||||
@@ -250,6 +255,7 @@ func handleConnectorComplete(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if teamID != "" {
|
||||
createReq.VercelSettings = &coredata.VercelConnectorSettings{
|
||||
TeamID: teamID,
|
||||
@@ -261,6 +267,7 @@ func handleConnectorComplete(
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot create connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -273,8 +280,10 @@ func handleConnectorComplete(
|
||||
parsedURL, err := url.Parse(redirectURL)
|
||||
if err != nil {
|
||||
logger.ErrorCtx(r.Context(), "cannot parse redirect URL", log.Error(err))
|
||||
|
||||
parsedURL, _ = url.Parse(baseURL.WithPath("/organizations/" + organizationID.String()).MustString())
|
||||
}
|
||||
|
||||
q := parsedURL.Query()
|
||||
q.Set("connector_id", cnnctr.ID.String())
|
||||
q.Set("provider", string(connectorProvider))
|
||||
@@ -296,11 +305,13 @@ func handleConnectorOAuth2Error(
|
||||
|
||||
provider := "unknown"
|
||||
redirectURL := baseURL.String()
|
||||
|
||||
if stateToken := query.Get("state"); stateToken != "" {
|
||||
if payload, err := connector.DecodeOAuth2StatePayload(stateToken); err == nil {
|
||||
if payload.Data.Provider != "" {
|
||||
provider = payload.Data.Provider
|
||||
}
|
||||
|
||||
if payload.Data.ContinueURL != "" {
|
||||
redirectURL = payload.Data.ContinueURL
|
||||
}
|
||||
@@ -331,6 +342,7 @@ func isValidPagerDutySubdomain(s string) bool {
|
||||
if s == "" || len(s) > 63 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, c := range s {
|
||||
switch {
|
||||
case c >= 'a' && c <= 'z':
|
||||
@@ -341,6 +353,7 @@ func isValidPagerDutySubdomain(s string) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ func (r *mutationResolver) CreateRightsRequest(ctx context.Context, input types.
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create rights request", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -76,7 +78,9 @@ func (r *mutationResolver) UpdateRightsRequest(ctx context.Context, input types.
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update rights request", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -123,7 +127,9 @@ func (r *rightsRequestResolver) Organization(ctx context.Context, obj *types.Rig
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@ func (r *mutationResolver) CreateRisk(ctx context.Context, input types.CreateRis
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create risk", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -91,7 +93,9 @@ func (r *mutationResolver) UpdateRisk(ctx context.Context, input types.UpdateRis
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update risk", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -252,10 +256,13 @@ func (r *mutationResolver) PublishRiskList(ctx context.Context, input types.Publ
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish risk list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -284,6 +291,7 @@ func (r *riskResolver) Owner(ctx context.Context, obj *types.Risk) (*types.Profi
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -305,6 +313,7 @@ func (r *riskResolver) Organization(ctx context.Context, obj *types.Risk) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -404,6 +413,7 @@ func (r *riskResolver) Controls(ctx context.Context, obj *types.Risk, first *int
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
var filters = coredata.NewControlFilter(nil)
|
||||
if filter != nil {
|
||||
filters = coredata.NewControlFilter(filter.Query)
|
||||
@@ -490,6 +500,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Risks.CountForOrganizationID(ctx, obj.ParentID, obj.Filters)
|
||||
@@ -497,6 +508,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
r.logger.ErrorCtx(ctx, "cannot count risks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *riskAssessmentScenarioResolver:
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
@@ -509,6 +521,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTas
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create task", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -87,7 +89,9 @@ func (r *mutationResolver) UpdateTask(ctx context.Context, input types.UpdateTas
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update task", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -134,6 +138,7 @@ func (r *taskResolver) AssignedTo(ctx context.Context, obj *types.Task) (*types.
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get assigned to", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -155,6 +160,7 @@ func (r *taskResolver) Organization(ctx context.Context, obj *types.Task) (*type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -180,6 +186,7 @@ func (r *taskResolver) Measure(ctx context.Context, obj *types.Task) (*types.Mea
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get measure", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -206,6 +213,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)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list task evidences", log.Error(err))
|
||||
@@ -235,6 +243,7 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task
|
||||
r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *organizationResolver:
|
||||
count, err := prb.Tasks.CountForOrganizationID(ctx, obj.ParentID)
|
||||
@@ -242,10 +251,12 @@ func (r *taskConnectionResolver) TotalCount(ctx context.Context, obj *types.Task
|
||||
r.logger.ErrorCtx(ctx, "cannot count tasks", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -66,9 +66,12 @@ func (r *mutationResolver) CreateThirdParty(ctx context.Context, input types.Cre
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return &types.CreateThirdPartyPayload{
|
||||
ThirdPartyEdge: types.NewThirdPartyEdge(thirdParty, coredata.ThirdPartyOrderFieldName),
|
||||
}, nil
|
||||
@@ -112,7 +115,9 @@ func (r *mutationResolver) UpdateThirdParty(ctx context.Context, input types.Upd
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -161,7 +166,9 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty contact", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -191,7 +198,9 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty contact", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -238,7 +247,9 @@ func (r *mutationResolver) CreateThirdPartyService(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty service", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -266,7 +277,9 @@ func (r *mutationResolver) UpdateThirdPartyService(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty service", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -316,7 +329,9 @@ func (r *mutationResolver) UploadThirdPartyComplianceReport(ctx context.Context,
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload thirdParty compliance report", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -366,7 +381,9 @@ func (r *mutationResolver) UploadThirdPartyBusinessAssociateAgreement(ctx contex
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload thirdParty business associate agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -395,7 +412,9 @@ func (r *mutationResolver) UpdateThirdPartyBusinessAssociateAgreement(ctx contex
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty business associate agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -445,7 +464,9 @@ func (r *mutationResolver) UploadThirdPartyDataPrivacyAgreement(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload thirdParty data privacy agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -474,7 +495,9 @@ func (r *mutationResolver) UpdateThirdPartyDataPrivacyAgreement(ctx context.Cont
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update thirdParty data privacy agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -524,7 +547,9 @@ func (r *mutationResolver) CreateThirdPartyRiskAssessment(ctx context.Context, i
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create thirdParty risk assessment", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -555,6 +580,7 @@ func (r *mutationResolver) AssessThirdParty(ctx context.Context, input types.Ass
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot assess thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -578,10 +604,13 @@ func (r *mutationResolver) PublishThirdPartyList(ctx context.Context, input type
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
|
||||
return nil, gqlutils.Invalid(ctx, errMinor)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot publish thirdParty list", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -606,6 +635,7 @@ func (r *thirdPartyResolver) Organization(ctx context.Context, obj *types.ThirdP
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -657,6 +687,7 @@ func (r *thirdPartyResolver) BusinessAssociateAgreement(ctx context.Context, obj
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty business associate agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -678,6 +709,7 @@ func (r *thirdPartyResolver) DataPrivacyAgreement(ctx context.Context, obj *type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty data privacy agreement", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -793,6 +825,7 @@ func (r *thirdPartyResolver) BusinessOwner(ctx context.Context, obj *types.Third
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get business owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -818,6 +851,7 @@ func (r *thirdPartyResolver) SecurityOwner(ctx context.Context, obj *types.Third
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get security owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -886,6 +920,7 @@ func (r *thirdPartyComplianceReportResolver) ThirdParty(ctx context.Context, obj
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -917,6 +952,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load evidence file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -943,6 +979,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *assetResolver:
|
||||
count, err := prb.ThirdParties.CountForAssetID(ctx, obj.ParentID)
|
||||
@@ -950,6 +987,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
case *datumResolver:
|
||||
count, err := prb.ThirdParties.CountForDatumID(ctx, obj.ParentID)
|
||||
@@ -957,10 +995,12 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
|
||||
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver")
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -986,6 +1026,7 @@ func (r *thirdPartyContactResolver) ThirdParty(ctx context.Context, obj *types.T
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1012,6 +1053,7 @@ func (r *thirdPartyDataPrivacyAgreementResolver) ThirdParty(ctx context.Context,
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1055,6 +1097,7 @@ func (r *thirdPartyRiskAssessmentResolver) ThirdParty(ctx context.Context, obj *
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1081,6 +1124,7 @@ func (r *thirdPartyServiceResolver) ThirdParty(ctx context.Context, obj *types.T
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get thirdParty", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ func (r *complianceFrameworkResolver) Framework(ctx context.Context, obj *types.
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -75,7 +76,9 @@ func (r *mutationResolver) UpdateTrustCenter(ctx context.Context, input types.Up
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -104,7 +107,9 @@ func (r *mutationResolver) UploadTrustCenterNda(ctx context.Context, input types
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot upload trust center NDA", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -148,6 +153,7 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
logoFile := input.LogoFile.Value()
|
||||
if logoFile == nil {
|
||||
var nilFile *probo.FileUpload
|
||||
|
||||
req.LogoFile = &nilFile
|
||||
} else {
|
||||
fileUpload := &probo.FileUpload{
|
||||
@@ -164,6 +170,7 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
darkLogoFile := input.DarkLogoFile.Value()
|
||||
if darkLogoFile == nil {
|
||||
var nilFile *probo.FileUpload
|
||||
|
||||
req.DarkLogoFile = &nilFile
|
||||
} else {
|
||||
fileUpload := &probo.FileUpload{
|
||||
@@ -181,7 +188,9 @@ func (r *mutationResolver) UpdateTrustCenterBrand(ctx context.Context, input typ
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center brand", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -198,27 +207,33 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
var documentAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
var reportAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
var fileAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
var (
|
||||
documentAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
reportAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
fileAccesses []probo.UpdateTrustCenterDocumentAccessRequest
|
||||
)
|
||||
|
||||
for _, documentAccess := range input.Documents {
|
||||
documentAccesses = append(documentAccesses, probo.UpdateTrustCenterDocumentAccessRequest{
|
||||
ID: documentAccess.ID,
|
||||
Status: documentAccess.Status,
|
||||
})
|
||||
}
|
||||
|
||||
for _, reportAccess := range input.Reports {
|
||||
reportAccesses = append(reportAccesses, probo.UpdateTrustCenterDocumentAccessRequest{
|
||||
ID: reportAccess.ID,
|
||||
Status: reportAccess.Status,
|
||||
})
|
||||
}
|
||||
|
||||
for _, fileAccess := range input.TrustCenterFiles {
|
||||
fileAccesses = append(fileAccesses, probo.UpdateTrustCenterDocumentAccessRequest{
|
||||
ID: fileAccess.ID,
|
||||
Status: fileAccess.Status,
|
||||
})
|
||||
}
|
||||
|
||||
access, err := prb.TrustCenterAccesses.Update(
|
||||
ctx,
|
||||
&probo.UpdateTrustCenterAccessRequest{
|
||||
@@ -232,7 +247,9 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center access", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -287,7 +304,9 @@ func (r *mutationResolver) CreateTrustCenterReference(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create trust center reference", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -326,7 +345,9 @@ func (r *mutationResolver) UpdateTrustCenterReference(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center reference", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -373,7 +394,9 @@ func (r *mutationResolver) CreateComplianceFramework(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create compliance framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -398,7 +421,9 @@ func (r *mutationResolver) UpdateComplianceFramework(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update compliance framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -425,7 +450,9 @@ func (r *mutationResolver) DeleteComplianceFramework(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete compliance framework", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -454,7 +481,9 @@ func (r *mutationResolver) CreateComplianceExternalURL(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create compliance external URL", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -481,7 +510,9 @@ func (r *mutationResolver) UpdateComplianceExternalURL(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update compliance external URL", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -502,7 +533,9 @@ func (r *mutationResolver) DeleteComplianceExternalURL(ctx context.Context, inpu
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete compliance external URL", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -538,7 +571,9 @@ func (r *mutationResolver) CreateTrustCenterFile(ctx context.Context, input type
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create trust center file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -568,7 +603,9 @@ func (r *mutationResolver) UpdateTrustCenterFile(ctx context.Context, input type
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update trust center file", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -634,7 +671,9 @@ func (r *mutationResolver) CreateCustomDomain(ctx context.Context, input types.C
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create custom domain", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -753,6 +792,7 @@ func (r *trustCenterResolver) Organization(ctx context.Context, obj *types.Trust
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -956,6 +996,7 @@ func (r *trustCenterAccessResolver) ActiveCount(ctx context.Context, obj *types.
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionTrustCenterAccessGet); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
count, err := prb.TrustCenterAccesses.CountActiveDocumentAccesses(ctx, obj.ID)
|
||||
@@ -980,6 +1021,7 @@ func (r *trustCenterAccessResolver) Profile(ctx context.Context, obj *types.Trus
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get profile", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1040,6 +1082,7 @@ func (r *trustCenterDocumentAccessResolver) Document(ctx context.Context, obj *t
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1143,6 +1186,7 @@ func (r *trustCenterFileResolver) Organization(ctx context.Context, obj *types.T
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -1167,6 +1211,7 @@ func (r *trustCenterFileConnectionResolver) TotalCount(ctx context.Context, obj
|
||||
r.logger.ErrorCtx(ctx, "cannot count trust center files", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -108,9 +108,13 @@ func NewAccessReviewCampaignScopeSource(
|
||||
status := coredata.AccessReviewCampaignSourceFetchStatusQueued
|
||||
fetchedAccountsCount := 0
|
||||
attemptCount := 0
|
||||
var lastError *string
|
||||
var fetchStartedAt *time.Time
|
||||
var fetchCompletedAt *time.Time
|
||||
|
||||
var (
|
||||
lastError *string
|
||||
fetchStartedAt *time.Time
|
||||
fetchCompletedAt *time.Time
|
||||
)
|
||||
|
||||
if fetch != nil {
|
||||
status = fetch.Status
|
||||
fetchedAccountsCount = fetch.FetchedAccountsCount
|
||||
|
||||
@@ -33,13 +33,16 @@ func TestNewAccessReviewCampaignScopeSource_DefaultFetchState(t *testing.T) {
|
||||
}
|
||||
|
||||
campaignID := gid.New(tenantID, coredata.AccessReviewCampaignEntityType)
|
||||
|
||||
got := NewAccessReviewCampaignScopeSource(campaignID, source, nil)
|
||||
if got.FetchStatus != coredata.AccessReviewCampaignSourceFetchStatusQueued {
|
||||
t.Fatalf("fetch status = %q, want QUEUED", got.FetchStatus)
|
||||
}
|
||||
|
||||
if got.FetchedAccountsCount != 0 {
|
||||
t.Fatalf("fetched accounts count = %d, want 0", got.FetchedAccountsCount)
|
||||
}
|
||||
|
||||
if got.AttemptCount != 0 {
|
||||
t.Fatalf("attempt count = %d, want 0", got.AttemptCount)
|
||||
}
|
||||
@@ -66,16 +69,20 @@ func TestNewAccessReviewCampaignScopeSource_UsesFetchState(t *testing.T) {
|
||||
}
|
||||
|
||||
campaignID := gid.New(tenantID, coredata.AccessReviewCampaignEntityType)
|
||||
|
||||
got := NewAccessReviewCampaignScopeSource(campaignID, source, fetch)
|
||||
if got.FetchStatus != coredata.AccessReviewCampaignSourceFetchStatusFailed {
|
||||
t.Fatalf("fetch status = %q, want FAILED", got.FetchStatus)
|
||||
}
|
||||
|
||||
if got.FetchedAccountsCount != 42 {
|
||||
t.Fatalf("fetched accounts count = %d, want 42", got.FetchedAccountsCount)
|
||||
}
|
||||
|
||||
if got.AttemptCount != 3 {
|
||||
t.Fatalf("attempt count = %d, want 3", got.AttemptCount)
|
||||
}
|
||||
|
||||
if got.LastError == nil || *got.LastError != errMsg {
|
||||
t.Fatalf("last error = %v, want %q", got.LastError, errMsg)
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ func NewComplianceExternalURLConnection(
|
||||
for i := range edges {
|
||||
edges[i] = NewComplianceExternalURLEdge(p.Data[i], p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &ComplianceExternalURLConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
|
||||
@@ -65,6 +65,7 @@ func NewCookieCategory(c *coredata.CookieCategory) *CookieCategory {
|
||||
if gcmConsentTypes == nil {
|
||||
gcmConsentTypes = []string{}
|
||||
}
|
||||
|
||||
return &CookieCategory{
|
||||
ID: c.ID,
|
||||
CookieBanner: &CookieBanner{
|
||||
|
||||
@@ -62,6 +62,7 @@ func NewEvidenceEdge(e *coredata.Evidence, orderBy coredata.EvidenceOrderField)
|
||||
|
||||
func NewEvidence(e *coredata.Evidence) *Evidence {
|
||||
var urlPtr *string = nil
|
||||
|
||||
if e.URL != "" {
|
||||
urlCopy := e.URL
|
||||
urlPtr = &urlCopy
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
func NewPageInfo[T page.Paginable[O], O page.OrderField](p *page.Page[T, O]) *PageInfo {
|
||||
data := pageinfo.NewPageInfo(p)
|
||||
|
||||
return &PageInfo{
|
||||
HasNextPage: data.HasNextPage,
|
||||
HasPreviousPage: data.HasPreviousPage,
|
||||
|
||||
@@ -51,6 +51,7 @@ func NewSlackConnection(c *coredata.Connector) *SlackConnection {
|
||||
if settings.Channel != "" {
|
||||
conn.Channel = &settings.Channel
|
||||
}
|
||||
|
||||
if settings.ChannelID != "" {
|
||||
conn.ChannelID = &settings.ChannelID
|
||||
}
|
||||
|
||||
@@ -113,5 +113,6 @@ func NewThirdPartySubprocessors(sps []probo.Subprocessor) []*ThirdPartySubproces
|
||||
Purpose: sp.Purpose,
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ func NewTrackerPatternConnectionWithFilter(
|
||||
) *TrackerPatternConnection {
|
||||
conn := NewTrackerPatternConnection(p, parentType, parentID)
|
||||
conn.Filter = filter
|
||||
|
||||
return conn
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ func NewTrackerResourceConnectionWithFilter(
|
||||
) *TrackerResourceConnection {
|
||||
conn := NewTrackerResourceConnection(p, parentType, parentID)
|
||||
conn.Filter = filter
|
||||
|
||||
return conn
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ func NewWebhookEventEdge(we *coredata.WebhookEvent, orderBy coredata.WebhookEven
|
||||
|
||||
func NewWebhookEvent(we *coredata.WebhookEvent) *WebhookEvent {
|
||||
var response *string
|
||||
|
||||
if len(we.Response) > 0 {
|
||||
s := string(we.Response)
|
||||
response = &s
|
||||
|
||||
@@ -79,6 +79,7 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeSignature)
|
||||
|
||||
document, err := prb.Documents.GetWithFilter(ctx, id, documentFilter)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -86,6 +87,7 @@ func (r *viewerResolver) SignableDocument(ctx context.Context, obj *types.Viewer
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get signable document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -158,6 +160,7 @@ func (r *viewerResolver) ApprovableDocument(ctx context.Context, obj *types.View
|
||||
identity := authn.IdentityFromContext(ctx)
|
||||
|
||||
documentFilter := coredata.NewDocumentFilter(nil).WithEmployeeIdentityID(&identity.ID, coredata.EmployeeFilterModeApproval)
|
||||
|
||||
document, err := prb.Documents.GetWithFilter(ctx, id, documentFilter)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
@@ -165,6 +168,7 @@ func (r *viewerResolver) ApprovableDocument(ctx context.Context, obj *types.View
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get approvable document", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,9 @@ func (r *mutationResolver) CreateWebhookSubscription(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create webhook subscription", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -71,7 +73,9 @@ func (r *mutationResolver) UpdateWebhookSubscription(ctx context.Context, input
|
||||
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
||||
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update webhook subscription", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -131,6 +135,7 @@ func (r *webhookSubscriptionResolver) Organization(ctx context.Context, obj *typ
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot load organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
@@ -204,10 +209,12 @@ func (r *webhookSubscriptionConnectionResolver) TotalCount(ctx context.Context,
|
||||
r.logger.ErrorCtx(ctx, "cannot count webhook subscriptions", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "unsupported resolver for webhook subscription connection", log.String("resolver", fmt.Sprintf("%T", obj.Resolver)))
|
||||
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user