Add public trust center documents
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -28,17 +28,17 @@ import (
|
||||
|
||||
type (
|
||||
Audit struct {
|
||||
ID gid.GID `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
ReportID *gid.GID `db:"report_id"`
|
||||
ValidFrom *time.Time `db:"valid_from"`
|
||||
ValidUntil *time.Time `db:"valid_until"`
|
||||
State AuditState `db:"state"`
|
||||
ShowOnTrustCenter bool `db:"show_on_trust_center"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
Name *string `db:"name"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
FrameworkID gid.GID `db:"framework_id"`
|
||||
ReportID *gid.GID `db:"report_id"`
|
||||
ValidFrom *time.Time `db:"valid_from"`
|
||||
ValidUntil *time.Time `db:"valid_until"`
|
||||
State AuditState `db:"state"`
|
||||
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Audits []*Audit
|
||||
@@ -75,7 +75,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -156,7 +156,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -207,7 +207,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -256,7 +256,7 @@ INSERT INTO audits (
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@@ -269,25 +269,25 @@ INSERT INTO audits (
|
||||
@valid_from,
|
||||
@valid_until,
|
||||
@state,
|
||||
@show_on_trust_center,
|
||||
@trust_center_visibility,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": a.OrganizationID,
|
||||
"framework_id": a.FrameworkID,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"show_on_trust_center": a.ShowOnTrustCenter,
|
||||
"created_at": a.CreatedAt,
|
||||
"updated_at": a.UpdatedAt,
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": a.OrganizationID,
|
||||
"framework_id": a.FrameworkID,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"trust_center_visibility": a.TrustCenterVisibility,
|
||||
"created_at": a.CreatedAt,
|
||||
"updated_at": a.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
@@ -311,7 +311,7 @@ SET
|
||||
valid_from = @valid_from,
|
||||
valid_until = @valid_until,
|
||||
state = @state,
|
||||
show_on_trust_center = @show_on_trust_center,
|
||||
trust_center_visibility = @trust_center_visibility,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
@@ -321,14 +321,14 @@ WHERE
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"show_on_trust_center": a.ShowOnTrustCenter,
|
||||
"updated_at": a.UpdatedAt,
|
||||
"id": a.ID,
|
||||
"name": a.Name,
|
||||
"report_id": a.ReportID,
|
||||
"valid_from": a.ValidFrom,
|
||||
"valid_until": a.ValidUntil,
|
||||
"state": a.State,
|
||||
"trust_center_visibility": a.TrustCenterVisibility,
|
||||
"updated_at": a.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -423,7 +423,7 @@ WITH audits_by_control AS (
|
||||
a.valid_from,
|
||||
a.valid_until,
|
||||
a.state,
|
||||
a.show_on_trust_center,
|
||||
a.trust_center_visibility,
|
||||
a.created_at,
|
||||
a.updated_at
|
||||
FROM
|
||||
@@ -442,7 +442,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -487,7 +487,7 @@ SELECT
|
||||
valid_from,
|
||||
valid_until,
|
||||
state,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
type (
|
||||
AuditFilter struct {
|
||||
showOnTrustCenter *bool
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
}
|
||||
)
|
||||
|
||||
@@ -29,25 +29,31 @@ func NewAuditFilter() *AuditFilter {
|
||||
}
|
||||
|
||||
func NewAuditTrustCenterFilter() *AuditFilter {
|
||||
showOnTrustCenter := true
|
||||
return &AuditFilter{
|
||||
showOnTrustCenter: &showOnTrustCenter,
|
||||
trustCenterVisibilities: []TrustCenterVisibility{
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *AuditFilter) SQLArguments() pgx.NamedArgs {
|
||||
args := pgx.NamedArgs{}
|
||||
|
||||
if f.showOnTrustCenter != nil {
|
||||
args["show_on_trust_center"] = *f.showOnTrustCenter
|
||||
if f.trustCenterVisibilities != nil {
|
||||
visibilities := make([]string, len(f.trustCenterVisibilities))
|
||||
for i, v := range f.trustCenterVisibilities {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
args["trust_center_visibilities"] = visibilities
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
func (f *AuditFilter) SQLFragment() string {
|
||||
if f.showOnTrustCenter != nil {
|
||||
return "show_on_trust_center = @show_on_trust_center"
|
||||
if f.trustCenterVisibilities != nil {
|
||||
return "trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])"
|
||||
}
|
||||
|
||||
return "TRUE"
|
||||
|
||||
@@ -28,15 +28,15 @@ import (
|
||||
|
||||
type (
|
||||
Document struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
Title string `db:"title"`
|
||||
DocumentType DocumentType `db:"document_type"`
|
||||
CurrentPublishedVersion *int `db:"current_published_version"`
|
||||
ShowOnTrustCenter bool `db:"show_on_trust_center"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
OwnerID gid.GID `db:"owner_id"`
|
||||
Title string `db:"title"`
|
||||
DocumentType DocumentType `db:"document_type"`
|
||||
CurrentPublishedVersion *int `db:"current_published_version"`
|
||||
TrustCenterVisibility TrustCenterVisibility `db:"trust_center_visibility"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
Documents []*Document
|
||||
@@ -69,7 +69,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -151,7 +151,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -201,7 +201,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -250,7 +250,7 @@ INSERT INTO
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
@@ -262,7 +262,7 @@ VALUES (
|
||||
@title,
|
||||
@document_type,
|
||||
@current_published_version,
|
||||
@show_on_trust_center,
|
||||
@trust_center_visibility,
|
||||
@created_at,
|
||||
@updated_at
|
||||
);
|
||||
@@ -276,7 +276,7 @@ VALUES (
|
||||
"title": p.Title,
|
||||
"document_type": p.DocumentType,
|
||||
"current_published_version": p.CurrentPublishedVersion,
|
||||
"show_on_trust_center": p.ShowOnTrustCenter,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
"created_at": p.CreatedAt,
|
||||
"updated_at": p.UpdatedAt,
|
||||
}
|
||||
@@ -334,7 +334,7 @@ SET
|
||||
current_published_version = @current_published_version,
|
||||
owner_id = @owner_id,
|
||||
document_type = @document_type,
|
||||
show_on_trust_center = @show_on_trust_center,
|
||||
trust_center_visibility = @trust_center_visibility,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
@@ -350,7 +350,7 @@ WHERE
|
||||
"current_published_version": p.CurrentPublishedVersion,
|
||||
"owner_id": p.OwnerID,
|
||||
"document_type": p.DocumentType,
|
||||
"show_on_trust_center": p.ShowOnTrustCenter,
|
||||
"trust_center_visibility": p.TrustCenterVisibility,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -375,7 +375,7 @@ WITH plcs AS (
|
||||
p.id,
|
||||
p.tenant_id,
|
||||
p.search_vector,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.deleted_at
|
||||
FROM
|
||||
documents p
|
||||
@@ -428,7 +428,7 @@ WITH plcs AS (
|
||||
p.title,
|
||||
p.document_type,
|
||||
p.current_published_version,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.created_at,
|
||||
p.updated_at,
|
||||
p.deleted_at
|
||||
@@ -446,7 +446,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -492,7 +492,7 @@ WITH plcs AS (
|
||||
p.id,
|
||||
p.tenant_id,
|
||||
p.search_vector,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.deleted_at
|
||||
FROM
|
||||
documents p
|
||||
@@ -544,7 +544,7 @@ WITH plcs AS (
|
||||
p.title,
|
||||
p.document_type,
|
||||
p.current_published_version,
|
||||
p.show_on_trust_center,
|
||||
p.trust_center_visibility,
|
||||
p.created_at,
|
||||
p.updated_at,
|
||||
p.search_vector,
|
||||
@@ -563,7 +563,7 @@ SELECT
|
||||
title,
|
||||
document_type,
|
||||
current_published_version,
|
||||
show_on_trust_center,
|
||||
trust_center_visibility,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
|
||||
type (
|
||||
DocumentFilter struct {
|
||||
query *string
|
||||
showOnTrustCenter *bool
|
||||
query *string
|
||||
trustCenterVisibilities []TrustCenterVisibility
|
||||
}
|
||||
)
|
||||
|
||||
@@ -32,16 +32,25 @@ func NewDocumentFilter(query *string) *DocumentFilter {
|
||||
}
|
||||
|
||||
func NewDocumentTrustCenterFilter() *DocumentFilter {
|
||||
showOnTrustCenter := true
|
||||
return &DocumentFilter{
|
||||
showOnTrustCenter: &showOnTrustCenter,
|
||||
trustCenterVisibilities: []TrustCenterVisibility{
|
||||
TrustCenterVisibilityPrivate,
|
||||
TrustCenterVisibilityPublic,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (f *DocumentFilter) SQLArguments() pgx.StrictNamedArgs {
|
||||
var visibilities []string
|
||||
if f.trustCenterVisibilities != nil {
|
||||
visibilities = make([]string, len(f.trustCenterVisibilities))
|
||||
for i, v := range f.trustCenterVisibilities {
|
||||
visibilities[i] = v.String()
|
||||
}
|
||||
}
|
||||
return pgx.StrictNamedArgs{
|
||||
"query": f.query,
|
||||
"show_on_trust_center": f.showOnTrustCenter,
|
||||
"query": f.query,
|
||||
"trust_center_visibilities": visibilities,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +67,8 @@ func (f *DocumentFilter) SQLFragment() string {
|
||||
END
|
||||
AND
|
||||
CASE
|
||||
WHEN @show_on_trust_center::boolean IS NOT NULL THEN
|
||||
show_on_trust_center = @show_on_trust_center::boolean
|
||||
WHEN @trust_center_visibilities::trust_center_visibility[] IS NOT NULL THEN
|
||||
trust_center_visibility = ANY(@trust_center_visibilities::trust_center_visibility[])
|
||||
ELSE TRUE
|
||||
END
|
||||
)`
|
||||
|
||||
25
pkg/coredata/migrations/20251002T131830Z.sql
Normal file
25
pkg/coredata/migrations/20251002T131830Z.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
CREATE TYPE trust_center_visibility AS ENUM (
|
||||
'NONE',
|
||||
'PRIVATE',
|
||||
'PUBLIC'
|
||||
);
|
||||
|
||||
ALTER TABLE documents ADD COLUMN trust_center_visibility trust_center_visibility NOT NULL DEFAULT 'NONE';
|
||||
|
||||
UPDATE documents SET trust_center_visibility = CASE
|
||||
WHEN show_on_trust_center = true THEN 'PRIVATE'::trust_center_visibility
|
||||
ELSE 'NONE'::trust_center_visibility
|
||||
END;
|
||||
|
||||
ALTER TABLE documents ALTER COLUMN trust_center_visibility DROP DEFAULT;
|
||||
ALTER TABLE documents DROP COLUMN show_on_trust_center;
|
||||
|
||||
ALTER TABLE audits ADD COLUMN trust_center_visibility trust_center_visibility NOT NULL DEFAULT 'NONE';
|
||||
|
||||
UPDATE audits SET trust_center_visibility = CASE
|
||||
WHEN show_on_trust_center = true THEN 'PRIVATE'::trust_center_visibility
|
||||
ELSE 'NONE'::trust_center_visibility
|
||||
END;
|
||||
|
||||
ALTER TABLE audits ALTER COLUMN trust_center_visibility DROP DEFAULT;
|
||||
ALTER TABLE audits DROP COLUMN show_on_trust_center;
|
||||
60
pkg/coredata/trust_center_visibility.go
Normal file
60
pkg/coredata/trust_center_visibility.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// 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 coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type TrustCenterVisibility string
|
||||
|
||||
const (
|
||||
TrustCenterVisibilityNone TrustCenterVisibility = "NONE"
|
||||
TrustCenterVisibilityPrivate TrustCenterVisibility = "PRIVATE"
|
||||
TrustCenterVisibilityPublic TrustCenterVisibility = "PUBLIC"
|
||||
)
|
||||
|
||||
func (tcv TrustCenterVisibility) String() string {
|
||||
return string(tcv)
|
||||
}
|
||||
|
||||
func (tcv *TrustCenterVisibility) Scan(value any) error {
|
||||
var s string
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for TrustCenterVisibility: %T", value)
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "NONE":
|
||||
*tcv = TrustCenterVisibilityNone
|
||||
case "PRIVATE":
|
||||
*tcv = TrustCenterVisibilityPrivate
|
||||
case "PUBLIC":
|
||||
*tcv = TrustCenterVisibilityPublic
|
||||
default:
|
||||
return fmt.Errorf("invalid TrustCenterVisibility value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tcv TrustCenterVisibility) Value() (driver.Value, error) {
|
||||
return tcv.String(), nil
|
||||
}
|
||||
@@ -34,21 +34,22 @@ type AuditService struct {
|
||||
|
||||
type (
|
||||
CreateAuditRequest struct {
|
||||
OrganizationID gid.GID
|
||||
FrameworkID gid.GID
|
||||
Name *string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
OrganizationID gid.GID
|
||||
FrameworkID gid.GID
|
||||
Name *string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
}
|
||||
|
||||
UpdateAuditRequest struct {
|
||||
ID gid.GID
|
||||
Name **string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
ShowOnTrustCenter *bool
|
||||
ID gid.GID
|
||||
Name **string
|
||||
ValidFrom *time.Time
|
||||
ValidUntil *time.Time
|
||||
State *coredata.AuditState
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
}
|
||||
|
||||
UpdateAuditStateRequest struct {
|
||||
@@ -113,22 +114,26 @@ func (s *AuditService) Create(
|
||||
now := time.Now()
|
||||
|
||||
audit := &coredata.Audit{
|
||||
ID: gid.New(s.svc.scope.GetTenantID(), coredata.AuditEntityType),
|
||||
Name: req.Name,
|
||||
OrganizationID: req.OrganizationID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
ValidFrom: req.ValidFrom,
|
||||
ValidUntil: req.ValidUntil,
|
||||
State: coredata.AuditStateNotStarted,
|
||||
ShowOnTrustCenter: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: gid.New(s.svc.scope.GetTenantID(), coredata.AuditEntityType),
|
||||
Name: req.Name,
|
||||
OrganizationID: req.OrganizationID,
|
||||
FrameworkID: req.FrameworkID,
|
||||
ValidFrom: req.ValidFrom,
|
||||
ValidUntil: req.ValidUntil,
|
||||
State: coredata.AuditStateNotStarted,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if req.State != nil {
|
||||
audit.State = *req.State
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
audit.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
}
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
@@ -182,8 +187,8 @@ func (s *AuditService) Update(
|
||||
if req.State != nil {
|
||||
audit.State = *req.State
|
||||
}
|
||||
if req.ShowOnTrustCenter != nil {
|
||||
audit.ShowOnTrustCenter = *req.ShowOnTrustCenter
|
||||
if req.TrustCenterVisibility != nil {
|
||||
audit.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
}
|
||||
|
||||
audit.UpdatedAt = time.Now()
|
||||
|
||||
@@ -40,11 +40,12 @@ type (
|
||||
}
|
||||
|
||||
CreateDocumentRequest struct {
|
||||
OrganizationID gid.GID
|
||||
Title string
|
||||
Content string
|
||||
OwnerID gid.GID
|
||||
DocumentType coredata.DocumentType
|
||||
OrganizationID gid.GID
|
||||
Title string
|
||||
Content string
|
||||
OwnerID gid.GID
|
||||
DocumentType coredata.DocumentType
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility
|
||||
}
|
||||
|
||||
UpdateDocumentVersionRequest struct {
|
||||
@@ -310,12 +311,16 @@ func (s *DocumentService) Create(
|
||||
people := &coredata.People{}
|
||||
|
||||
document := &coredata.Document{
|
||||
ID: documentID,
|
||||
Title: req.Title,
|
||||
DocumentType: req.DocumentType,
|
||||
ShowOnTrustCenter: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
ID: documentID,
|
||||
Title: req.Title,
|
||||
DocumentType: req.DocumentType,
|
||||
TrustCenterVisibility: coredata.TrustCenterVisibilityNone,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
if req.TrustCenterVisibility != nil {
|
||||
document.TrustCenterVisibility = *req.TrustCenterVisibility
|
||||
}
|
||||
|
||||
documentVersion := &coredata.DocumentVersion{
|
||||
@@ -1096,7 +1101,7 @@ func (s *DocumentService) Update(
|
||||
newOwnerID *gid.GID,
|
||||
documentType *coredata.DocumentType,
|
||||
title *string,
|
||||
showOnTrustCenter *bool,
|
||||
trustCenterVisibility *coredata.TrustCenterVisibility,
|
||||
) (*coredata.Document, error) {
|
||||
document := &coredata.Document{}
|
||||
people := &coredata.People{}
|
||||
@@ -1124,8 +1129,8 @@ func (s *DocumentService) Update(
|
||||
document.Title = *title
|
||||
}
|
||||
|
||||
if showOnTrustCenter != nil {
|
||||
document.ShowOnTrustCenter = *showOnTrustCenter
|
||||
if trustCenterVisibility != nil {
|
||||
document.TrustCenterVisibility = *trustCenterVisibility
|
||||
}
|
||||
|
||||
document.UpdatedAt = now
|
||||
|
||||
@@ -152,6 +152,22 @@ enum AuditState
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterVisibility
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibility") {
|
||||
NONE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityNone"
|
||||
)
|
||||
PRIVATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPrivate"
|
||||
)
|
||||
PUBLIC
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPublic"
|
||||
)
|
||||
}
|
||||
|
||||
enum NonconformityStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.NonconformityStatus") {
|
||||
OPEN
|
||||
@@ -1950,7 +1966,7 @@ type Document implements Node {
|
||||
description: String!
|
||||
documentType: DocumentType!
|
||||
currentPublishedVersion: Int
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
owner: People! @goField(forceResolver: true)
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
|
||||
@@ -2054,7 +2070,7 @@ type Audit implements Node {
|
||||
filter: ControlFilter
|
||||
): ControlConnection! @goField(forceResolver: true)
|
||||
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
@@ -3345,6 +3361,7 @@ input CreateDocumentInput {
|
||||
content: String!
|
||||
ownerId: ID!
|
||||
documentType: DocumentType!
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateDocumentInput {
|
||||
@@ -3353,7 +3370,7 @@ input UpdateDocumentInput {
|
||||
content: String
|
||||
ownerId: ID
|
||||
documentType: DocumentType
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input ExportDocumentVersionPDFInput {
|
||||
@@ -3413,6 +3430,7 @@ input CreateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateAuditInput {
|
||||
@@ -3421,7 +3439,7 @@ input UpdateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input DeleteAuditInput {
|
||||
|
||||
@@ -139,19 +139,19 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
Audit struct {
|
||||
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
Framework func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Name func(childComplexity int) int
|
||||
Organization func(childComplexity int) int
|
||||
Report func(childComplexity int) int
|
||||
ReportURL func(childComplexity int) int
|
||||
ShowOnTrustCenter func(childComplexity int) int
|
||||
State func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
ValidFrom func(childComplexity int) int
|
||||
ValidUntil func(childComplexity int) int
|
||||
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
Framework func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Name func(childComplexity int) int
|
||||
Organization func(childComplexity int) int
|
||||
Report func(childComplexity int) int
|
||||
ReportURL func(childComplexity int) int
|
||||
State func(childComplexity int) int
|
||||
TrustCenterVisibility func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
ValidFrom func(childComplexity int) int
|
||||
ValidUntil func(childComplexity int) int
|
||||
}
|
||||
|
||||
AuditConnection struct {
|
||||
@@ -573,8 +573,8 @@ type ComplexityRoot struct {
|
||||
ID func(childComplexity int) int
|
||||
Organization func(childComplexity int) int
|
||||
Owner func(childComplexity int) int
|
||||
ShowOnTrustCenter func(childComplexity int) int
|
||||
Title func(childComplexity int) int
|
||||
TrustCenterVisibility func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
Versions func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionOrderBy, filter *types.DocumentVersionFilter) int
|
||||
}
|
||||
@@ -2132,13 +2132,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Audit.ReportURL(childComplexity), true
|
||||
|
||||
case "Audit.showOnTrustCenter":
|
||||
if e.complexity.Audit.ShowOnTrustCenter == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Audit.ShowOnTrustCenter(childComplexity), true
|
||||
|
||||
case "Audit.state":
|
||||
if e.complexity.Audit.State == nil {
|
||||
break
|
||||
@@ -2146,6 +2139,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Audit.State(childComplexity), true
|
||||
|
||||
case "Audit.trustCenterVisibility":
|
||||
if e.complexity.Audit.TrustCenterVisibility == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Audit.TrustCenterVisibility(childComplexity), true
|
||||
|
||||
case "Audit.updatedAt":
|
||||
if e.complexity.Audit.UpdatedAt == nil {
|
||||
break
|
||||
@@ -3317,13 +3317,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Document.Owner(childComplexity), true
|
||||
|
||||
case "Document.showOnTrustCenter":
|
||||
if e.complexity.Document.ShowOnTrustCenter == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Document.ShowOnTrustCenter(childComplexity), true
|
||||
|
||||
case "Document.title":
|
||||
if e.complexity.Document.Title == nil {
|
||||
break
|
||||
@@ -3331,6 +3324,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
||||
|
||||
return e.complexity.Document.Title(childComplexity), true
|
||||
|
||||
case "Document.trustCenterVisibility":
|
||||
if e.complexity.Document.TrustCenterVisibility == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Document.TrustCenterVisibility(childComplexity), true
|
||||
|
||||
case "Document.updatedAt":
|
||||
if e.complexity.Document.UpdatedAt == nil {
|
||||
break
|
||||
@@ -8705,6 +8705,22 @@ enum AuditState
|
||||
)
|
||||
}
|
||||
|
||||
enum TrustCenterVisibility
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibility") {
|
||||
NONE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityNone"
|
||||
)
|
||||
PRIVATE
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPrivate"
|
||||
)
|
||||
PUBLIC
|
||||
@goEnum(
|
||||
value: "github.com/getprobo/probo/pkg/coredata.TrustCenterVisibilityPublic"
|
||||
)
|
||||
}
|
||||
|
||||
enum NonconformityStatus
|
||||
@goModel(model: "github.com/getprobo/probo/pkg/coredata.NonconformityStatus") {
|
||||
OPEN
|
||||
@@ -10503,7 +10519,7 @@ type Document implements Node {
|
||||
description: String!
|
||||
documentType: DocumentType!
|
||||
currentPublishedVersion: Int
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
owner: People! @goField(forceResolver: true)
|
||||
organization: Organization! @goField(forceResolver: true)
|
||||
|
||||
@@ -10607,7 +10623,7 @@ type Audit implements Node {
|
||||
filter: ControlFilter
|
||||
): ControlConnection! @goField(forceResolver: true)
|
||||
|
||||
showOnTrustCenter: Boolean!
|
||||
trustCenterVisibility: TrustCenterVisibility!
|
||||
createdAt: Datetime!
|
||||
updatedAt: Datetime!
|
||||
}
|
||||
@@ -11898,6 +11914,7 @@ input CreateDocumentInput {
|
||||
content: String!
|
||||
ownerId: ID!
|
||||
documentType: DocumentType!
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateDocumentInput {
|
||||
@@ -11906,7 +11923,7 @@ input UpdateDocumentInput {
|
||||
content: String
|
||||
ownerId: ID
|
||||
documentType: DocumentType
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input ExportDocumentVersionPDFInput {
|
||||
@@ -11966,6 +11983,7 @@ input CreateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input UpdateAuditInput {
|
||||
@@ -11974,7 +11992,7 @@ input UpdateAuditInput {
|
||||
validFrom: Datetime
|
||||
validUntil: Datetime
|
||||
state: AuditState
|
||||
showOnTrustCenter: Boolean
|
||||
trustCenterVisibility: TrustCenterVisibility
|
||||
}
|
||||
|
||||
input DeleteAuditInput {
|
||||
@@ -22353,8 +22371,8 @@ func (ec *executionContext) fieldContext_Audit_controls(ctx context.Context, fie
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Audit_showOnTrustCenter(ctx context.Context, field graphql.CollectedField, obj *types.Audit) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
func (ec *executionContext) _Audit_trustCenterVisibility(ctx context.Context, field graphql.CollectedField, obj *types.Audit) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
@@ -22367,7 +22385,7 @@ func (ec *executionContext) _Audit_showOnTrustCenter(ctx context.Context, field
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.ShowOnTrustCenter, nil
|
||||
return obj.TrustCenterVisibility, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -22379,19 +22397,19 @@ func (ec *executionContext) _Audit_showOnTrustCenter(ctx context.Context, field
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
res := resTmp.(coredata.TrustCenterVisibility)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
return ec.marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Audit_showOnTrustCenter(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
func (ec *executionContext) fieldContext_Audit_trustCenterVisibility(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Audit",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
return nil, errors.New("field of type TrustCenterVisibility does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
@@ -22736,8 +22754,8 @@ func (ec *executionContext) fieldContext_AuditEdge_node(_ context.Context, field
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -28170,8 +28188,8 @@ func (ec *executionContext) fieldContext_DeleteAuditReportPayload_audit(_ contex
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -30138,8 +30156,8 @@ func (ec *executionContext) fieldContext_Document_currentPublishedVersion(_ cont
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Document_showOnTrustCenter(ctx context.Context, field graphql.CollectedField, obj *types.Document) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
func (ec *executionContext) _Document_trustCenterVisibility(ctx context.Context, field graphql.CollectedField, obj *types.Document) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
@@ -30152,7 +30170,7 @@ func (ec *executionContext) _Document_showOnTrustCenter(ctx context.Context, fie
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.ShowOnTrustCenter, nil
|
||||
return obj.TrustCenterVisibility, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
@@ -30164,19 +30182,19 @@ func (ec *executionContext) _Document_showOnTrustCenter(ctx context.Context, fie
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
res := resTmp.(coredata.TrustCenterVisibility)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
return ec.marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Document_showOnTrustCenter(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
func (ec *executionContext) fieldContext_Document_trustCenterVisibility(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Document",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Boolean does not have child fields")
|
||||
return nil, errors.New("field of type TrustCenterVisibility does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
@@ -30803,8 +30821,8 @@ func (ec *executionContext) fieldContext_DocumentEdge_node(_ context.Context, fi
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -30917,8 +30935,8 @@ func (ec *executionContext) fieldContext_DocumentVersion_document(_ context.Cont
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -42270,8 +42288,8 @@ func (ec *executionContext) fieldContext_Nonconformity_audit(_ context.Context,
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -47969,8 +47987,8 @@ func (ec *executionContext) fieldContext_PublishDocumentVersionPayload_document(
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -48677,8 +48695,8 @@ func (ec *executionContext) fieldContext_Report_audit(_ context.Context, field g
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -53308,8 +53326,8 @@ func (ec *executionContext) fieldContext_TrustCenterDocumentAccess_document(_ co
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -54511,8 +54529,8 @@ func (ec *executionContext) fieldContext_UpdateAuditPayload_audit(_ context.Cont
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -54781,8 +54799,8 @@ func (ec *executionContext) fieldContext_UpdateDocumentPayload_document(_ contex
|
||||
return ec.fieldContext_Document_documentType(ctx, field)
|
||||
case "currentPublishedVersion":
|
||||
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Document_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
|
||||
case "owner":
|
||||
return ec.fieldContext_Document_owner(ctx, field)
|
||||
case "organization":
|
||||
@@ -56169,8 +56187,8 @@ func (ec *executionContext) fieldContext_UploadAuditReportPayload_audit(_ contex
|
||||
return ec.fieldContext_Audit_state(ctx, field)
|
||||
case "controls":
|
||||
return ec.fieldContext_Audit_controls(ctx, field)
|
||||
case "showOnTrustCenter":
|
||||
return ec.fieldContext_Audit_showOnTrustCenter(ctx, field)
|
||||
case "trustCenterVisibility":
|
||||
return ec.fieldContext_Audit_trustCenterVisibility(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_Audit_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
@@ -64908,7 +64926,7 @@ func (ec *executionContext) unmarshalInputCreateAuditInput(ctx context.Context,
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"organizationId", "frameworkId", "name", "validFrom", "validUntil", "state"}
|
||||
fieldsInOrder := [...]string{"organizationId", "frameworkId", "name", "validFrom", "validUntil", "state", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -64957,6 +64975,13 @@ func (ec *executionContext) unmarshalInputCreateAuditInput(ctx context.Context,
|
||||
return it, err
|
||||
}
|
||||
it.State = data
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65299,7 +65324,7 @@ func (ec *executionContext) unmarshalInputCreateDocumentInput(ctx context.Contex
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"organizationId", "title", "content", "ownerId", "documentType"}
|
||||
fieldsInOrder := [...]string{"organizationId", "title", "content", "ownerId", "documentType", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -65341,6 +65366,13 @@ func (ec *executionContext) unmarshalInputCreateDocumentInput(ctx context.Contex
|
||||
return it, err
|
||||
}
|
||||
it.DocumentType = data
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69154,7 +69186,7 @@ func (ec *executionContext) unmarshalInputUpdateAuditInput(ctx context.Context,
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "name", "validFrom", "validUntil", "state", "showOnTrustCenter"}
|
||||
fieldsInOrder := [...]string{"id", "name", "validFrom", "validUntil", "state", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -69196,13 +69228,13 @@ func (ec *executionContext) unmarshalInputUpdateAuditInput(ctx context.Context,
|
||||
return it, err
|
||||
}
|
||||
it.State = data
|
||||
case "showOnTrustCenter":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("showOnTrustCenter"))
|
||||
data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.ShowOnTrustCenter = data
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69409,7 +69441,7 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "title", "content", "ownerId", "documentType", "showOnTrustCenter"}
|
||||
fieldsInOrder := [...]string{"id", "title", "content", "ownerId", "documentType", "trustCenterVisibility"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -69451,13 +69483,13 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
|
||||
return it, err
|
||||
}
|
||||
it.DocumentType = data
|
||||
case "showOnTrustCenter":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("showOnTrustCenter"))
|
||||
data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v)
|
||||
case "trustCenterVisibility":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trustCenterVisibility"))
|
||||
data, err := ec.unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.ShowOnTrustCenter = data
|
||||
it.TrustCenterVisibility = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72132,8 +72164,8 @@ func (ec *executionContext) _Audit(ctx context.Context, sel ast.SelectionSet, ob
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "showOnTrustCenter":
|
||||
out.Values[i] = ec._Audit_showOnTrustCenter(ctx, field, obj)
|
||||
case "trustCenterVisibility":
|
||||
out.Values[i] = ec._Audit_trustCenterVisibility(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
@@ -76300,8 +76332,8 @@ func (ec *executionContext) _Document(ctx context.Context, sel ast.SelectionSet,
|
||||
}
|
||||
case "currentPublishedVersion":
|
||||
out.Values[i] = ec._Document_currentPublishedVersion(ctx, field, obj)
|
||||
case "showOnTrustCenter":
|
||||
out.Values[i] = ec._Document_showOnTrustCenter(ctx, field, obj)
|
||||
case "trustCenterVisibility":
|
||||
out.Values[i] = ec._Document_trustCenterVisibility(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
@@ -93295,6 +93327,36 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, v any) (coredata.TrustCenterVisibility, error) {
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[tmp]
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, sel ast.SelectionSet, v coredata.TrustCenterVisibility) graphql.Marshaler {
|
||||
_ = sel
|
||||
res := graphql.MarshalString(marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[v])
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[string]coredata.TrustCenterVisibility{
|
||||
"NONE": coredata.TrustCenterVisibilityNone,
|
||||
"PRIVATE": coredata.TrustCenterVisibilityPrivate,
|
||||
"PUBLIC": coredata.TrustCenterVisibilityPublic,
|
||||
}
|
||||
marshalNTrustCenterVisibility2githubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[coredata.TrustCenterVisibility]string{
|
||||
coredata.TrustCenterVisibilityNone: "NONE",
|
||||
coredata.TrustCenterVisibilityPrivate: "PRIVATE",
|
||||
coredata.TrustCenterVisibilityPublic: "PUBLIC",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalNUnassignTaskInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐUnassignTaskInput(ctx context.Context, v any) (types.UnassignTaskInput, error) {
|
||||
res, err := ec.unmarshalInputUnassignTaskInput(ctx, v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
@@ -96681,6 +96743,38 @@ func (ec *executionContext) unmarshalOTrustCenterReferenceOrder2ᚖgithubᚗcom
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, v any) (*coredata.TrustCenterVisibility, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
tmp, err := graphql.UnmarshalString(v)
|
||||
res := unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[tmp]
|
||||
return &res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility(ctx context.Context, sel ast.SelectionSet, v *coredata.TrustCenterVisibility) graphql.Marshaler {
|
||||
if v == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
_ = sel
|
||||
_ = ctx
|
||||
res := graphql.MarshalString(marshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility[*v])
|
||||
return res
|
||||
}
|
||||
|
||||
var (
|
||||
unmarshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[string]coredata.TrustCenterVisibility{
|
||||
"NONE": coredata.TrustCenterVisibilityNone,
|
||||
"PRIVATE": coredata.TrustCenterVisibilityPrivate,
|
||||
"PUBLIC": coredata.TrustCenterVisibilityPublic,
|
||||
}
|
||||
marshalOTrustCenterVisibility2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋcoredataᚐTrustCenterVisibility = map[coredata.TrustCenterVisibility]string{
|
||||
coredata.TrustCenterVisibilityNone: "NONE",
|
||||
coredata.TrustCenterVisibilityPrivate: "PRIVATE",
|
||||
coredata.TrustCenterVisibilityPublic: "PUBLIC",
|
||||
}
|
||||
)
|
||||
|
||||
func (ec *executionContext) unmarshalOUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v any) (*graphql.Upload, error) {
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
|
||||
@@ -54,14 +54,14 @@ func NewAuditConnection(
|
||||
|
||||
func NewAudit(a *coredata.Audit) *Audit {
|
||||
return &Audit{
|
||||
ID: a.ID,
|
||||
ValidFrom: a.ValidFrom,
|
||||
ValidUntil: a.ValidUntil,
|
||||
State: a.State,
|
||||
Name: a.Name,
|
||||
ShowOnTrustCenter: a.ShowOnTrustCenter,
|
||||
CreatedAt: a.CreatedAt,
|
||||
UpdatedAt: a.UpdatedAt,
|
||||
ID: a.ID,
|
||||
ValidFrom: a.ValidFrom,
|
||||
ValidUntil: a.ValidUntil,
|
||||
State: a.State,
|
||||
Name: a.Name,
|
||||
TrustCenterVisibility: a.TrustCenterVisibility,
|
||||
CreatedAt: a.CreatedAt,
|
||||
UpdatedAt: a.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func NewDocument(document *coredata.Document) *Document {
|
||||
Title: document.Title,
|
||||
DocumentType: document.DocumentType,
|
||||
CurrentPublishedVersion: document.CurrentPublishedVersion,
|
||||
ShowOnTrustCenter: document.ShowOnTrustCenter,
|
||||
TrustCenterVisibility: document.TrustCenterVisibility,
|
||||
CreatedAt: document.CreatedAt,
|
||||
UpdatedAt: document.UpdatedAt,
|
||||
}
|
||||
|
||||
@@ -62,19 +62,19 @@ type AssignTaskPayload struct {
|
||||
}
|
||||
|
||||
type Audit struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
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"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
ShowOnTrustCenter bool `json:"showOnTrustCenter"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
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"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Audit) IsNode() {}
|
||||
@@ -237,12 +237,13 @@ type CreateAssetPayload struct {
|
||||
}
|
||||
|
||||
type CreateAuditInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
FrameworkID gid.GID `json:"frameworkId"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
FrameworkID gid.GID `json:"frameworkId"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type CreateAuditPayload struct {
|
||||
@@ -330,11 +331,12 @@ type CreateDatumPayload struct {
|
||||
}
|
||||
|
||||
type CreateDocumentInput struct {
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
OrganizationID gid.GID `json:"organizationId"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
OwnerID gid.GID `json:"ownerId"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type CreateDocumentPayload struct {
|
||||
@@ -943,18 +945,18 @@ type DeleteVendorServicePayload struct {
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Title string `json:"title"`
|
||||
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"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
DocumentType coredata.DocumentType `json:"documentType"`
|
||||
CurrentPublishedVersion *int `json:"currentPublishedVersion,omitempty"`
|
||||
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
|
||||
Owner *People `json:"owner"`
|
||||
Organization *Organization `json:"organization"`
|
||||
Versions *DocumentVersionConnection `json:"versions"`
|
||||
Controls *ControlConnection `json:"controls"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Document) IsNode() {}
|
||||
@@ -1615,12 +1617,12 @@ type UpdateAssetPayload struct {
|
||||
}
|
||||
|
||||
type UpdateAuditInput struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
|
||||
ID gid.GID `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
ValidFrom *time.Time `json:"validFrom,omitempty"`
|
||||
ValidUntil *time.Time `json:"validUntil,omitempty"`
|
||||
State *coredata.AuditState `json:"state,omitempty"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateAuditPayload struct {
|
||||
@@ -1668,12 +1670,12 @@ 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"`
|
||||
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
|
||||
ShowOnTrustCenter *bool `json:"showOnTrustCenter,omitempty"`
|
||||
ID gid.GID `json:"id"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Content *string `json:"content,omitempty"`
|
||||
OwnerID *gid.GID `json:"ownerId,omitempty"`
|
||||
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
|
||||
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateDocumentPayload struct {
|
||||
|
||||
@@ -2500,11 +2500,12 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
|
||||
document, documentVersion, err := prb.Documents.Create(
|
||||
ctx,
|
||||
probo.CreateDocumentRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
DocumentType: input.DocumentType,
|
||||
Title: input.Title,
|
||||
OwnerID: input.OwnerID,
|
||||
Content: input.Content,
|
||||
OrganizationID: input.OrganizationID,
|
||||
DocumentType: input.DocumentType,
|
||||
Title: input.Title,
|
||||
OwnerID: input.OwnerID,
|
||||
Content: input.Content,
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -2527,7 +2528,7 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
|
||||
input.OwnerID,
|
||||
input.DocumentType,
|
||||
input.Title,
|
||||
input.ShowOnTrustCenter,
|
||||
input.TrustCenterVisibility,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
@@ -2963,12 +2964,13 @@ func (r *mutationResolver) CreateAudit(ctx context.Context, input types.CreateAu
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
|
||||
req := probo.CreateAuditRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
FrameworkID: input.FrameworkID,
|
||||
Name: input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
OrganizationID: input.OrganizationID,
|
||||
FrameworkID: input.FrameworkID,
|
||||
Name: input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Create(ctx, &req)
|
||||
@@ -2986,12 +2988,12 @@ func (r *mutationResolver) UpdateAudit(ctx context.Context, input types.UpdateAu
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
|
||||
req := probo.UpdateAuditRequest{
|
||||
ID: input.ID,
|
||||
Name: &input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
ShowOnTrustCenter: input.ShowOnTrustCenter,
|
||||
ID: input.ID,
|
||||
Name: &input.Name,
|
||||
ValidFrom: input.ValidFrom,
|
||||
ValidUntil: input.ValidUntil,
|
||||
State: input.State,
|
||||
TrustCenterVisibility: input.TrustCenterVisibility,
|
||||
}
|
||||
|
||||
audit, err := prb.Audits.Update(ctx, &req)
|
||||
|
||||
@@ -59,6 +59,17 @@ func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Re
|
||||
|
||||
// IsUserAuthorized is the resolver for the isUserAuthorized field.
|
||||
func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Document) (bool, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
document, err := publicTrustService.Documents.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, obj.ID.TenantID())
|
||||
if err != nil {
|
||||
return false, nil
|
||||
@@ -153,9 +164,27 @@ func (r *mutationResolver) RequestAllAccesses(ctx context.Context, input types.R
|
||||
|
||||
// ExportDocumentPDF is the resolver for the exportDocumentPDF field.
|
||||
func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.ExportDocumentPDFInput) (*types.ExportDocumentPDFPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.DocumentID.TenantID())
|
||||
|
||||
document, err := publicTrustService.Documents.Get(ctx, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
pdf, err := publicTrustService.Documents.ExportPDFWithoutWatermark(ctx, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot export document PDF: %w", err))
|
||||
}
|
||||
|
||||
return &types.ExportDocumentPDFPayload{
|
||||
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, input.DocumentID.TenantID())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export document PDF: %w", err)
|
||||
panic(fmt.Errorf("cannot export document PDF: %w", err))
|
||||
}
|
||||
|
||||
tokenData := TokenAccessFromContext(ctx)
|
||||
@@ -214,6 +243,24 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
|
||||
|
||||
// ExportReportPDF is the resolver for the exportReportPDF field.
|
||||
func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.ExportReportPDFInput) (*types.ExportReportPDFPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.ReportID.TenantID())
|
||||
|
||||
audit, err := publicTrustService.Audits.GetByReportID(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load audit: %w", err))
|
||||
}
|
||||
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
pdf, err := publicTrustService.Reports.ExportPDFWithoutWatermark(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot export report PDF: %w", err))
|
||||
}
|
||||
|
||||
return &types.ExportReportPDFPayload{
|
||||
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, input.ReportID.TenantID())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export report PDF: %w", err)
|
||||
@@ -296,6 +343,15 @@ func (r *mutationResolver) AcceptNonDisclosureAgreement(ctx context.Context, inp
|
||||
func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input types.RequestDocumentAccessInput) (*types.RequestAccessesPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.TrustCenterID.TenantID())
|
||||
|
||||
document, err := publicTrustService.Documents.Get(ctx, input.DocumentID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return nil, fmt.Errorf("document is publicly available and does not require access request")
|
||||
}
|
||||
|
||||
userData := r.UserFromContext(ctx)
|
||||
if userData != nil {
|
||||
return nil, fmt.Errorf("sessions users cannot request trust center access")
|
||||
@@ -340,6 +396,15 @@ func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input type
|
||||
func (r *mutationResolver) RequestReportAccess(ctx context.Context, input types.RequestReportAccessInput) (*types.RequestAccessesPayload, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, input.TrustCenterID.TenantID())
|
||||
|
||||
audit, err := publicTrustService.Audits.GetByReportID(ctx, input.ReportID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load audit: %w", err))
|
||||
}
|
||||
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return nil, fmt.Errorf("report is publicly available and does not require access request")
|
||||
}
|
||||
|
||||
userData := r.UserFromContext(ctx)
|
||||
if userData != nil {
|
||||
return nil, fmt.Errorf("session users cannot request trust center access")
|
||||
@@ -484,6 +549,17 @@ func (r *queryResolver) TrustCenterBySlug(ctx context.Context, slug string) (*ty
|
||||
|
||||
// IsUserAuthorized is the resolver for the isUserAuthorized field.
|
||||
func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report) (bool, error) {
|
||||
publicTrustService := r.PublicTrustService(ctx, obj.ID.TenantID())
|
||||
|
||||
audit, err := publicTrustService.Audits.GetByReportID(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot load document: %w", err))
|
||||
}
|
||||
|
||||
if audit.TrustCenterVisibility == coredata.TrustCenterVisibilityPublic {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
privateTrustService, err := r.PrivateTrustService(ctx, obj.ID.TenantID())
|
||||
if err != nil {
|
||||
return false, nil
|
||||
|
||||
@@ -53,6 +53,31 @@ func (s AuditService) Get(
|
||||
return audit, nil
|
||||
}
|
||||
|
||||
func (s AuditService) GetByReportID(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
) (*coredata.Audit, error) {
|
||||
audit := &coredata.Audit{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := audit.LoadByReportID(ctx, conn, s.svc.scope, reportID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load audit: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return audit, nil
|
||||
}
|
||||
|
||||
func (s AuditService) ListForOrganizationId(
|
||||
ctx context.Context,
|
||||
organizationID gid.GID,
|
||||
|
||||
@@ -88,6 +88,55 @@ func (s *DocumentService) ExportPDF(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
email string,
|
||||
) ([]byte, error) {
|
||||
pdfData, err := s.exportPDFData(ctx, documentID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export document PDF: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
}
|
||||
|
||||
func (s *DocumentService) ExportPDFWithoutWatermark(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) ([]byte, error) {
|
||||
return s.exportPDFData(ctx, documentID)
|
||||
}
|
||||
|
||||
func (s DocumentService) Get(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) (*coredata.Document, error) {
|
||||
document := &coredata.Document{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := document.LoadByID(ctx, conn, s.svc.scope, documentID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return document, nil
|
||||
}
|
||||
|
||||
func (s *DocumentService) exportPDFData(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) ([]byte, error) {
|
||||
document := &coredata.Document{}
|
||||
version := &coredata.DocumentVersion{}
|
||||
@@ -100,7 +149,7 @@ func (s *DocumentService) ExportPDF(
|
||||
return fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
|
||||
if !document.ShowOnTrustCenter {
|
||||
if document.TrustCenterVisibility == coredata.TrustCenterVisibilityNone {
|
||||
return fmt.Errorf("document not visible on trust center")
|
||||
}
|
||||
|
||||
@@ -163,35 +212,5 @@ func (s *DocumentService) ExportPDF(
|
||||
return nil, fmt.Errorf("cannot read PDF data: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
}
|
||||
|
||||
func (s DocumentService) Get(
|
||||
ctx context.Context,
|
||||
documentID gid.GID,
|
||||
) (*coredata.Document, error) {
|
||||
document := &coredata.Document{}
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
err := document.LoadByID(ctx, conn, s.svc.scope, documentID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return document, nil
|
||||
return pdfData, nil
|
||||
}
|
||||
|
||||
@@ -89,6 +89,30 @@ func (s ReportService) ExportPDF(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
email string,
|
||||
) ([]byte, error) {
|
||||
pdfData, err := s.exportPDFData(ctx, reportID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot export report PDF: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
}
|
||||
|
||||
func (s ReportService) ExportPDFWithoutWatermark(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
) ([]byte, error) {
|
||||
return s.exportPDFData(ctx, reportID)
|
||||
}
|
||||
|
||||
func (s ReportService) exportPDFData(
|
||||
ctx context.Context,
|
||||
reportID gid.GID,
|
||||
) ([]byte, error) {
|
||||
report, err := s.Get(ctx, reportID)
|
||||
if err != nil {
|
||||
@@ -109,10 +133,5 @@ func (s ReportService) ExportPDF(
|
||||
return nil, fmt.Errorf("cannot read PDF data: %w", err)
|
||||
}
|
||||
|
||||
watermarkedPDF, err := watermarkpdf.AddConfidentialWithTimestamp(pdfData, email)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot add watermark to PDF: %w", err)
|
||||
}
|
||||
|
||||
return watermarkedPDF, nil
|
||||
return pdfData, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user