Introduce pkg/mail.Addr

Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
Émile Ré
2025-12-12 15:32:46 +01:00
parent cab9d6f2ed
commit c0b2a5702d
85 changed files with 842 additions and 646 deletions

View File

@@ -37,3 +37,6 @@ models:
BigInt:
model:
- "go.probo.inc/probo/pkg/server/gqlutils/types/bigint.BigIntScalar"
EmailAddr:
model:
- "go.probo.inc/probo/pkg/server/gqlutils/types/mail.AddrScalar"

View File

@@ -19,6 +19,7 @@ scalar Datetime
scalar Upload
scalar Duration
scalar BigInt
scalar EmailAddr
# Interfaces
interface Node {
@@ -99,7 +100,8 @@ enum MembershipRole
EMPLOYEE
@goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleEmployee")
VIEWER @goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleViewer")
AUDITOR @goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleAuditor")
AUDITOR
@goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleAuditor")
}
enum APIRole @goModel(model: "go.probo.inc/probo/pkg/coredata.APIRole") {
@@ -1687,7 +1689,7 @@ type Organization implements Node {
type User implements Node {
id: ID!
fullName: String!
email: String!
email: EmailAddr!
createdAt: Datetime!
updatedAt: Datetime!
}
@@ -1698,7 +1700,7 @@ type Membership implements Node {
organizationID: ID!
role: MembershipRole!
fullName: String!
emailAddress: String!
emailAddress: EmailAddr!
authMethod: UserAuthMethod! @goField(forceResolver: true)
createdAt: Datetime!
updatedAt: Datetime!
@@ -1706,7 +1708,7 @@ type Membership implements Node {
type Invitation implements Node {
id: ID!
email: String!
email: EmailAddr!
fullName: String!
role: MembershipRole!
status: InvitationStatus!
@@ -1737,8 +1739,8 @@ type SlackConnectionEdge {
type People implements Node {
id: ID!
fullName: String!
primaryEmailAddress: String!
additionalEmailAddresses: [String!]!
primaryEmailAddress: EmailAddr!
additionalEmailAddresses: [EmailAddr!]!
kind: PeopleKind!
position: String
contractStartDate: Datetime
@@ -1841,7 +1843,7 @@ type VendorContact implements Node {
id: ID!
vendor: Vendor! @goField(forceResolver: true)
fullName: String
email: String
email: EmailAddr
phone: String
role: String
createdAt: Datetime!
@@ -2342,7 +2344,7 @@ type TrustCenterEdge {
type TrustCenterAccess implements Node {
id: ID!
email: String!
email: EmailAddr!
name: String!
active: Boolean!
hasAcceptedNonDisclosureAgreement: Boolean!
@@ -3185,7 +3187,7 @@ input DeleteTrustCenterNDAInput {
input CreateTrustCenterAccessInput {
trustCenterId: ID!
email: String!
email: EmailAddr!
name: String!
active: Boolean!
}
@@ -3306,7 +3308,7 @@ input DeleteVendorInput {
input CreateVendorContactInput {
vendorId: ID!
fullName: String
email: String
email: EmailAddr
phone: String
role: String
}
@@ -3314,7 +3316,7 @@ input CreateVendorContactInput {
input UpdateVendorContactInput {
id: ID!
fullName: String @goField(omittable: true)
email: String @goField(omittable: true)
email: EmailAddr @goField(omittable: true)
phone: String @goField(omittable: true)
role: String @goField(omittable: true)
}
@@ -3346,8 +3348,8 @@ input DeleteVendorServiceInput {
input CreatePeopleInput {
organizationId: ID!
fullName: String!
primaryEmailAddress: String!
additionalEmailAddresses: [String!]
primaryEmailAddress: EmailAddr!
additionalEmailAddresses: [EmailAddr!]
kind: PeopleKind!
position: String
contractStartDate: Datetime
@@ -3357,8 +3359,8 @@ input CreatePeopleInput {
input UpdatePeopleInput {
id: ID!
fullName: String
primaryEmailAddress: String
additionalEmailAddresses: [String!]
primaryEmailAddress: EmailAddr
additionalEmailAddresses: [EmailAddr!]
kind: PeopleKind
position: String @goField(omittable: true)
contractStartDate: Datetime @goField(omittable: true)
@@ -3646,7 +3648,7 @@ input UpdateDocumentInput {
input ExportDocumentVersionPDFInput {
documentVersionId: ID!
withWatermark: Boolean!
watermarkEmail: String
watermarkEmail: EmailAddr
withSignatures: Boolean!
}
@@ -3684,7 +3686,7 @@ input ConfirmEmailInput {
input InviteUserInput {
organizationId: ID!
email: String!
email: EmailAddr!
fullName: String!
role: MembershipRole!
createPeople: Boolean!
@@ -4459,7 +4461,7 @@ input BulkDeleteDocumentsInput {
input BulkExportDocumentsInput {
documentIds: [ID!]!
withWatermark: Boolean!
watermarkEmail: String
watermarkEmail: EmailAddr
withSignatures: Boolean!
}

View File

@@ -18,11 +18,13 @@ import (
"github.com/vektah/gqlparser/v2/ast"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
"go.probo.inc/probo/pkg/server/api/console/v1/types"
"go.probo.inc/probo/pkg/server/gqlutils/types/bigint"
"go.probo.inc/probo/pkg/server/gqlutils/types/cursor"
gid1 "go.probo.inc/probo/pkg/server/gqlutils/types/gid"
mail1 "go.probo.inc/probo/pkg/server/gqlutils/types/mail"
)
// region ************************** generated!.gotpl **************************
@@ -9573,6 +9575,7 @@ scalar Datetime
scalar Upload
scalar Duration
scalar BigInt
scalar EmailAddr
# Interfaces
interface Node {
@@ -9653,7 +9656,8 @@ enum MembershipRole
EMPLOYEE
@goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleEmployee")
VIEWER @goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleViewer")
AUDITOR @goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleAuditor")
AUDITOR
@goEnum(value: "go.probo.inc/probo/pkg/coredata.MembershipRoleAuditor")
}
enum APIRole @goModel(model: "go.probo.inc/probo/pkg/coredata.APIRole") {
@@ -11241,7 +11245,7 @@ type Organization implements Node {
type User implements Node {
id: ID!
fullName: String!
email: String!
email: EmailAddr!
createdAt: Datetime!
updatedAt: Datetime!
}
@@ -11252,7 +11256,7 @@ type Membership implements Node {
organizationID: ID!
role: MembershipRole!
fullName: String!
emailAddress: String!
emailAddress: EmailAddr!
authMethod: UserAuthMethod! @goField(forceResolver: true)
createdAt: Datetime!
updatedAt: Datetime!
@@ -11260,7 +11264,7 @@ type Membership implements Node {
type Invitation implements Node {
id: ID!
email: String!
email: EmailAddr!
fullName: String!
role: MembershipRole!
status: InvitationStatus!
@@ -11291,8 +11295,8 @@ type SlackConnectionEdge {
type People implements Node {
id: ID!
fullName: String!
primaryEmailAddress: String!
additionalEmailAddresses: [String!]!
primaryEmailAddress: EmailAddr!
additionalEmailAddresses: [EmailAddr!]!
kind: PeopleKind!
position: String
contractStartDate: Datetime
@@ -11395,7 +11399,7 @@ type VendorContact implements Node {
id: ID!
vendor: Vendor! @goField(forceResolver: true)
fullName: String
email: String
email: EmailAddr
phone: String
role: String
createdAt: Datetime!
@@ -11896,7 +11900,7 @@ type TrustCenterEdge {
type TrustCenterAccess implements Node {
id: ID!
email: String!
email: EmailAddr!
name: String!
active: Boolean!
hasAcceptedNonDisclosureAgreement: Boolean!
@@ -12739,7 +12743,7 @@ input DeleteTrustCenterNDAInput {
input CreateTrustCenterAccessInput {
trustCenterId: ID!
email: String!
email: EmailAddr!
name: String!
active: Boolean!
}
@@ -12860,7 +12864,7 @@ input DeleteVendorInput {
input CreateVendorContactInput {
vendorId: ID!
fullName: String
email: String
email: EmailAddr
phone: String
role: String
}
@@ -12868,7 +12872,7 @@ input CreateVendorContactInput {
input UpdateVendorContactInput {
id: ID!
fullName: String @goField(omittable: true)
email: String @goField(omittable: true)
email: EmailAddr @goField(omittable: true)
phone: String @goField(omittable: true)
role: String @goField(omittable: true)
}
@@ -12900,8 +12904,8 @@ input DeleteVendorServiceInput {
input CreatePeopleInput {
organizationId: ID!
fullName: String!
primaryEmailAddress: String!
additionalEmailAddresses: [String!]
primaryEmailAddress: EmailAddr!
additionalEmailAddresses: [EmailAddr!]
kind: PeopleKind!
position: String
contractStartDate: Datetime
@@ -12911,8 +12915,8 @@ input CreatePeopleInput {
input UpdatePeopleInput {
id: ID!
fullName: String
primaryEmailAddress: String
additionalEmailAddresses: [String!]
primaryEmailAddress: EmailAddr
additionalEmailAddresses: [EmailAddr!]
kind: PeopleKind
position: String @goField(omittable: true)
contractStartDate: Datetime @goField(omittable: true)
@@ -13200,7 +13204,7 @@ input UpdateDocumentInput {
input ExportDocumentVersionPDFInput {
documentVersionId: ID!
withWatermark: Boolean!
watermarkEmail: String
watermarkEmail: EmailAddr
withSignatures: Boolean!
}
@@ -13238,7 +13242,7 @@ input ConfirmEmailInput {
input InviteUserInput {
organizationId: ID!
email: String!
email: EmailAddr!
fullName: String!
role: MembershipRole!
createPeople: Boolean!
@@ -14013,7 +14017,7 @@ input BulkDeleteDocumentsInput {
input BulkExportDocumentsInput {
documentIds: [ID!]!
withWatermark: Boolean!
watermarkEmail: String
watermarkEmail: EmailAddr
withSignatures: Boolean!
}
@@ -28689,7 +28693,7 @@ func (ec *executionContext) _Invitation_email(ctx context.Context, field graphql
return obj.Email, nil
},
nil,
ec.marshalNString2string,
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
true,
true,
)
@@ -28702,7 +28706,7 @@ func (ec *executionContext) fieldContext_Invitation_email(_ context.Context, fie
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -30443,7 +30447,7 @@ func (ec *executionContext) _Membership_emailAddress(ctx context.Context, field
return obj.EmailAddress, nil
},
nil,
ec.marshalNString2string,
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
true,
true,
)
@@ -30456,7 +30460,7 @@ func (ec *executionContext) fieldContext_Membership_emailAddress(_ context.Conte
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -40421,7 +40425,7 @@ func (ec *executionContext) _People_primaryEmailAddress(ctx context.Context, fie
return obj.PrimaryEmailAddress, nil
},
nil,
ec.marshalNString2string,
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
true,
true,
)
@@ -40434,7 +40438,7 @@ func (ec *executionContext) fieldContext_People_primaryEmailAddress(_ context.Co
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -40450,7 +40454,7 @@ func (ec *executionContext) _People_additionalEmailAddresses(ctx context.Context
return obj.AdditionalEmailAddresses, nil
},
nil,
ec.marshalNString2ᚕstringᚄ,
ec.marshalNEmailAddr2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ,
true,
true,
)
@@ -40463,7 +40467,7 @@ func (ec *executionContext) fieldContext_People_additionalEmailAddresses(_ conte
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -46593,7 +46597,7 @@ func (ec *executionContext) _TrustCenterAccess_email(ctx context.Context, field
return obj.Email, nil
},
nil,
ec.marshalNString2string,
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
true,
true,
)
@@ -46606,7 +46610,7 @@ func (ec *executionContext) fieldContext_TrustCenterAccess_email(_ context.Conte
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -50525,7 +50529,7 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle
return obj.Email, nil
},
nil,
ec.marshalNString2string,
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
true,
true,
)
@@ -50538,7 +50542,7 @@ func (ec *executionContext) fieldContext_User_email(_ context.Context, field gra
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -52953,7 +52957,7 @@ func (ec *executionContext) _VendorContact_email(ctx context.Context, field grap
return obj.Email, nil
},
nil,
ec.marshalOString2ᚖstring,
ec.marshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
true,
false,
)
@@ -52966,7 +52970,7 @@ func (ec *executionContext) fieldContext_VendorContact_email(_ context.Context,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -56539,7 +56543,7 @@ func (ec *executionContext) unmarshalInputBulkExportDocumentsInput(ctx context.C
it.WithWatermark = data
case "watermarkEmail":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("watermarkEmail"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -57848,14 +57852,14 @@ func (ec *executionContext) unmarshalInputCreatePeopleInput(ctx context.Context,
it.FullName = data
case "primaryEmailAddress":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryEmailAddress"))
data, err := ec.unmarshalNString2string(ctx, v)
data, err := ec.unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
it.PrimaryEmailAddress = data
case "additionalEmailAddresses":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("additionalEmailAddresses"))
data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ(ctx, v)
if err != nil {
return it, err
}
@@ -58497,7 +58501,7 @@ func (ec *executionContext) unmarshalInputCreateTrustCenterAccessInput(ctx conte
it.TrustCenterID = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalNString2string(ctx, v)
data, err := ec.unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -58662,7 +58666,7 @@ func (ec *executionContext) unmarshalInputCreateVendorContactInput(ctx context.C
it.FullName = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -60475,7 +60479,7 @@ func (ec *executionContext) unmarshalInputExportDocumentVersionPDFInput(ctx cont
it.WithWatermark = data
case "watermarkEmail":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("watermarkEmail"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -60896,7 +60900,7 @@ func (ec *executionContext) unmarshalInputInviteUserInput(ctx context.Context, o
it.OrganizationID = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalNString2string(ctx, v)
data, err := ec.unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -62825,14 +62829,14 @@ func (ec *executionContext) unmarshalInputUpdatePeopleInput(ctx context.Context,
it.FullName = data
case "primaryEmailAddress":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryEmailAddress"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
it.PrimaryEmailAddress = data
case "additionalEmailAddresses":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("additionalEmailAddresses"))
data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ(ctx, v)
if err != nil {
return it, err
}
@@ -63564,7 +63568,7 @@ func (ec *executionContext) unmarshalInputUpdateVendorContactInput(ctx context.C
it.FullName = graphql.OmittableOf(data)
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -86860,6 +86864,74 @@ var (
}
)
func (ec *executionContext) unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, v any) (mail.Addr, error) {
res, err := mail1.UnmarshalAddrScalar(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, sel ast.SelectionSet, v mail.Addr) graphql.Marshaler {
_ = sel
res := mail1.MarshalAddrScalar(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
}
func (ec *executionContext) unmarshalNEmailAddr2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ(ctx context.Context, v any) ([]*mail.Addr, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]*mail.Addr, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalNEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNEmailAddr2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ(ctx context.Context, sel ast.SelectionSet, v []*mail.Addr) graphql.Marshaler {
ret := make(graphql.Array, len(v))
for i := range v {
ret[i] = ec.marshalNEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalNEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, v any) (*mail.Addr, error) {
res, err := mail1.UnmarshalAddrScalar(v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, sel ast.SelectionSet, v *mail.Addr) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
_ = sel
res := mail1.MarshalAddrScalar(*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
}
func (ec *executionContext) unmarshalNEnableSAMLInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEnableSAMLInput(ctx context.Context, v any) (types.EnableSAMLInput, error) {
res, err := ec.unmarshalInputEnableSAMLInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -92570,6 +92642,60 @@ func (ec *executionContext) marshalODuration2ᚖtimeᚐDuration(ctx context.Cont
return res
}
func (ec *executionContext) unmarshalOEmailAddr2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ(ctx context.Context, v any) ([]*mail.Addr, error) {
if v == nil {
return nil, nil
}
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]*mail.Addr, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalNEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalOEmailAddr2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ(ctx context.Context, sel ast.SelectionSet, v []*mail.Addr) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
for i := range v {
ret[i] = ec.marshalNEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, v any) (*mail.Addr, error) {
if v == nil {
return nil, nil
}
res, err := mail1.UnmarshalAddrScalar(v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, sel ast.SelectionSet, v *mail.Addr) graphql.Marshaler {
if v == nil {
return graphql.Null
}
_ = sel
_ = ctx
res := mail1.MarshalAddrScalar(*v)
return res
}
func (ec *executionContext) unmarshalOEvidenceOrder2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidenceOrderBy(ctx context.Context, v any) (*types.EvidenceOrderBy, error) {
if v == nil {
return nil, nil

View File

@@ -17,6 +17,7 @@ package types
import (
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
)
@@ -64,11 +65,16 @@ func NewPeopleEdge(p *coredata.People, orderBy coredata.PeopleOrderField) *Peopl
}
func NewPeople(p *coredata.People) *People {
var emailAddresses []*mail.Addr
for _, emailAddress := range p.AdditionalEmailAddresses {
emailAddresses = append(emailAddresses, &emailAddress)
}
return &People{
ID: p.ID,
FullName: p.FullName,
PrimaryEmailAddress: p.PrimaryEmailAddress,
AdditionalEmailAddresses: p.AdditionalEmailAddresses,
AdditionalEmailAddresses: emailAddresses,
Kind: p.Kind,
Position: p.Position,
ContractStartDate: p.ContractStartDate,

View File

@@ -12,6 +12,7 @@ import (
"github.com/99designs/gqlgen/graphql"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
)
@@ -105,10 +106,10 @@ type BulkDeleteDocumentsPayload struct {
}
type BulkExportDocumentsInput struct {
DocumentIds []gid.GID `json:"documentIds"`
WithWatermark bool `json:"withWatermark"`
WatermarkEmail *string `json:"watermarkEmail,omitempty"`
WithSignatures bool `json:"withSignatures"`
DocumentIds []gid.GID `json:"documentIds"`
WithWatermark bool `json:"withWatermark"`
WatermarkEmail *mail.Addr `json:"watermarkEmail,omitempty"`
WithSignatures bool `json:"withSignatures"`
}
type BulkExportDocumentsPayload struct {
@@ -419,8 +420,8 @@ type CreateOrganizationPayload struct {
type CreatePeopleInput struct {
OrganizationID gid.GID `json:"organizationId"`
FullName string `json:"fullName"`
PrimaryEmailAddress string `json:"primaryEmailAddress"`
AdditionalEmailAddresses []string `json:"additionalEmailAddresses,omitempty"`
PrimaryEmailAddress mail.Addr `json:"primaryEmailAddress"`
AdditionalEmailAddresses []*mail.Addr `json:"additionalEmailAddresses,omitempty"`
Kind coredata.PeopleKind `json:"kind"`
Position *string `json:"position,omitempty"`
ContractStartDate *time.Time `json:"contractStartDate,omitempty"`
@@ -551,10 +552,10 @@ type CreateTaskPayload struct {
}
type CreateTrustCenterAccessInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
Email string `json:"email"`
Name string `json:"name"`
Active bool `json:"active"`
TrustCenterID gid.GID `json:"trustCenterId"`
Email mail.Addr `json:"email"`
Name string `json:"name"`
Active bool `json:"active"`
}
type CreateTrustCenterAccessPayload struct {
@@ -586,11 +587,11 @@ type CreateTrustCenterReferencePayload struct {
}
type CreateVendorContactInput struct {
VendorID gid.GID `json:"vendorId"`
FullName *string `json:"fullName,omitempty"`
Email *string `json:"email,omitempty"`
Phone *string `json:"phone,omitempty"`
Role *string `json:"role,omitempty"`
VendorID gid.GID `json:"vendorId"`
FullName *string `json:"fullName,omitempty"`
Email *mail.Addr `json:"email,omitempty"`
Phone *string `json:"phone,omitempty"`
Role *string `json:"role,omitempty"`
}
type CreateVendorContactPayload struct {
@@ -1135,10 +1136,10 @@ type EvidenceEdge struct {
}
type ExportDocumentVersionPDFInput struct {
DocumentVersionID gid.GID `json:"documentVersionId"`
WithWatermark bool `json:"withWatermark"`
WatermarkEmail *string `json:"watermarkEmail,omitempty"`
WithSignatures bool `json:"withSignatures"`
DocumentVersionID gid.GID `json:"documentVersionId"`
WithWatermark bool `json:"withWatermark"`
WatermarkEmail *mail.Addr `json:"watermarkEmail,omitempty"`
WithSignatures bool `json:"withSignatures"`
}
type ExportDocumentVersionPDFPayload struct {
@@ -1254,7 +1255,7 @@ type InitiateDomainVerificationPayload struct {
type Invitation struct {
ID gid.GID `json:"id"`
Email string `json:"email"`
Email mail.Addr `json:"email"`
FullName string `json:"fullName"`
Role coredata.MembershipRole `json:"role"`
Status coredata.InvitationStatus `json:"status"`
@@ -1283,7 +1284,7 @@ type InvitationOrder struct {
type InviteUserInput struct {
OrganizationID gid.GID `json:"organizationId"`
Email string `json:"email"`
Email mail.Addr `json:"email"`
FullName string `json:"fullName"`
Role coredata.MembershipRole `json:"role"`
CreatePeople bool `json:"createPeople"`
@@ -1345,7 +1346,7 @@ type Membership struct {
OrganizationID gid.GID `json:"organizationID"`
Role coredata.MembershipRole `json:"role"`
FullName string `json:"fullName"`
EmailAddress string `json:"emailAddress"`
EmailAddress mail.Addr `json:"emailAddress"`
AuthMethod coredata.UserAuthMethod `json:"authMethod"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
@@ -1493,8 +1494,8 @@ type PageInfo struct {
type People struct {
ID gid.GID `json:"id"`
FullName string `json:"fullName"`
PrimaryEmailAddress string `json:"primaryEmailAddress"`
AdditionalEmailAddresses []string `json:"additionalEmailAddresses"`
PrimaryEmailAddress mail.Addr `json:"primaryEmailAddress"`
AdditionalEmailAddresses []*mail.Addr `json:"additionalEmailAddresses"`
Kind coredata.PeopleKind `json:"kind"`
Position *string `json:"position,omitempty"`
ContractStartDate *time.Time `json:"contractStartDate,omitempty"`
@@ -1772,7 +1773,7 @@ func (this TrustCenter) GetID() gid.GID { return this.ID }
type TrustCenterAccess struct {
ID gid.GID `json:"id"`
Email string `json:"email"`
Email mail.Addr `json:"email"`
Name string `json:"name"`
Active bool `json:"active"`
HasAcceptedNonDisclosureAgreement bool `json:"hasAcceptedNonDisclosureAgreement"`
@@ -2056,8 +2057,8 @@ type UpdateOrganizationPayload struct {
type UpdatePeopleInput struct {
ID gid.GID `json:"id"`
FullName *string `json:"fullName,omitempty"`
PrimaryEmailAddress *string `json:"primaryEmailAddress,omitempty"`
AdditionalEmailAddresses []string `json:"additionalEmailAddresses,omitempty"`
PrimaryEmailAddress *mail.Addr `json:"primaryEmailAddress,omitempty"`
AdditionalEmailAddresses []*mail.Addr `json:"additionalEmailAddresses,omitempty"`
Kind *coredata.PeopleKind `json:"kind,omitempty"`
Position graphql.Omittable[*string] `json:"position,omitempty"`
ContractStartDate graphql.Omittable[*time.Time] `json:"contractStartDate,omitempty"`
@@ -2201,11 +2202,11 @@ type UpdateVendorBusinessAssociateAgreementPayload struct {
}
type UpdateVendorContactInput struct {
ID gid.GID `json:"id"`
FullName graphql.Omittable[*string] `json:"fullName,omitempty"`
Email graphql.Omittable[*string] `json:"email,omitempty"`
Phone graphql.Omittable[*string] `json:"phone,omitempty"`
Role graphql.Omittable[*string] `json:"role,omitempty"`
ID gid.GID `json:"id"`
FullName graphql.Omittable[*string] `json:"fullName,omitempty"`
Email graphql.Omittable[*mail.Addr] `json:"email,omitempty"`
Phone graphql.Omittable[*string] `json:"phone,omitempty"`
Role graphql.Omittable[*string] `json:"role,omitempty"`
}
type UpdateVendorContactPayload struct {
@@ -2329,7 +2330,7 @@ type UploadVendorDataPrivacyAgreementPayload struct {
type User struct {
ID gid.GID `json:"id"`
FullName string `json:"fullName"`
Email string `json:"email"`
Email mail.Addr `json:"email"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
@@ -2419,14 +2420,14 @@ type VendorComplianceReportEdge struct {
}
type VendorContact struct {
ID gid.GID `json:"id"`
Vendor *Vendor `json:"vendor"`
FullName *string `json:"fullName,omitempty"`
Email *string `json:"email,omitempty"`
Phone *string `json:"phone,omitempty"`
Role *string `json:"role,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
ID gid.GID `json:"id"`
Vendor *Vendor `json:"vendor"`
FullName *string `json:"fullName,omitempty"`
Email *mail.Addr `json:"email,omitempty"`
Phone *string `json:"phone,omitempty"`
Role *string `json:"role,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (VendorContact) IsNode() {}

View File

@@ -19,6 +19,7 @@ import (
"go.probo.inc/probo/pkg/authz"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
"go.probo.inc/probo/pkg/probo"
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
@@ -1458,7 +1459,7 @@ func (r *mutationResolver) CreateOrganization(ctx context.Context, input types.C
OrganizationID: organization.ID,
FullName: currentUser.FullName,
PrimaryEmailAddress: currentUser.EmailAddress,
AdditionalEmailAddresses: []string{},
AdditionalEmailAddresses: []mail.Addr{},
Kind: coredata.PeopleKindEmployee,
},
)
@@ -1903,7 +1904,7 @@ func (r *mutationResolver) InviteUser(ctx context.Context, input types.InviteUse
OrganizationID: input.OrganizationID,
FullName: input.FullName,
PrimaryEmailAddress: input.Email,
AdditionalEmailAddresses: []string{},
AdditionalEmailAddresses: []mail.Addr{},
Kind: coredata.PeopleKindEmployee,
})
if err != nil {
@@ -1993,7 +1994,7 @@ func (r *mutationResolver) CreatePeople(ctx context.Context, input types.CreateP
OrganizationID: input.OrganizationID,
FullName: input.FullName,
PrimaryEmailAddress: input.PrimaryEmailAddress,
AdditionalEmailAddresses: []string{},
AdditionalEmailAddresses: []mail.Addr{},
Kind: input.Kind,
Position: input.Position,
ContractStartDate: input.ContractStartDate,
@@ -2019,11 +2020,15 @@ func (r *mutationResolver) UpdatePeople(ctx context.Context, input types.UpdateP
prb := r.ProboService(ctx, input.ID.TenantID())
var emailAddresses []mail.Addr
for _, emailAddress := range input.AdditionalEmailAddresses {
emailAddresses = append(emailAddresses, *emailAddress)
}
people, err := prb.Peoples.Update(ctx, probo.UpdatePeopleRequest{
ID: input.ID,
FullName: input.FullName,
PrimaryEmailAddress: input.PrimaryEmailAddress,
AdditionalEmailAddresses: &input.AdditionalEmailAddresses,
AdditionalEmailAddresses: &emailAddresses,
Kind: input.Kind,
Position: UnwrapOmittable(input.Position),
ContractStartDate: UnwrapOmittable(input.ContractStartDate),

View File

@@ -5,6 +5,11 @@ info:
components:
schemas:
EmailAddress:
type: string
format: string
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/mail.Addr
Duration:
type: string
description: A duration
@@ -89,12 +94,12 @@ components:
type: string
description: Full name
primary_email_address:
type: string
$ref: "#/components/schemas/EmailAddress"
description: Primary email address
additional_email_addresses:
type: array
items:
type: string
$ref: "#/components/schemas/EmailAddress"
description: Additional email addresses
kind:
$ref: "#/components/schemas/PeopleKind"
@@ -372,12 +377,12 @@ components:
type: string
description: Full name
primary_email_address:
type: string
$ref: "#/components/schemas/EmailAddress"
description: Primary email address
additional_email_addresses:
type: array
items:
type: string
$ref: "#/components/schemas/EmailAddress"
description: Additional email addresses
kind:
$ref: "#/components/schemas/PeopleKind"
@@ -414,13 +419,13 @@ components:
type: string
description: Full name
primary_email_address:
type: string
$ref: "#/components/schemas/EmailAddress"
description: Primary email address
additional_email_addresses:
anyOf:
- type: array
items:
type: string
$ref: "#/components/schemas/EmailAddress"
- type: "null"
description: No additional email addresses
description: Additional email addresses

View File

@@ -6,6 +6,7 @@ import (
"go.probo.inc/mcpgen/mcp"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
"time"
)
@@ -32,8 +33,8 @@ var (
AddNonconformityToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["nonconformity"],"properties":{"nonconformity":{"type":"object","required":["id","organization_id","reference_id","root_cause","owner_id","status","created_at","updated_at"],"properties":{"audit_id":{"description":"Audit ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No audit"}]},"corrective_action":{"description":"Corrective action"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"date_identified":{"description":"Date identified","format":"date-time"},"description":{"description":"Description"},"due_date":{"description":"Due date","format":"date-time"},"effectiveness_check":{"description":"Effectiveness check"},"id":{"type":"string","format":"string"},"organization_id":{"type":"string","format":"string"},"owner_id":{"type":"string","format":"string"},"reference_id":{"type":"string","description":"Reference ID"},"root_cause":{"type":"string","description":"Root cause"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"status":{"type":"string","enum":["OPEN","IN_PROGRESS","CLOSED"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
AddObligationToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id","owner_id","status"],"properties":{"actions_to_be_implemented":{"type":"string","description":"Actions to be implemented"},"area":{"type":"string","description":"Area"},"due_date":{"type":"string","description":"Due date","format":"date-time"},"last_review_date":{"type":"string","description":"Last review date","format":"date-time"},"organization_id":{"type":"string","format":"string"},"owner_id":{"type":"string","format":"string"},"regulator":{"type":"string","description":"Regulator"},"requirement":{"type":"string","description":"Requirement"},"source":{"type":"string","description":"Source"},"status":{"description":"Status","anyOf":[{"type":"string","enum":["NON_COMPLIANT","PARTIALLY_COMPLIANT","COMPLIANT"]},{"type":"null","description":"No status"}]}}}`)
AddObligationToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["obligation"],"properties":{"obligation":{"type":"object","required":["id","organization_id","owner_id","status","created_at","updated_at"],"properties":{"actions_to_be_implemented":{"description":"Actions to be implemented"},"area":{"description":"Area"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"due_date":{"description":"Due date","format":"date-time"},"id":{"type":"string","format":"string"},"last_review_date":{"description":"Last review date","format":"date-time"},"organization_id":{"type":"string","format":"string"},"owner_id":{"type":"string","format":"string"},"regulator":{"description":"Regulator"},"requirement":{"description":"Requirement"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"source":{"description":"Source"},"source_id":{"description":"Source ID"},"status":{"type":"string","enum":["NON_COMPLIANT","PARTIALLY_COMPLIANT","COMPLIANT"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
AddPeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id","full_name","primary_email_address","kind"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string"}},"contract_end_date":{"type":"string","description":"Contract end date","format":"date-time"},"contract_start_date":{"type":"string","description":"Contract start date","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"type":"string","description":"Position"},"primary_email_address":{"type":"string","description":"Primary email address"}}}`)
AddPeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"people":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","description":"Primary email address"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
AddPeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id","full_name","primary_email_address","kind"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string","format":"string"}},"contract_end_date":{"type":"string","description":"Contract end date","format":"date-time"},"contract_start_date":{"type":"string","description":"Contract start date","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"type":"string","description":"Position"},"primary_email_address":{"type":"string","format":"string"}}}`)
AddPeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"people":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string","format":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","format":"string"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
AddRiskToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id","name","category","treatment","inherent_likelihood","inherent_impact"],"properties":{"category":{"type":"string","description":"Risk category"},"description":{"type":"string","description":"Risk description"},"inherent_impact":{"type":"integer","description":"Inherent impact"},"inherent_likelihood":{"type":"integer","description":"Inherent likelihood"},"name":{"type":"string","description":"Risk name"},"note":{"type":"string","description":"Risk note"},"organization_id":{"type":"string","format":"string"},"owner_id":{"type":"string","format":"string"},"residual_impact":{"type":"integer","description":"Residual impact"},"residual_likelihood":{"type":"integer","description":"Residual likelihood"},"treatment":{"type":"string","enum":["MITIGATED","ACCEPTED","AVOIDED","TRANSFERRED"]}}}`)
AddRiskToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["risk"],"properties":{"risk":{"type":"object","required":["id","organization_id","name","category","treatment","inherent_likelihood","inherent_impact","inherent_risk_score","residual_likelihood","residual_impact","residual_risk_score","note","created_at","updated_at"],"properties":{"category":{"type":"string","description":"Risk category"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"description":"Risk description"},"id":{"type":"string","format":"string"},"inherent_impact":{"type":"integer","description":"Inherent impact"},"inherent_likelihood":{"type":"integer","description":"Inherent likelihood"},"inherent_risk_score":{"type":"integer","description":"Inherent risk score"},"name":{"type":"string","description":"Risk name"},"note":{"type":"string","description":"Risk note"},"organization_id":{"type":"string","format":"string"},"owner_id":{"anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No owner"}]},"residual_impact":{"type":"integer","description":"Residual impact"},"residual_likelihood":{"type":"integer","description":"Residual likelihood"},"residual_risk_score":{"type":"integer","description":"Residual risk score"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"treatment":{"type":"string","enum":["MITIGATED","ACCEPTED","AVOIDED","TRANSFERRED"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
AddTaskToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id","name"],"properties":{"assigned_to_id":{"description":"Assigned to person ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"Not assigned"}]},"deadline":{"type":"string","description":"Deadline","format":"date-time"},"description":{"type":"string","description":"Task description"},"measure_id":{"description":"Measure ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No measure"}]},"name":{"type":"string","description":"Task name"},"organization_id":{"type":"string","format":"string"},"time_estimate":{"type":"string","description":"A duration"}}}`)
@@ -75,7 +76,7 @@ var (
GetObligationToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"string"}}}`)
GetObligationToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["obligation"],"properties":{"obligation":{"type":"object","required":["id","organization_id","owner_id","status","created_at","updated_at"],"properties":{"actions_to_be_implemented":{"description":"Actions to be implemented"},"area":{"description":"Area"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"due_date":{"description":"Due date","format":"date-time"},"id":{"type":"string","format":"string"},"last_review_date":{"description":"Last review date","format":"date-time"},"organization_id":{"type":"string","format":"string"},"owner_id":{"type":"string","format":"string"},"regulator":{"description":"Regulator"},"requirement":{"description":"Requirement"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"source":{"description":"Source"},"source_id":{"description":"Source ID"},"status":{"type":"string","enum":["NON_COMPLIANT","PARTIALLY_COMPLIANT","COMPLIANT"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
GetPeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"string"}}}`)
GetPeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"people":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","description":"Primary email address"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
GetPeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"people":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string","format":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","format":"string"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
GetRiskToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"string"}}}`)
GetRiskToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["risk"],"properties":{"risk":{"type":"object","required":["id","organization_id","name","category","treatment","inherent_likelihood","inherent_impact","inherent_risk_score","residual_likelihood","residual_impact","residual_risk_score","note","created_at","updated_at"],"properties":{"category":{"type":"string","description":"Risk category"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"description":"Risk description"},"id":{"type":"string","format":"string"},"inherent_impact":{"type":"integer","description":"Inherent impact"},"inherent_likelihood":{"type":"integer","description":"Inherent likelihood"},"inherent_risk_score":{"type":"integer","description":"Inherent risk score"},"name":{"type":"string","description":"Risk name"},"note":{"type":"string","description":"Risk note"},"organization_id":{"type":"string","format":"string"},"owner_id":{"anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No owner"}]},"residual_impact":{"type":"integer","description":"Residual impact"},"residual_likelihood":{"type":"integer","description":"Residual likelihood"},"residual_risk_score":{"type":"integer","description":"Residual risk score"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"treatment":{"type":"string","enum":["MITIGATED","ACCEPTED","AVOIDED","TRANSFERRED"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
GetSnapshotToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"string"}}}`)
@@ -117,7 +118,7 @@ var (
ListOrganizationsToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","properties":{"organization_id":{"type":"string","format":"string"}}}`)
ListOrganizationsToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","properties":{"organizations":{"type":"array","items":{"type":"object","required":["id","name","description","created_at","updated_at"],"properties":{"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"description":"Organization description"},"id":{"type":"string","format":"string"},"name":{"type":"string","description":"Organization name"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}}`)
ListPeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id"],"properties":{"cursor":{"type":"string","format":"string"},"filter":{"type":"object","properties":{"exclude_contract_ended":{"type":"boolean","description":"Exclude people with ended contracts"}}},"order_by":{"type":"object","required":["field","direction"],"properties":{"direction":{"type":"string","enum":["ASC","DESC"]},"field":{"type":"string","enum":["CREATED_AT","FULL_NAME","KIND"]}}},"organization_id":{"type":"string","format":"string"},"size":{"type":"integer","description":"Page size"}}}`)
ListPeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"next_cursor":{"type":"string","format":"string"},"people":{"type":"array","items":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","description":"Primary email address"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}}`)
ListPeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"next_cursor":{"type":"string","format":"string"},"people":{"type":"array","items":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string","format":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","format":"string"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}}`)
ListRisksToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id"],"properties":{"cursor":{"type":"string","format":"string"},"filter":{"type":"object","properties":{"query":{"type":"string","description":"Search query"},"snapshot_id":{"type":"string","format":"string"}}},"order_by":{"type":"object","required":["field","direction"],"properties":{"direction":{"type":"string","enum":["ASC","DESC"]},"field":{"type":"string","enum":["CREATED_AT","UPDATED_AT","NAME","CATEGORY","TREATMENT","INHERENT_RISK_SCORE","RESIDUAL_RISK_SCORE","OWNER_FULL_NAME"]}}},"organization_id":{"type":"string","format":"string"},"size":{"type":"integer","description":"Page size"}}}`)
ListRisksToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["risks"],"properties":{"next_cursor":{"type":"string","format":"string"},"risks":{"type":"array","items":{"type":"object","required":["id","organization_id","name","category","treatment","inherent_likelihood","inherent_impact","inherent_risk_score","residual_likelihood","residual_impact","residual_risk_score","note","created_at","updated_at"],"properties":{"category":{"type":"string","description":"Risk category"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"description":"Risk description"},"id":{"type":"string","format":"string"},"inherent_impact":{"type":"integer","description":"Inherent impact"},"inherent_likelihood":{"type":"integer","description":"Inherent likelihood"},"inherent_risk_score":{"type":"integer","description":"Inherent risk score"},"name":{"type":"string","description":"Risk name"},"note":{"type":"string","description":"Risk note"},"organization_id":{"type":"string","format":"string"},"owner_id":{"anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No owner"}]},"residual_impact":{"type":"integer","description":"Residual impact"},"residual_likelihood":{"type":"integer","description":"Residual likelihood"},"residual_risk_score":{"type":"integer","description":"Residual risk score"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"treatment":{"type":"string","enum":["MITIGATED","ACCEPTED","AVOIDED","TRANSFERRED"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}}`)
ListSnapshotsToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id"],"properties":{"cursor":{"type":"string","format":"string"},"order_by":{"type":"object","required":["field","direction"],"properties":{"direction":{"type":"string","enum":["ASC","DESC"]},"field":{"type":"string","enum":["CREATED_AT","NAME","TYPE"]}}},"organization_id":{"type":"string","format":"string"},"size":{"type":"integer","description":"Page size"}}}`)
@@ -164,8 +165,8 @@ var (
UpdateNonconformityToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["nonconformity"],"properties":{"nonconformity":{"type":"object","required":["id","organization_id","reference_id","root_cause","owner_id","status","created_at","updated_at"],"properties":{"audit_id":{"description":"Audit ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No audit"}]},"corrective_action":{"description":"Corrective action"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"date_identified":{"description":"Date identified","format":"date-time"},"description":{"description":"Description"},"due_date":{"description":"Due date","format":"date-time"},"effectiveness_check":{"description":"Effectiveness check"},"id":{"type":"string","format":"string"},"organization_id":{"type":"string","format":"string"},"owner_id":{"type":"string","format":"string"},"reference_id":{"type":"string","description":"Reference ID"},"root_cause":{"type":"string","description":"Root cause"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"status":{"type":"string","enum":["OPEN","IN_PROGRESS","CLOSED"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
UpdateObligationToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"actions_to_be_implemented":{"description":"Actions to be implemented"},"area":{"description":"Area"},"due_date":{"description":"Due date","format":"date-time"},"id":{"type":"string","format":"string"},"last_review_date":{"description":"Last review date","format":"date-time"},"owner_id":{"description":"Owner ID","anyOf":[{"type":"string","format":"string"},{"type":"null"}]},"regulator":{"description":"Regulator"},"requirement":{"description":"Requirement"},"source":{"description":"Source"},"status":{"description":"Status","anyOf":[{"type":"string","enum":["NON_COMPLIANT","PARTIALLY_COMPLIANT","COMPLIANT"]},{"type":"null","description":"No status"}]}}}`)
UpdateObligationToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["obligation"],"properties":{"obligation":{"type":"object","required":["id","organization_id","owner_id","status","created_at","updated_at"],"properties":{"actions_to_be_implemented":{"description":"Actions to be implemented"},"area":{"description":"Area"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"due_date":{"description":"Due date","format":"date-time"},"id":{"type":"string","format":"string"},"last_review_date":{"description":"Last review date","format":"date-time"},"organization_id":{"type":"string","format":"string"},"owner_id":{"type":"string","format":"string"},"regulator":{"description":"Regulator"},"requirement":{"description":"Requirement"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"source":{"description":"Source"},"source_id":{"description":"Source ID"},"status":{"type":"string","enum":["NON_COMPLIANT","PARTIALLY_COMPLIANT","COMPLIANT"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
UpdatePeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"additional_email_addresses":{"description":"Additional email addresses","anyOf":[{"type":"array","items":{"type":"string"}},{"type":"null","description":"No additional email addresses"}]},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"position":{"description":"Position"},"primary_email_address":{"type":"string","description":"Primary email address"}}}`)
UpdatePeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"people":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","description":"Primary email address"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
UpdatePeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"additional_email_addresses":{"description":"Additional email addresses","anyOf":[{"type":"array","items":{"type":"string","format":"string"}},{"type":"null","description":"No additional email addresses"}]},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"position":{"description":"Position"},"primary_email_address":{"type":"string","format":"string"}}}`)
UpdatePeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"people":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string","format":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","format":"string"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
UpdateRiskToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"category":{"type":"string","description":"Risk category"},"description":{"description":"Risk description"},"id":{"type":"string","format":"string"},"inherent_impact":{"type":"integer","description":"Inherent impact"},"inherent_likelihood":{"type":"integer","description":"Inherent likelihood"},"name":{"type":"string","description":"Risk name"},"note":{"type":"string","description":"Risk note"},"owner_id":{"description":"Owner ID","anyOf":[{"type":"string","format":"string"},{"type":"null"}]},"residual_impact":{"type":"integer","description":"Residual impact"},"residual_likelihood":{"type":"integer","description":"Residual likelihood"},"treatment":{"type":"string","enum":["MITIGATED","ACCEPTED","AVOIDED","TRANSFERRED"]}}}`)
UpdateRiskToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["risk"],"properties":{"risk":{"type":"object","required":["id","organization_id","name","category","treatment","inherent_likelihood","inherent_impact","inherent_risk_score","residual_likelihood","residual_impact","residual_risk_score","note","created_at","updated_at"],"properties":{"category":{"type":"string","description":"Risk category"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"description":"Risk description"},"id":{"type":"string","format":"string"},"inherent_impact":{"type":"integer","description":"Inherent impact"},"inherent_likelihood":{"type":"integer","description":"Inherent likelihood"},"inherent_risk_score":{"type":"integer","description":"Inherent risk score"},"name":{"type":"string","description":"Risk name"},"note":{"type":"string","description":"Risk note"},"organization_id":{"type":"string","format":"string"},"owner_id":{"anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No owner"}]},"residual_impact":{"type":"integer","description":"Residual impact"},"residual_likelihood":{"type":"integer","description":"Residual likelihood"},"residual_risk_score":{"type":"integer","description":"Residual risk score"},"snapshot_id":{"description":"Snapshot ID","anyOf":[{"type":"string","format":"string"},{"type":"null","description":"No snapshot"}]},"treatment":{"type":"string","enum":["MITIGATED","ACCEPTED","AVOIDED","TRANSFERRED"]},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
UpdateTaskToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"deadline":{"description":"Deadline","anyOf":[{"type":"string","description":"Deadline","format":"date-time"},{"type":"null","description":"No deadline"}]},"description":{"description":"Task description"},"id":{"type":"string","format":"string"},"name":{"type":"string","description":"Task name"},"state":{"description":"Task state","anyOf":[{"type":"string","enum":["TODO","DONE"]},{"type":"null","description":"No state"}]},"time_estimate":{"description":"Time estimate","anyOf":[{"type":"string","description":"A duration"},{"type":"null","description":"No time estimate"}]}}}`)
@@ -404,7 +405,7 @@ type AddObligationOutput struct {
// AddPeopleInput represents the schema
type AddPeopleInput struct {
// Additional email addresses
AdditionalEmailAddresses []string `json:"additional_email_addresses,omitempty"`
AdditionalEmailAddresses []mail.Addr `json:"additional_email_addresses,omitempty"`
// Contract end date
ContractEndDate *time.Time `json:"contract_end_date,omitempty"`
// Contract start date
@@ -418,7 +419,7 @@ type AddPeopleInput struct {
// Position
Position *string `json:"position,omitempty"`
// Primary email address
PrimaryEmailAddress string `json:"primary_email_address"`
PrimaryEmailAddress mail.Addr `json:"primary_email_address"`
}
// AddPeopleOutput represents the schema
@@ -1548,7 +1549,7 @@ type Organization struct {
// People represents the schema
type People struct {
// Additional email addresses
AdditionalEmailAddresses []string `json:"additional_email_addresses"`
AdditionalEmailAddresses []mail.Addr `json:"additional_email_addresses"`
// Contract end date
ContractEndDate *time.Time `json:"contract_end_date,omitempty"`
// Contract start date
@@ -1566,7 +1567,7 @@ type People struct {
// Position
Position *string `json:"position,omitempty"`
// Primary email address
PrimaryEmailAddress string `json:"primary_email_address"`
PrimaryEmailAddress mail.Addr `json:"primary_email_address"`
// Update timestamp
UpdatedAt time.Time `json:"updated_at"`
}
@@ -2025,7 +2026,7 @@ type UpdateObligationOutput struct {
// UpdatePeopleInput represents the schema
type UpdatePeopleInput struct {
// Additional email addresses
AdditionalEmailAddresses *[]string `json:"additional_email_addresses,omitempty"`
AdditionalEmailAddresses *[]mail.Addr `json:"additional_email_addresses,omitempty"`
// Contract end date
ContractEndDate mcp.Omittable[*time.Time] `json:"contract_end_date,omitempty"`
// Contract start date
@@ -2039,7 +2040,7 @@ type UpdatePeopleInput struct {
// Position
Position mcp.Omittable[*string] `json:"position,omitempty"`
// Primary email address
PrimaryEmailAddress *string `json:"primary_email_address,omitempty"`
PrimaryEmailAddress *mail.Addr `json:"primary_email_address,omitempty"`
}
// UpdatePeopleOutput represents the schema

View File

@@ -146,7 +146,7 @@ func SlackHandler(slackSvc *slack.Service, slackSigningSecret string, logger *lo
return
}
if initialSlackMessage.RequesterEmail == nil || *initialSlackMessage.RequesterEmail == "" {
if initialSlackMessage.RequesterEmail == nil {
logger.ErrorCtx(ctx, "missing requester email", log.String("slack_message_id", initialSlackMessage.ID.String()))
httpserver.RenderJSON(w, http.StatusInternalServerError, SlackInteractiveResponse{Success: false, Message: "internal server error"})
return

View File

@@ -27,3 +27,6 @@ models:
CursorKey:
model:
- "go.probo.inc/probo/pkg/server/gqlutils/types/cursor.CursorKeyScalar"
EmailAddr:
model:
- "go.probo.inc/probo/pkg/server/gqlutils/types/mail.AddrScalar"

View File

@@ -19,8 +19,9 @@ enum Role {
USER
}
scalar Datetime
scalar CursorKey
scalar Datetime
scalar EmailAddr
interface Node {
id: ID!
@@ -46,11 +47,9 @@ type Organization implements Node {
enum DocumentType
@goModel(model: "go.probo.inc/probo/pkg/coredata.DocumentType") {
OTHER
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
ISMS @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeISMS")
POLICY
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
POLICY @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
PROCEDURE
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeProcedure")
}
@@ -357,9 +356,7 @@ enum CountryCode
enum VendorCategory
@goModel(model: "go.probo.inc/probo/pkg/coredata.VendorCategory") {
ANALYTICS
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics")
CLOUD_MONITORING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryCloudMonitoring"
@@ -389,28 +386,21 @@ enum VendorCategory
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEmployeeManagement"
)
ENGINEERING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering")
FINANCE
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance")
IDENTITY_PROVIDER
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIdentityProvider"
)
IT @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIT")
MARKETING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing")
OFFICE_OPERATIONS
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOfficeOperations"
)
OTHER
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
PASSWORD_MANAGEMENT
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryPasswordManagement"
@@ -424,15 +414,10 @@ enum VendorCategory
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryProfessionalServices"
)
RECRUITING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting"
)
SALES
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting")
SALES @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
SECURITY
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity")
VERSION_CONTROL
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryVersionControl"
@@ -542,7 +527,7 @@ type TrustCenter implements Node {
type TrustCenterAccess implements Node {
id: ID!
email: String!
email: EmailAddr!
name: String!
createdAt: Datetime!
updatedAt: Datetime!
@@ -550,7 +535,7 @@ type TrustCenterAccess implements Node {
input RequestAllAccessesInput {
trustCenterId: ID!
email: String
email: EmailAddr
name: String
}
@@ -573,21 +558,21 @@ input AcceptNonDisclosureAgreementInput {
input RequestDocumentAccessInput {
trustCenterId: ID!
documentId: ID!
email: String
email: EmailAddr
name: String
}
input RequestReportAccessInput {
trustCenterId: ID!
reportId: ID!
email: String
email: EmailAddr
name: String
}
input RequestTrustCenterFileAccessInput {
trustCenterId: ID!
trustCenterFileId: ID!
email: String
email: EmailAddr
name: String
}

View File

@@ -18,10 +18,12 @@ import (
"github.com/vektah/gqlparser/v2/ast"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
"go.probo.inc/probo/pkg/server/gqlutils/types/cursor"
gid1 "go.probo.inc/probo/pkg/server/gqlutils/types/gid"
mail1 "go.probo.inc/probo/pkg/server/gqlutils/types/mail"
)
// region ************************** generated!.gotpl **************************
@@ -1115,8 +1117,9 @@ enum Role {
USER
}
scalar Datetime
scalar CursorKey
scalar Datetime
scalar EmailAddr
interface Node {
id: ID!
@@ -1142,11 +1145,9 @@ type Organization implements Node {
enum DocumentType
@goModel(model: "go.probo.inc/probo/pkg/coredata.DocumentType") {
OTHER
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeOther")
ISMS @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeISMS")
POLICY
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
POLICY @goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypePolicy")
PROCEDURE
@goEnum(value: "go.probo.inc/probo/pkg/coredata.DocumentTypeProcedure")
}
@@ -1453,9 +1454,7 @@ enum CountryCode
enum VendorCategory
@goModel(model: "go.probo.inc/probo/pkg/coredata.VendorCategory") {
ANALYTICS
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryAnalytics")
CLOUD_MONITORING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryCloudMonitoring"
@@ -1485,28 +1484,21 @@ enum VendorCategory
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEmployeeManagement"
)
ENGINEERING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryEngineering")
FINANCE
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryFinance")
IDENTITY_PROVIDER
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIdentityProvider"
)
IT @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryIT")
MARKETING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryMarketing")
OFFICE_OPERATIONS
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOfficeOperations"
)
OTHER
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
OTHER @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryOther")
PASSWORD_MANAGEMENT
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryPasswordManagement"
@@ -1520,15 +1512,10 @@ enum VendorCategory
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryProfessionalServices"
)
RECRUITING
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting"
)
SALES
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategoryRecruiting")
SALES @goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySales")
SECURITY
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity"
)
@goEnum(value: "go.probo.inc/probo/pkg/coredata.VendorCategorySecurity")
VERSION_CONTROL
@goEnum(
value: "go.probo.inc/probo/pkg/coredata.VendorCategoryVersionControl"
@@ -1638,7 +1625,7 @@ type TrustCenter implements Node {
type TrustCenterAccess implements Node {
id: ID!
email: String!
email: EmailAddr!
name: String!
createdAt: Datetime!
updatedAt: Datetime!
@@ -1646,7 +1633,7 @@ type TrustCenterAccess implements Node {
input RequestAllAccessesInput {
trustCenterId: ID!
email: String
email: EmailAddr
name: String
}
@@ -1669,21 +1656,21 @@ input AcceptNonDisclosureAgreementInput {
input RequestDocumentAccessInput {
trustCenterId: ID!
documentId: ID!
email: String
email: EmailAddr
name: String
}
input RequestReportAccessInput {
trustCenterId: ID!
reportId: ID!
email: String
email: EmailAddr
name: String
}
input RequestTrustCenterFileAccessInput {
trustCenterId: ID!
trustCenterFileId: ID!
email: String
email: EmailAddr
name: String
}
@@ -4584,7 +4571,7 @@ func (ec *executionContext) _TrustCenterAccess_email(ctx context.Context, field
return obj.Email, nil
},
nil,
ec.marshalNString2string,
ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr,
true,
true,
)
@@ -4597,7 +4584,7 @@ func (ec *executionContext) fieldContext_TrustCenterAccess_email(_ context.Conte
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
return nil, errors.New("field of type EmailAddr does not have child fields")
},
}
return fc, nil
@@ -7165,7 +7152,7 @@ func (ec *executionContext) unmarshalInputRequestAllAccessesInput(ctx context.Co
it.TrustCenterID = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -7213,7 +7200,7 @@ func (ec *executionContext) unmarshalInputRequestDocumentAccessInput(ctx context
it.DocumentID = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -7261,7 +7248,7 @@ func (ec *executionContext) unmarshalInputRequestReportAccessInput(ctx context.C
it.ReportID = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -7309,7 +7296,7 @@ func (ec *executionContext) unmarshalInputRequestTrustCenterFileAccessInput(ctx
it.TrustCenterFileID = data
case "email":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
data, err := ec.unmarshalOString2ᚖstring(ctx, v)
data, err := ec.unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx, v)
if err != nil {
return it, err
}
@@ -10647,6 +10634,22 @@ var (
}
)
func (ec *executionContext) unmarshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, v any) (mail.Addr, error) {
res, err := mail1.UnmarshalAddrScalar(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, sel ast.SelectionSet, v mail.Addr) graphql.Marshaler {
_ = sel
res := mail1.MarshalAddrScalar(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
}
func (ec *executionContext) unmarshalNExportDocumentPDFInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐExportDocumentPDFInput(ctx context.Context, v any) (types.ExportDocumentPDFInput, error) {
res, err := ec.unmarshalInputExportDocumentPDFInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -11431,6 +11434,24 @@ func (ec *executionContext) marshalOCursorKey2ᚖgoᚗproboᚗincᚋproboᚋpkg
return res
}
func (ec *executionContext) unmarshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, v any) (*mail.Addr, error) {
if v == nil {
return nil, nil
}
res, err := mail1.UnmarshalAddrScalar(v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOEmailAddr2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr(ctx context.Context, sel ast.SelectionSet, v *mail.Addr) graphql.Marshaler {
if v == nil {
return graphql.Null
}
_ = sel
_ = ctx
res := mail1.MarshalAddrScalar(*v)
return res
}
func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v any) (*int, error) {
if v == nil {
return nil, nil

View File

@@ -21,20 +21,17 @@ import (
"github.com/99designs/gqlgen/graphql"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
)
type TokenAccessData struct {
TrustCenterID gid.GID
Email string
Email mail.Addr
TenantID gid.TenantID
Scope string
}
func (t *TokenAccessData) GetEmail() string {
return t.Email
}
type ContextAccessor interface {
UserFromContext(ctx context.Context) *coredata.User
TokenAccessFromContext(ctx context.Context) *TokenAccessData

View File

@@ -11,6 +11,7 @@ import (
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
)
@@ -140,30 +141,30 @@ type RequestAccessesPayload struct {
}
type RequestAllAccessesInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
TrustCenterID gid.GID `json:"trustCenterId"`
Email *mail.Addr `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
}
type RequestDocumentAccessInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
DocumentID gid.GID `json:"documentId"`
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
TrustCenterID gid.GID `json:"trustCenterId"`
DocumentID gid.GID `json:"documentId"`
Email *mail.Addr `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
}
type RequestReportAccessInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
ReportID gid.GID `json:"reportId"`
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
TrustCenterID gid.GID `json:"trustCenterId"`
ReportID gid.GID `json:"reportId"`
Email *mail.Addr `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
}
type RequestTrustCenterFileAccessInput struct {
TrustCenterID gid.GID `json:"trustCenterId"`
TrustCenterFileID gid.GID `json:"trustCenterFileId"`
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
TrustCenterID gid.GID `json:"trustCenterId"`
TrustCenterFileID gid.GID `json:"trustCenterFileId"`
Email *mail.Addr `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
}
type TrustCenter struct {
@@ -187,7 +188,7 @@ func (this TrustCenter) GetID() gid.GID { return this.ID }
type TrustCenterAccess struct {
ID gid.GID `json:"id"`
Email string `json:"email"`
Email mail.Addr `json:"email"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`

View File

@@ -13,6 +13,7 @@ import (
"github.com/vektah/gqlparser/v2/gqlerror"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
"go.probo.inc/probo/pkg/mail"
"go.probo.inc/probo/pkg/page"
"go.probo.inc/probo/pkg/server/api/trust/v1/schema"
"go.probo.inc/probo/pkg/server/api/trust/v1/types"
@@ -82,7 +83,7 @@ func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Docu
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
if err != nil {
return false, nil
}
@@ -108,7 +109,7 @@ func (r *documentResolver) HasUserRequestedAccess(ctx context.Context, obj *type
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
// Try to load document access - if it exists (regardless of active status), user has requested it
_, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
_, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
if err != nil {
return false, nil // No access requested or error
}
@@ -133,8 +134,8 @@ func (r *mutationResolver) RequestAllAccesses(ctx context.Context, input types.R
if email != nil || input.Name != nil {
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
}
emailValue := tokenData.GetEmail()
email = &emailValue
*email = tokenData.Email
}
if email == nil {
return nil, fmt.Errorf("email is required for unauthenticated users")
@@ -202,13 +203,13 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
if ndaExists {
tokenData := TokenAccessFromContext(ctx)
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.GetEmail())
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.Email)
if err != nil {
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
}
}
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), input.DocumentID)
documentAccess, err := privateTrustService.TrustCenterAccesses.LoadDocumentAccess(ctx, tokenData.TrustCenterID, tokenData.Email, input.DocumentID)
if err != nil {
panic(fmt.Errorf("cannot check document access: %w", err))
}
@@ -223,12 +224,12 @@ func (r *mutationResolver) ExportDocumentPDF(ctx context.Context, input types.Ex
}
userData := UserFromContext(ctx)
userEmail := ""
var userEmail mail.Addr
if userData != nil {
userEmail = userData.EmailAddress
}
if tokenData != nil {
userEmail = tokenData.GetEmail()
userEmail = tokenData.Email
}
pdf, err := privateTrustService.Documents.ExportPDF(ctx, input.DocumentID, userEmail)
@@ -280,13 +281,13 @@ func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.Expo
}
if ndaExists {
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.GetEmail())
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.Email)
if err != nil {
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
}
}
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), input.ReportID)
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.Email, input.ReportID)
if err != nil {
panic(fmt.Errorf("cannot check report access: %w", err))
}
@@ -301,12 +302,12 @@ func (r *mutationResolver) ExportReportPDF(ctx context.Context, input types.Expo
}
userData := UserFromContext(ctx)
userEmail := ""
var userEmail mail.Addr
if userData != nil {
userEmail = userData.EmailAddress
}
if tokenData != nil {
userEmail = tokenData.GetEmail()
userEmail = tokenData.Email
}
pdf, err := privateTrustService.Reports.ExportPDF(ctx, input.ReportID, userEmail)
@@ -331,7 +332,7 @@ func (r *mutationResolver) AcceptNonDisclosureAgreement(ctx context.Context, inp
return nil, fmt.Errorf("token not found")
}
err = privateTrustService.TrustCenterAccesses.AcceptNonDisclosureAgreement(ctx, input.TrustCenterID, tokenData.GetEmail())
err = privateTrustService.TrustCenterAccesses.AcceptNonDisclosureAgreement(ctx, input.TrustCenterID, tokenData.Email)
if err != nil {
return nil, fmt.Errorf("cannot accept NDA: %w", err)
}
@@ -360,11 +361,7 @@ func (r *mutationResolver) RequestDocumentAccess(ctx context.Context, input type
email := input.Email
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
if email != nil || input.Name != nil {
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
}
emailValue := tokenData.GetEmail()
email = &emailValue
*email = tokenData.Email
}
if email == nil {
return nil, fmt.Errorf("email is required for unauthenticated users")
@@ -413,11 +410,7 @@ func (r *mutationResolver) RequestReportAccess(ctx context.Context, input types.
email := input.Email
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
if email != nil || input.Name != nil {
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
}
emailValue := tokenData.GetEmail()
email = &emailValue
*email = tokenData.Email
}
if email == nil {
return nil, fmt.Errorf("email is required for unauthenticated users")
@@ -466,11 +459,7 @@ func (r *mutationResolver) RequestTrustCenterFileAccess(ctx context.Context, inp
email := input.Email
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
if email != nil || input.Name != nil {
return nil, fmt.Errorf("email and name are not allowed for authenticated users")
}
emailValue := tokenData.GetEmail()
email = &emailValue
*email = tokenData.Email
}
if email == nil {
return nil, fmt.Errorf("email is required for unauthenticated users")
@@ -538,13 +527,13 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
}
if ndaExists {
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.GetEmail())
hasAcceptedNDA, err = privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, tokenData.TrustCenterID, tokenData.Email)
if err != nil {
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
}
}
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), input.TrustCenterFileID)
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.Email, input.TrustCenterFileID)
if err != nil {
panic(fmt.Errorf("cannot check trust center file access: %w", err))
}
@@ -559,12 +548,12 @@ func (r *mutationResolver) ExportTrustCenterFile(ctx context.Context, input type
}
userData := UserFromContext(ctx)
userEmail := ""
var userEmail mail.Addr
if userData != nil {
userEmail = userData.EmailAddress
}
if tokenData != nil {
userEmail = tokenData.GetEmail()
userEmail = tokenData.Email
}
fileData, err := privateTrustService.TrustCenterFiles.ExportFile(ctx, input.TrustCenterFileID, userEmail)
@@ -743,7 +732,7 @@ func (r *reportResolver) IsUserAuthorized(ctx context.Context, obj *types.Report
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
reportAccess, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
if err != nil {
return false, nil
}
@@ -768,7 +757,7 @@ func (r *reportResolver) HasUserRequestedAccess(ctx context.Context, obj *types.
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
_, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
_, err := privateTrustService.TrustCenterAccesses.LoadReportAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
if err != nil {
return false, nil
}
@@ -822,7 +811,7 @@ func (r *trustCenterResolver) HasAcceptedNonDisclosureAgreement(ctx context.Cont
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
hasAcceptedNDA, err := privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, obj.ID, tokenData.GetEmail())
hasAcceptedNDA, err := privateTrustService.TrustCenterAccesses.HasAcceptedNonDisclosureAgreement(ctx, obj.ID, tokenData.Email)
if err != nil {
panic(fmt.Errorf("cannot check if user has accepted NDA: %w", err))
}
@@ -947,7 +936,7 @@ func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *typ
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
fileAccess, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
if err != nil {
return false, nil
}
@@ -972,7 +961,7 @@ func (r *trustCenterFileResolver) HasUserRequestedAccess(ctx context.Context, ob
tokenData := TokenAccessFromContext(ctx)
if tokenData != nil {
_, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.GetEmail(), obj.ID)
_, err := privateTrustService.TrustCenterAccesses.LoadTrustCenterFileAccess(ctx, tokenData.TrustCenterID, tokenData.Email, obj.ID)
if err != nil {
return false, nil
}