Add trust center configuration

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-07-24 21:11:46 +02:00
parent e85a7b4955
commit 32c47a1988
49 changed files with 4755 additions and 126 deletions

View File

@@ -703,6 +703,14 @@ input RiskFilter {
}
# Core Types
type TrustCenter implements Node {
id: ID!
active: Boolean!
slug: String!
createdAt: Datetime!
updatedAt: Datetime!
}
type Organization implements Node {
id: ID!
name: String!
@@ -816,6 +824,8 @@ type Organization implements Node {
orderBy: AuditOrder
): AuditConnection! @goField(forceResolver: true)
trustCenter: TrustCenter @goField(forceResolver: true)
createdAt: Datetime!
updatedAt: Datetime!
}
@@ -891,6 +901,7 @@ type Vendor implements Node {
headquarterAddress: String
legalName: String
websiteUrl: String
showOnTrustCenter: Boolean!
createdAt: Datetime!
updatedAt: Datetime!
}
@@ -1052,6 +1063,7 @@ type Document implements Node {
description: String!
documentType: DocumentType!
currentPublishedVersion: Int
showOnTrustCenter: Boolean!
owner: People! @goField(forceResolver: true)
organization: Organization! @goField(forceResolver: true)
@@ -1134,6 +1146,7 @@ type Audit implements Node {
report: Report @goField(forceResolver: true)
reportUrl: String @goField(forceResolver: true)
state: AuditState!
showOnTrustCenter: Boolean!
createdAt: Datetime!
updatedAt: Datetime!
}
@@ -1397,6 +1410,10 @@ type Mutation {
input: UpdateOrganizationInput!
): UpdateOrganizationPayload!
updateTrustCenter(
input: UpdateTrustCenterInput!
): UpdateTrustCenterPayload!
# User mutations
confirmEmail(input: ConfirmEmailInput!): ConfirmEmailPayload!
inviteUser(input: InviteUserInput!): InviteUserPayload!
@@ -1563,6 +1580,12 @@ input UpdateOrganizationInput {
logo: Upload
}
input UpdateTrustCenterInput {
trustCenterId: ID!
active: Boolean
slug: String
}
input CreateVendorInput {
organizationId: ID!
name: String!
@@ -1605,6 +1628,7 @@ input UpdateVendorInput {
trustPageUrl: String
businessOwnerId: ID
securityOwnerId: ID
showOnTrustCenter: Boolean
}
input DeleteVendorInput {
@@ -1836,6 +1860,7 @@ input UpdateDocumentInput {
ownerId: ID
createdBy: ID
documentType: DocumentType
showOnTrustCenter: Boolean
}
input ExportDocumentVersionPDFInput {
@@ -1897,6 +1922,7 @@ input UpdateAuditInput {
validFrom: Datetime
validUntil: Datetime
state: AuditState
showOnTrustCenter: Boolean
}
input DeleteAuditInput {
@@ -1921,6 +1947,10 @@ type UpdateOrganizationPayload {
organization: Organization!
}
type UpdateTrustCenterPayload {
trustCenter: TrustCenter!
}
type CreateControlPayload {
controlEdge: ControlEdge!
}

File diff suppressed because it is too large Load Diff

View File

@@ -54,12 +54,13 @@ func NewAuditConnection(
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,
ID: a.ID,
ValidFrom: a.ValidFrom,
ValidUntil: a.ValidUntil,
State: a.State,
ShowOnTrustCenter: a.ShowOnTrustCenter,
CreatedAt: a.CreatedAt,
UpdatedAt: a.UpdatedAt,
}
}

View File

@@ -79,6 +79,7 @@ func NewDocument(document *coredata.Document) *Document {
Title: document.Title,
DocumentType: document.DocumentType,
CurrentPublishedVersion: document.CurrentPublishedVersion,
ShowOnTrustCenter: document.ShowOnTrustCenter,
CreatedAt: document.CreatedAt,
UpdatedAt: document.UpdatedAt,
}

View File

@@ -0,0 +1,29 @@
// 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 NewTrustCenter(tc *coredata.TrustCenter) *TrustCenter {
return &TrustCenter{
ID: tc.ID,
Active: tc.Active,
Slug: tc.Slug,
CreatedAt: tc.CreatedAt,
UpdatedAt: tc.UpdatedAt,
}
}

View File

@@ -57,16 +57,17 @@ type AssignTaskPayload struct {
}
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"`
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"`
ShowOnTrustCenter bool `json:"showOnTrustCenter"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (Audit) IsNode() {}
@@ -582,6 +583,7 @@ type Document struct {
Description string `json:"description"`
DocumentType coredata.DocumentType `json:"documentType"`
CurrentPublishedVersion *int `json:"currentPublishedVersion,omitempty"`
ShowOnTrustCenter bool `json:"showOnTrustCenter"`
Owner *People `json:"owner"`
Organization *Organization `json:"organization"`
Versions *DocumentVersionConnection `json:"versions"`
@@ -800,24 +802,25 @@ type Mutation struct {
}
type Organization struct {
ID gid.GID `json:"id"`
Name string `json:"name"`
LogoURL *string `json:"logoUrl,omitempty"`
Users *UserConnection `json:"users"`
Connectors *ConnectorConnection `json:"connectors"`
Frameworks *FrameworkConnection `json:"frameworks"`
Controls *ControlConnection `json:"controls"`
Vendors *VendorConnection `json:"vendors"`
Peoples *PeopleConnection `json:"peoples"`
Documents *DocumentConnection `json:"documents"`
Measures *MeasureConnection `json:"measures"`
Risks *RiskConnection `json:"risks"`
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"`
ID gid.GID `json:"id"`
Name string `json:"name"`
LogoURL *string `json:"logoUrl,omitempty"`
Users *UserConnection `json:"users"`
Connectors *ConnectorConnection `json:"connectors"`
Frameworks *FrameworkConnection `json:"frameworks"`
Controls *ControlConnection `json:"controls"`
Vendors *VendorConnection `json:"vendors"`
Peoples *PeopleConnection `json:"peoples"`
Documents *DocumentConnection `json:"documents"`
Measures *MeasureConnection `json:"measures"`
Risks *RiskConnection `json:"risks"`
Tasks *TaskConnection `json:"tasks"`
Assets *AssetConnection `json:"assets"`
Data *DatumConnection `json:"data"`
Audits *AuditConnection `json:"audits"`
TrustCenter *TrustCenter `json:"trustCenter,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (Organization) IsNode() {}
@@ -992,6 +995,17 @@ type TaskEdge struct {
Node *Task `json:"node"`
}
type TrustCenter struct {
ID gid.GID `json:"id"`
Active bool `json:"active"`
Slug string `json:"slug"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (TrustCenter) IsNode() {}
func (this TrustCenter) GetID() gid.GID { return this.ID }
type UnassignTaskInput struct {
TaskID gid.GID `json:"taskId"`
}
@@ -1016,10 +1030,11 @@ type UpdateAssetPayload struct {
}
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"`
ID gid.GID `json:"id"`
ValidFrom *time.Time `json:"validFrom,omitempty"`
ValidUntil *time.Time `json:"validUntil,omitempty"`
State *coredata.AuditState `json:"state,omitempty"`
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
}
type UpdateAuditPayload struct {
@@ -1052,12 +1067,13 @@ type UpdateDatumPayload struct {
}
type UpdateDocumentInput struct {
ID gid.GID `json:"id"`
Title *string `json:"title,omitempty"`
Content *string `json:"content,omitempty"`
OwnerID *gid.GID `json:"ownerId,omitempty"`
CreatedBy *gid.GID `json:"createdBy,omitempty"`
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
ID gid.GID `json:"id"`
Title *string `json:"title,omitempty"`
Content *string `json:"content,omitempty"`
OwnerID *gid.GID `json:"ownerId,omitempty"`
CreatedBy *gid.GID `json:"createdBy,omitempty"`
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
}
type UpdateDocumentPayload struct {
@@ -1151,6 +1167,16 @@ type UpdateTaskPayload struct {
Task *Task `json:"task"`
}
type UpdateTrustCenterInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
Active *bool `json:"active,omitempty"`
Slug *string `json:"slug,omitempty"`
}
type UpdateTrustCenterPayload struct {
TrustCenter *TrustCenter `json:"trustCenter"`
}
type UpdateVendorInput struct {
ID gid.GID `json:"id"`
Name *string `json:"name,omitempty"`
@@ -1171,6 +1197,7 @@ type UpdateVendorInput struct {
TrustPageURL *string `json:"trustPageUrl,omitempty"`
BusinessOwnerID *gid.GID `json:"businessOwnerId,omitempty"`
SecurityOwnerID *gid.GID `json:"securityOwnerId,omitempty"`
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
}
type UpdateVendorPayload struct {
@@ -1261,6 +1288,7 @@ type Vendor struct {
HeadquarterAddress *string `json:"headquarterAddress,omitempty"`
LegalName *string `json:"legalName,omitempty"`
WebsiteURL *string `json:"websiteUrl,omitempty"`
ShowOnTrustCenter bool `json:"showOnTrustCenter"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}

View File

@@ -79,6 +79,7 @@ func NewVendor(v *coredata.Vendor) *Vendor {
LegalName: v.LegalName,
WebsiteURL: v.WebsiteURL,
Category: v.Category,
ShowOnTrustCenter: v.ShowOnTrustCenter,
UpdatedAt: v.UpdatedAt,
CreatedAt: v.CreatedAt,
}

View File

@@ -980,6 +980,24 @@ func (r *mutationResolver) UpdateOrganization(ctx context.Context, input types.U
}, nil
}
// UpdateTrustCenter is the resolver for the updateTrustCenter field.
func (r *mutationResolver) UpdateTrustCenter(ctx context.Context, input types.UpdateTrustCenterInput) (*types.UpdateTrustCenterPayload, error) {
prb := r.ProboService(ctx, input.TrustCenterID.TenantID())
trustCenter, err := prb.TrustCenters.Update(ctx, &probo.UpdateTrustCenterRequest{
ID: input.TrustCenterID,
Active: input.Active,
Slug: input.Slug,
})
if err != nil {
return nil, fmt.Errorf("cannot update trust center: %w", err)
}
return &types.UpdateTrustCenterPayload{
TrustCenter: types.NewTrustCenter(trustCenter),
}, nil
}
// ConfirmEmail is the resolver for the confirmEmail field.
func (r *mutationResolver) ConfirmEmail(ctx context.Context, input types.ConfirmEmailInput) (*types.ConfirmEmailPayload, error) {
err := r.usrmgrSvc.ConfirmEmail(ctx, input.Token)
@@ -1158,6 +1176,7 @@ func (r *mutationResolver) UpdateVendor(ctx context.Context, input types.UpdateV
Certifications: input.Certifications,
BusinessOwnerID: input.BusinessOwnerID,
SecurityOwnerID: input.SecurityOwnerID,
ShowOnTrustCenter: input.ShowOnTrustCenter,
})
if err != nil {
return nil, fmt.Errorf("cannot update vendor: %w", err)
@@ -1879,6 +1898,7 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
input.OwnerID,
input.DocumentType,
input.Title,
input.ShowOnTrustCenter,
)
if err != nil {
@@ -2300,10 +2320,11 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu
prb := r.ProboService(ctx, input.ID.TenantID())
req := probo.UpdateAuditRequest{
ID: input.ID,
ValidFrom: input.ValidFrom,
ValidUntil: input.ValidUntil,
State: input.State,
ID: input.ID,
ValidFrom: input.ValidFrom,
ValidUntil: input.ValidUntil,
State: input.State,
ShowOnTrustCenter: input.ShowOnTrustCenter,
}
audit, err := prb.Audits.Update(ctx, &req)
@@ -2718,6 +2739,18 @@ func (r *organizationResolver) Audits(ctx context.Context, obj *types.Organizati
return types.NewAuditConnection(page, r, 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())
trustCenter, err := prb.TrustCenters.GetByOrganizationID(ctx, obj.ID)
if err != nil {
return nil, fmt.Errorf("cannot get trust center: %w", err)
}
return types.NewTrustCenter(trustCenter), 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())
@@ -2849,6 +2882,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
panic(fmt.Errorf("cannot get report: %w", err))
}
return types.NewReport(report), nil
case coredata.TrustCenterEntityType:
trustCenter, err := prb.TrustCenters.GetByOrganizationID(ctx, id)
if err != nil {
panic(fmt.Errorf("cannot get trust center: %w", err))
}
return types.NewTrustCenter(trustCenter), nil
default:
}