Add vendor compliance reports
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -226,6 +226,20 @@ enum EvidenceOrderField
|
||||
CREATED_AT
|
||||
}
|
||||
|
||||
enum VendorComplianceReportOrderField
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/coredata.VendorComplianceReportOrderField"
|
||||
) {
|
||||
REPORT_DATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorComplianceReportOrderFieldReportDate"
|
||||
)
|
||||
CREATED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.VendorComplianceReportOrderFieldCreatedAt"
|
||||
)
|
||||
}
|
||||
|
||||
enum OrganizationOrderField {
|
||||
NAME
|
||||
CREATED_AT
|
||||
@@ -313,6 +327,14 @@ input EvidenceOrder
|
||||
field: EvidenceOrderField!
|
||||
}
|
||||
|
||||
input VendorComplianceReportOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.VendorComplianceReportOrderBy"
|
||||
) {
|
||||
direction: OrderDirection!
|
||||
field: VendorComplianceReportOrderField!
|
||||
}
|
||||
|
||||
input OrganizationOrder {
|
||||
direction: OrderDirection!
|
||||
field: OrganizationOrderField!
|
||||
@@ -406,6 +428,15 @@ type Vendor implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
description: String!
|
||||
|
||||
complianceReports(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: VendorComplianceReportOrder
|
||||
): VendorComplianceReportConnection! @goField(forceResolver: true)
|
||||
|
||||
serviceStartAt: Datetime!
|
||||
serviceTerminationAt: Datetime
|
||||
serviceCriticality: ServiceCriticality!
|
||||
@@ -417,6 +448,20 @@ type Vendor implements Node {
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type VendorComplianceReport implements Node {
|
||||
id: ID!
|
||||
vendor: Vendor! @goField(forceResolver: true)
|
||||
reportDate: Datetime!
|
||||
validUntil: Datetime
|
||||
reportName: String!
|
||||
|
||||
fileUrl: String! @goField(forceResolver: true)
|
||||
fileSize: Int!
|
||||
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Framework implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
@@ -699,6 +744,16 @@ type RiskEdge {
|
||||
node: Risk!
|
||||
}
|
||||
|
||||
type VendorComplianceReportConnection {
|
||||
edges: [VendorComplianceReportEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type VendorComplianceReportEdge {
|
||||
cursor: CursorKey!
|
||||
node: VendorComplianceReport!
|
||||
}
|
||||
|
||||
# Root Types
|
||||
type Query {
|
||||
node(id: ID!): Node!
|
||||
@@ -777,6 +832,14 @@ type Mutation {
|
||||
createEvidence(input: CreateEvidenceInput!): CreateEvidencePayload!
|
||||
deleteEvidence(input: DeleteEvidenceInput!): DeleteEvidencePayload!
|
||||
|
||||
# Vendor Compliance Report mutations
|
||||
uploadVendorComplianceReport(
|
||||
input: UploadVendorComplianceReportInput!
|
||||
): UploadVendorComplianceReportPayload!
|
||||
deleteVendorComplianceReport(
|
||||
input: DeleteVendorComplianceReportInput!
|
||||
): DeleteVendorComplianceReportPayload!
|
||||
|
||||
# Policy mutations
|
||||
createPolicy(input: CreatePolicyInput!): CreatePolicyPayload!
|
||||
updatePolicy(input: UpdatePolicyInput!): UpdatePolicyPayload!
|
||||
@@ -999,6 +1062,18 @@ input DeleteEvidenceInput {
|
||||
evidenceId: ID!
|
||||
}
|
||||
|
||||
input UploadVendorComplianceReportInput {
|
||||
vendorId: ID!
|
||||
reportDate: Datetime!
|
||||
validUntil: Datetime
|
||||
reportName: String!
|
||||
file: Upload!
|
||||
}
|
||||
|
||||
input DeleteVendorComplianceReportInput {
|
||||
reportId: ID!
|
||||
}
|
||||
|
||||
input CreatePolicyInput {
|
||||
organizationId: ID!
|
||||
name: String!
|
||||
@@ -1173,6 +1248,14 @@ type DeleteEvidencePayload {
|
||||
deletedEvidenceId: ID!
|
||||
}
|
||||
|
||||
type UploadVendorComplianceReportPayload {
|
||||
vendorComplianceReportEdge: VendorComplianceReportEdge!
|
||||
}
|
||||
|
||||
type DeleteVendorComplianceReportPayload {
|
||||
deletedVendorComplianceReportId: ID!
|
||||
}
|
||||
|
||||
type CreatePolicyPayload {
|
||||
policyEdge: PolicyEdge!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -281,6 +281,14 @@ type DeleteTaskPayload struct {
|
||||
DeletedTaskID gid.GID `json:"deletedTaskId"`
|
||||
}
|
||||
|
||||
type DeleteVendorComplianceReportInput struct {
|
||||
ReportID gid.GID `json:"reportId"`
|
||||
}
|
||||
|
||||
type DeleteVendorComplianceReportPayload struct {
|
||||
DeletedVendorComplianceReportID gid.GID `json:"deletedVendorComplianceReportId"`
|
||||
}
|
||||
|
||||
type DeleteVendorInput struct {
|
||||
VendorID gid.GID `json:"vendorId"`
|
||||
}
|
||||
@@ -679,6 +687,18 @@ type UpdateVendorPayload struct {
|
||||
Vendor *Vendor `json:"vendor"`
|
||||
}
|
||||
|
||||
type UploadVendorComplianceReportInput struct {
|
||||
VendorID gid.GID `json:"vendorId"`
|
||||
ReportDate time.Time `json:"reportDate"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
ReportName string `json:"reportName"`
|
||||
File graphql.Upload `json:"file"`
|
||||
}
|
||||
|
||||
type UploadVendorComplianceReportPayload struct {
|
||||
VendorComplianceReportEdge *VendorComplianceReportEdge `json:"vendorComplianceReportEdge"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID gid.GID `json:"id"`
|
||||
FullName string `json:"fullName"`
|
||||
@@ -701,23 +721,49 @@ type UserEdge struct {
|
||||
}
|
||||
|
||||
type Vendor struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
ServiceStartAt time.Time `json:"serviceStartAt"`
|
||||
ServiceTerminationAt *time.Time `json:"serviceTerminationAt,omitempty"`
|
||||
ServiceCriticality coredata.ServiceCriticality `json:"serviceCriticality"`
|
||||
RiskTier coredata.RiskTier `json:"riskTier"`
|
||||
StatusPageURL *string `json:"statusPageUrl,omitempty"`
|
||||
TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"`
|
||||
PrivacyPolicyURL *string `json:"privacyPolicyUrl,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
ComplianceReports *VendorComplianceReportConnection `json:"complianceReports"`
|
||||
ServiceStartAt time.Time `json:"serviceStartAt"`
|
||||
ServiceTerminationAt *time.Time `json:"serviceTerminationAt,omitempty"`
|
||||
ServiceCriticality coredata.ServiceCriticality `json:"serviceCriticality"`
|
||||
RiskTier coredata.RiskTier `json:"riskTier"`
|
||||
StatusPageURL *string `json:"statusPageUrl,omitempty"`
|
||||
TermsOfServiceURL *string `json:"termsOfServiceUrl,omitempty"`
|
||||
PrivacyPolicyURL *string `json:"privacyPolicyUrl,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Vendor) IsNode() {}
|
||||
func (this Vendor) GetID() gid.GID { return this.ID }
|
||||
|
||||
type VendorComplianceReport struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Vendor *Vendor `json:"vendor"`
|
||||
ReportDate time.Time `json:"reportDate"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
ReportName string `json:"reportName"`
|
||||
FileURL string `json:"fileUrl"`
|
||||
FileSize int `json:"fileSize"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (VendorComplianceReport) IsNode() {}
|
||||
func (this VendorComplianceReport) GetID() gid.GID { return this.ID }
|
||||
|
||||
type VendorComplianceReportConnection struct {
|
||||
Edges []*VendorComplianceReportEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type VendorComplianceReportEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *VendorComplianceReport `json:"node"`
|
||||
}
|
||||
|
||||
type VendorConnection struct {
|
||||
Edges []*VendorEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
|
||||
56
pkg/server/api/console/v1/types/vendor_compliance_report.go
Normal file
56
pkg/server/api/console/v1/types/vendor_compliance_report.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
VendorComplianceReportOrderBy OrderBy[coredata.VendorComplianceReportOrderField]
|
||||
)
|
||||
|
||||
func NewVendorComplianceReportConnection(p *page.Page[*coredata.VendorComplianceReport, coredata.VendorComplianceReportOrderField]) *VendorComplianceReportConnection {
|
||||
var edges = make([]*VendorComplianceReportEdge, len(p.Data))
|
||||
|
||||
for i := range edges {
|
||||
edges[i] = NewVendorComplianceReportEdge(p.Data[i], p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &VendorComplianceReportConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorComplianceReportEdge(c *coredata.VendorComplianceReport, orderBy coredata.VendorComplianceReportOrderField) *VendorComplianceReportEdge {
|
||||
return &VendorComplianceReportEdge{
|
||||
Cursor: c.CursorKey(orderBy),
|
||||
Node: NewVendorComplianceReport(c),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVendorComplianceReport(c *coredata.VendorComplianceReport) *VendorComplianceReport {
|
||||
return &VendorComplianceReport{
|
||||
ID: c.ID,
|
||||
ReportDate: c.ReportDate,
|
||||
ValidUntil: c.ValidUntil,
|
||||
ReportName: c.ReportName,
|
||||
FileSize: c.FileSize,
|
||||
CreatedAt: c.CreatedAt,
|
||||
UpdatedAt: c.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -866,6 +866,43 @@ func (r *mutationResolver) DeleteEvidence(ctx context.Context, input types.Delet
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UploadVendorComplianceReport is the resolver for the uploadVendorComplianceReport field.
|
||||
func (r *mutationResolver) UploadVendorComplianceReport(ctx context.Context, input types.UploadVendorComplianceReportInput) (*types.UploadVendorComplianceReportPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.VendorID.TenantID())
|
||||
|
||||
vendorComplianceReport, err := svc.VendorComplianceReports.Upload(
|
||||
ctx,
|
||||
input.VendorID,
|
||||
&probo.VendorComplianceReportCreateRequest{
|
||||
File: input.File.File,
|
||||
ReportDate: input.ReportDate,
|
||||
ValidUntil: input.ValidUntil,
|
||||
ReportName: input.ReportName,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to upload vendor compliance report: %w", err))
|
||||
}
|
||||
|
||||
return &types.UploadVendorComplianceReportPayload{
|
||||
VendorComplianceReportEdge: types.NewVendorComplianceReportEdge(vendorComplianceReport, coredata.VendorComplianceReportOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteVendorComplianceReport is the resolver for the deleteVendorComplianceReport field.
|
||||
func (r *mutationResolver) DeleteVendorComplianceReport(ctx context.Context, input types.DeleteVendorComplianceReportInput) (*types.DeleteVendorComplianceReportPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ReportID.TenantID())
|
||||
|
||||
err := svc.VendorComplianceReports.Delete(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to delete vendor compliance report: %w", err))
|
||||
}
|
||||
|
||||
return &types.DeleteVendorComplianceReportPayload{
|
||||
DeletedVendorComplianceReportID: input.ReportID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreatePolicy is the resolver for the createPolicy field.
|
||||
func (r *mutationResolver) CreatePolicy(ctx context.Context, input types.CreatePolicyInput) (*types.CreatePolicyPayload, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.OrganizationID.TenantID())
|
||||
@@ -1218,6 +1255,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
panic(fmt.Errorf("cannot get risk: %w", err))
|
||||
}
|
||||
return types.NewRisk(risk), nil
|
||||
case coredata.VendorComplianceReportEntityType:
|
||||
vendorComplianceReport, err := svc.VendorComplianceReports.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get vendor compliance report: %w", err))
|
||||
}
|
||||
return types.NewVendorComplianceReport(vendorComplianceReport), nil
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -1305,6 +1348,55 @@ func (r *taskResolver) Evidences(ctx context.Context, obj *types.Task, first *in
|
||||
return types.NewEvidenceConnection(page), nil
|
||||
}
|
||||
|
||||
// ComplianceReports is the resolver for the complianceReports field.
|
||||
func (r *vendorResolver) ComplianceReports(ctx context.Context, obj *types.Vendor, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorComplianceReportOrderBy) (*types.VendorComplianceReportConnection, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.VendorComplianceReportOrderField]{
|
||||
Field: coredata.VendorComplianceReportOrderFieldReportDate,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.VendorComplianceReportOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := svc.VendorComplianceReports.ListForVendorID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to list vendor compliance reports: %w", err))
|
||||
}
|
||||
|
||||
return types.NewVendorComplianceReportConnection(page), nil
|
||||
}
|
||||
|
||||
// Vendor is the resolver for the vendor field.
|
||||
func (r *vendorComplianceReportResolver) Vendor(ctx context.Context, obj *types.VendorComplianceReport) (*types.Vendor, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get vendor: %w", err))
|
||||
}
|
||||
|
||||
return types.NewVendor(vendor), nil
|
||||
}
|
||||
|
||||
// FileURL is the resolver for the fileUrl field.
|
||||
func (r *vendorComplianceReportResolver) FileURL(ctx context.Context, obj *types.VendorComplianceReport) (string, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
|
||||
fileURL, err := svc.VendorComplianceReports.GenerateFileURL(ctx, obj.ID, 1*time.Hour)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to generate file URL: %w", err))
|
||||
}
|
||||
|
||||
return fileURL, nil
|
||||
}
|
||||
|
||||
// Organizations is the resolver for the organizations field.
|
||||
func (r *viewerResolver) Organizations(ctx context.Context, obj *types.Viewer, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrganizationOrder) (*types.OrganizationConnection, error) {
|
||||
user := UserFromContext(ctx)
|
||||
@@ -1360,6 +1452,14 @@ func (r *Resolver) Risk() schema.RiskResolver { return &riskResolver{r} }
|
||||
// Task returns schema.TaskResolver implementation.
|
||||
func (r *Resolver) Task() schema.TaskResolver { return &taskResolver{r} }
|
||||
|
||||
// Vendor returns schema.VendorResolver implementation.
|
||||
func (r *Resolver) Vendor() schema.VendorResolver { return &vendorResolver{r} }
|
||||
|
||||
// VendorComplianceReport returns schema.VendorComplianceReportResolver implementation.
|
||||
func (r *Resolver) VendorComplianceReport() schema.VendorComplianceReportResolver {
|
||||
return &vendorComplianceReportResolver{r}
|
||||
}
|
||||
|
||||
// Viewer returns schema.ViewerResolver implementation.
|
||||
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
||||
|
||||
@@ -1373,4 +1473,6 @@ type policyResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
||||
type riskResolver struct{ *Resolver }
|
||||
type taskResolver struct{ *Resolver }
|
||||
type vendorResolver struct{ *Resolver }
|
||||
type vendorComplianceReportResolver struct{ *Resolver }
|
||||
type viewerResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user