Rename vendors to third parties
Renames the user-facing 'vendor' concept to 'third party' across the entire codebase. The shared common_third_parties reference table is unchanged. Migration. Renames the vendor_category enum, the vendors and vendor_<entity> tables (contacts, services, compliance_reports, business_associate_agreements, data_privacy_agreements, risk_assessments) and their vendor_id columns, the asset_vendors / data_vendors / processing_activity_vendors junction tables, generated_documents.vendors_document_id, the webhook_event_type 'vendor:<verb>' values, and the snapshots_type 'VENDORS' value. Backend. Renames coredata models and SQL queries, probo services, GraphQL / MCP API surface, console / trust / webhook resolvers and types, the CLI (prb vendor* -> prb third-party*; pkg/cmd/vendormgmt -> pkg/cmd/thirdpartymgmt), the document generator, vetting agent prompts, and the common-third-parties-import command. Frontend, packages, n8n, e2e. Renames apps/console pages, components, hooks, routes, dialogs, and tabs; the shared @probo/vendors package (now @probo/third-parties); the @probo/ui Vendors atoms (now ThirdParties, VendorLogo -> ThirdPartyLogo); the n8n community node actions/vendor folder (now actions/thirdParty); and the e2e Go test suite (console and MCP). Filesystem and URL paths use kebab-case (third-parties), GraphQL fields and TypeScript identifiers use camelCase (thirdParty / thirdParties), Go types use PascalCase (ThirdParty), and human-facing text uses 'third party' with a space. Co-authored-by: Bryan Frimin <bryan@getprobo.com> Signed-off-by: Bryan Frimin <bryan@getprobo.com> Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -45,19 +45,19 @@ func (r *Resolver) ListOrganizationsTool(ctx context.Context, req *mcp.CallToolR
|
||||
return nil, result, nil
|
||||
}
|
||||
|
||||
// ListVendorsTool handles the listVendors tool
|
||||
// List all vendors for the organization
|
||||
func (r *Resolver) ListVendorsTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListVendorsInput) (*mcp.CallToolResult, types.ListVendorsOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionVendorList)
|
||||
// ListThirdPartiesTool handles the listThirdParties tool
|
||||
// List all thirdParties for the organization
|
||||
func (r *Resolver) ListThirdPartiesTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListThirdPartiesInput) (*mcp.CallToolResult, types.ListThirdPartiesOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionThirdPartyList)
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID)
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorOrderField]{
|
||||
Field: coredata.VendorOrderFieldCreatedAt,
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: coredata.ThirdPartyOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if input.OrderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.VendorOrderField]{
|
||||
pageOrderBy = page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: input.OrderBy.Field,
|
||||
Direction: input.OrderBy.Direction,
|
||||
}
|
||||
@@ -65,26 +65,26 @@ func (r *Resolver) ListVendorsTool(ctx context.Context, req *mcp.CallToolRequest
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
vendorFilter := coredata.NewVendorFilter(nil)
|
||||
thirdPartyFilter := coredata.NewThirdPartyFilter(nil)
|
||||
|
||||
page, err := prb.Vendors.ListForOrganizationID(ctx, input.OrganizationID, cursor, vendorFilter)
|
||||
page, err := prb.ThirdParties.ListForOrganizationID(ctx, input.OrganizationID, cursor, thirdPartyFilter)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization vendors: %w", err))
|
||||
panic(fmt.Errorf("cannot list organization thirdParties: %w", err))
|
||||
}
|
||||
|
||||
return nil, types.NewListVendorsOutput(page), nil
|
||||
return nil, types.NewListThirdPartiesOutput(page), nil
|
||||
}
|
||||
|
||||
// AddVendorTool handles the addVendor tool
|
||||
// Add a new vendor to the organization
|
||||
func (r *Resolver) AddVendorTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddVendorInput) (*mcp.CallToolResult, types.AddVendorOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionVendorCreate)
|
||||
// AddThirdPartyTool handles the addThirdParty tool
|
||||
// Add a new thirdParty to the organization
|
||||
func (r *Resolver) AddThirdPartyTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddThirdPartyInput) (*mcp.CallToolResult, types.AddThirdPartyOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionThirdPartyCreate)
|
||||
|
||||
svc := r.ProboService(ctx, input.OrganizationID)
|
||||
|
||||
var category *coredata.VendorCategory
|
||||
var category *coredata.ThirdPartyCategory
|
||||
if input.Category != nil {
|
||||
cat := coredata.VendorCategory(*input.Category)
|
||||
cat := coredata.ThirdPartyCategory(*input.Category)
|
||||
category = &cat
|
||||
}
|
||||
|
||||
@@ -96,9 +96,9 @@ func (r *Resolver) AddVendorTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
}
|
||||
}
|
||||
|
||||
vendor, err := svc.Vendors.Create(
|
||||
thirdParty, err := svc.ThirdParties.Create(
|
||||
ctx,
|
||||
probo.CreateVendorRequest{
|
||||
probo.CreateThirdPartyRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
Name: input.Name,
|
||||
Description: input.Description,
|
||||
@@ -122,16 +122,16 @@ func (r *Resolver) AddVendorTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, types.AddVendorOutput{}, fmt.Errorf("failed to create vendor: %w", err)
|
||||
return nil, types.AddThirdPartyOutput{}, fmt.Errorf("failed to create thirdParty: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.NewAddVendorOutput(vendor), nil
|
||||
return nil, types.NewAddThirdPartyOutput(thirdParty), nil
|
||||
}
|
||||
|
||||
// UpdateVendorTool handles the updateVendor tool
|
||||
// Update an existing vendor
|
||||
func (r *Resolver) UpdateVendorTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateVendorInput) (*mcp.CallToolResult, types.UpdateVendorOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionVendorUpdate)
|
||||
// UpdateThirdPartyTool handles the updateThirdParty tool
|
||||
// Update an existing thirdParty
|
||||
func (r *Resolver) UpdateThirdPartyTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateThirdPartyInput) (*mcp.CallToolResult, types.UpdateThirdPartyOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionThirdPartyUpdate)
|
||||
|
||||
svc := r.ProboService(ctx, input.ID)
|
||||
|
||||
@@ -210,9 +210,9 @@ func (r *Resolver) UpdateVendorTool(ctx context.Context, req *mcp.CallToolReques
|
||||
securityOwnerID = &input.SecurityOwnerID
|
||||
}
|
||||
|
||||
var category *coredata.VendorCategory
|
||||
var category *coredata.ThirdPartyCategory
|
||||
if input.Category != nil {
|
||||
cat := coredata.VendorCategory(*input.Category)
|
||||
cat := coredata.ThirdPartyCategory(*input.Category)
|
||||
category = &cat
|
||||
}
|
||||
|
||||
@@ -224,9 +224,9 @@ func (r *Resolver) UpdateVendorTool(ctx context.Context, req *mcp.CallToolReques
|
||||
}
|
||||
}
|
||||
|
||||
vendor, err := svc.Vendors.Update(
|
||||
thirdParty, err := svc.ThirdParties.Update(
|
||||
ctx,
|
||||
probo.UpdateVendorRequest{
|
||||
probo.UpdateThirdPartyRequest{
|
||||
ID: input.ID,
|
||||
Name: input.Name,
|
||||
Description: description,
|
||||
@@ -250,10 +250,10 @@ func (r *Resolver) UpdateVendorTool(ctx context.Context, req *mcp.CallToolReques
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, types.UpdateVendorOutput{}, fmt.Errorf("failed to update vendor: %w", err)
|
||||
return nil, types.UpdateThirdPartyOutput{}, fmt.Errorf("failed to update thirdParty: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.NewUpdateVendorOutput(vendor), nil
|
||||
return nil, types.NewUpdateThirdPartyOutput(thirdParty), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) ListRisksTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListRisksInput) (*mcp.CallToolResult, types.ListRisksOutput, error) {
|
||||
@@ -593,7 +593,7 @@ func (r *Resolver) AddAssetTool(ctx context.Context, req *mcp.CallToolRequest, i
|
||||
OwnerID: input.OwnerID,
|
||||
AssetType: input.AssetType,
|
||||
DataTypesStored: input.DataTypesStored,
|
||||
VendorIDs: input.VendorIds,
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -619,7 +619,7 @@ func (r *Resolver) UpdateAssetTool(ctx context.Context, req *mcp.CallToolRequest
|
||||
OwnerID: input.OwnerID,
|
||||
AssetType: input.AssetType,
|
||||
DataTypesStored: input.DataTypesStored,
|
||||
VendorIDs: input.VendorIds,
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -684,7 +684,7 @@ func (r *Resolver) AddDatumTool(ctx context.Context, req *mcp.CallToolRequest, i
|
||||
Name: input.Name,
|
||||
DataClassification: input.DataClassification,
|
||||
OwnerID: input.OwnerID,
|
||||
VendorIDs: input.VendorIds,
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -708,7 +708,7 @@ func (r *Resolver) UpdateDatumTool(ctx context.Context, req *mcp.CallToolRequest
|
||||
Name: input.Name,
|
||||
DataClassification: input.DataClassification,
|
||||
OwnerID: input.OwnerID,
|
||||
VendorIDs: input.VendorIds,
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -1004,7 +1004,7 @@ func (r *Resolver) AddProcessingActivityTool(ctx context.Context, req *mcp.CallT
|
||||
NextReviewDate: input.NextReviewDate,
|
||||
Role: input.Role,
|
||||
DataProtectionOfficerID: input.DataProtectionOfficerID,
|
||||
VendorIDs: input.VendorIds,
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -1021,9 +1021,9 @@ func (r *Resolver) UpdateProcessingActivityTool(ctx context.Context, req *mcp.Ca
|
||||
|
||||
svc := r.ProboService(ctx, input.ID)
|
||||
|
||||
var vendorIDs *[]gid.GID
|
||||
if input.VendorIds != nil {
|
||||
vendorIDs = &input.VendorIds
|
||||
var thirdPartyIDs *[]gid.GID
|
||||
if input.ThirdPartyIds != nil {
|
||||
thirdPartyIDs = &input.ThirdPartyIds
|
||||
}
|
||||
|
||||
processingActivity, err := svc.ProcessingActivities.Update(
|
||||
@@ -1049,7 +1049,7 @@ func (r *Resolver) UpdateProcessingActivityTool(ctx context.Context, req *mcp.Ca
|
||||
NextReviewDate: UnwrapOmittable(input.NextReviewDate),
|
||||
Role: input.Role,
|
||||
DataProtectionOfficerID: UnwrapOmittable(input.DataProtectionOfficerID),
|
||||
VendorIDs: vendorIDs,
|
||||
ThirdPartyIDs: thirdPartyIDs,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -2729,19 +2729,19 @@ func (r *Resolver) DeleteApplicabilityStatementTool(ctx context.Context, req *mc
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListVendorRiskAssessmentsTool handles the listVendorRiskAssessments tool
|
||||
// List all risk assessments for a vendor
|
||||
func (r *Resolver) ListVendorRiskAssessmentsTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListVendorRiskAssessmentsInput) (*mcp.CallToolResult, types.ListVendorRiskAssessmentsOutput, error) {
|
||||
r.MustAuthorize(ctx, input.VendorID, probo.ActionVendorRiskAssessmentList)
|
||||
// ListThirdPartyRiskAssessmentsTool handles the listThirdPartyRiskAssessments tool
|
||||
// List all risk assessments for a thirdParty
|
||||
func (r *Resolver) ListThirdPartyRiskAssessmentsTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListThirdPartyRiskAssessmentsInput) (*mcp.CallToolResult, types.ListThirdPartyRiskAssessmentsOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ThirdPartyID, probo.ActionThirdPartyRiskAssessmentList)
|
||||
|
||||
prb := r.ProboService(ctx, input.VendorID)
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID)
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorRiskAssessmentOrderField]{
|
||||
Field: coredata.VendorRiskAssessmentOrderFieldCreatedAt,
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyRiskAssessmentOrderField]{
|
||||
Field: coredata.ThirdPartyRiskAssessmentOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if input.OrderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.VendorRiskAssessmentOrderField]{
|
||||
pageOrderBy = page.OrderBy[coredata.ThirdPartyRiskAssessmentOrderField]{
|
||||
Field: input.OrderBy.Field,
|
||||
Direction: input.OrderBy.Direction,
|
||||
}
|
||||
@@ -2749,25 +2749,25 @@ func (r *Resolver) ListVendorRiskAssessmentsTool(ctx context.Context, req *mcp.C
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
p, err := prb.Vendors.ListRiskAssessments(ctx, input.VendorID, cursor)
|
||||
p, err := prb.ThirdParties.ListRiskAssessments(ctx, input.ThirdPartyID, cursor)
|
||||
if err != nil {
|
||||
return nil, types.ListVendorRiskAssessmentsOutput{}, fmt.Errorf("cannot list vendor risk assessments: %w", err)
|
||||
return nil, types.ListThirdPartyRiskAssessmentsOutput{}, fmt.Errorf("cannot list thirdParty risk assessments: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.NewListVendorRiskAssessmentsOutput(p), nil
|
||||
return nil, types.NewListThirdPartyRiskAssessmentsOutput(p), nil
|
||||
}
|
||||
|
||||
// AddVendorRiskAssessmentTool handles the addVendorRiskAssessment tool
|
||||
// Add a new risk assessment for a vendor
|
||||
func (r *Resolver) AddVendorRiskAssessmentTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddVendorRiskAssessmentInput) (*mcp.CallToolResult, types.AddVendorRiskAssessmentOutput, error) {
|
||||
r.MustAuthorize(ctx, input.VendorID, probo.ActionVendorRiskAssessmentCreate)
|
||||
// AddThirdPartyRiskAssessmentTool handles the addThirdPartyRiskAssessment tool
|
||||
// Add a new risk assessment for a thirdParty
|
||||
func (r *Resolver) AddThirdPartyRiskAssessmentTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddThirdPartyRiskAssessmentInput) (*mcp.CallToolResult, types.AddThirdPartyRiskAssessmentOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ThirdPartyID, probo.ActionThirdPartyRiskAssessmentCreate)
|
||||
|
||||
prb := r.ProboService(ctx, input.VendorID)
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID)
|
||||
|
||||
assessment, err := prb.Vendors.CreateRiskAssessment(
|
||||
assessment, err := prb.ThirdParties.CreateRiskAssessment(
|
||||
ctx,
|
||||
probo.CreateVendorRiskAssessmentRequest{
|
||||
VendorID: input.VendorID,
|
||||
probo.CreateThirdPartyRiskAssessmentRequest{
|
||||
ThirdPartyID: input.ThirdPartyID,
|
||||
ExpiresAt: input.ExpiresAt,
|
||||
DataSensitivity: input.DataSensitivity,
|
||||
BusinessImpact: input.BusinessImpact,
|
||||
@@ -2775,24 +2775,24 @@ func (r *Resolver) AddVendorRiskAssessmentTool(ctx context.Context, req *mcp.Cal
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, types.AddVendorRiskAssessmentOutput{}, fmt.Errorf("failed to create vendor risk assessment: %w", err)
|
||||
return nil, types.AddThirdPartyRiskAssessmentOutput{}, fmt.Errorf("failed to create thirdParty risk assessment: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.NewAddVendorRiskAssessmentOutput(assessment), nil
|
||||
return nil, types.NewAddThirdPartyRiskAssessmentOutput(assessment), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) DeleteVendorTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteVendorInput) (*mcp.CallToolResult, types.DeleteVendorOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionVendorDelete)
|
||||
func (r *Resolver) DeleteThirdPartyTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteThirdPartyInput) (*mcp.CallToolResult, types.DeleteThirdPartyOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionThirdPartyDelete)
|
||||
|
||||
svc := r.ProboService(ctx, input.ID)
|
||||
|
||||
err := svc.Vendors.Delete(ctx, input.ID)
|
||||
err := svc.ThirdParties.Delete(ctx, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.DeleteVendorOutput{}, fmt.Errorf("failed to delete vendor: %w", err)
|
||||
return nil, types.DeleteThirdPartyOutput{}, fmt.Errorf("failed to delete thirdParty: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeleteVendorOutput{
|
||||
DeletedVendorID: input.ID,
|
||||
return nil, types.DeleteThirdPartyOutput{
|
||||
DeletedThirdPartyID: input.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -3841,19 +3841,19 @@ func (r *Resolver) PublishAssetListTool(ctx context.Context, req *mcp.CallToolRe
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListVendorContactsTool handles the listVendorContacts tool
|
||||
// List all contacts for a vendor
|
||||
func (r *Resolver) ListVendorContactsTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListVendorContactsInput) (*mcp.CallToolResult, types.ListVendorContactsOutput, error) {
|
||||
r.MustAuthorize(ctx, input.VendorID, probo.ActionVendorContactList)
|
||||
// ListThirdPartyContactsTool handles the listThirdPartyContacts tool
|
||||
// List all contacts for a thirdParty
|
||||
func (r *Resolver) ListThirdPartyContactsTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListThirdPartyContactsInput) (*mcp.CallToolResult, types.ListThirdPartyContactsOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ThirdPartyID, probo.ActionThirdPartyContactList)
|
||||
|
||||
prb := r.ProboService(ctx, input.VendorID)
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID)
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorContactOrderField]{
|
||||
Field: coredata.VendorContactOrderFieldCreatedAt,
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyContactOrderField]{
|
||||
Field: coredata.ThirdPartyContactOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if input.OrderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.VendorContactOrderField]{
|
||||
pageOrderBy = page.OrderBy[coredata.ThirdPartyContactOrderField]{
|
||||
Field: input.OrderBy.Field,
|
||||
Direction: input.OrderBy.Direction,
|
||||
}
|
||||
@@ -3861,50 +3861,50 @@ func (r *Resolver) ListVendorContactsTool(ctx context.Context, req *mcp.CallTool
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
p, err := prb.VendorContacts.List(ctx, input.VendorID, cursor)
|
||||
p, err := prb.ThirdPartyContacts.List(ctx, input.ThirdPartyID, cursor)
|
||||
if err != nil {
|
||||
return nil, types.ListVendorContactsOutput{}, fmt.Errorf("cannot list vendor contacts: %w", err)
|
||||
return nil, types.ListThirdPartyContactsOutput{}, fmt.Errorf("cannot list thirdParty contacts: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.NewListVendorContactsOutput(p), nil
|
||||
return nil, types.NewListThirdPartyContactsOutput(p), nil
|
||||
}
|
||||
|
||||
// AddVendorContactTool handles the addVendorContact tool
|
||||
// Add a new contact to a vendor
|
||||
func (r *Resolver) AddVendorContactTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddVendorContactInput) (*mcp.CallToolResult, types.AddVendorContactOutput, error) {
|
||||
r.MustAuthorize(ctx, input.VendorID, probo.ActionVendorContactCreate)
|
||||
// AddThirdPartyContactTool handles the addThirdPartyContact tool
|
||||
// Add a new contact to a thirdParty
|
||||
func (r *Resolver) AddThirdPartyContactTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddThirdPartyContactInput) (*mcp.CallToolResult, types.AddThirdPartyContactOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ThirdPartyID, probo.ActionThirdPartyContactCreate)
|
||||
|
||||
prb := r.ProboService(ctx, input.VendorID)
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID)
|
||||
|
||||
emailAddr, err := mail.ParseAddr(input.Email)
|
||||
if err != nil {
|
||||
return nil, types.AddVendorContactOutput{}, fmt.Errorf("invalid email address: %w", err)
|
||||
return nil, types.AddThirdPartyContactOutput{}, fmt.Errorf("invalid email address: %w", err)
|
||||
}
|
||||
|
||||
vendorContact, err := prb.VendorContacts.Create(ctx, probo.CreateVendorContactRequest{
|
||||
VendorID: input.VendorID,
|
||||
FullName: &input.FullName,
|
||||
Email: &emailAddr,
|
||||
Phone: &input.Phone,
|
||||
Role: &input.Role,
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Create(ctx, probo.CreateThirdPartyContactRequest{
|
||||
ThirdPartyID: input.ThirdPartyID,
|
||||
FullName: &input.FullName,
|
||||
Email: &emailAddr,
|
||||
Phone: &input.Phone,
|
||||
Role: &input.Role,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, types.AddVendorContactOutput{}, fmt.Errorf("cannot create vendor contact: %w", err)
|
||||
return nil, types.AddThirdPartyContactOutput{}, fmt.Errorf("cannot create thirdParty contact: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.AddVendorContactOutput{
|
||||
VendorContact: types.NewVendorContact(vendorContact),
|
||||
return nil, types.AddThirdPartyContactOutput{
|
||||
ThirdPartyContact: types.NewThirdPartyContact(thirdPartyContact),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateVendorContactTool handles the updateVendorContact tool
|
||||
// Update an existing vendor contact
|
||||
func (r *Resolver) UpdateVendorContactTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateVendorContactInput) (*mcp.CallToolResult, types.UpdateVendorContactOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionVendorContactUpdate)
|
||||
// UpdateThirdPartyContactTool handles the updateThirdPartyContact tool
|
||||
// Update an existing thirdParty contact
|
||||
func (r *Resolver) UpdateThirdPartyContactTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateThirdPartyContactInput) (*mcp.CallToolResult, types.UpdateThirdPartyContactOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionThirdPartyContactUpdate)
|
||||
|
||||
prb := r.ProboService(ctx, input.ID)
|
||||
|
||||
updateReq := probo.UpdateVendorContactRequest{
|
||||
updateReq := probo.UpdateThirdPartyContactRequest{
|
||||
ID: input.ID,
|
||||
}
|
||||
|
||||
@@ -3915,7 +3915,7 @@ func (r *Resolver) UpdateVendorContactTool(ctx context.Context, req *mcp.CallToo
|
||||
if input.Email != nil {
|
||||
emailAddr, err := mail.ParseAddr(*input.Email)
|
||||
if err != nil {
|
||||
return nil, types.UpdateVendorContactOutput{}, fmt.Errorf("invalid email address: %w", err)
|
||||
return nil, types.UpdateThirdPartyContactOutput{}, fmt.Errorf("invalid email address: %w", err)
|
||||
}
|
||||
emailPtr := &emailAddr
|
||||
updateReq.Email = &emailPtr
|
||||
@@ -3929,46 +3929,46 @@ func (r *Resolver) UpdateVendorContactTool(ctx context.Context, req *mcp.CallToo
|
||||
updateReq.Role = &input.Role
|
||||
}
|
||||
|
||||
vendorContact, err := prb.VendorContacts.Update(ctx, updateReq)
|
||||
thirdPartyContact, err := prb.ThirdPartyContacts.Update(ctx, updateReq)
|
||||
if err != nil {
|
||||
return nil, types.UpdateVendorContactOutput{}, fmt.Errorf("cannot update vendor contact: %w", err)
|
||||
return nil, types.UpdateThirdPartyContactOutput{}, fmt.Errorf("cannot update thirdParty contact: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateVendorContactOutput{
|
||||
VendorContact: types.NewVendorContact(vendorContact),
|
||||
return nil, types.UpdateThirdPartyContactOutput{
|
||||
ThirdPartyContact: types.NewThirdPartyContact(thirdPartyContact),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteVendorContactTool handles the deleteVendorContact tool
|
||||
// Delete a vendor contact
|
||||
func (r *Resolver) DeleteVendorContactTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteVendorContactInput) (*mcp.CallToolResult, types.DeleteVendorContactOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionVendorContactDelete)
|
||||
// DeleteThirdPartyContactTool handles the deleteThirdPartyContact tool
|
||||
// Delete a thirdParty contact
|
||||
func (r *Resolver) DeleteThirdPartyContactTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteThirdPartyContactInput) (*mcp.CallToolResult, types.DeleteThirdPartyContactOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionThirdPartyContactDelete)
|
||||
|
||||
prb := r.ProboService(ctx, input.ID)
|
||||
|
||||
err := prb.VendorContacts.Delete(ctx, input.ID)
|
||||
err := prb.ThirdPartyContacts.Delete(ctx, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.DeleteVendorContactOutput{}, fmt.Errorf("cannot delete vendor contact: %w", err)
|
||||
return nil, types.DeleteThirdPartyContactOutput{}, fmt.Errorf("cannot delete thirdParty contact: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeleteVendorContactOutput{
|
||||
DeletedVendorContactID: input.ID,
|
||||
return nil, types.DeleteThirdPartyContactOutput{
|
||||
DeletedThirdPartyContactID: input.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListVendorServicesTool handles the listVendorServices tool
|
||||
// List all services for a vendor
|
||||
func (r *Resolver) ListVendorServicesTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListVendorServicesInput) (*mcp.CallToolResult, types.ListVendorServicesOutput, error) {
|
||||
r.MustAuthorize(ctx, input.VendorID, probo.ActionVendorServiceList)
|
||||
// ListThirdPartyServicesTool handles the listThirdPartyServices tool
|
||||
// List all services for a thirdParty
|
||||
func (r *Resolver) ListThirdPartyServicesTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListThirdPartyServicesInput) (*mcp.CallToolResult, types.ListThirdPartyServicesOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ThirdPartyID, probo.ActionThirdPartyServiceList)
|
||||
|
||||
prb := r.ProboService(ctx, input.VendorID)
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID)
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorServiceOrderField]{
|
||||
Field: coredata.VendorServiceOrderFieldCreatedAt,
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyServiceOrderField]{
|
||||
Field: coredata.ThirdPartyServiceOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if input.OrderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.VendorServiceOrderField]{
|
||||
pageOrderBy = page.OrderBy[coredata.ThirdPartyServiceOrderField]{
|
||||
Field: input.OrderBy.Field,
|
||||
Direction: input.OrderBy.Direction,
|
||||
}
|
||||
@@ -3976,43 +3976,43 @@ func (r *Resolver) ListVendorServicesTool(ctx context.Context, req *mcp.CallTool
|
||||
|
||||
cursor := types.NewCursor(input.Size, input.Cursor, pageOrderBy)
|
||||
|
||||
p, err := prb.VendorServices.List(ctx, input.VendorID, cursor)
|
||||
p, err := prb.ThirdPartyServices.List(ctx, input.ThirdPartyID, cursor)
|
||||
if err != nil {
|
||||
return nil, types.ListVendorServicesOutput{}, fmt.Errorf("cannot list vendor services: %w", err)
|
||||
return nil, types.ListThirdPartyServicesOutput{}, fmt.Errorf("cannot list thirdParty services: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.NewListVendorServicesOutput(p), nil
|
||||
return nil, types.NewListThirdPartyServicesOutput(p), nil
|
||||
}
|
||||
|
||||
// AddVendorServiceTool handles the addVendorService tool
|
||||
// Add a new service to a vendor
|
||||
func (r *Resolver) AddVendorServiceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddVendorServiceInput) (*mcp.CallToolResult, types.AddVendorServiceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.VendorID, probo.ActionVendorServiceCreate)
|
||||
// AddThirdPartyServiceTool handles the addThirdPartyService tool
|
||||
// Add a new service to a thirdParty
|
||||
func (r *Resolver) AddThirdPartyServiceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddThirdPartyServiceInput) (*mcp.CallToolResult, types.AddThirdPartyServiceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ThirdPartyID, probo.ActionThirdPartyServiceCreate)
|
||||
|
||||
prb := r.ProboService(ctx, input.VendorID)
|
||||
prb := r.ProboService(ctx, input.ThirdPartyID)
|
||||
|
||||
vendorService, err := prb.VendorServices.Create(ctx, probo.CreateVendorServiceRequest{
|
||||
VendorID: input.VendorID,
|
||||
Name: input.Name,
|
||||
Description: input.Description,
|
||||
thirdPartyService, err := prb.ThirdPartyServices.Create(ctx, probo.CreateThirdPartyServiceRequest{
|
||||
ThirdPartyID: input.ThirdPartyID,
|
||||
Name: input.Name,
|
||||
Description: input.Description,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, types.AddVendorServiceOutput{}, fmt.Errorf("cannot create vendor service: %w", err)
|
||||
return nil, types.AddThirdPartyServiceOutput{}, fmt.Errorf("cannot create thirdParty service: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.AddVendorServiceOutput{
|
||||
VendorService: types.NewVendorService(vendorService),
|
||||
return nil, types.AddThirdPartyServiceOutput{
|
||||
ThirdPartyService: types.NewThirdPartyService(thirdPartyService),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateVendorServiceTool handles the updateVendorService tool
|
||||
// Update an existing vendor service
|
||||
func (r *Resolver) UpdateVendorServiceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateVendorServiceInput) (*mcp.CallToolResult, types.UpdateVendorServiceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionVendorServiceUpdate)
|
||||
// UpdateThirdPartyServiceTool handles the updateThirdPartyService tool
|
||||
// Update an existing thirdParty service
|
||||
func (r *Resolver) UpdateThirdPartyServiceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateThirdPartyServiceInput) (*mcp.CallToolResult, types.UpdateThirdPartyServiceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionThirdPartyServiceUpdate)
|
||||
|
||||
prb := r.ProboService(ctx, input.ID)
|
||||
|
||||
updateReq := probo.UpdateVendorServiceRequest{
|
||||
updateReq := probo.UpdateThirdPartyServiceRequest{
|
||||
ID: input.ID,
|
||||
}
|
||||
|
||||
@@ -4024,30 +4024,30 @@ func (r *Resolver) UpdateVendorServiceTool(ctx context.Context, req *mcp.CallToo
|
||||
updateReq.Description = &input.Description
|
||||
}
|
||||
|
||||
vendorService, err := prb.VendorServices.Update(ctx, updateReq)
|
||||
thirdPartyService, err := prb.ThirdPartyServices.Update(ctx, updateReq)
|
||||
if err != nil {
|
||||
return nil, types.UpdateVendorServiceOutput{}, fmt.Errorf("cannot update vendor service: %w", err)
|
||||
return nil, types.UpdateThirdPartyServiceOutput{}, fmt.Errorf("cannot update thirdParty service: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.UpdateVendorServiceOutput{
|
||||
VendorService: types.NewVendorService(vendorService),
|
||||
return nil, types.UpdateThirdPartyServiceOutput{
|
||||
ThirdPartyService: types.NewThirdPartyService(thirdPartyService),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteVendorServiceTool handles the deleteVendorService tool
|
||||
// Delete a vendor service
|
||||
func (r *Resolver) DeleteVendorServiceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteVendorServiceInput) (*mcp.CallToolResult, types.DeleteVendorServiceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionVendorServiceDelete)
|
||||
// DeleteThirdPartyServiceTool handles the deleteThirdPartyService tool
|
||||
// Delete a thirdParty service
|
||||
func (r *Resolver) DeleteThirdPartyServiceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteThirdPartyServiceInput) (*mcp.CallToolResult, types.DeleteThirdPartyServiceOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionThirdPartyServiceDelete)
|
||||
|
||||
prb := r.ProboService(ctx, input.ID)
|
||||
|
||||
err := prb.VendorServices.Delete(ctx, input.ID)
|
||||
err := prb.ThirdPartyServices.Delete(ctx, input.ID)
|
||||
if err != nil {
|
||||
return nil, types.DeleteVendorServiceOutput{}, fmt.Errorf("cannot delete vendor service: %w", err)
|
||||
return nil, types.DeleteThirdPartyServiceOutput{}, fmt.Errorf("cannot delete thirdParty service: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.DeleteVendorServiceOutput{
|
||||
DeletedVendorServiceID: input.ID,
|
||||
return nil, types.DeleteThirdPartyServiceOutput{
|
||||
DeletedThirdPartyServiceID: input.ID,
|
||||
}, nil
|
||||
}
|
||||
func (r *Resolver) DeleteAssetTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteAssetInput) (*mcp.CallToolResult, types.DeleteAssetOutput, error) {
|
||||
@@ -4572,24 +4572,24 @@ func (r *Resolver) DeleteCustomDomainTool(ctx context.Context, req *mcp.CallTool
|
||||
return nil, types.DeleteCustomDomainOutput{DeletedCustomDomain: deletedDomain}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) AssessVendorTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AssessVendorInput) (*mcp.CallToolResult, types.AssessVendorOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionVendorAssess)
|
||||
func (r *Resolver) AssessThirdPartyTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AssessThirdPartyInput) (*mcp.CallToolResult, types.AssessThirdPartyOutput, error) {
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionThirdPartyAssess)
|
||||
|
||||
svc := r.ProboService(ctx, input.ID)
|
||||
|
||||
result, err := svc.Vendors.Assess(
|
||||
result, err := svc.ThirdParties.Assess(
|
||||
ctx,
|
||||
probo.AssessVendorRequest{
|
||||
probo.AssessThirdPartyRequest{
|
||||
ID: input.ID,
|
||||
WebsiteURL: input.WebsiteURL,
|
||||
Procedure: input.Procedure,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, types.AssessVendorOutput{}, fmt.Errorf("cannot assess vendor: %w", err)
|
||||
return nil, types.AssessThirdPartyOutput{}, fmt.Errorf("cannot assess thirdParty: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.NewAssessVendorOutput(result), nil
|
||||
return nil, types.NewAssessThirdPartyOutput(result), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) PublishFindingListTool(ctx context.Context, req *mcp.CallToolRequest, input *types.PublishFindingListInput) (*mcp.CallToolResult, types.PublishFindingListOutput, error) {
|
||||
@@ -4672,17 +4672,17 @@ func (r *Resolver) PublishTransferImpactAssessmentListTool(ctx context.Context,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) PublishVendorListTool(ctx context.Context, req *mcp.CallToolRequest, input *types.PublishVendorListInput) (*mcp.CallToolResult, types.PublishVendorListOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionVendorPublish)
|
||||
func (r *Resolver) PublishThirdPartyListTool(ctx context.Context, req *mcp.CallToolRequest, input *types.PublishThirdPartyListInput) (*mcp.CallToolResult, types.PublishThirdPartyListOutput, error) {
|
||||
r.MustAuthorize(ctx, input.OrganizationID, probo.ActionThirdPartyPublish)
|
||||
|
||||
svc := r.ProboService(ctx, input.OrganizationID)
|
||||
|
||||
document, documentVersion, err := svc.GeneratedDocuments.PublishVendorList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := svc.GeneratedDocuments.PublishThirdPartyList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
if err != nil {
|
||||
return nil, types.PublishVendorListOutput{}, fmt.Errorf("cannot publish vendor list: %w", err)
|
||||
return nil, types.PublishThirdPartyListOutput{}, fmt.Errorf("cannot publish thirdParty list: %w", err)
|
||||
}
|
||||
|
||||
return nil, types.PublishVendorListOutput{
|
||||
return nil, types.PublishThirdPartyListOutput{
|
||||
DocumentID: document.ID,
|
||||
DocumentVersionID: documentVersion.ID,
|
||||
}, nil
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,11 +20,11 @@ import (
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
)
|
||||
|
||||
func NewVendorRiskAssessment(v *coredata.VendorRiskAssessment) *VendorRiskAssessment {
|
||||
return &VendorRiskAssessment{
|
||||
func NewThirdPartyRiskAssessment(v *coredata.ThirdPartyRiskAssessment) *ThirdPartyRiskAssessment {
|
||||
return &ThirdPartyRiskAssessment{
|
||||
ID: v.ID,
|
||||
OrganizationID: v.OrganizationID,
|
||||
VendorID: v.VendorID,
|
||||
ThirdPartyID: v.ThirdPartyID,
|
||||
ExpiresAt: v.ExpiresAt,
|
||||
DataSensitivity: v.DataSensitivity,
|
||||
BusinessImpact: v.BusinessImpact,
|
||||
@@ -34,10 +34,10 @@ func NewVendorRiskAssessment(v *coredata.VendorRiskAssessment) *VendorRiskAssess
|
||||
}
|
||||
}
|
||||
|
||||
func NewListVendorRiskAssessmentsOutput(p *page.Page[*coredata.VendorRiskAssessment, coredata.VendorRiskAssessmentOrderField]) ListVendorRiskAssessmentsOutput {
|
||||
assessments := make([]*VendorRiskAssessment, 0, len(p.Data))
|
||||
func NewListThirdPartyRiskAssessmentsOutput(p *page.Page[*coredata.ThirdPartyRiskAssessment, coredata.ThirdPartyRiskAssessmentOrderField]) ListThirdPartyRiskAssessmentsOutput {
|
||||
assessments := make([]*ThirdPartyRiskAssessment, 0, len(p.Data))
|
||||
for _, v := range p.Data {
|
||||
assessments = append(assessments, NewVendorRiskAssessment(v))
|
||||
assessments = append(assessments, NewThirdPartyRiskAssessment(v))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
@@ -46,30 +46,30 @@ func NewListVendorRiskAssessmentsOutput(p *page.Page[*coredata.VendorRiskAssessm
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return ListVendorRiskAssessmentsOutput{
|
||||
NextCursor: nextCursor,
|
||||
VendorRiskAssessments: assessments,
|
||||
return ListThirdPartyRiskAssessmentsOutput{
|
||||
NextCursor: nextCursor,
|
||||
ThirdPartyRiskAssessments: assessments,
|
||||
}
|
||||
}
|
||||
|
||||
func NewAddVendorRiskAssessmentOutput(v *coredata.VendorRiskAssessment) AddVendorRiskAssessmentOutput {
|
||||
return AddVendorRiskAssessmentOutput{
|
||||
VendorRiskAssessment: NewVendorRiskAssessment(v),
|
||||
func NewAddThirdPartyRiskAssessmentOutput(v *coredata.ThirdPartyRiskAssessment) AddThirdPartyRiskAssessmentOutput {
|
||||
return AddThirdPartyRiskAssessmentOutput{
|
||||
ThirdPartyRiskAssessment: NewThirdPartyRiskAssessment(v),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendor(v *coredata.Vendor) *Vendor {
|
||||
func NewThirdParty(v *coredata.ThirdParty) *ThirdParty {
|
||||
countries := make([]string, len(v.Countries))
|
||||
for i, c := range v.Countries {
|
||||
countries[i] = string(c)
|
||||
}
|
||||
|
||||
return &Vendor{
|
||||
return &ThirdParty{
|
||||
ID: v.ID,
|
||||
OrganizationID: v.OrganizationID,
|
||||
Name: v.Name,
|
||||
Description: v.Description,
|
||||
Category: VendorCategory(v.Category),
|
||||
Category: ThirdPartyCategory(v.Category),
|
||||
HeadquarterAddress: v.HeadquarterAddress,
|
||||
LegalName: v.LegalName,
|
||||
WebsiteURL: v.WebsiteURL,
|
||||
@@ -91,37 +91,37 @@ func NewVendor(v *coredata.Vendor) *Vendor {
|
||||
}
|
||||
}
|
||||
|
||||
func NewListVendorsOutput(vendorPage *page.Page[*coredata.Vendor, coredata.VendorOrderField]) ListVendorsOutput {
|
||||
vendors := make([]*Vendor, 0, len(vendorPage.Data))
|
||||
for _, v := range vendorPage.Data {
|
||||
vendors = append(vendors, NewVendor(v))
|
||||
func NewListThirdPartiesOutput(thirdPartyPage *page.Page[*coredata.ThirdParty, coredata.ThirdPartyOrderField]) ListThirdPartiesOutput {
|
||||
thirdParties := make([]*ThirdParty, 0, len(thirdPartyPage.Data))
|
||||
for _, v := range thirdPartyPage.Data {
|
||||
thirdParties = append(thirdParties, NewThirdParty(v))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
if len(vendorPage.Data) > 0 {
|
||||
cursorKey := vendorPage.Data[len(vendorPage.Data)-1].CursorKey(vendorPage.Cursor.OrderBy.Field)
|
||||
if len(thirdPartyPage.Data) > 0 {
|
||||
cursorKey := thirdPartyPage.Data[len(thirdPartyPage.Data)-1].CursorKey(thirdPartyPage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return ListVendorsOutput{
|
||||
NextCursor: nextCursor,
|
||||
Vendors: vendors,
|
||||
return ListThirdPartiesOutput{
|
||||
NextCursor: nextCursor,
|
||||
ThirdParties: thirdParties,
|
||||
}
|
||||
}
|
||||
|
||||
func NewAddVendorOutput(v *coredata.Vendor) AddVendorOutput {
|
||||
return AddVendorOutput{
|
||||
Vendor: NewVendor(v),
|
||||
func NewAddThirdPartyOutput(v *coredata.ThirdParty) AddThirdPartyOutput {
|
||||
return AddThirdPartyOutput{
|
||||
ThirdParty: NewThirdParty(v),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUpdateVendorOutput(v *coredata.Vendor) UpdateVendorOutput {
|
||||
return UpdateVendorOutput{
|
||||
Vendor: NewVendor(v),
|
||||
func NewUpdateThirdPartyOutput(v *coredata.ThirdParty) UpdateThirdPartyOutput {
|
||||
return UpdateThirdPartyOutput{
|
||||
ThirdParty: NewThirdParty(v),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorContact(vc *coredata.VendorContact) *VendorContact {
|
||||
func NewThirdPartyContact(vc *coredata.ThirdPartyContact) *ThirdPartyContact {
|
||||
var fullName string
|
||||
if vc.FullName != nil {
|
||||
fullName = *vc.FullName
|
||||
@@ -142,22 +142,22 @@ func NewVendorContact(vc *coredata.VendorContact) *VendorContact {
|
||||
role = *vc.Role
|
||||
}
|
||||
|
||||
return &VendorContact{
|
||||
ID: vc.ID,
|
||||
VendorID: vc.VendorID,
|
||||
FullName: fullName,
|
||||
Email: email,
|
||||
Phone: phone,
|
||||
Role: role,
|
||||
CreatedAt: vc.CreatedAt,
|
||||
UpdatedAt: vc.UpdatedAt,
|
||||
return &ThirdPartyContact{
|
||||
ID: vc.ID,
|
||||
ThirdPartyID: vc.ThirdPartyID,
|
||||
FullName: fullName,
|
||||
Email: email,
|
||||
Phone: phone,
|
||||
Role: role,
|
||||
CreatedAt: vc.CreatedAt,
|
||||
UpdatedAt: vc.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewListVendorContactsOutput(p *page.Page[*coredata.VendorContact, coredata.VendorContactOrderField]) ListVendorContactsOutput {
|
||||
contacts := make([]*VendorContact, 0, len(p.Data))
|
||||
func NewListThirdPartyContactsOutput(p *page.Page[*coredata.ThirdPartyContact, coredata.ThirdPartyContactOrderField]) ListThirdPartyContactsOutput {
|
||||
contacts := make([]*ThirdPartyContact, 0, len(p.Data))
|
||||
for _, vc := range p.Data {
|
||||
contacts = append(contacts, NewVendorContact(vc))
|
||||
contacts = append(contacts, NewThirdPartyContact(vc))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
@@ -166,32 +166,32 @@ func NewListVendorContactsOutput(p *page.Page[*coredata.VendorContact, coredata.
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return ListVendorContactsOutput{
|
||||
NextCursor: nextCursor,
|
||||
VendorContacts: contacts,
|
||||
return ListThirdPartyContactsOutput{
|
||||
NextCursor: nextCursor,
|
||||
ThirdPartyContacts: contacts,
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorService(vs *coredata.VendorService) *VendorService {
|
||||
func NewThirdPartyService(vs *coredata.ThirdPartyService) *ThirdPartyService {
|
||||
var description string
|
||||
if vs.Description != nil {
|
||||
description = *vs.Description
|
||||
}
|
||||
|
||||
return &VendorService{
|
||||
ID: vs.ID,
|
||||
VendorID: vs.VendorID,
|
||||
Name: vs.Name,
|
||||
Description: description,
|
||||
CreatedAt: vs.CreatedAt,
|
||||
UpdatedAt: vs.UpdatedAt,
|
||||
return &ThirdPartyService{
|
||||
ID: vs.ID,
|
||||
ThirdPartyID: vs.ThirdPartyID,
|
||||
Name: vs.Name,
|
||||
Description: description,
|
||||
CreatedAt: vs.CreatedAt,
|
||||
UpdatedAt: vs.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewListVendorServicesOutput(p *page.Page[*coredata.VendorService, coredata.VendorServiceOrderField]) ListVendorServicesOutput {
|
||||
services := make([]*VendorService, 0, len(p.Data))
|
||||
func NewListThirdPartyServicesOutput(p *page.Page[*coredata.ThirdPartyService, coredata.ThirdPartyServiceOrderField]) ListThirdPartyServicesOutput {
|
||||
services := make([]*ThirdPartyService, 0, len(p.Data))
|
||||
for _, vs := range p.Data {
|
||||
services = append(services, NewVendorService(vs))
|
||||
services = append(services, NewThirdPartyService(vs))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
@@ -200,16 +200,16 @@ func NewListVendorServicesOutput(p *page.Page[*coredata.VendorService, coredata.
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return ListVendorServicesOutput{
|
||||
NextCursor: nextCursor,
|
||||
VendorServices: services,
|
||||
return ListThirdPartyServicesOutput{
|
||||
NextCursor: nextCursor,
|
||||
ThirdPartyServices: services,
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorSubprocessors(sps []probo.Subprocessor) []*VendorSubprocessor {
|
||||
result := make([]*VendorSubprocessor, len(sps))
|
||||
func NewThirdPartySubprocessors(sps []probo.Subprocessor) []*ThirdPartySubprocessor {
|
||||
result := make([]*ThirdPartySubprocessor, len(sps))
|
||||
for i, sp := range sps {
|
||||
result[i] = &VendorSubprocessor{
|
||||
result[i] = &ThirdPartySubprocessor{
|
||||
Name: sp.Name,
|
||||
Country: sp.Country,
|
||||
Purpose: sp.Purpose,
|
||||
@@ -218,10 +218,10 @@ func NewVendorSubprocessors(sps []probo.Subprocessor) []*VendorSubprocessor {
|
||||
return result
|
||||
}
|
||||
|
||||
func NewAssessVendorOutput(result *probo.AssessVendorResult) AssessVendorOutput {
|
||||
return AssessVendorOutput{
|
||||
Vendor: NewVendor(result.Vendor),
|
||||
func NewAssessThirdPartyOutput(result *probo.AssessThirdPartyResult) AssessThirdPartyOutput {
|
||||
return AssessThirdPartyOutput{
|
||||
ThirdParty: NewThirdParty(result.ThirdParty),
|
||||
Report: result.Report,
|
||||
Subprocessors: NewVendorSubprocessors(result.Subprocessors),
|
||||
Subprocessors: NewThirdPartySubprocessors(result.Subprocessors),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user