Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-20 18:18:39 -07:00
parent 4d1a98ffdb
commit 8bf7be0c0d
22 changed files with 389 additions and 1026 deletions

View File

@@ -32,9 +32,7 @@ func (r *mutationResolver) CreateThirdParty(ctx context.Context, input types.Cre
return nil, err
}
prb := r.probo
thirdParty, err := prb.ThirdParties.Create(
thirdParty, err := r.probo.ThirdParties.Create(
ctx, scope,
probo.CreateThirdPartyRequest{
OrganizationID: input.OrganizationID,
@@ -85,9 +83,7 @@ func (r *mutationResolver) UpdateThirdParty(ctx context.Context, input types.Upd
return nil, err
}
prb := r.probo
thirdParty, err := prb.ThirdParties.Update(
thirdParty, err := r.probo.ThirdParties.Update(
ctx, scope,
probo.UpdateThirdPartyRequest{
ID: input.ID,
@@ -135,9 +131,7 @@ func (r *mutationResolver) DeleteThirdParty(ctx context.Context, input types.Del
return nil, err
}
prb := r.probo
if err := prb.ThirdParties.Delete(ctx, scope, input.ThirdPartyID); err != nil {
if err := r.probo.ThirdParties.Delete(ctx, scope, input.ThirdPartyID); err != nil {
r.logger.ErrorCtx(ctx, "cannot delete thirdParty", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -154,8 +148,6 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty
return nil, err
}
prb := r.probo
req := probo.CreateThirdPartyContactRequest{
ThirdPartyID: input.ThirdPartyID,
FullName: input.FullName,
@@ -164,7 +156,7 @@ func (r *mutationResolver) CreateThirdPartyContact(ctx context.Context, input ty
Role: input.Role,
}
thirdPartyContact, err := prb.ThirdPartyContacts.Create(ctx, scope, req)
thirdPartyContact, err := r.probo.ThirdPartyContacts.Create(ctx, scope, req)
if err != nil {
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
@@ -187,8 +179,6 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty
return nil, err
}
prb := r.probo
req := probo.UpdateThirdPartyContactRequest{
ID: input.ID,
FullName: gqlutils.UnwrapOmittable(input.FullName),
@@ -197,7 +187,7 @@ func (r *mutationResolver) UpdateThirdPartyContact(ctx context.Context, input ty
Role: gqlutils.UnwrapOmittable(input.Role),
}
thirdPartyContact, err := prb.ThirdPartyContacts.Update(ctx, scope, req)
thirdPartyContact, err := r.probo.ThirdPartyContacts.Update(ctx, scope, req)
if err != nil {
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
@@ -220,9 +210,7 @@ func (r *mutationResolver) DeleteThirdPartyContact(ctx context.Context, input ty
return nil, err
}
prb := r.probo
if err := prb.ThirdPartyContacts.Delete(ctx, scope, input.ThirdPartyContactID); err != nil {
if err := r.probo.ThirdPartyContacts.Delete(ctx, scope, input.ThirdPartyContactID); err != nil {
r.logger.ErrorCtx(ctx, "cannot delete thirdParty contact", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -239,15 +227,13 @@ func (r *mutationResolver) CreateThirdPartyService(ctx context.Context, input ty
return nil, err
}
prb := r.probo
req := probo.CreateThirdPartyServiceRequest{
ThirdPartyID: input.ThirdPartyID,
Name: input.Name,
Description: input.Description,
}
thirdPartyService, err := prb.ThirdPartyServices.Create(ctx, scope, req)
thirdPartyService, err := r.probo.ThirdPartyServices.Create(ctx, scope, req)
if err != nil {
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
@@ -270,15 +256,13 @@ func (r *mutationResolver) UpdateThirdPartyService(ctx context.Context, input ty
return nil, err
}
prb := r.probo
req := probo.UpdateThirdPartyServiceRequest{
ID: input.ID,
Name: input.Name,
Description: gqlutils.UnwrapOmittable(input.Description),
}
thirdPartyService, err := prb.ThirdPartyServices.Update(ctx, scope, req)
thirdPartyService, err := r.probo.ThirdPartyServices.Update(ctx, scope, req)
if err != nil {
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
@@ -301,9 +285,7 @@ func (r *mutationResolver) DeleteThirdPartyService(ctx context.Context, input ty
return nil, err
}
prb := r.probo
if err := prb.ThirdPartyServices.Delete(ctx, scope, input.ThirdPartyServiceID); err != nil {
if err := r.probo.ThirdPartyServices.Delete(ctx, scope, input.ThirdPartyServiceID); err != nil {
r.logger.ErrorCtx(ctx, "cannot delete thirdParty service", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -320,9 +302,7 @@ func (r *mutationResolver) UploadThirdPartyComplianceReport(ctx context.Context,
return nil, err
}
prb := r.probo
thirdPartyComplianceReport, err := prb.ThirdPartyComplianceReports.Upload(
thirdPartyComplianceReport, err := r.probo.ThirdPartyComplianceReports.Upload(
ctx, scope,
input.ThirdPartyID,
&probo.ThirdPartyComplianceReportCreateRequest{
@@ -354,9 +334,7 @@ func (r *mutationResolver) DeleteThirdPartyComplianceReport(ctx context.Context,
return nil, err
}
prb := r.probo
if err := prb.ThirdPartyComplianceReports.Delete(ctx, scope, input.ReportID); err != nil {
if err := r.probo.ThirdPartyComplianceReports.Delete(ctx, scope, input.ReportID); err != nil {
r.logger.ErrorCtx(ctx, "cannot delete thirdParty compliance report", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -373,9 +351,7 @@ func (r *mutationResolver) UploadThirdPartyBusinessAssociateAgreement(ctx contex
return nil, err
}
prb := r.probo
thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.Upload(
thirdPartyBusinessAssociateAgreement, file, err := r.probo.ThirdPartyBusinessAssociateAgreements.Upload(
ctx, scope,
input.ThirdPartyID,
&probo.ThirdPartyBusinessAssociateAgreementCreateRequest{
@@ -407,9 +383,7 @@ func (r *mutationResolver) UpdateThirdPartyBusinessAssociateAgreement(ctx contex
return nil, err
}
prb := r.probo
thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.Update(
thirdPartyBusinessAssociateAgreement, file, err := r.probo.ThirdPartyBusinessAssociateAgreements.Update(
ctx, scope,
input.ThirdPartyID,
&probo.ThirdPartyBusinessAssociateAgreementUpdateRequest{
@@ -439,9 +413,7 @@ func (r *mutationResolver) DeleteThirdPartyBusinessAssociateAgreement(ctx contex
return nil, err
}
prb := r.probo
if err := prb.ThirdPartyBusinessAssociateAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil {
if err := r.probo.ThirdPartyBusinessAssociateAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil {
r.logger.ErrorCtx(ctx, "cannot delete thirdParty business associate agreement", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -458,9 +430,7 @@ func (r *mutationResolver) UploadThirdPartyDataPrivacyAgreement(ctx context.Cont
return nil, err
}
prb := r.probo
thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.Upload(
thirdPartyDataPrivacyAgreement, file, err := r.probo.ThirdPartyDataPrivacyAgreements.Upload(
ctx, scope,
input.ThirdPartyID,
&probo.ThirdPartyDataPrivacyAgreementCreateRequest{
@@ -492,9 +462,7 @@ func (r *mutationResolver) UpdateThirdPartyDataPrivacyAgreement(ctx context.Cont
return nil, err
}
prb := r.probo
thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.Update(
thirdPartyDataPrivacyAgreement, file, err := r.probo.ThirdPartyDataPrivacyAgreements.Update(
ctx, scope,
input.ThirdPartyID,
&probo.ThirdPartyDataPrivacyAgreementUpdateRequest{
@@ -524,9 +492,7 @@ func (r *mutationResolver) DeleteThirdPartyDataPrivacyAgreement(ctx context.Cont
return nil, err
}
prb := r.probo
if err := prb.ThirdPartyDataPrivacyAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil {
if err := r.probo.ThirdPartyDataPrivacyAgreements.DeleteByThirdPartyID(ctx, scope, input.ThirdPartyID); err != nil {
r.logger.ErrorCtx(ctx, "cannot delete thirdParty data privacy agreement", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
@@ -543,9 +509,7 @@ func (r *mutationResolver) CreateThirdPartyRiskAssessment(ctx context.Context, i
return nil, err
}
prb := r.probo
thirdPartyRiskAssessment, err := prb.ThirdParties.CreateRiskAssessment(
thirdPartyRiskAssessment, err := r.probo.ThirdParties.CreateRiskAssessment(
ctx, scope,
probo.CreateThirdPartyRiskAssessmentRequest{
ThirdPartyID: input.ThirdPartyID,
@@ -577,9 +541,7 @@ func (r *mutationResolver) AssessThirdParty(ctx context.Context, input types.Ass
return nil, err
}
prb := r.probo
result, err := prb.ThirdParties.Assess(
result, err := r.probo.ThirdParties.Assess(
ctx, scope,
probo.AssessThirdPartyRequest{
ID: input.ID,
@@ -611,9 +573,7 @@ func (r *mutationResolver) PublishThirdPartyList(ctx context.Context, input type
return nil, err
}
prb := r.probo
document, documentVersion, err := prb.GeneratedDocuments.PublishThirdPartyList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor)
document, documentVersion, err := r.probo.GeneratedDocuments.PublishThirdPartyList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor)
if err != nil {
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
return nil, gqlutils.Conflict(ctx, err)
@@ -663,8 +623,6 @@ func (r *thirdPartyResolver) ComplianceReports(ctx context.Context, obj *types.T
return nil, err
}
prb := r.probo
pageOrderBy := page.OrderBy[coredata.ThirdPartyComplianceReportOrderField]{
Field: coredata.ThirdPartyComplianceReportOrderFieldReportDate,
Direction: page.OrderDirectionDesc,
@@ -678,7 +636,7 @@ func (r *thirdPartyResolver) ComplianceReports(ctx context.Context, obj *types.T
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.ThirdPartyComplianceReports.ListForThirdPartyID(ctx, scope, obj.ID, cursor)
page, err := r.probo.ThirdPartyComplianceReports.ListForThirdPartyID(ctx, scope, obj.ID, cursor)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list thirdParty compliance reports", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -694,9 +652,7 @@ func (r *thirdPartyResolver) BusinessAssociateAgreement(ctx context.Context, obj
return nil, err
}
prb := r.probo
thirdPartyBusinessAssociateAgreement, file, err := prb.ThirdPartyBusinessAssociateAgreements.GetByThirdPartyID(ctx, scope, obj.ID)
thirdPartyBusinessAssociateAgreement, file, err := r.probo.ThirdPartyBusinessAssociateAgreements.GetByThirdPartyID(ctx, scope, obj.ID)
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return nil, nil
@@ -717,9 +673,7 @@ func (r *thirdPartyResolver) DataPrivacyAgreement(ctx context.Context, obj *type
return nil, err
}
prb := r.probo
thirdPartyDataPrivacyAgreement, file, err := prb.ThirdPartyDataPrivacyAgreements.GetByThirdPartyID(ctx, scope, obj.ID)
thirdPartyDataPrivacyAgreement, file, err := r.probo.ThirdPartyDataPrivacyAgreements.GetByThirdPartyID(ctx, scope, obj.ID)
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return nil, nil
@@ -740,8 +694,6 @@ func (r *thirdPartyResolver) Contacts(ctx context.Context, obj *types.ThirdParty
return nil, err
}
prb := r.probo
pageOrderBy := page.OrderBy[coredata.ThirdPartyContactOrderField]{
Field: coredata.ThirdPartyContactOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
@@ -755,7 +707,7 @@ func (r *thirdPartyResolver) Contacts(ctx context.Context, obj *types.ThirdParty
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.ThirdPartyContacts.List(ctx, scope, obj.ID, cursor)
page, err := r.probo.ThirdPartyContacts.List(ctx, scope, obj.ID, cursor)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list thirdParty contacts", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -771,8 +723,6 @@ func (r *thirdPartyResolver) Services(ctx context.Context, obj *types.ThirdParty
return nil, err
}
prb := r.probo
pageOrderBy := page.OrderBy[coredata.ThirdPartyServiceOrderField]{
Field: coredata.ThirdPartyServiceOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
@@ -786,7 +736,7 @@ func (r *thirdPartyResolver) Services(ctx context.Context, obj *types.ThirdParty
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.ThirdPartyServices.List(ctx, scope, obj.ID, cursor)
page, err := r.probo.ThirdPartyServices.List(ctx, scope, obj.ID, cursor)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list thirdParty services", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -802,8 +752,6 @@ func (r *thirdPartyResolver) RiskAssessments(ctx context.Context, obj *types.Thi
return nil, err
}
prb := r.probo
pageOrderBy := page.OrderBy[coredata.ThirdPartyRiskAssessmentOrderField]{
Field: coredata.ThirdPartyRiskAssessmentOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
@@ -817,7 +765,7 @@ func (r *thirdPartyResolver) RiskAssessments(ctx context.Context, obj *types.Thi
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
page, err := prb.ThirdParties.ListRiskAssessments(ctx, scope, obj.ID, cursor)
page, err := r.probo.ThirdParties.ListRiskAssessments(ctx, scope, obj.ID, cursor)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list thirdParty risk assessments", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -890,9 +838,7 @@ func (r *thirdPartyBusinessAssociateAgreementResolver) ThirdParty(ctx context.Co
return nil, err
}
prb := r.probo
thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID)
thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, obj.ID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
@@ -911,9 +857,7 @@ func (r *thirdPartyBusinessAssociateAgreementResolver) FileURL(ctx context.Conte
return "", err
}
prb := r.probo
fileURL, err := prb.ThirdPartyBusinessAssociateAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour)
fileURL, err := r.probo.ThirdPartyBusinessAssociateAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot generate file URL", log.Error(err))
return "", gqlutils.Internal(ctx)
@@ -934,9 +878,7 @@ func (r *thirdPartyComplianceReportResolver) ThirdParty(ctx context.Context, obj
return nil, err
}
prb := r.probo
thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID)
thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, obj.ID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
@@ -957,9 +899,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type
return nil, err
}
prb := r.probo
evidence, err := prb.ThirdPartyComplianceReports.Get(ctx, scope, obj.ID)
evidence, err := r.probo.ThirdPartyComplianceReports.Get(ctx, scope, obj.ID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot load evidence", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -969,7 +909,7 @@ func (r *thirdPartyComplianceReportResolver) File(ctx context.Context, obj *type
return nil, nil
}
file, err := prb.Files.Get(ctx, scope, *evidence.ReportFileId)
file, err := r.probo.Files.Get(ctx, scope, *evidence.ReportFileId)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
@@ -995,11 +935,9 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
return 0, err
}
prb := r.probo
switch obj.Resolver.(type) {
case *organizationResolver:
count, err := prb.ThirdParties.CountForOrganizationID(ctx, scope, obj.ParentID)
count, err := r.probo.ThirdParties.CountForOrganizationID(ctx, scope, obj.ParentID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
return 0, gqlutils.Internal(ctx)
@@ -1007,7 +945,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
return count, nil
case *assetResolver:
count, err := prb.ThirdParties.CountForAssetID(ctx, scope, obj.ParentID)
count, err := r.probo.ThirdParties.CountForAssetID(ctx, scope, obj.ParentID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
return 0, gqlutils.Internal(ctx)
@@ -1015,7 +953,7 @@ func (r *thirdPartyConnectionResolver) TotalCount(ctx context.Context, obj *type
return count, nil
case *datumResolver:
count, err := prb.ThirdParties.CountForDatumID(ctx, scope, obj.ParentID)
count, err := r.probo.ThirdParties.CountForDatumID(ctx, scope, obj.ParentID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot count thirdParties", log.Error(err))
return 0, gqlutils.Internal(ctx)
@@ -1036,16 +974,14 @@ func (r *thirdPartyContactResolver) ThirdParty(ctx context.Context, obj *types.T
return nil, err
}
prb := r.probo
// Get the thirdParty contact to access the ThirdPartyID
thirdPartyContact, err := prb.ThirdPartyContacts.Get(ctx, scope, obj.ID)
thirdPartyContact, err := r.probo.ThirdPartyContacts.Get(ctx, scope, obj.ID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot get thirdParty contact", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
thirdParty, err := prb.ThirdParties.Get(ctx, scope, thirdPartyContact.ThirdPartyID)
thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, thirdPartyContact.ThirdPartyID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
@@ -1071,9 +1007,7 @@ func (r *thirdPartyDataPrivacyAgreementResolver) ThirdParty(ctx context.Context,
return nil, err
}
prb := r.probo
thirdParty, err := prb.ThirdParties.Get(ctx, scope, obj.ID)
thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, obj.ID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
@@ -1094,9 +1028,7 @@ func (r *thirdPartyDataPrivacyAgreementResolver) FileURL(ctx context.Context, ob
return "", err
}
prb := r.probo
fileURL, err := prb.ThirdPartyDataPrivacyAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour)
fileURL, err := r.probo.ThirdPartyDataPrivacyAgreements.GenerateFileURL(ctx, scope, obj.ID, 1*time.Hour)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot generate file URL", log.Error(err))
return "", gqlutils.Internal(ctx)
@@ -1117,9 +1049,7 @@ func (r *thirdPartyRiskAssessmentResolver) ThirdParty(ctx context.Context, obj *
return nil, err
}
prb := r.probo
thirdParty, err := prb.ThirdParties.GetByRiskAssessmentID(ctx, scope, obj.ID)
thirdParty, err := r.probo.ThirdParties.GetByRiskAssessmentID(ctx, scope, obj.ID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)