Add trust center files

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-10-24 10:04:54 +02:00
parent e53b1239db
commit 1bd6f7c1c9
55 changed files with 9074 additions and 394 deletions

View File

@@ -1187,6 +1187,24 @@ enum TrustCenterReferenceOrderField
)
}
enum TrustCenterFileOrderField
@goModel(
model: "github.com/getprobo/probo/pkg/coredata.TrustCenterFileOrderField"
) {
NAME
@goEnum(
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterFileOrderFieldName"
)
CREATED_AT
@goEnum(
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterFileOrderFieldCreatedAt"
)
UPDATED_AT
@goEnum(
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterFileOrderFieldUpdatedAt"
)
}
enum SnapshotsType
@goModel(model: "github.com/getprobo/probo/pkg/coredata.SnapshotsType") {
RISKS
@@ -1422,6 +1440,14 @@ input TrustCenterReferenceOrder
field: TrustCenterReferenceOrderField!
}
input TrustCenterFileOrder
@goModel(
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.TrustCenterFileOrderBy"
) {
direction: OrderDirection!
field: TrustCenterFileOrderField!
}
input EvidenceOrder
@goModel(
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.EvidenceOrderBy"
@@ -1749,6 +1775,14 @@ type Organization implements Node {
orderBy: SnapshotOrder
): SnapshotConnection! @goField(forceResolver: true)
trustCenterFiles(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: TrustCenterFileOrder
): TrustCenterFileConnection! @goField(forceResolver: true)
trustCenter: TrustCenter @goField(forceResolver: true)
customDomain: CustomDomain @goField(forceResolver: true)
@@ -2391,6 +2425,7 @@ type TrustCenterDocumentAccess implements Node {
trustCenterAccess: TrustCenterAccess! @goField(forceResolver: true)
document: Document @goField(forceResolver: true)
report: Report @goField(forceResolver: true)
trustCenterFile: TrustCenterFile @goField(forceResolver: true)
}
type TrustCenterDocumentAccessConnection
@@ -2441,6 +2476,31 @@ type TrustCenterReferenceEdge {
node: TrustCenterReference!
}
type TrustCenterFile implements Node {
id: ID!
name: String!
category: String!
fileUrl: String! @goField(forceResolver: true)
trustCenterVisibility: TrustCenterVisibility!
createdAt: Datetime!
updatedAt: Datetime!
organization: Organization! @goField(forceResolver: true)
}
type TrustCenterFileConnection
@goModel(
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.TrustCenterFileConnection"
) {
totalCount: Int! @goField(forceResolver: true)
edges: [TrustCenterFileEdge!]!
pageInfo: PageInfo!
}
type TrustCenterFileEdge {
cursor: CursorKey!
node: TrustCenterFile!
}
type UserConnection
@goModel(
model: "github.com/getprobo/probo/pkg/server/api/console/v1/types.UserConnection"
@@ -2824,6 +2884,23 @@ type Mutation {
input: DeleteTrustCenterReferenceInput!
): DeleteTrustCenterReferencePayload!
# Trust Center File mutations
createTrustCenterFile(
input: CreateTrustCenterFileInput!
): CreateTrustCenterFilePayload!
updateTrustCenterFile(
input: UpdateTrustCenterFileInput!
): UpdateTrustCenterFilePayload!
getTrustCenterFile(
input: GetTrustCenterFileInput!
): GetTrustCenterFilePayload!
deleteTrustCenterFile(
input: DeleteTrustCenterFileInput!
): DeleteTrustCenterFilePayload!
# User mutations
confirmEmail(input: ConfirmEmailInput!): ConfirmEmailPayload!
inviteUser(input: InviteUserInput!): InviteUserPayload!
@@ -3151,6 +3228,7 @@ input UpdateTrustCenterAccessInput {
active: Boolean
documentIds: [ID!]
reportIds: [ID!]
trustCenterFileIds: [ID!]
}
input DeleteTrustCenterAccessInput {
@@ -3177,6 +3255,29 @@ input DeleteTrustCenterReferenceInput {
id: ID!
}
input CreateTrustCenterFileInput {
organizationId: ID!
name: String!
category: String!
file: Upload!
trustCenterVisibility: TrustCenterVisibility!
}
input UpdateTrustCenterFileInput {
id: ID!
name: String
category: String
trustCenterVisibility: TrustCenterVisibility
}
input GetTrustCenterFileInput {
id: ID!
}
input DeleteTrustCenterFileInput {
id: ID!
}
input CreateVendorInput {
organizationId: ID!
name: String!
@@ -3854,6 +3955,22 @@ type DeleteTrustCenterReferencePayload {
deletedTrustCenterReferenceId: ID!
}
type CreateTrustCenterFilePayload {
trustCenterFileEdge: TrustCenterFileEdge!
}
type UpdateTrustCenterFilePayload {
trustCenterFile: TrustCenterFile!
}
type GetTrustCenterFilePayload {
trustCenterFile: TrustCenterFile!
}
type DeleteTrustCenterFilePayload {
deletedTrustCenterFileId: ID!
}
type CreateControlPayload {
controlEdge: ControlEdge!
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,65 @@
// 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 TrustCenterFileOrderBy = OrderBy[coredata.TrustCenterFileOrderField]
type TrustCenterFileConnection struct {
TotalCount int `json:"totalCount"`
Edges []*TrustCenterFileEdge `json:"edges"`
PageInfo *PageInfo `json:"pageInfo"`
ParentID gid.GID `json:"-"`
}
func NewTrustCenterFile(tcf *coredata.TrustCenterFile) *TrustCenterFile {
return &TrustCenterFile{
ID: tcf.ID,
Name: tcf.Name,
Category: tcf.Category,
TrustCenterVisibility: tcf.TrustCenterVisibility,
CreatedAt: tcf.CreatedAt,
UpdatedAt: tcf.UpdatedAt,
}
}
func NewTrustCenterFileConnection(
p *page.Page[*coredata.TrustCenterFile, coredata.TrustCenterFileOrderField],
parentID gid.GID,
) *TrustCenterFileConnection {
var edges = make([]*TrustCenterFileEdge, len(p.Data))
for i := range edges {
edges[i] = NewTrustCenterFileEdge(p.Data[i], p.Cursor.OrderBy.Field)
}
return &TrustCenterFileConnection{
Edges: edges,
PageInfo: NewPageInfo(p),
ParentID: parentID,
}
}
func NewTrustCenterFileEdge(tcf *coredata.TrustCenterFile, orderBy coredata.TrustCenterFileOrderField) *TrustCenterFileEdge {
return &TrustCenterFileEdge{
Cursor: tcf.CursorKey(orderBy),
Node: NewTrustCenterFile(tcf),
}
}

View File

@@ -541,6 +541,18 @@ type CreateTrustCenterAccessPayload struct {
TrustCenterAccessEdge *TrustCenterAccessEdge `json:"trustCenterAccessEdge"`
}
type CreateTrustCenterFileInput struct {
OrganizationID gid.GID `json:"organizationId"`
Name string `json:"name"`
Category string `json:"category"`
File graphql.Upload `json:"file"`
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
}
type CreateTrustCenterFilePayload struct {
TrustCenterFileEdge *TrustCenterFileEdge `json:"trustCenterFileEdge"`
}
type CreateTrustCenterReferenceInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
Name string `json:"name"`
@@ -916,6 +928,14 @@ type DeleteTrustCenterAccessPayload struct {
DeletedTrustCenterAccessID gid.GID `json:"deletedTrustCenterAccessId"`
}
type DeleteTrustCenterFileInput struct {
ID gid.GID `json:"id"`
}
type DeleteTrustCenterFilePayload struct {
DeletedTrustCenterFileID gid.GID `json:"deletedTrustCenterFileId"`
}
type DeleteTrustCenterNDAInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
}
@@ -1170,6 +1190,14 @@ type GenerateFrameworkStateOfApplicabilityPayload struct {
Data string `json:"data"`
}
type GetTrustCenterFileInput struct {
ID gid.GID `json:"id"`
}
type GetTrustCenterFilePayload struct {
TrustCenterFile *TrustCenterFile `json:"trustCenterFile"`
}
type ImportFrameworkInput struct {
OrganizationID gid.GID `json:"organizationId"`
File graphql.Upload `json:"file"`
@@ -1365,6 +1393,7 @@ type Organization struct {
ContinualImprovements *ContinualImprovementConnection `json:"continualImprovements"`
ProcessingActivities *ProcessingActivityConnection `json:"processingActivities"`
Snapshots *SnapshotConnection `json:"snapshots"`
TrustCenterFiles *TrustCenterFileConnection `json:"trustCenterFiles"`
TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
CustomDomain *CustomDomain `json:"customDomain,omitempty"`
CreatedAt time.Time `json:"createdAt"`
@@ -1675,6 +1704,7 @@ type TrustCenterDocumentAccess struct {
TrustCenterAccess *TrustCenterAccess `json:"trustCenterAccess"`
Document *Document `json:"document,omitempty"`
Report *Report `json:"report,omitempty"`
TrustCenterFile *TrustCenterFile `json:"trustCenterFile,omitempty"`
}
func (TrustCenterDocumentAccess) IsNode() {}
@@ -1690,6 +1720,25 @@ type TrustCenterEdge struct {
Node *TrustCenter `json:"node"`
}
type TrustCenterFile struct {
ID gid.GID `json:"id"`
Name string `json:"name"`
Category string `json:"category"`
FileURL string `json:"fileUrl"`
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Organization *Organization `json:"organization"`
}
func (TrustCenterFile) IsNode() {}
func (this TrustCenterFile) GetID() gid.GID { return this.ID }
type TrustCenterFileEdge struct {
Cursor page.CursorKey `json:"cursor"`
Node *TrustCenterFile `json:"node"`
}
type TrustCenterReference struct {
ID gid.GID `json:"id"`
Name string `json:"name"`
@@ -1948,17 +1997,29 @@ type UpdateTaskPayload struct {
}
type UpdateTrustCenterAccessInput struct {
ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"`
Active *bool `json:"active,omitempty"`
DocumentIds []gid.GID `json:"documentIds,omitempty"`
ReportIds []gid.GID `json:"reportIds,omitempty"`
ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"`
Active *bool `json:"active,omitempty"`
DocumentIds []gid.GID `json:"documentIds,omitempty"`
ReportIds []gid.GID `json:"reportIds,omitempty"`
TrustCenterFileIds []gid.GID `json:"trustCenterFileIds,omitempty"`
}
type UpdateTrustCenterAccessPayload struct {
TrustCenterAccess *TrustCenterAccess `json:"trustCenterAccess"`
}
type UpdateTrustCenterFileInput struct {
ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"`
Category *string `json:"category,omitempty"`
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
}
type UpdateTrustCenterFilePayload struct {
TrustCenterFile *TrustCenterFile `json:"trustCenterFile"`
}
type UpdateTrustCenterInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
Active *bool `json:"active,omitempty"`

View File

@@ -1288,11 +1288,12 @@ func (r *mutationResolver) UpdateTrustCenterAccess(ctx context.Context, input ty
prb := r.ProboService(ctx, input.ID.TenantID())
access, err := prb.TrustCenterAccesses.Update(ctx, &probo.UpdateTrustCenterAccessRequest{
ID: input.ID,
Name: input.Name,
Active: input.Active,
DocumentIDs: input.DocumentIds,
ReportIDs: input.ReportIds,
ID: input.ID,
Name: input.Name,
Active: input.Active,
DocumentIDs: input.DocumentIds,
ReportIDs: input.ReportIds,
TrustCenterFileIDs: input.TrustCenterFileIds,
})
if err != nil {
panic(fmt.Errorf("cannot update trust center access: %w", err))
@@ -1390,6 +1391,82 @@ func (r *mutationResolver) DeleteTrustCenterReference(ctx context.Context, input
}, nil
}
// CreateTrustCenterFile is the resolver for the createTrustCenterFile field.
func (r *mutationResolver) CreateTrustCenterFile(ctx context.Context, input types.CreateTrustCenterFileInput) (*types.CreateTrustCenterFilePayload, error) {
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
file, err := prb.TrustCenterFiles.Create(ctx, &probo.CreateTrustCenterFileRequest{
OrganizationID: input.OrganizationID,
Name: input.Name,
Category: input.Category,
File: probo.File{
Content: input.File.File,
Filename: input.File.Filename,
Size: input.File.Size,
ContentType: input.File.ContentType,
},
TrustCenterVisibility: input.TrustCenterVisibility,
})
if err != nil {
return nil, fmt.Errorf("cannot create trust center file: %w", err)
}
return &types.CreateTrustCenterFilePayload{
TrustCenterFileEdge: types.NewTrustCenterFileEdge(file, coredata.TrustCenterFileOrderFieldCreatedAt),
}, nil
}
// UpdateTrustCenterFile is the resolver for the updateTrustCenterFile field.
func (r *mutationResolver) UpdateTrustCenterFile(ctx context.Context, input types.UpdateTrustCenterFileInput) (*types.UpdateTrustCenterFilePayload, error) {
prb := r.ProboService(ctx, input.ID.TenantID())
file, err := prb.TrustCenterFiles.Update(ctx, &probo.UpdateTrustCenterFileRequest{
ID: input.ID,
Name: input.Name,
Category: input.Category,
TrustCenterVisibility: input.TrustCenterVisibility,
})
if err != nil {
return nil, fmt.Errorf("cannot update trust center file: %w", err)
}
return &types.UpdateTrustCenterFilePayload{
TrustCenterFile: types.NewTrustCenterFile(file),
}, nil
}
// GetTrustCenterFile is the resolver for the getTrustCenterFile field.
func (r *mutationResolver) GetTrustCenterFile(ctx context.Context, input types.GetTrustCenterFileInput) (*types.GetTrustCenterFilePayload, error) {
prb := r.ProboService(ctx, input.ID.TenantID())
file, err := prb.TrustCenterFiles.Get(ctx, &probo.GetTrustCenterFileRequest{
ID: input.ID,
})
if err != nil {
return nil, fmt.Errorf("cannot get trust center file: %w", err)
}
return &types.GetTrustCenterFilePayload{
TrustCenterFile: types.NewTrustCenterFile(file),
}, nil
}
// DeleteTrustCenterFile is the resolver for the deleteTrustCenterFile field.
func (r *mutationResolver) DeleteTrustCenterFile(ctx context.Context, input types.DeleteTrustCenterFileInput) (*types.DeleteTrustCenterFilePayload, error) {
prb := r.ProboService(ctx, input.ID.TenantID())
err := prb.TrustCenterFiles.Delete(ctx, &probo.DeleteTrustCenterFileRequest{
ID: input.ID,
})
if err != nil {
return nil, fmt.Errorf("cannot delete trust center file: %w", err)
}
return &types.DeleteTrustCenterFilePayload{
DeletedTrustCenterFileID: input.ID,
}, nil
}
// ConfirmEmail is the resolver for the confirmEmail field.
func (r *mutationResolver) ConfirmEmail(ctx context.Context, input types.ConfirmEmailInput) (*types.ConfirmEmailPayload, error) {
err := r.authSvc.ConfirmEmail(ctx, input.Token)
@@ -4153,6 +4230,31 @@ func (r *organizationResolver) Snapshots(ctx context.Context, obj *types.Organiz
return types.NewSnapshotConnection(page, r, obj.ID), nil
}
// TrustCenterFiles is the resolver for the trustCenterFiles field.
func (r *organizationResolver) TrustCenterFiles(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.TrustCenterFileOrderField]) (*types.TrustCenterFileConnection, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.TrustCenterFileOrderField]{
Field: coredata.TrustCenterFileOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if orderBy != nil {
pageOrderBy = page.OrderBy[coredata.TrustCenterFileOrderField]{
Field: orderBy.Field,
Direction: orderBy.Direction,
}
}
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
pageResult, err := prb.TrustCenterFiles.ListForOrganizationID(ctx, obj.ID, cursor)
if err != nil {
panic(fmt.Errorf("cannot list organization trust center files: %w", err))
}
return types.NewTrustCenterFileConnection(pageResult, obj.ID), nil
}
// TrustCenter is the resolver for the trustCenter field.
func (r *organizationResolver) TrustCenter(ctx context.Context, obj *types.Organization) (*types.TrustCenter, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
@@ -4930,6 +5032,29 @@ func (r *trustCenterDocumentAccessResolver) Report(ctx context.Context, obj *typ
return types.NewReport(report), nil
}
// TrustCenterFile is the resolver for the trustCenterFile field.
func (r *trustCenterDocumentAccessResolver) TrustCenterFile(ctx context.Context, obj *types.TrustCenterDocumentAccess) (*types.TrustCenterFile, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
documentAccess, err := prb.TrustCenterAccesses.GetDocumentAccess(ctx, obj.ID)
if err != nil {
return nil, fmt.Errorf("cannot load trust center document access: %w", err)
}
if documentAccess.TrustCenterFileID == nil {
return nil, nil
}
trustCenterFile, err := prb.TrustCenterFiles.Get(ctx, &probo.GetTrustCenterFileRequest{
ID: *documentAccess.TrustCenterFileID,
})
if err != nil {
return nil, fmt.Errorf("cannot load trust center file: %w", err)
}
return types.NewTrustCenterFile(trustCenterFile), nil
}
// TotalCount is the resolver for the totalCount field.
func (r *trustCenterDocumentAccessConnectionResolver) TotalCount(ctx context.Context, obj *types.TrustCenterDocumentAccessConnection) (int, error) {
prb := r.ProboService(ctx, obj.ParentID.TenantID())
@@ -4942,6 +5067,48 @@ func (r *trustCenterDocumentAccessConnectionResolver) TotalCount(ctx context.Con
return count, nil
}
// FileURL is the resolver for the fileUrl field.
func (r *trustCenterFileResolver) FileURL(ctx context.Context, obj *types.TrustCenterFile) (string, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
fileURL, err := prb.TrustCenterFiles.GenerateFileURL(ctx, obj.ID, 1*time.Hour)
if err != nil {
panic(fmt.Errorf("failed to generate file URL: %w", err))
}
return fileURL, nil
}
// Organization is the resolver for the organization field.
func (r *trustCenterFileResolver) Organization(ctx context.Context, obj *types.TrustCenterFile) (*types.Organization, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
file, err := prb.TrustCenterFiles.Get(ctx, &probo.GetTrustCenterFileRequest{
ID: obj.ID,
})
if err != nil {
panic(fmt.Errorf("cannot get trust center file: %w", err))
}
organization, err := prb.Organizations.Get(ctx, file.OrganizationID)
if err != nil {
panic(fmt.Errorf("cannot get organization: %w", err))
}
return types.NewOrganization(organization), nil
}
// TotalCount is the resolver for the totalCount field.
func (r *trustCenterFileConnectionResolver) TotalCount(ctx context.Context, obj *types.TrustCenterFileConnection) (int, error) {
prb := r.ProboService(ctx, obj.ParentID.TenantID())
count, err := prb.TrustCenterFiles.CountForOrganizationID(ctx, obj.ParentID)
if err != nil {
panic(fmt.Errorf("cannot count trust center files: %w", err))
}
return count, nil
}
// LogoURL is the resolver for the logoUrl field.
func (r *trustCenterReferenceResolver) LogoURL(ctx context.Context, obj *types.TrustCenterReference) (string, error) {
prb := r.ProboService(ctx, obj.ID.TenantID())
@@ -5563,6 +5730,16 @@ func (r *Resolver) TrustCenterDocumentAccessConnection() schema.TrustCenterDocum
return &trustCenterDocumentAccessConnectionResolver{r}
}
// TrustCenterFile returns schema.TrustCenterFileResolver implementation.
func (r *Resolver) TrustCenterFile() schema.TrustCenterFileResolver {
return &trustCenterFileResolver{r}
}
// TrustCenterFileConnection returns schema.TrustCenterFileConnectionResolver implementation.
func (r *Resolver) TrustCenterFileConnection() schema.TrustCenterFileConnectionResolver {
return &trustCenterFileConnectionResolver{r}
}
// TrustCenterReference returns schema.TrustCenterReferenceResolver implementation.
func (r *Resolver) TrustCenterReference() schema.TrustCenterReferenceResolver {
return &trustCenterReferenceResolver{r}
@@ -5658,6 +5835,8 @@ type trustCenterResolver struct{ *Resolver }
type trustCenterAccessResolver struct{ *Resolver }
type trustCenterDocumentAccessResolver struct{ *Resolver }
type trustCenterDocumentAccessConnectionResolver struct{ *Resolver }
type trustCenterFileResolver struct{ *Resolver }
type trustCenterFileConnectionResolver struct{ *Resolver }
type trustCenterReferenceResolver struct{ *Resolver }
type trustCenterReferenceConnectionResolver struct{ *Resolver }
type userConnectionResolver struct{ *Resolver }