@@ -127,6 +127,30 @@ enum RiskTreatment
|
||||
)
|
||||
}
|
||||
|
||||
enum AuditState
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.AuditState") {
|
||||
NOT_STARTED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditStateNotStarted"
|
||||
)
|
||||
IN_PROGRESS
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditStateInProgress"
|
||||
)
|
||||
COMPLETED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditStateCompleted"
|
||||
)
|
||||
REJECTED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditStateRejected"
|
||||
)
|
||||
OUTDATED
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditStateOutdated"
|
||||
)
|
||||
}
|
||||
|
||||
# Order Field Enums
|
||||
enum UserOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.UserOrderField") {
|
||||
@@ -521,6 +545,27 @@ enum ControlStatus
|
||||
value: "github.com/getprobo/probo/pkg/coredata.ControlStatusExcluded"
|
||||
)
|
||||
}
|
||||
|
||||
enum AuditOrderField
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.AuditOrderField") {
|
||||
CREATED_AT
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldCreatedAt"
|
||||
)
|
||||
VALID_FROM
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldValidFrom"
|
||||
)
|
||||
VALID_UNTIL
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldValidUntil"
|
||||
)
|
||||
STATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.AuditOrderFieldState"
|
||||
)
|
||||
}
|
||||
|
||||
# Input Types
|
||||
input UserOrder
|
||||
@goModel(
|
||||
@@ -594,6 +639,14 @@ input RiskOrder
|
||||
field: RiskOrderField!
|
||||
}
|
||||
|
||||
input AuditOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.AuditOrderBy"
|
||||
) {
|
||||
direction: OrderDirection!
|
||||
field: AuditOrderField!
|
||||
}
|
||||
|
||||
input EvidenceOrder
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.EvidenceOrderBy"
|
||||
@@ -755,6 +808,14 @@ type Organization implements Node {
|
||||
orderBy: DatumOrder
|
||||
): DatumConnection! @goField(forceResolver: true)
|
||||
|
||||
audits(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
orderBy: AuditOrder
|
||||
): AuditConnection! @goField(forceResolver: true)
|
||||
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
@@ -1064,6 +1125,30 @@ type Risk implements Node {
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Audit implements Node {
|
||||
id: ID!
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
framework: Framework! @goField(forceResolver: true)
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
report: Report @goField(forceResolver: true)
|
||||
reportUrl: String @goField(forceResolver: true)
|
||||
state: AuditState!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Report implements Node {
|
||||
id: ID!
|
||||
objectKey: String!
|
||||
mimeType: String!
|
||||
filename: String!
|
||||
size: Int!
|
||||
downloadUrl: String @goField(forceResolver: true)
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
|
||||
type Session {
|
||||
id: ID!
|
||||
expiresAt: Datetime!
|
||||
@@ -1283,6 +1368,20 @@ type DatumEdge {
|
||||
node: Datum!
|
||||
}
|
||||
|
||||
type AuditConnection
|
||||
@goModel(
|
||||
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.AuditConnection"
|
||||
) {
|
||||
totalCount: Int! @goField(forceResolver: true)
|
||||
edges: [AuditEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type AuditEdge {
|
||||
cursor: CursorKey!
|
||||
node: Audit!
|
||||
}
|
||||
|
||||
# Root Types
|
||||
type Query {
|
||||
node(id: ID!): Node!
|
||||
@@ -1437,6 +1536,12 @@ type Mutation {
|
||||
createDatum(input: CreateDatumInput!): CreateDatumPayload!
|
||||
updateDatum(input: UpdateDatumInput!): UpdateDatumPayload!
|
||||
deleteDatum(input: DeleteDatumInput!): DeleteDatumPayload!
|
||||
|
||||
createAudit(input: CreateAuditInput!): CreateAuditPayload!
|
||||
updateAudit(input: UpdateAuditInput!): UpdateAuditPayload!
|
||||
deleteAudit(input: DeleteAuditInput!): DeleteAuditPayload!
|
||||
uploadAuditReport(input: UploadAuditReportInput!): UploadAuditReportPayload!
|
||||
deleteAuditReport(input: DeleteAuditReportInput!): DeleteAuditReportPayload!
|
||||
}
|
||||
|
||||
# Input Types
|
||||
@@ -1778,6 +1883,35 @@ input DeleteControlInput {
|
||||
controlId: ID!
|
||||
}
|
||||
|
||||
# Audit input types
|
||||
input CreateAuditInput {
|
||||
organizationId: ID!
|
||||
frameworkId: ID!
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
}
|
||||
|
||||
input UpdateAuditInput {
|
||||
id: ID!
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
}
|
||||
|
||||
input DeleteAuditInput {
|
||||
auditId: ID!
|
||||
}
|
||||
|
||||
input UploadAuditReportInput {
|
||||
auditId: ID!
|
||||
file: Upload!
|
||||
}
|
||||
|
||||
input DeleteAuditReportInput {
|
||||
auditId: ID!
|
||||
}
|
||||
|
||||
# Payload Types
|
||||
type CreateOrganizationPayload {
|
||||
organizationEdge: OrganizationEdge!
|
||||
@@ -2354,3 +2488,23 @@ type UpdateDatumPayload {
|
||||
type DeleteDatumPayload {
|
||||
deletedDatumId: ID!
|
||||
}
|
||||
|
||||
type CreateAuditPayload {
|
||||
auditEdge: AuditEdge!
|
||||
}
|
||||
|
||||
type UpdateAuditPayload {
|
||||
audit: Audit!
|
||||
}
|
||||
|
||||
type DeleteAuditPayload {
|
||||
deletedAuditId: ID!
|
||||
}
|
||||
|
||||
type UploadAuditReportPayload {
|
||||
audit: Audit!
|
||||
}
|
||||
|
||||
type DeleteAuditReportPayload {
|
||||
audit: Audit!
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
71
pkg/server/api/console/v1/types/audit.go
Normal file
71
pkg/server/api/console/v1/types/audit.go
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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/gid"
|
||||
"github.com/getprobo/probo/pkg/page"
|
||||
)
|
||||
|
||||
type (
|
||||
AuditOrderBy OrderBy[coredata.AuditOrderField]
|
||||
|
||||
AuditConnection struct {
|
||||
TotalCount int
|
||||
Edges []*AuditEdge
|
||||
PageInfo PageInfo
|
||||
|
||||
Resolver any
|
||||
ParentID gid.GID
|
||||
}
|
||||
)
|
||||
|
||||
func NewAuditConnection(
|
||||
p *page.Page[*coredata.Audit, coredata.AuditOrderField],
|
||||
parentType any,
|
||||
parentID gid.GID,
|
||||
) *AuditConnection {
|
||||
edges := make([]*AuditEdge, len(p.Data))
|
||||
for i, audit := range p.Data {
|
||||
edges[i] = NewAuditEdge(audit, p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &AuditConnection{
|
||||
Edges: edges,
|
||||
PageInfo: *NewPageInfo(p),
|
||||
|
||||
Resolver: parentType,
|
||||
ParentID: parentID,
|
||||
}
|
||||
}
|
||||
|
||||
func NewAudit(a *coredata.Audit) *Audit {
|
||||
return &Audit{
|
||||
ID: a.ID,
|
||||
ValidFrom: a.ValidFrom,
|
||||
ValidUntil: a.ValidUntil,
|
||||
State: a.State,
|
||||
CreatedAt: a.CreatedAt,
|
||||
UpdatedAt: a.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewAuditEdge(a *coredata.Audit, orderField coredata.AuditOrderField) *AuditEdge {
|
||||
return &AuditEdge{
|
||||
Node: NewAudit(a),
|
||||
Cursor: a.CursorKey(orderField),
|
||||
}
|
||||
}
|
||||
31
pkg/server/api/console/v1/types/report.go
Normal file
31
pkg/server/api/console/v1/types/report.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
func NewReport(r *coredata.Report) *Report {
|
||||
return &Report{
|
||||
ID: r.ID,
|
||||
ObjectKey: r.ObjectKey,
|
||||
MimeType: r.MimeType,
|
||||
Filename: r.Filename,
|
||||
Size: int(r.Size),
|
||||
CreatedAt: r.CreatedAt,
|
||||
UpdatedAt: r.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,27 @@ type AssignTaskPayload struct {
|
||||
Task *Task `json:"task"`
|
||||
}
|
||||
|
||||
type Audit struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Framework *Framework `json:"framework"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
Report *Report `json:"report,omitempty"`
|
||||
ReportURL *string `json:"reportUrl,omitempty"`
|
||||
State coredata.AuditState `json:"state"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Audit) IsNode() {}
|
||||
func (this Audit) GetID() gid.GID { return this.ID }
|
||||
|
||||
type AuditEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *Audit `json:"node"`
|
||||
}
|
||||
|
||||
type BulkPublishDocumentVersionsInput struct {
|
||||
DocumentIds []gid.GID `json:"documentIds"`
|
||||
Changelog string `json:"changelog"`
|
||||
@@ -158,6 +179,18 @@ type CreateAssetPayload struct {
|
||||
AssetEdge *AssetEdge `json:"assetEdge"`
|
||||
}
|
||||
|
||||
type CreateAuditInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
FrameworkID gid.GID `json:"frameworkId"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
type CreateAuditPayload struct {
|
||||
AuditEdge *AuditEdge `json:"auditEdge"`
|
||||
}
|
||||
|
||||
type CreateControlDocumentMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
@@ -399,6 +432,22 @@ type DeleteAssetPayload struct {
|
||||
DeletedAssetID gid.GID `json:"deletedAssetId"`
|
||||
}
|
||||
|
||||
type DeleteAuditInput struct {
|
||||
AuditID gid.GID `json:"auditId"`
|
||||
}
|
||||
|
||||
type DeleteAuditPayload struct {
|
||||
DeletedAuditID gid.GID `json:"deletedAuditId"`
|
||||
}
|
||||
|
||||
type DeleteAuditReportInput struct {
|
||||
AuditID gid.GID `json:"auditId"`
|
||||
}
|
||||
|
||||
type DeleteAuditReportPayload struct {
|
||||
Audit *Audit `json:"audit"`
|
||||
}
|
||||
|
||||
type DeleteControlDocumentMappingInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
DocumentID gid.GID `json:"documentId"`
|
||||
@@ -766,6 +815,7 @@ type Organization struct {
|
||||
Tasks *TaskConnection `json:"tasks"`
|
||||
Assets *AssetConnection `json:"assets"`
|
||||
Data *DatumConnection `json:"data"`
|
||||
Audits *AuditConnection `json:"audits"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
@@ -838,6 +888,20 @@ type RemoveUserPayload struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type Report struct {
|
||||
ID gid.GID `json:"id"`
|
||||
ObjectKey string `json:"objectKey"`
|
||||
MimeType string `json:"mimeType"`
|
||||
Filename string `json:"filename"`
|
||||
Size int `json:"size"`
|
||||
DownloadURL *string `json:"downloadUrl,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Report) IsNode() {}
|
||||
func (this Report) GetID() gid.GID { return this.ID }
|
||||
|
||||
type RequestEvidenceInput struct {
|
||||
TaskID gid.GID `json:"taskId"`
|
||||
Name string `json:"name"`
|
||||
@@ -951,6 +1015,17 @@ type UpdateAssetPayload struct {
|
||||
Asset *Asset `json:"asset"`
|
||||
}
|
||||
|
||||
type UpdateAuditInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateAuditPayload struct {
|
||||
Audit *Audit `json:"audit"`
|
||||
}
|
||||
|
||||
type UpdateControlInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
SectionTitle *string `json:"sectionTitle,omitempty"`
|
||||
@@ -1102,6 +1177,15 @@ type UpdateVendorPayload struct {
|
||||
Vendor *Vendor `json:"vendor"`
|
||||
}
|
||||
|
||||
type UploadAuditReportInput struct {
|
||||
AuditID gid.GID `json:"auditId"`
|
||||
File graphql.Upload `json:"file"`
|
||||
}
|
||||
|
||||
type UploadAuditReportPayload struct {
|
||||
Audit *Audit `json:"audit"`
|
||||
}
|
||||
|
||||
type UploadMeasureEvidenceInput struct {
|
||||
MeasureID gid.GID `json:"measureId"`
|
||||
File graphql.Upload `json:"file"`
|
||||
|
||||
@@ -107,6 +107,88 @@ func (r *assetConnectionResolver) TotalCount(ctx context.Context, obj *types.Ass
|
||||
panic(fmt.Errorf("unsupported resolver: %T", obj.Resolver))
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *auditResolver) Organization(ctx context.Context, obj *types.Audit) (*types.Organization, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
audit, err := prb.Audits.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
|
||||
organization, err := prb.Organizations.Get(ctx, audit.OrganizationID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
return types.NewOrganization(organization), nil
|
||||
}
|
||||
|
||||
// Framework is the resolver for the framework field.
|
||||
func (r *auditResolver) Framework(ctx context.Context, obj *types.Audit) (*types.Framework, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
audit, err := prb.Audits.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
|
||||
framework, err := prb.Frameworks.Get(ctx, audit.FrameworkID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load framework: %w", err)
|
||||
}
|
||||
|
||||
return types.NewFramework(framework), nil
|
||||
}
|
||||
|
||||
// Report is the resolver for the report field.
|
||||
func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Report, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
audit, err := prb.Audits.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
|
||||
if audit.ReportID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
report, err := prb.Reports.Get(ctx, *audit.ReportID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot load report: %w", err)
|
||||
}
|
||||
|
||||
return types.NewReport(report), nil
|
||||
}
|
||||
|
||||
// ReportURL is the resolver for the reportUrl field.
|
||||
func (r *auditResolver) ReportURL(ctx context.Context, obj *types.Audit) (*string, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
if obj.Report == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
url, err := prb.Audits.GenerateReportURL(ctx, obj.ID, 15*time.Minute)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot generate report URL: %w", err)
|
||||
}
|
||||
|
||||
return url, nil
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *auditConnectionResolver) TotalCount(ctx context.Context, obj *types.AuditConnection) (int, error) {
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
|
||||
count, err := prb.Audits.CountForOrganizationID(ctx, obj.ParentID)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count audits: %w", err)
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// Framework is the resolver for the framework field.
|
||||
func (r *controlResolver) Framework(ctx context.Context, obj *types.Control) (*types.Framework, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -2191,6 +2273,101 @@ func (r *mutationResolver) DeleteDatum(ctx context.Context, input types.DeleteDa
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CreateAudit is the resolver for the createAudit field.
|
||||
func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAuditInput) (*types.CreateAuditPayload, error) {
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
req := probo.CreateAuditRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
FrameworkID: input.FrameworkID,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Create(ctx, &req)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot create audit: %w", err))
|
||||
}
|
||||
|
||||
return &types.CreateAuditPayload{
|
||||
AuditEdge: types.NewAuditEdge(audit, coredata.AuditOrderFieldCreatedAt),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UpdateAudit is the resolver for the updateAudit field.
|
||||
func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAuditInput) (*types.UpdateAuditPayload, error) {
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
req := probo.UpdateAuditRequest{
|
||||
ID: input.ID,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Update(ctx, &req)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot update audit: %w", err))
|
||||
}
|
||||
|
||||
return &types.UpdateAuditPayload{
|
||||
Audit: types.NewAudit(audit),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteAudit is the resolver for the deleteAudit field.
|
||||
func (r *mutationResolver) DeleteAudit(ctx context.Context, input types.DeleteAuditInput) (*types.DeleteAuditPayload, error) {
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
|
||||
err := prb.Audits.Delete(ctx, input.AuditID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot delete audit: %w", err))
|
||||
}
|
||||
|
||||
return &types.DeleteAuditPayload{
|
||||
DeletedAuditID: input.AuditID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UploadAuditReport is the resolver for the uploadAuditReport field.
|
||||
func (r *mutationResolver) UploadAuditReport(ctx context.Context, input types.UploadAuditReportInput) (*types.UploadAuditReportPayload, error) {
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
|
||||
req := probo.UploadAuditReportRequest{
|
||||
AuditID: input.AuditID,
|
||||
File: probo.File{
|
||||
Content: input.File.File,
|
||||
Filename: input.File.Filename,
|
||||
Size: input.File.Size,
|
||||
ContentType: input.File.ContentType,
|
||||
},
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.UploadReport(ctx, req)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot upload audit report: %w", err))
|
||||
}
|
||||
|
||||
return &types.UploadAuditReportPayload{
|
||||
Audit: types.NewAudit(audit),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteAuditReport is the resolver for the deleteAuditReport field.
|
||||
func (r *mutationResolver) DeleteAuditReport(ctx context.Context, input types.DeleteAuditReportInput) (*types.DeleteAuditReportPayload, error) {
|
||||
prb := r.ProboService(ctx, input.AuditID.TenantID())
|
||||
|
||||
audit, err := prb.Audits.DeleteReport(ctx, input.AuditID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot delete audit report: %w", err)
|
||||
}
|
||||
|
||||
return &types.DeleteAuditReportPayload{
|
||||
Audit: types.NewAudit(audit),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// LogoURL is the resolver for the logoUrl field.
|
||||
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -2516,6 +2693,31 @@ func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization
|
||||
return types.NewDataConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// Audits is the resolver for the audits field.
|
||||
func (r *organizationResolver) Audits(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.AuditOrderBy) (*types.AuditConnection, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.AuditOrderField]{
|
||||
Field: coredata.AuditOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
if orderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.AuditOrderField]{
|
||||
Field: orderBy.Field,
|
||||
Direction: orderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.Audits.ListForOrganizationID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list organization audits: %w", err))
|
||||
}
|
||||
|
||||
return types.NewAuditConnection(page, r, obj.ID), nil
|
||||
}
|
||||
|
||||
// TotalCount is the resolver for the totalCount field.
|
||||
func (r *peopleConnectionResolver) TotalCount(ctx context.Context, obj *types.PeopleConnection) (int, error) {
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
@@ -2635,6 +2837,18 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
||||
panic(fmt.Errorf("cannot get data: %w", err))
|
||||
}
|
||||
return types.NewDatum(datum), nil
|
||||
case coredata.AuditEntityType:
|
||||
audit, err := prb.Audits.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get audit: %w", err))
|
||||
}
|
||||
return types.NewAudit(audit), nil
|
||||
case coredata.ReportEntityType:
|
||||
report, err := prb.Reports.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot get report: %w", err))
|
||||
}
|
||||
return types.NewReport(report), nil
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -2652,6 +2866,18 @@ func (r *queryResolver) Viewer(ctx context.Context) (*types.Viewer, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DownloadURL is the resolver for the downloadUrl field.
|
||||
func (r *reportResolver) DownloadURL(ctx context.Context, obj *types.Report) (*string, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
|
||||
url, err := prb.Reports.GenerateDownloadURL(ctx, obj.ID, 15*time.Minute)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot generate download URL: %w", err)
|
||||
}
|
||||
|
||||
return url, nil
|
||||
}
|
||||
|
||||
// Owner is the resolver for the owner field.
|
||||
func (r *riskResolver) Owner(ctx context.Context, obj *types.Risk) (*types.People, error) {
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
@@ -3136,6 +3362,14 @@ func (r *Resolver) AssetConnection() schema.AssetConnectionResolver {
|
||||
return &assetConnectionResolver{r}
|
||||
}
|
||||
|
||||
// Audit returns schema.AuditResolver implementation.
|
||||
func (r *Resolver) Audit() schema.AuditResolver { return &auditResolver{r} }
|
||||
|
||||
// AuditConnection returns schema.AuditConnectionResolver implementation.
|
||||
func (r *Resolver) AuditConnection() schema.AuditConnectionResolver {
|
||||
return &auditConnectionResolver{r}
|
||||
}
|
||||
|
||||
// Control returns schema.ControlResolver implementation.
|
||||
func (r *Resolver) Control() schema.ControlResolver { return &controlResolver{r} }
|
||||
|
||||
@@ -3208,6 +3442,9 @@ func (r *Resolver) PeopleConnection() schema.PeopleConnectionResolver {
|
||||
// Query returns schema.QueryResolver implementation.
|
||||
func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} }
|
||||
|
||||
// Report returns schema.ReportResolver implementation.
|
||||
func (r *Resolver) Report() schema.ReportResolver { return &reportResolver{r} }
|
||||
|
||||
// Risk returns schema.RiskResolver implementation.
|
||||
func (r *Resolver) Risk() schema.RiskResolver { return &riskResolver{r} }
|
||||
|
||||
@@ -3246,6 +3483,8 @@ func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
||||
|
||||
type assetResolver struct{ *Resolver }
|
||||
type assetConnectionResolver struct{ *Resolver }
|
||||
type auditResolver struct{ *Resolver }
|
||||
type auditConnectionResolver struct{ *Resolver }
|
||||
type controlResolver struct{ *Resolver }
|
||||
type controlConnectionResolver struct{ *Resolver }
|
||||
type datumResolver struct{ *Resolver }
|
||||
@@ -3264,6 +3503,7 @@ type mutationResolver struct{ *Resolver }
|
||||
type organizationResolver struct{ *Resolver }
|
||||
type peopleConnectionResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
||||
type reportResolver struct{ *Resolver }
|
||||
type riskResolver struct{ *Resolver }
|
||||
type riskConnectionResolver struct{ *Resolver }
|
||||
type taskResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user