Add trust center references
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -452,6 +452,24 @@ type VendorEdge {
|
||||
node: Vendor!
|
||||
}
|
||||
|
||||
type TrustCenterReference implements Node {
|
||||
id: ID!
|
||||
name: String!
|
||||
description: String!
|
||||
websiteUrl: String!
|
||||
logoUrl: String! @goField(forceResolver: true)
|
||||
}
|
||||
|
||||
type TrustCenterReferenceConnection {
|
||||
edges: [TrustCenterReferenceEdge!]!
|
||||
pageInfo: PageInfo!
|
||||
}
|
||||
|
||||
type TrustCenterReferenceEdge {
|
||||
cursor: CursorKey!
|
||||
node: TrustCenterReference!
|
||||
}
|
||||
|
||||
type TrustCenter implements Node {
|
||||
id: ID!
|
||||
active: Boolean!
|
||||
@@ -482,6 +500,13 @@ type TrustCenter implements Node {
|
||||
last: Int
|
||||
before: CursorKey
|
||||
): VendorConnection! @goField(forceResolver: true)
|
||||
|
||||
references(
|
||||
first: Int
|
||||
after: CursorKey
|
||||
last: Int
|
||||
before: CursorKey
|
||||
): TrustCenterReferenceConnection! @goField(forceResolver: true)
|
||||
}
|
||||
|
||||
type TrustCenterAccess implements Node {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
49
pkg/server/api/trust/v1/types/trust_center_reference.go
Normal file
49
pkg/server/api/trust/v1/types/trust_center_reference.go
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
func NewTrustCenterReference(tcc *coredata.TrustCenterReference) *TrustCenterReference {
|
||||
return &TrustCenterReference{
|
||||
ID: tcc.ID,
|
||||
Name: tcc.Name,
|
||||
Description: tcc.Description,
|
||||
WebsiteURL: tcc.WebsiteURL,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTrustCenterReferenceConnection(p *page.Page[*coredata.TrustCenterReference, coredata.TrustCenterReferenceOrderField]) *TrustCenterReferenceConnection {
|
||||
edges := make([]*TrustCenterReferenceEdge, len(p.Data))
|
||||
|
||||
for i, item := range p.Data {
|
||||
edges[i] = NewTrustCenterReferenceEdge(item, p.Cursor.OrderBy.Field)
|
||||
}
|
||||
|
||||
return &TrustCenterReferenceConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
}
|
||||
}
|
||||
|
||||
func NewTrustCenterReferenceEdge(tcc *coredata.TrustCenterReference, orderBy coredata.TrustCenterReferenceOrderField) *TrustCenterReferenceEdge {
|
||||
return &TrustCenterReferenceEdge{
|
||||
Cursor: tcc.CursorKey(orderBy),
|
||||
Node: NewTrustCenterReference(tcc),
|
||||
}
|
||||
}
|
||||
@@ -134,17 +134,18 @@ func (Report) IsNode() {}
|
||||
func (this Report) GetID() gid.GID { return this.ID }
|
||||
|
||||
type TrustCenter struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Active bool `json:"active"`
|
||||
Slug string `json:"slug"`
|
||||
NdaFileName *string `json:"ndaFileName,omitempty"`
|
||||
NdaFileURL *string `json:"ndaFileUrl,omitempty"`
|
||||
Organization *Organization `json:"organization"`
|
||||
IsUserAuthenticated bool `json:"isUserAuthenticated"`
|
||||
HasAcceptedNonDisclosureAgreement bool `json:"hasAcceptedNonDisclosureAgreement"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Audits *AuditConnection `json:"audits"`
|
||||
Vendors *VendorConnection `json:"vendors"`
|
||||
ID gid.GID `json:"id"`
|
||||
Active bool `json:"active"`
|
||||
Slug string `json:"slug"`
|
||||
NdaFileName *string `json:"ndaFileName,omitempty"`
|
||||
NdaFileURL *string `json:"ndaFileUrl,omitempty"`
|
||||
Organization *Organization `json:"organization"`
|
||||
IsUserAuthenticated bool `json:"isUserAuthenticated"`
|
||||
HasAcceptedNonDisclosureAgreement bool `json:"hasAcceptedNonDisclosureAgreement"`
|
||||
Documents *DocumentConnection `json:"documents"`
|
||||
Audits *AuditConnection `json:"audits"`
|
||||
Vendors *VendorConnection `json:"vendors"`
|
||||
References *TrustCenterReferenceConnection `json:"references"`
|
||||
}
|
||||
|
||||
func (TrustCenter) IsNode() {}
|
||||
@@ -161,6 +162,27 @@ type TrustCenterAccess struct {
|
||||
func (TrustCenterAccess) IsNode() {}
|
||||
func (this TrustCenterAccess) GetID() gid.GID { return this.ID }
|
||||
|
||||
type TrustCenterReference struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
WebsiteURL string `json:"websiteUrl"`
|
||||
LogoURL string `json:"logoUrl"`
|
||||
}
|
||||
|
||||
func (TrustCenterReference) IsNode() {}
|
||||
func (this TrustCenterReference) GetID() gid.GID { return this.ID }
|
||||
|
||||
type TrustCenterReferenceConnection struct {
|
||||
Edges []*TrustCenterReferenceEdge `json:"edges"`
|
||||
PageInfo *PageInfo `json:"pageInfo"`
|
||||
}
|
||||
|
||||
type TrustCenterReferenceEdge struct {
|
||||
Cursor page.CursorKey `json:"cursor"`
|
||||
Node *TrustCenterReference `json:"node"`
|
||||
}
|
||||
|
||||
type Vendor struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -330,6 +330,36 @@ func (r *trustCenterResolver) Vendors(ctx context.Context, obj *types.TrustCente
|
||||
return types.NewVendorConnection(vendorPage), nil
|
||||
}
|
||||
|
||||
// References is the resolver for the references field.
|
||||
func (r *trustCenterResolver) References(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TrustCenterReferenceConnection, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.TrustCenterReferenceOrderField]{
|
||||
Field: coredata.TrustCenterReferenceOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
referencePage, err := publicTrustService.TrustCenterReferences.ListForTrustCenterID(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot list public trust center references: %w", err))
|
||||
}
|
||||
|
||||
return types.NewTrustCenterReferenceConnection(referencePage), nil
|
||||
}
|
||||
|
||||
// LogoURL is the resolver for the logoUrl field.
|
||||
func (r *trustCenterReferenceResolver) LogoURL(ctx context.Context, obj *types.TrustCenterReference) (string, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
logoURL, err := publicTrustService.TrustCenterReferences.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot generate logo URL: %w", err))
|
||||
}
|
||||
|
||||
return logoURL, nil
|
||||
}
|
||||
|
||||
// Audit returns schema.AuditResolver implementation.
|
||||
func (r *Resolver) Audit() schema.AuditResolver { return &auditResolver{r} }
|
||||
|
||||
@@ -345,8 +375,14 @@ func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} }
|
||||
// TrustCenter returns schema.TrustCenterResolver implementation.
|
||||
func (r *Resolver) TrustCenter() schema.TrustCenterResolver { return &trustCenterResolver{r} }
|
||||
|
||||
// TrustCenterReference returns schema.TrustCenterReferenceResolver implementation.
|
||||
func (r *Resolver) TrustCenterReference() schema.TrustCenterReferenceResolver {
|
||||
return &trustCenterReferenceResolver{r}
|
||||
}
|
||||
|
||||
type auditResolver struct{ *Resolver }
|
||||
type mutationResolver struct{ *Resolver }
|
||||
type organizationResolver struct{ *Resolver }
|
||||
type queryResolver struct{ *Resolver }
|
||||
type trustCenterResolver struct{ *Resolver }
|
||||
type trustCenterReferenceResolver struct{ *Resolver }
|
||||
|
||||
Reference in New Issue
Block a user