Store a short entity name instead of the full home heading so orgs can brand portals for sub-entities. Restore hero i18n composition and keep the English document title composed from the entity name. Signed-off-by: Émile Ré <emile@probo.com>
1671 lines
60 KiB
Go
1671 lines
60 KiB
Go
package console_v1
|
|
|
|
// This file will be automatically regenerated based on the schema, any resolver
|
|
// implementations
|
|
// will be copied through when generating and any unknown code will be moved to the end.
|
|
// Code generated by github.com/99designs/gqlgen version v0.17.94
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/vikstrous/dataloadgen"
|
|
"go.gearno.de/kit/log"
|
|
"go.probo.inc/probo/pkg/complianceportal/management"
|
|
"go.probo.inc/probo/pkg/coredata"
|
|
"go.probo.inc/probo/pkg/iam"
|
|
"go.probo.inc/probo/pkg/page"
|
|
"go.probo.inc/probo/pkg/probo"
|
|
"go.probo.inc/probo/pkg/resourcealias"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/dataloader"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/types"
|
|
"go.probo.inc/probo/pkg/server/gqlutils"
|
|
"go.probo.inc/probo/pkg/validator"
|
|
)
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *complianceCustomLinkResolver) Permission(ctx context.Context, obj *types.ComplianceCustomLink, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// Framework is the resolver for the framework field.
|
|
func (r *complianceFrameworkResolver) Framework(ctx context.Context, obj *types.ComplianceFramework) (*types.Framework, error) {
|
|
if _, err := r.authorize(ctx, obj.FrameworkID, probo.ActionFrameworkGet); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
loaders := dataloader.FromContext(ctx)
|
|
|
|
framework, err := loaders.Framework.Load(ctx, obj.FrameworkID)
|
|
if err != nil {
|
|
if errors.Is(err, dataloadgen.ErrNotFound) {
|
|
return nil, gqlutils.NotFound(ctx, err)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewFramework(framework), nil
|
|
}
|
|
|
|
// Logo is the resolver for the logo field.
|
|
func (r *compliancePortalResolver) Logo(ctx context.Context, obj *types.CompliancePortal) (*types.File, error) {
|
|
if _, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalGet); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if obj.Logo == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return r.loadFile(ctx, obj.Logo.ID)
|
|
}
|
|
|
|
// DarkLogo is the resolver for the darkLogo field.
|
|
func (r *compliancePortalResolver) DarkLogo(ctx context.Context, obj *types.CompliancePortal) (*types.File, error) {
|
|
if _, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalGet); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if obj.DarkLogo == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return r.loadFile(ctx, obj.DarkLogo.ID)
|
|
}
|
|
|
|
// Nda is the resolver for the nda field.
|
|
func (r *compliancePortalResolver) Nda(ctx context.Context, obj *types.CompliancePortal) (*types.File, error) {
|
|
hasPermission, err := r.Resolver.Permission(ctx, obj, management.ActionCompliancePortalGetNda)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot authorize", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
if !hasPermission || obj.Nda == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return r.loadFile(ctx, obj.Nda.ID)
|
|
}
|
|
|
|
// Organization is the resolver for the organization field.
|
|
func (r *compliancePortalResolver) Organization(ctx context.Context, obj *types.CompliancePortal) (*types.Organization, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
compliancePortal, err := r.management.Get(ctx, scope, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot get compliance portal", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
organization, err := r.probo.Organizations.Get(ctx, scope, compliancePortal.OrganizationID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, gqlutils.NotFound(ctx, err)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewOrganization(organization), nil
|
|
}
|
|
|
|
// Accesses is the resolver for the accesses field.
|
|
func (r *compliancePortalResolver) Accesses(ctx context.Context, obj *types.CompliancePortal, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.CompliancePortalAccessOrderField]) (*types.CompliancePortalAccessConnection, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalAccessList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pageOrderBy := page.OrderBy[coredata.CompliancePortalAccessOrderField]{
|
|
Field: coredata.CompliancePortalAccessOrderFieldCreatedAt,
|
|
Direction: page.OrderDirectionDesc,
|
|
}
|
|
|
|
if orderBy != nil {
|
|
pageOrderBy = page.OrderBy[coredata.CompliancePortalAccessOrderField]{
|
|
Field: orderBy.Field,
|
|
Direction: orderBy.Direction,
|
|
}
|
|
}
|
|
|
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
result, err := r.management.ListAccesses(ctx, scope, obj.ID, cursor)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list compliance portal accesses", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCompliancePortalAccessConnection(result), nil
|
|
}
|
|
|
|
// References is the resolver for the references field.
|
|
func (r *compliancePortalResolver) References(ctx context.Context, obj *types.CompliancePortal, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.CompliancePortalReferenceOrderField]) (*types.CompliancePortalReferenceConnection, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalReferenceList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pageOrderBy := page.OrderBy[coredata.CompliancePortalReferenceOrderField]{
|
|
Field: coredata.CompliancePortalReferenceOrderFieldRank,
|
|
Direction: page.OrderDirectionAsc,
|
|
}
|
|
|
|
if orderBy != nil {
|
|
pageOrderBy = page.OrderBy[coredata.CompliancePortalReferenceOrderField]{
|
|
Field: orderBy.Field,
|
|
Direction: orderBy.Direction,
|
|
}
|
|
}
|
|
|
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
result, err := r.management.ListReferences(ctx, scope, obj.ID, cursor)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list compliance portal references", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCompliancePortalReferenceConnection(result, obj.ID), nil
|
|
}
|
|
|
|
// CommitmentGroups is the resolver for the commitmentGroups field.
|
|
func (r *compliancePortalResolver) CommitmentGroups(ctx context.Context, obj *types.CompliancePortal, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.CompliancePortalCommitmentGroupOrderField]) (*types.CompliancePortalCommitmentGroupConnection, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalCommitmentGroupList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pageOrderBy := page.OrderBy[coredata.CompliancePortalCommitmentGroupOrderField]{
|
|
Field: coredata.CompliancePortalCommitmentGroupOrderFieldRank,
|
|
Direction: page.OrderDirectionAsc,
|
|
}
|
|
|
|
if orderBy != nil {
|
|
pageOrderBy = page.OrderBy[coredata.CompliancePortalCommitmentGroupOrderField]{
|
|
Field: orderBy.Field,
|
|
Direction: orderBy.Direction,
|
|
}
|
|
}
|
|
|
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
result, err := r.management.ListCommitmentGroups(ctx, scope, obj.ID, cursor)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list compliance portal commitment groups", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCompliancePortalCommitmentGroupConnection(result, obj.ID), nil
|
|
}
|
|
|
|
// ComplianceFrameworks is the resolver for the complianceFrameworks field.
|
|
func (r *compliancePortalResolver) ComplianceFrameworks(ctx context.Context, obj *types.CompliancePortal, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.ComplianceFrameworkOrderField]) (*types.ComplianceFrameworkConnection, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionComplianceFrameworkList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pageOrderBy := page.OrderBy[coredata.ComplianceFrameworkOrderField]{
|
|
Field: coredata.ComplianceFrameworkOrderFieldRank,
|
|
Direction: page.OrderDirectionAsc,
|
|
}
|
|
|
|
if orderBy != nil {
|
|
pageOrderBy = page.OrderBy[coredata.ComplianceFrameworkOrderField]{
|
|
Field: orderBy.Field,
|
|
Direction: orderBy.Direction,
|
|
}
|
|
}
|
|
|
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
result, err := r.management.ListFrameworksWithHidden(ctx, scope, obj.ID, cursor)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list compliance frameworks", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewComplianceFrameworkConnection(result), nil
|
|
}
|
|
|
|
// CustomLinks is the resolver for the customLinks field.
|
|
func (r *compliancePortalResolver) CustomLinks(ctx context.Context, obj *types.CompliancePortal, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.ComplianceCustomLinkOrderField]) (*types.ComplianceCustomLinkConnection, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionComplianceCustomLinkList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pageOrderBy := page.OrderBy[coredata.ComplianceCustomLinkOrderField]{
|
|
Field: coredata.ComplianceCustomLinkOrderFieldRank,
|
|
Direction: page.OrderDirectionAsc,
|
|
}
|
|
|
|
if orderBy != nil {
|
|
pageOrderBy = page.OrderBy[coredata.ComplianceCustomLinkOrderField]{
|
|
Field: orderBy.Field,
|
|
Direction: orderBy.Direction,
|
|
}
|
|
}
|
|
|
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
result, err := r.management.ListCustomLinks(ctx, scope, obj.ID, cursor)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list compliance custom links", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewComplianceCustomLinkConnection(result), nil
|
|
}
|
|
|
|
// MailingList is the resolver for the mailingList field.
|
|
func (r *compliancePortalResolver) MailingList(ctx context.Context, obj *types.CompliancePortal) (*types.MailingList, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionMailingListSubscriberList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if obj.MailingList != nil {
|
|
return obj.MailingList, nil
|
|
}
|
|
|
|
ml, err := r.management.GetMailingList(ctx, scope, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot get mailing list for compliance portal", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
if ml == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return types.NewMailingList(ml), nil
|
|
}
|
|
|
|
// DefaultDomain is the resolver for the defaultDomain field.
|
|
func (r *compliancePortalResolver) DefaultDomain(ctx context.Context, obj *types.CompliancePortal) (*types.CustomDomain, error) {
|
|
if obj.DefaultDomain == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCustomDomainGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
domain, err := r.management.GetDomain(ctx, scope, obj.DefaultDomain.ID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, nil
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load default domain", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCustomDomain(domain, r.customDomainCname), nil
|
|
}
|
|
|
|
// CustomDomain is the resolver for the customDomain field.
|
|
func (r *compliancePortalResolver) CustomDomain(ctx context.Context, obj *types.CompliancePortal) (*types.CustomDomain, error) {
|
|
if obj.CustomDomain == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCustomDomainGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
domain, err := r.management.GetDomain(ctx, scope, obj.CustomDomain.ID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, nil
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load custom domain", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCustomDomain(domain, r.customDomainCname), nil
|
|
}
|
|
|
|
// PublicURL is the resolver for the publicUrl field.
|
|
func (r *compliancePortalResolver) PublicURL(ctx context.Context, obj *types.CompliancePortal) (string, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalGet)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
publicURL, err := r.management.PublicURL(ctx, scope, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot resolve compliance portal public url", log.Error(err))
|
|
return "", gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return publicURL, nil
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *compliancePortalResolver) Permission(ctx context.Context, obj *types.CompliancePortal, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// NdaSignature is the resolver for the ndaSignature field.
|
|
func (r *compliancePortalAccessResolver) NdaSignature(ctx context.Context, obj *types.CompliancePortalAccess) (*types.ElectronicSignature, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalAccessGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
access, err := r.management.GetAccess(ctx, scope, obj.ID)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot load compliance portal access: %w", err)
|
|
}
|
|
|
|
if access.ElectronicSignatureID == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
sig, err := r.esign.GetSignatureByID(ctx, scope, *access.ElectronicSignatureID)
|
|
if err != nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return types.NewElectronicSignature(sig), nil
|
|
}
|
|
|
|
// PendingRequestCount is the resolver for the pendingRequestCount field.
|
|
func (r *compliancePortalAccessResolver) PendingRequestCount(ctx context.Context, obj *types.CompliancePortalAccess) (int, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalAccessGet)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
count, err := r.management.CountPendingRequestDocumentAccesses(ctx, scope, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot count pending request document accesses", log.Error(err))
|
|
return 0, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return count, nil
|
|
}
|
|
|
|
// ActiveCount is the resolver for the activeCount field.
|
|
func (r *compliancePortalAccessResolver) ActiveCount(ctx context.Context, obj *types.CompliancePortalAccess) (int, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalAccessGet)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
count, err := r.management.CountActiveDocumentAccesses(ctx, scope, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot count active document accesses", log.Error(err))
|
|
return 0, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return count, nil
|
|
}
|
|
|
|
// Profile is the resolver for the profile field.
|
|
func (r *compliancePortalAccessResolver) Profile(ctx context.Context, obj *types.CompliancePortalAccess) (*types.Profile, error) {
|
|
if _, err := r.authorize(ctx, obj.ID, iam.ActionMembershipProfileGet); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
profile, err := r.iam.OrganizationService.GetProfileForIdentityAndOrganization(ctx, obj.IdentityID, obj.OrganizationID)
|
|
if err != nil {
|
|
if _, ok := errors.AsType[*iam.ErrProfileNotFound](err); ok {
|
|
return nil, gqlutils.NotFound(ctx, err)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot get profile", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewProfile(profile), nil
|
|
}
|
|
|
|
// AvailableDocumentAccesses is the resolver for the availableDocumentAccesses field.
|
|
func (r *compliancePortalAccessResolver) AvailableDocumentAccesses(ctx context.Context, obj *types.CompliancePortalAccess, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]) (*types.CompliancePortalDocumentAccessConnection, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalAccessGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pageOrderBy := page.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]{
|
|
Field: coredata.CompliancePortalDocumentAccessOrderFieldCreatedAt,
|
|
Direction: page.OrderDirectionDesc,
|
|
}
|
|
|
|
if orderBy != nil {
|
|
pageOrderBy = page.OrderBy[coredata.CompliancePortalDocumentAccessOrderField]{
|
|
Field: orderBy.Field,
|
|
Direction: orderBy.Direction,
|
|
}
|
|
}
|
|
|
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
result, err := r.management.ListAvailableDocumentAccesses(ctx, scope, obj.ID, cursor)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list compliance portal document accesses", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCompliancePortalDocumentAccessConnection(result, obj, obj.ID), nil
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *compliancePortalAccessResolver) Permission(ctx context.Context, obj *types.CompliancePortalAccess, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *compliancePortalCommitmentResolver) Permission(ctx context.Context, obj *types.CompliancePortalCommitment, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// TotalCount is the resolver for the totalCount field.
|
|
func (r *compliancePortalCommitmentConnectionResolver) TotalCount(ctx context.Context, obj *types.CompliancePortalCommitmentConnection) (int, error) {
|
|
scope, err := r.authorize(ctx, obj.ParentID, management.ActionCompliancePortalCommitmentList)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
count, err := r.management.CountCommitments(ctx, scope, obj.ParentID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot count compliance portal commitments", log.Error(err))
|
|
return 0, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return count, nil
|
|
}
|
|
|
|
// Commitments is the resolver for the commitments field.
|
|
func (r *compliancePortalCommitmentGroupResolver) Commitments(ctx context.Context, obj *types.CompliancePortalCommitmentGroup, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.OrderBy[coredata.CompliancePortalCommitmentOrderField]) (*types.CompliancePortalCommitmentConnection, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalCommitmentList)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pageOrderBy := page.OrderBy[coredata.CompliancePortalCommitmentOrderField]{
|
|
Field: coredata.CompliancePortalCommitmentOrderFieldRank,
|
|
Direction: page.OrderDirectionAsc,
|
|
}
|
|
|
|
if orderBy != nil {
|
|
pageOrderBy = page.OrderBy[coredata.CompliancePortalCommitmentOrderField]{
|
|
Field: orderBy.Field,
|
|
Direction: orderBy.Direction,
|
|
}
|
|
}
|
|
|
|
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
result, err := r.management.ListCommitments(ctx, scope, obj.ID, cursor)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list compliance portal commitments", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCompliancePortalCommitmentConnection(result, obj.ID), nil
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *compliancePortalCommitmentGroupResolver) Permission(ctx context.Context, obj *types.CompliancePortalCommitmentGroup, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// TotalCount is the resolver for the totalCount field.
|
|
func (r *compliancePortalCommitmentGroupConnectionResolver) TotalCount(ctx context.Context, obj *types.CompliancePortalCommitmentGroupConnection) (int, error) {
|
|
scope, err := r.authorize(ctx, obj.ParentID, management.ActionCompliancePortalCommitmentGroupList)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
count, err := r.management.CountCommitmentGroups(ctx, scope, obj.ParentID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot count compliance portal commitment groups", log.Error(err))
|
|
return 0, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return count, nil
|
|
}
|
|
|
|
// Document is the resolver for the document field.
|
|
func (r *compliancePortalDocumentAccessResolver) Document(ctx context.Context, obj *types.CompliancePortalDocumentAccess) (*types.Document, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, probo.ActionDocumentGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if obj.DocumentID == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
document, err := r.probo.Documents.Get(ctx, scope, *obj.DocumentID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, gqlutils.NotFound(ctx, err)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load document", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewDocument(document), nil
|
|
}
|
|
|
|
// ReportFile is the resolver for the reportFile field.
|
|
func (r *compliancePortalDocumentAccessResolver) ReportFile(ctx context.Context, obj *types.CompliancePortalDocumentAccess) (*types.File, error) {
|
|
if obj.ReportFile == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
if _, err := r.authorize(ctx, obj.ReportFile.ID, probo.ActionFileGet); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
loaders := dataloader.FromContext(ctx)
|
|
|
|
file, err := loaders.File.Load(ctx, obj.ReportFile.ID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) || errors.Is(err, dataloadgen.ErrNotFound) {
|
|
return nil, gqlutils.NotFound(ctx, err)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load report file", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewFile(file, r.fileManager), nil
|
|
}
|
|
|
|
// Audit is the resolver for the audit field.
|
|
func (r *compliancePortalDocumentAccessResolver) Audit(ctx context.Context, obj *types.CompliancePortalDocumentAccess) (*types.Audit, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, probo.ActionAuditGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if obj.ReportFileID == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
audit, err := r.probo.Audits.GetByReportFileID(ctx, scope, *obj.ReportFileID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, nil
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load audit for report file", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewAudit(audit), nil
|
|
}
|
|
|
|
// CompliancePortalFile is the resolver for the compliancePortalFile field.
|
|
func (r *compliancePortalDocumentAccessResolver) CompliancePortalFile(ctx context.Context, obj *types.CompliancePortalDocumentAccess) (*types.CompliancePortalFile, error) {
|
|
scope, err := r.authorize(ctx, obj.CompliancePortalAccessID, management.ActionCompliancePortalFileGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if obj.CompliancePortalFileID == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
compliancePortalFile, err := r.management.GetFile(ctx, scope, *obj.CompliancePortalFileID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot load compliance portal file", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCompliancePortalFile(compliancePortalFile), nil
|
|
}
|
|
|
|
// TotalCount is the resolver for the totalCount field.
|
|
func (r *compliancePortalDocumentAccessConnectionResolver) TotalCount(ctx context.Context, obj *types.CompliancePortalDocumentAccessConnection) (int, error) {
|
|
scope, err := r.authorize(ctx, obj.ParentID, management.ActionCompliancePortalDocumentAccessList)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
count, err := r.management.CountDocumentAccesses(ctx, scope, obj.ParentID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot count compliance portal document accesses", log.Error(err))
|
|
return 0, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return count, nil
|
|
}
|
|
|
|
// File is the resolver for the file field.
|
|
func (r *compliancePortalFileResolver) File(ctx context.Context, obj *types.CompliancePortalFile) (*types.File, error) {
|
|
if _, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalFileGetFileUrl); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return r.loadFile(ctx, obj.File.ID)
|
|
}
|
|
|
|
// Alias is the resolver for the alias field.
|
|
func (r *compliancePortalFileResolver) Alias(ctx context.Context, obj *types.CompliancePortalFile) (*string, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, resourcealias.ActionAliasGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return r.resourceAlias.GetByResourceID(ctx, scope, obj.ID)
|
|
}
|
|
|
|
// Organization is the resolver for the organization field.
|
|
func (r *compliancePortalFileResolver) Organization(ctx context.Context, obj *types.CompliancePortalFile) (*types.Organization, error) {
|
|
scope, err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
compliancePortalFile, err := r.management.GetFile(ctx, scope, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot get compliance portal file", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
organization, err := r.probo.Organizations.Get(ctx, scope, compliancePortalFile.OrganizationID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, gqlutils.NotFound(ctx, err)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot get organization", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewOrganization(organization), nil
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *compliancePortalFileResolver) Permission(ctx context.Context, obj *types.CompliancePortalFile, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// TotalCount is the resolver for the totalCount field.
|
|
func (r *compliancePortalFileConnectionResolver) TotalCount(ctx context.Context, obj *types.CompliancePortalFileConnection) (int, error) {
|
|
scope, err := r.authorize(ctx, obj.ParentID, management.ActionCompliancePortalFileList)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
count, err := r.management.CountFilesForOrganizationID(ctx, scope, obj.ParentID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot count compliance portal files", log.Error(err))
|
|
return 0, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return count, nil
|
|
}
|
|
|
|
// Logo is the resolver for the logo field.
|
|
func (r *compliancePortalReferenceResolver) Logo(ctx context.Context, obj *types.CompliancePortalReference) (*types.File, error) {
|
|
if _, err := r.authorize(ctx, obj.ID, management.ActionCompliancePortalReferenceGetLogoUrl); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return r.loadFile(ctx, obj.Logo.ID)
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *compliancePortalReferenceResolver) Permission(ctx context.Context, obj *types.CompliancePortalReference, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// TotalCount is the resolver for the totalCount field.
|
|
func (r *compliancePortalReferenceConnectionResolver) TotalCount(ctx context.Context, obj *types.CompliancePortalReferenceConnection) (int, error) {
|
|
scope, err := r.authorize(ctx, obj.ParentID, management.ActionCompliancePortalReferenceList)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
count, err := r.management.CountReferences(ctx, scope, obj.ParentID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot count compliance portal references", log.Error(err))
|
|
return 0, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return count, nil
|
|
}
|
|
|
|
// Certificate is the resolver for the certificate field.
|
|
func (r *customDomainResolver) Certificate(ctx context.Context, obj *types.CustomDomain) (*types.Certificate, error) {
|
|
if obj.Certificate == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
scope, err := r.authorize(ctx, obj.ID, management.ActionCustomDomainGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
cert, err := r.certManager.Get(ctx, scope, obj.Certificate.ID)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, nil
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load certificate", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewCertificate(cert), nil
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *customDomainResolver) Permission(ctx context.Context, obj *types.CustomDomain, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// UpdateCompliancePortal is the resolver for the updateCompliancePortal field.
|
|
func (r *mutationResolver) UpdateCompliancePortal(ctx context.Context, input types.UpdateCompliancePortalInput) (*types.UpdateCompliancePortalPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionCompliancePortalUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
compliancePortal, _, err := r.management.Update(
|
|
ctx, scope,
|
|
&management.UpdateRequest{
|
|
ID: input.CompliancePortalID,
|
|
Active: input.Active,
|
|
SearchEngineIndexing: input.SearchEngineIndexing,
|
|
Description: gqlutils.UnwrapOmittable(input.Description),
|
|
WebsiteURL: gqlutils.UnwrapOmittable(input.WebsiteURL),
|
|
Email: gqlutils.UnwrapOmittable(input.Email),
|
|
HeadquarterAddress: gqlutils.UnwrapOmittable(input.HeadquarterAddress),
|
|
EntityName: input.EntityName,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance portal", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateCompliancePortalPayload{
|
|
CompliancePortal: types.NewCompliancePortal(compliancePortal),
|
|
}, nil
|
|
}
|
|
|
|
// UploadCompliancePortalNda is the resolver for the uploadCompliancePortalNDA field.
|
|
func (r *mutationResolver) UploadCompliancePortalNda(ctx context.Context, input types.UploadCompliancePortalNDAInput) (*types.UploadCompliancePortalNDAPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionCompliancePortalNonDisclosureAgreementUpload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
compliancePortal, _, err := r.management.UploadNDA(
|
|
ctx, scope,
|
|
&management.UploadNDARequest{
|
|
CompliancePortalID: input.CompliancePortalID,
|
|
File: input.File.File,
|
|
FileName: input.FileName,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot upload compliance portal NDA", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UploadCompliancePortalNDAPayload{
|
|
CompliancePortal: types.NewCompliancePortal(compliancePortal),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteCompliancePortalNda is the resolver for the deleteCompliancePortalNDA field.
|
|
func (r *mutationResolver) DeleteCompliancePortalNda(ctx context.Context, input types.DeleteCompliancePortalNDAInput) (*types.DeleteCompliancePortalNDAPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionCompliancePortalNonDisclosureAgreementDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
compliancePortal, _, err := r.management.DeleteNDA(ctx, scope, input.CompliancePortalID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance portal NDA", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteCompliancePortalNDAPayload{
|
|
CompliancePortal: types.NewCompliancePortal(compliancePortal),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateCompliancePortalBrand is the resolver for the updateCompliancePortalBrand field.
|
|
func (r *mutationResolver) UpdateCompliancePortalBrand(ctx context.Context, input types.UpdateCompliancePortalBrandInput) (*types.UpdateCompliancePortalBrandPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionCompliancePortalUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req := &management.UpdateBrandRequest{
|
|
CompliancePortalID: input.CompliancePortalID,
|
|
}
|
|
|
|
if input.LogoFile.IsSet() {
|
|
logoFile := input.LogoFile.Value()
|
|
if logoFile == nil {
|
|
var nilFile *management.FileUpload
|
|
|
|
req.LogoFile = &nilFile
|
|
} else {
|
|
fileUpload := &management.FileUpload{
|
|
Content: logoFile.File,
|
|
Filename: logoFile.Filename,
|
|
Size: logoFile.Size,
|
|
ContentType: logoFile.ContentType,
|
|
}
|
|
req.LogoFile = &fileUpload
|
|
}
|
|
}
|
|
|
|
if input.DarkLogoFile.IsSet() {
|
|
darkLogoFile := input.DarkLogoFile.Value()
|
|
if darkLogoFile == nil {
|
|
var nilFile *management.FileUpload
|
|
|
|
req.DarkLogoFile = &nilFile
|
|
} else {
|
|
fileUpload := &management.FileUpload{
|
|
Content: darkLogoFile.File,
|
|
Filename: darkLogoFile.Filename,
|
|
Size: darkLogoFile.Size,
|
|
ContentType: darkLogoFile.ContentType,
|
|
}
|
|
req.DarkLogoFile = &fileUpload
|
|
}
|
|
}
|
|
|
|
compliancePortal, _, err := r.management.UpdateBrand(ctx, scope, req)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance portal brand", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateCompliancePortalBrandPayload{
|
|
CompliancePortal: types.NewCompliancePortal(compliancePortal),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateCompliancePortalAccess is the resolver for the updateCompliancePortalAccess field.
|
|
func (r *mutationResolver) UpdateCompliancePortalAccess(ctx context.Context, input types.UpdateCompliancePortalAccessInput) (*types.UpdateCompliancePortalAccessPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalAccessUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var (
|
|
documentAccesses []management.UpdateDocumentAccessRequest
|
|
reportAccesses []management.UpdateDocumentAccessRequest
|
|
fileAccesses []management.UpdateDocumentAccessRequest
|
|
)
|
|
|
|
for _, documentAccess := range input.Documents {
|
|
documentAccesses = append(documentAccesses, management.UpdateDocumentAccessRequest{
|
|
ID: documentAccess.ID,
|
|
Status: documentAccess.Status,
|
|
})
|
|
}
|
|
|
|
for _, reportAccess := range input.Reports {
|
|
reportAccesses = append(reportAccesses, management.UpdateDocumentAccessRequest{
|
|
ID: reportAccess.ID,
|
|
Status: reportAccess.Status,
|
|
})
|
|
}
|
|
|
|
for _, fileAccess := range input.CompliancePortalFiles {
|
|
fileAccesses = append(fileAccesses, management.UpdateDocumentAccessRequest{
|
|
ID: fileAccess.ID,
|
|
Status: fileAccess.Status,
|
|
})
|
|
}
|
|
|
|
access, err := r.management.UpdateAccess(
|
|
ctx, scope,
|
|
&management.UpdateAccessRequest{
|
|
ID: input.ID,
|
|
DocumentAccesses: documentAccesses,
|
|
ReportAccesses: reportAccesses,
|
|
CompliancePortalFileAccesses: fileAccesses,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance portal access", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateCompliancePortalAccessPayload{
|
|
CompliancePortalAccess: types.NewCompliancePortalAccess(access),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteCompliancePortalAccess is the resolver for the deleteCompliancePortalAccess field.
|
|
func (r *mutationResolver) DeleteCompliancePortalAccess(ctx context.Context, input types.DeleteCompliancePortalAccessInput) (*types.DeleteCompliancePortalAccessPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalAccessDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.DeleteAccess(ctx, scope, input.ID); err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance portal access", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteCompliancePortalAccessPayload{
|
|
DeletedCompliancePortalAccessID: input.ID,
|
|
}, nil
|
|
}
|
|
|
|
// CreateCompliancePortalReference is the resolver for the createCompliancePortalReference field.
|
|
func (r *mutationResolver) CreateCompliancePortalReference(ctx context.Context, input types.CreateCompliancePortalReferenceInput) (*types.CreateCompliancePortalReferencePayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionCompliancePortalReferenceCreate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
reference, err := r.management.CreateReference(
|
|
ctx, scope,
|
|
&management.CreateReferenceRequest{
|
|
CompliancePortalID: input.CompliancePortalID,
|
|
Name: input.Name,
|
|
Description: input.Description,
|
|
WebsiteURL: input.WebsiteURL,
|
|
LogoFile: management.File{
|
|
Content: input.LogoFile.File,
|
|
Filename: input.LogoFile.Filename,
|
|
Size: input.LogoFile.Size,
|
|
ContentType: input.LogoFile.ContentType,
|
|
},
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot create compliance portal reference", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateCompliancePortalReferencePayload{
|
|
CompliancePortalReferenceEdge: types.NewCompliancePortalReferenceEdge(reference, coredata.CompliancePortalReferenceOrderFieldRank),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateCompliancePortalReference is the resolver for the updateCompliancePortalReference field.
|
|
func (r *mutationResolver) UpdateCompliancePortalReference(ctx context.Context, input types.UpdateCompliancePortalReferenceInput) (*types.UpdateCompliancePortalReferencePayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalReferenceUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req := &management.UpdateReferenceRequest{
|
|
ID: input.ID,
|
|
Name: input.Name,
|
|
Description: gqlutils.UnwrapOmittable(input.Description),
|
|
WebsiteURL: input.WebsiteURL,
|
|
Rank: input.Rank,
|
|
}
|
|
|
|
if input.LogoFile != nil {
|
|
req.LogoFile = &management.File{
|
|
Content: input.LogoFile.File,
|
|
Filename: input.LogoFile.Filename,
|
|
Size: input.LogoFile.Size,
|
|
ContentType: input.LogoFile.ContentType,
|
|
}
|
|
}
|
|
|
|
reference, err := r.management.UpdateReference(ctx, scope, req)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance portal reference", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateCompliancePortalReferencePayload{
|
|
CompliancePortalReference: types.NewCompliancePortalReference(reference),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteCompliancePortalReference is the resolver for the deleteCompliancePortalReference field.
|
|
func (r *mutationResolver) DeleteCompliancePortalReference(ctx context.Context, input types.DeleteCompliancePortalReferenceInput) (*types.DeleteCompliancePortalReferencePayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalReferenceDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.DeleteReference(ctx, scope, input.ID); err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance portal reference", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteCompliancePortalReferencePayload{
|
|
DeletedCompliancePortalReferenceID: input.ID,
|
|
}, nil
|
|
}
|
|
|
|
// CreateCompliancePortalCommitmentGroup is the resolver for the createCompliancePortalCommitmentGroup field.
|
|
func (r *mutationResolver) CreateCompliancePortalCommitmentGroup(ctx context.Context, input types.CreateCompliancePortalCommitmentGroupInput) (*types.CreateCompliancePortalCommitmentGroupPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionCompliancePortalCommitmentGroupCreate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
group, err := r.management.CreateCommitmentGroup(
|
|
ctx, scope,
|
|
&management.CreateCompliancePortalCommitmentGroupRequest{
|
|
CompliancePortalID: input.CompliancePortalID,
|
|
Title: input.Title,
|
|
Description: input.Description,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot create compliance portal commitment group", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateCompliancePortalCommitmentGroupPayload{
|
|
CompliancePortalCommitmentGroupEdge: types.NewCompliancePortalCommitmentGroupEdge(group, coredata.CompliancePortalCommitmentGroupOrderFieldRank),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateCompliancePortalCommitmentGroup is the resolver for the updateCompliancePortalCommitmentGroup field.
|
|
func (r *mutationResolver) UpdateCompliancePortalCommitmentGroup(ctx context.Context, input types.UpdateCompliancePortalCommitmentGroupInput) (*types.UpdateCompliancePortalCommitmentGroupPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalCommitmentGroupUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
group, err := r.management.UpdateCommitmentGroup(
|
|
ctx, scope,
|
|
&management.UpdateCompliancePortalCommitmentGroupRequest{
|
|
ID: input.ID,
|
|
Title: input.Title,
|
|
Description: input.Description,
|
|
Rank: input.Rank,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance portal commitment group", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateCompliancePortalCommitmentGroupPayload{
|
|
CompliancePortalCommitmentGroup: types.NewCompliancePortalCommitmentGroup(group),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteCompliancePortalCommitmentGroup is the resolver for the deleteCompliancePortalCommitmentGroup field.
|
|
func (r *mutationResolver) DeleteCompliancePortalCommitmentGroup(ctx context.Context, input types.DeleteCompliancePortalCommitmentGroupInput) (*types.DeleteCompliancePortalCommitmentGroupPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalCommitmentGroupDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.DeleteCommitmentGroup(ctx, scope, input.ID); err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance portal commitment group", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteCompliancePortalCommitmentGroupPayload{
|
|
DeletedCompliancePortalCommitmentGroupID: input.ID,
|
|
}, nil
|
|
}
|
|
|
|
// CreateCompliancePortalCommitment is the resolver for the createCompliancePortalCommitment field.
|
|
func (r *mutationResolver) CreateCompliancePortalCommitment(ctx context.Context, input types.CreateCompliancePortalCommitmentInput) (*types.CreateCompliancePortalCommitmentPayload, error) {
|
|
scope, err := r.authorize(ctx, input.GroupID, management.ActionCompliancePortalCommitmentCreate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
commitment, err := r.management.CreateCommitment(
|
|
ctx, scope,
|
|
&management.CreateCompliancePortalCommitmentRequest{
|
|
GroupID: input.GroupID,
|
|
Icon: input.Icon,
|
|
Eyebrow: input.Eyebrow,
|
|
Title: input.Title,
|
|
Description: input.Description,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot create compliance portal commitment", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateCompliancePortalCommitmentPayload{
|
|
CompliancePortalCommitmentEdge: types.NewCompliancePortalCommitmentEdge(commitment, coredata.CompliancePortalCommitmentOrderFieldRank),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateCompliancePortalCommitment is the resolver for the updateCompliancePortalCommitment field.
|
|
func (r *mutationResolver) UpdateCompliancePortalCommitment(ctx context.Context, input types.UpdateCompliancePortalCommitmentInput) (*types.UpdateCompliancePortalCommitmentPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalCommitmentUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
commitment, err := r.management.UpdateCommitment(
|
|
ctx, scope,
|
|
&management.UpdateCompliancePortalCommitmentRequest{
|
|
ID: input.ID,
|
|
Icon: input.Icon,
|
|
Eyebrow: input.Eyebrow,
|
|
Title: input.Title,
|
|
Description: input.Description,
|
|
Rank: input.Rank,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance portal commitment", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateCompliancePortalCommitmentPayload{
|
|
CompliancePortalCommitment: types.NewCompliancePortalCommitment(commitment),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteCompliancePortalCommitment is the resolver for the deleteCompliancePortalCommitment field.
|
|
func (r *mutationResolver) DeleteCompliancePortalCommitment(ctx context.Context, input types.DeleteCompliancePortalCommitmentInput) (*types.DeleteCompliancePortalCommitmentPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalCommitmentDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.DeleteCommitment(ctx, scope, input.ID); err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance portal commitment", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteCompliancePortalCommitmentPayload{
|
|
DeletedCompliancePortalCommitmentID: input.ID,
|
|
}, nil
|
|
}
|
|
|
|
// CreateComplianceFramework is the resolver for the createComplianceFramework field.
|
|
func (r *mutationResolver) CreateComplianceFramework(ctx context.Context, input types.CreateComplianceFrameworkInput) (*types.CreateComplianceFrameworkPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionComplianceFrameworkCreate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
cf, err := r.management.CreateFramework(
|
|
ctx, scope,
|
|
&management.CreateFrameworkRequest{
|
|
CompliancePortalID: input.CompliancePortalID,
|
|
FrameworkID: input.FrameworkID,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot create compliance framework", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateComplianceFrameworkPayload{
|
|
ComplianceFrameworkEdge: types.NewComplianceFrameworkEdge(cf, coredata.ComplianceFrameworkOrderFieldRank),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateComplianceFramework is the resolver for the updateComplianceFramework field.
|
|
func (r *mutationResolver) UpdateComplianceFramework(ctx context.Context, input types.UpdateComplianceFrameworkInput) (*types.UpdateComplianceFrameworkPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionComplianceFrameworkUpdateRank)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
cf, err := r.management.UpdateFramework(ctx, scope, &management.UpdateFrameworkRequest{
|
|
ID: input.ID,
|
|
Rank: input.Rank,
|
|
})
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance framework", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateComplianceFrameworkPayload{
|
|
ComplianceFramework: types.NewComplianceFramework(cf),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteComplianceFramework is the resolver for the deleteComplianceFramework field.
|
|
func (r *mutationResolver) DeleteComplianceFramework(ctx context.Context, input types.DeleteComplianceFrameworkInput) (*types.DeleteComplianceFrameworkPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionComplianceFrameworkDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.DeleteFramework(
|
|
ctx, scope,
|
|
&management.DeleteFrameworkRequest{
|
|
ID: input.ID,
|
|
},
|
|
); err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance framework", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteComplianceFrameworkPayload{
|
|
DeletedComplianceFrameworkID: input.ID,
|
|
}, nil
|
|
}
|
|
|
|
// CreateComplianceCustomLink is the resolver for the createComplianceCustomLink field.
|
|
func (r *mutationResolver) CreateComplianceCustomLink(ctx context.Context, input types.CreateComplianceCustomLinkInput) (*types.CreateComplianceCustomLinkPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionComplianceCustomLinkCreate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
item, err := r.management.CreateCustomLink(
|
|
ctx, scope,
|
|
&management.CreateCustomLinkRequest{
|
|
CompliancePortalID: input.CompliancePortalID,
|
|
Name: input.Name,
|
|
URL: input.URL,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot create compliance custom link", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateComplianceCustomLinkPayload{
|
|
ComplianceCustomLinkEdge: types.NewComplianceCustomLinkEdge(item, coredata.ComplianceCustomLinkOrderFieldRank),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateComplianceCustomLink is the resolver for the updateComplianceCustomLink field.
|
|
func (r *mutationResolver) UpdateComplianceCustomLink(ctx context.Context, input types.UpdateComplianceCustomLinkInput) (*types.UpdateComplianceCustomLinkPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionComplianceCustomLinkUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
item, err := r.management.UpdateCustomLink(ctx, scope, &management.UpdateCustomLinkRequest{
|
|
ID: input.ID,
|
|
Name: input.Name,
|
|
URL: input.URL,
|
|
Rank: input.Rank,
|
|
})
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance custom link", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateComplianceCustomLinkPayload{
|
|
ComplianceCustomLink: types.NewComplianceCustomLink(item),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteComplianceCustomLink is the resolver for the deleteComplianceCustomLink field.
|
|
func (r *mutationResolver) DeleteComplianceCustomLink(ctx context.Context, input types.DeleteComplianceCustomLinkInput) (*types.DeleteComplianceCustomLinkPayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionComplianceCustomLinkDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.DeleteCustomLink(ctx, scope, &management.DeleteCustomLinkRequest{ID: input.ID}); err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance custom link", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteComplianceCustomLinkPayload{
|
|
DeletedComplianceCustomLinkID: input.ID,
|
|
}, nil
|
|
}
|
|
|
|
// CreateCompliancePortalFile is the resolver for the createCompliancePortalFile field.
|
|
func (r *mutationResolver) CreateCompliancePortalFile(ctx context.Context, input types.CreateCompliancePortalFileInput) (*types.CreateCompliancePortalFilePayload, error) {
|
|
scope, err := r.authorize(ctx, input.OrganizationID, management.ActionCompliancePortalFileCreate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
file, err := r.management.CreateFile(
|
|
ctx, scope,
|
|
&management.CreateFileRequest{
|
|
OrganizationID: input.OrganizationID,
|
|
Name: input.Name,
|
|
Category: input.Category,
|
|
File: management.File{
|
|
Content: input.File.File,
|
|
Filename: input.File.Filename,
|
|
Size: input.File.Size,
|
|
ContentType: input.File.ContentType,
|
|
},
|
|
CompliancePortalVisibility: input.CompliancePortalVisibility,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot create compliance portal file", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateCompliancePortalFilePayload{
|
|
CompliancePortalFileEdge: types.NewCompliancePortalFileEdge(file, coredata.CompliancePortalFileOrderFieldCreatedAt),
|
|
}, nil
|
|
}
|
|
|
|
// UpdateCompliancePortalFile is the resolver for the updateCompliancePortalFile field.
|
|
func (r *mutationResolver) UpdateCompliancePortalFile(ctx context.Context, input types.UpdateCompliancePortalFileInput) (*types.UpdateCompliancePortalFilePayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalFileUpdate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
file, err := r.management.UpdateFile(
|
|
ctx, scope,
|
|
&management.UpdateFileRequest{
|
|
ID: input.ID,
|
|
Name: input.Name,
|
|
Category: input.Category,
|
|
CompliancePortalVisibility: input.CompliancePortalVisibility,
|
|
},
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot update compliance portal file", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateCompliancePortalFilePayload{
|
|
CompliancePortalFile: types.NewCompliancePortalFile(file),
|
|
}, nil
|
|
}
|
|
|
|
// GetCompliancePortalFile is the resolver for the getCompliancePortalFile field.
|
|
func (r *mutationResolver) GetCompliancePortalFile(ctx context.Context, input types.GetCompliancePortalFileInput) (*types.GetCompliancePortalFilePayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalFileGet)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
file, err := r.management.GetFile(ctx, scope, input.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot get compliance portal file", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.GetCompliancePortalFilePayload{
|
|
CompliancePortalFile: types.NewCompliancePortalFile(file),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteCompliancePortalFile is the resolver for the deleteCompliancePortalFile field.
|
|
func (r *mutationResolver) DeleteCompliancePortalFile(ctx context.Context, input types.DeleteCompliancePortalFileInput) (*types.DeleteCompliancePortalFilePayload, error) {
|
|
scope, err := r.authorize(ctx, input.ID, management.ActionCompliancePortalFileDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.DeleteFile(ctx, scope, input.ID); err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot delete compliance portal file", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteCompliancePortalFilePayload{
|
|
DeletedCompliancePortalFileID: input.ID,
|
|
}, nil
|
|
}
|
|
|
|
// CreateCustomDomain is the resolver for the createCustomDomain field.
|
|
func (r *mutationResolver) CreateCustomDomain(ctx context.Context, input types.CreateCustomDomainInput) (*types.CreateCustomDomainPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CompliancePortalID, management.ActionCustomDomainCreate)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
domain, err := r.management.AddCustomDomain(
|
|
ctx, scope,
|
|
input.CompliancePortalID,
|
|
input.Domain,
|
|
)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
|
|
if errors.Is(err, management.ErrCustomDomainSlotTaken) {
|
|
return nil, gqlutils.Conflictf(ctx, "compliance page already has a custom domain")
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot create custom domain", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.CreateCustomDomainPayload{
|
|
CustomDomain: types.NewCustomDomain(domain, r.customDomainCname),
|
|
}, nil
|
|
}
|
|
|
|
// DeleteCustomDomain is the resolver for the deleteCustomDomain field.
|
|
func (r *mutationResolver) DeleteCustomDomain(ctx context.Context, input types.DeleteCustomDomainInput) (*types.DeleteCustomDomainPayload, error) {
|
|
scope, err := r.authorize(ctx, input.CustomDomainID, management.ActionCustomDomainDelete)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.management.RemoveCustomDomain(ctx, scope, input.CustomDomainID); err != nil {
|
|
if errors.Is(err, management.ErrCustomDomainManaged) {
|
|
return nil, gqlutils.Conflictf(ctx, "managed domain cannot be deleted")
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot delete custom domain", log.Error(err))
|
|
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.DeleteCustomDomainPayload{
|
|
DeletedCustomDomainID: input.CustomDomainID,
|
|
}, nil
|
|
}
|
|
|
|
// ComplianceCustomLink returns schema.ComplianceCustomLinkResolver implementation.
|
|
func (r *Resolver) ComplianceCustomLink() schema.ComplianceCustomLinkResolver {
|
|
return &complianceCustomLinkResolver{r}
|
|
}
|
|
|
|
// ComplianceFramework returns schema.ComplianceFrameworkResolver implementation.
|
|
func (r *Resolver) ComplianceFramework() schema.ComplianceFrameworkResolver {
|
|
return &complianceFrameworkResolver{r}
|
|
}
|
|
|
|
// CompliancePortal returns schema.CompliancePortalResolver implementation.
|
|
func (r *Resolver) CompliancePortal() schema.CompliancePortalResolver {
|
|
return &compliancePortalResolver{r}
|
|
}
|
|
|
|
// CompliancePortalAccess returns schema.CompliancePortalAccessResolver implementation.
|
|
func (r *Resolver) CompliancePortalAccess() schema.CompliancePortalAccessResolver {
|
|
return &compliancePortalAccessResolver{r}
|
|
}
|
|
|
|
// CompliancePortalCommitment returns schema.CompliancePortalCommitmentResolver implementation.
|
|
func (r *Resolver) CompliancePortalCommitment() schema.CompliancePortalCommitmentResolver {
|
|
return &compliancePortalCommitmentResolver{r}
|
|
}
|
|
|
|
// CompliancePortalCommitmentConnection returns schema.CompliancePortalCommitmentConnectionResolver implementation.
|
|
func (r *Resolver) CompliancePortalCommitmentConnection() schema.CompliancePortalCommitmentConnectionResolver {
|
|
return &compliancePortalCommitmentConnectionResolver{r}
|
|
}
|
|
|
|
// CompliancePortalCommitmentGroup returns schema.CompliancePortalCommitmentGroupResolver implementation.
|
|
func (r *Resolver) CompliancePortalCommitmentGroup() schema.CompliancePortalCommitmentGroupResolver {
|
|
return &compliancePortalCommitmentGroupResolver{r}
|
|
}
|
|
|
|
// CompliancePortalCommitmentGroupConnection returns schema.CompliancePortalCommitmentGroupConnectionResolver implementation.
|
|
func (r *Resolver) CompliancePortalCommitmentGroupConnection() schema.CompliancePortalCommitmentGroupConnectionResolver {
|
|
return &compliancePortalCommitmentGroupConnectionResolver{r}
|
|
}
|
|
|
|
// CompliancePortalDocumentAccess returns schema.CompliancePortalDocumentAccessResolver implementation.
|
|
func (r *Resolver) CompliancePortalDocumentAccess() schema.CompliancePortalDocumentAccessResolver {
|
|
return &compliancePortalDocumentAccessResolver{r}
|
|
}
|
|
|
|
// CompliancePortalDocumentAccessConnection returns schema.CompliancePortalDocumentAccessConnectionResolver implementation.
|
|
func (r *Resolver) CompliancePortalDocumentAccessConnection() schema.CompliancePortalDocumentAccessConnectionResolver {
|
|
return &compliancePortalDocumentAccessConnectionResolver{r}
|
|
}
|
|
|
|
// CompliancePortalFile returns schema.CompliancePortalFileResolver implementation.
|
|
func (r *Resolver) CompliancePortalFile() schema.CompliancePortalFileResolver {
|
|
return &compliancePortalFileResolver{r}
|
|
}
|
|
|
|
// CompliancePortalFileConnection returns schema.CompliancePortalFileConnectionResolver implementation.
|
|
func (r *Resolver) CompliancePortalFileConnection() schema.CompliancePortalFileConnectionResolver {
|
|
return &compliancePortalFileConnectionResolver{r}
|
|
}
|
|
|
|
// CompliancePortalReference returns schema.CompliancePortalReferenceResolver implementation.
|
|
func (r *Resolver) CompliancePortalReference() schema.CompliancePortalReferenceResolver {
|
|
return &compliancePortalReferenceResolver{r}
|
|
}
|
|
|
|
// CompliancePortalReferenceConnection returns schema.CompliancePortalReferenceConnectionResolver implementation.
|
|
func (r *Resolver) CompliancePortalReferenceConnection() schema.CompliancePortalReferenceConnectionResolver {
|
|
return &compliancePortalReferenceConnectionResolver{r}
|
|
}
|
|
|
|
// CustomDomain returns schema.CustomDomainResolver implementation.
|
|
func (r *Resolver) CustomDomain() schema.CustomDomainResolver { return &customDomainResolver{r} }
|
|
|
|
type (
|
|
complianceCustomLinkResolver struct{ *Resolver }
|
|
complianceFrameworkResolver struct{ *Resolver }
|
|
compliancePortalResolver struct{ *Resolver }
|
|
compliancePortalAccessResolver struct{ *Resolver }
|
|
compliancePortalCommitmentResolver struct{ *Resolver }
|
|
compliancePortalCommitmentConnectionResolver struct{ *Resolver }
|
|
compliancePortalCommitmentGroupResolver struct{ *Resolver }
|
|
compliancePortalCommitmentGroupConnectionResolver struct{ *Resolver }
|
|
compliancePortalDocumentAccessResolver struct{ *Resolver }
|
|
compliancePortalDocumentAccessConnectionResolver struct{ *Resolver }
|
|
compliancePortalFileResolver struct{ *Resolver }
|
|
compliancePortalFileConnectionResolver struct{ *Resolver }
|
|
compliancePortalReferenceResolver struct{ *Resolver }
|
|
compliancePortalReferenceConnectionResolver struct{ *Resolver }
|
|
customDomainResolver struct{ *Resolver }
|
|
)
|