Stop using coredata.People except for people service and people page resolvers
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -42,7 +42,7 @@ func (car *CreateAssetRequest) Validate() error {
|
||||
v.Check(car.OrganizationID, "organization_id", validator.Required(), validator.GID(coredata.OrganizationEntityType))
|
||||
v.Check(car.Name, "name", validator.Required(), validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(car.Amount, "amount", validator.Required(), validator.Min(1))
|
||||
v.Check(car.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(car.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(car.AssetType, "asset_type", validator.Required(), validator.OneOfSlice(coredata.AssetTypes()))
|
||||
v.Check(car.DataTypesStored, "data_types_stored", validator.Required(), validator.SafeText(ContentMaxLength))
|
||||
v.CheckEach(car.VendorIDs, "vendor_ids", func(index int, item any) {
|
||||
@@ -58,7 +58,7 @@ func (uar *UpdateAssetRequest) Validate() error {
|
||||
v.Check(uar.ID, "id", validator.Required(), validator.GID(coredata.AssetEntityType))
|
||||
v.Check(uar.Name, "name", validator.SafeTextNoNewLine(NameMaxLength))
|
||||
v.Check(uar.Amount, "amount", validator.Min(1))
|
||||
v.Check(uar.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(uar.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(uar.AssetType, "asset_type", validator.OneOfSlice(coredata.AssetTypes()))
|
||||
v.Check(uar.DataTypesStored, "data_types_stored", validator.SafeText(ContentMaxLength))
|
||||
v.CheckEach(uar.VendorIDs, "vendor_ids", func(index int, item any) {
|
||||
@@ -189,9 +189,9 @@ func (s AssetService) Update(
|
||||
asset.Amount = *req.Amount
|
||||
}
|
||||
if req.OwnerID != nil {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
profile := &coredata.MembershipProfile{}
|
||||
if err := profile.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
asset.OwnerID = *req.OwnerID
|
||||
}
|
||||
@@ -247,9 +247,9 @@ func (s AssetService) Create(
|
||||
}
|
||||
|
||||
err := s.svc.pg.WithTx(ctx, func(conn pg.Conn) error {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
profile := &coredata.MembershipProfile{}
|
||||
if err := profile.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
|
||||
if err := asset.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (ccir *CreateContinualImprovementRequest) Validate() error {
|
||||
v.Check(ccir.ReferenceID, "reference_id", validator.SafeText(NameMaxLength))
|
||||
v.Check(ccir.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(ccir.Source, "source", validator.SafeText(ContentMaxLength))
|
||||
v.Check(ccir.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(ccir.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(ccir.Status, "status", validator.OneOfSlice(coredata.ContinualImprovementStatuses()))
|
||||
v.Check(ccir.Priority, "priority", validator.OneOfSlice(coredata.ContinualImprovementPriorities()))
|
||||
|
||||
@@ -75,7 +75,7 @@ func (ucir *UpdateContinualImprovementRequest) Validate() error {
|
||||
v.Check(ucir.ReferenceID, "reference_id", validator.SafeText(NameMaxLength))
|
||||
v.Check(ucir.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(ucir.Source, "source", validator.SafeText(ContentMaxLength))
|
||||
v.Check(ucir.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(ucir.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(ucir.Status, "status", validator.OneOfSlice(coredata.ContinualImprovementStatuses()))
|
||||
v.Check(ucir.Priority, "priority", validator.OneOfSlice(coredata.ContinualImprovementPriorities()))
|
||||
|
||||
@@ -138,9 +138,9 @@ func (s *ContinualImprovementService) Create(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
owner := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
|
||||
if err := improvement.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
@@ -184,9 +184,9 @@ func (s *ContinualImprovementService) Update(
|
||||
}
|
||||
|
||||
if req.OwnerID != nil {
|
||||
owner := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
improvement.OwnerID = *req.OwnerID
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (cdr *CreateDatumRequest) Validate() error {
|
||||
v.Check(cdr.OrganizationID, "organization_id", validator.Required(), validator.GID(coredata.OrganizationEntityType))
|
||||
v.Check(cdr.Name, "name", validator.SafeTextNoNewLine(NameMaxLength))
|
||||
v.Check(cdr.DataClassification, "data_classification", validator.Required(), validator.OneOfSlice(coredata.DataClassifications()))
|
||||
v.Check(cdr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(cdr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.CheckEach(cdr.VendorIDs, "vendor_ids", func(index int, item any) {
|
||||
v.Check(item, fmt.Sprintf("vendor_ids[%d]", index), validator.Required(), validator.GID(coredata.VendorEntityType))
|
||||
})
|
||||
@@ -68,7 +68,7 @@ func (udr *UpdateDatumRequest) Validate() error {
|
||||
v.Check(udr.ID, "id", validator.Required(), validator.GID(coredata.DatumEntityType))
|
||||
v.Check(udr.Name, "name", validator.SafeTextNoNewLine(NameMaxLength))
|
||||
v.Check(udr.DataClassification, "data_classification", validator.OneOfSlice(coredata.DataClassifications()))
|
||||
v.Check(udr.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(udr.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.CheckEach(udr.VendorIDs, "vendor_ids", func(index int, item any) {
|
||||
v.Check(item, fmt.Sprintf("vendor_ids[%d]", index), validator.Required(), validator.GID(coredata.VendorEntityType))
|
||||
})
|
||||
@@ -196,9 +196,9 @@ func (s DatumService) Update(
|
||||
datum.DataClassification = *req.DataClassification
|
||||
}
|
||||
if req.OwnerID != nil {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
datum.OwnerID = *req.OwnerID
|
||||
}
|
||||
@@ -249,9 +249,9 @@ func (s DatumService) Create(
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
|
||||
if err := datum.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
|
||||
@@ -102,7 +102,7 @@ func (cdr *CreateDocumentRequest) Validate() error {
|
||||
v.Check(cdr.OrganizationID, "organization_id", validator.Required(), validator.GID(coredata.OrganizationEntityType))
|
||||
v.Check(cdr.Title, "title", validator.Required(), validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(cdr.Content, "content", validator.Required(), validator.NotEmpty(), validator.MaxLen(documentMaxLength))
|
||||
v.Check(cdr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(cdr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(cdr.Classification, "classification", validator.Required(), validator.OneOfSlice(coredata.DocumentClassifications()))
|
||||
v.Check(cdr.DocumentType, "document_type", validator.Required(), validator.OneOfSlice(coredata.DocumentTypes()))
|
||||
v.Check(cdr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities()))
|
||||
@@ -115,7 +115,7 @@ func (udr *UpdateDocumentRequest) Validate() error {
|
||||
|
||||
v.Check(udr.DocumentID, "document_id", validator.Required(), validator.GID(coredata.DocumentEntityType))
|
||||
v.Check(udr.Title, "title", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(udr.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(udr.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(udr.Classification, "classification", validator.OneOfSlice(coredata.DocumentClassifications()))
|
||||
v.Check(udr.DocumentType, "document_type", validator.OneOfSlice(coredata.DocumentTypes()))
|
||||
v.Check(udr.TrustCenterVisibility, "trust_center_visibility", validator.OneOfSlice(coredata.TrustCenterVisibilities()))
|
||||
@@ -395,7 +395,7 @@ func (s *DocumentService) Create(
|
||||
documentVersionID := gid.New(s.svc.scope.GetTenantID(), coredata.DocumentVersionEntityType)
|
||||
|
||||
organization := &coredata.Organization{}
|
||||
people := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
|
||||
document := &coredata.Document{
|
||||
ID: documentID,
|
||||
@@ -431,12 +431,12 @@ func (s *DocumentService) Create(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load people: %w", err)
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
|
||||
document.OrganizationID = organization.ID
|
||||
document.OwnerID = people.ID
|
||||
document.OwnerID = owner.ID
|
||||
|
||||
if err := document.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot insert document: %w", err)
|
||||
@@ -519,9 +519,9 @@ func (s *DocumentService) SendSigningNotifications(
|
||||
err := s.svc.pg.WithTx(
|
||||
ctx,
|
||||
func(tx pg.Conn) error {
|
||||
var peoples coredata.Peoples
|
||||
if err := peoples.LoadAwaitingSigning(ctx, tx, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot load people: %w", err)
|
||||
var signatories coredata.MembershipProfiles
|
||||
if err := signatories.LoadAwaitingSigning(ctx, tx, s.svc.scope); err != nil {
|
||||
return fmt.Errorf("cannot load signatories: %w", err)
|
||||
}
|
||||
|
||||
organization := &coredata.Organization{}
|
||||
@@ -529,21 +529,21 @@ func (s *DocumentService) SendSigningNotifications(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
for _, people := range peoples {
|
||||
for _, signatory := range signatories {
|
||||
token, err := statelesstoken.NewToken(
|
||||
s.svc.tokenSecret,
|
||||
TokenTypeSigningRequest,
|
||||
time.Hour*24*30,
|
||||
SigningRequestData{
|
||||
OrganizationID: organizationID,
|
||||
PeopleID: people.ID,
|
||||
PeopleID: signatory.ID,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create signing request token: %w", err)
|
||||
}
|
||||
|
||||
emailPresenter := emails.NewPresenter(s.svc.fileManager, s.svc.bucket, s.svc.baseURL, people.FullName)
|
||||
emailPresenter := emails.NewPresenter(s.svc.fileManager, s.svc.bucket, s.svc.baseURL, signatory.FullName)
|
||||
|
||||
subject, textBody, htmlBody, err := emailPresenter.RenderDocumentSigning(
|
||||
ctx,
|
||||
@@ -556,8 +556,9 @@ func (s *DocumentService) SendSigningNotifications(
|
||||
}
|
||||
|
||||
email := coredata.NewEmail(
|
||||
people.FullName,
|
||||
people.PrimaryEmailAddress,
|
||||
signatory.FullName,
|
||||
// FIXME: load email with profile
|
||||
"contact@getprobo.com",
|
||||
subject,
|
||||
textBody,
|
||||
htmlBody,
|
||||
@@ -620,6 +621,7 @@ func (s *DocumentService) SignDocumentVersionByEmail(
|
||||
}
|
||||
|
||||
people := &coredata.People{}
|
||||
// FIXME: will be done differently
|
||||
if err := people.LoadByEmailAndOrganizationID(ctx, conn, s.svc.scope, userEmail, documentVersion.OrganizationID); err != nil {
|
||||
return fmt.Errorf("cannot find people record for user email in organization %q: %w", documentVersion.OrganizationID, err)
|
||||
}
|
||||
@@ -790,7 +792,7 @@ func (s *DocumentService) createSignatureRequestInTx(
|
||||
signatoryID gid.GID,
|
||||
ignoreExisting bool,
|
||||
) (*coredata.DocumentVersionSignature, error) {
|
||||
signatory := &coredata.People{}
|
||||
signatory := &coredata.MembershipProfile{}
|
||||
documentVersion := &coredata.DocumentVersion{}
|
||||
|
||||
if err := documentVersion.LoadByID(ctx, tx, s.svc.scope, documentVersionID); err != nil {
|
||||
@@ -1383,7 +1385,7 @@ func (s *DocumentService) Update(
|
||||
}
|
||||
|
||||
document := &coredata.Document{}
|
||||
people := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
now := time.Now()
|
||||
|
||||
err := s.svc.pg.WithTx(
|
||||
@@ -1414,10 +1416,10 @@ func (s *DocumentService) Update(
|
||||
}
|
||||
|
||||
if req.OwnerID != nil {
|
||||
if err := people.LoadByID(ctx, tx, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner %q: %w", *req.OwnerID, err)
|
||||
if err := owner.LoadByID(ctx, tx, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile %q: %w", *req.OwnerID, err)
|
||||
}
|
||||
document.OwnerID = people.ID
|
||||
document.OwnerID = owner.ID
|
||||
}
|
||||
|
||||
document.UpdatedAt = now
|
||||
@@ -1637,7 +1639,7 @@ func exportDocumentPDF(
|
||||
) ([]byte, error) {
|
||||
document := &coredata.Document{}
|
||||
version := &coredata.DocumentVersion{}
|
||||
owner := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
organization := &coredata.Organization{}
|
||||
|
||||
if err := version.LoadByID(ctx, conn, scope, documentVersionID); err != nil {
|
||||
@@ -1649,7 +1651,7 @@ func exportDocumentPDF(
|
||||
}
|
||||
|
||||
if err := owner.LoadByID(ctx, conn, scope, document.OwnerID); err != nil {
|
||||
return nil, fmt.Errorf("cannot load document owner: %w", err)
|
||||
return nil, fmt.Errorf("cannot load document owner profile: %w", err)
|
||||
}
|
||||
|
||||
if err := organization.LoadByID(ctx, conn, scope, document.OrganizationID); err != nil {
|
||||
|
||||
@@ -59,7 +59,7 @@ func (cmr *CreateMeetingRequest) Validate() error {
|
||||
v.Check(cmr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(cmr.Date, "date", validator.Required())
|
||||
v.CheckEach(cmr.AttendeeIDs, "attendee_ids", func(index int, item any) {
|
||||
v.Check(item, fmt.Sprintf("attendee_ids[%d]", index), validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(item, fmt.Sprintf("attendee_ids[%d]", index), validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
})
|
||||
v.Check(cmr.Minutes, "minutes", validator.SafeText(MinutesMaxLength))
|
||||
|
||||
@@ -72,7 +72,7 @@ func (umr *UpdateMeetingRequest) Validate() error {
|
||||
v.Check(umr.MeetingID, "meeting_id", validator.Required(), validator.GID(coredata.MeetingEntityType))
|
||||
v.Check(umr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.CheckEach(umr.AttendeeIDs, "attendee_ids", func(index int, item any) {
|
||||
v.Check(item, fmt.Sprintf("attendee_ids[%d]", index), validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(item, fmt.Sprintf("attendee_ids[%d]", index), validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
})
|
||||
v.Check(umr.Minutes, "minutes", validator.SafeText(MinutesMaxLength))
|
||||
|
||||
@@ -196,9 +196,9 @@ func (s MeetingService) Create(
|
||||
}
|
||||
|
||||
if len(req.AttendeeIDs) > 0 {
|
||||
var attendeePeople coredata.Peoples
|
||||
var attendeePeople coredata.MembershipProfiles
|
||||
if err := attendeePeople.LoadByIDs(ctx, conn, s.svc.scope, req.AttendeeIDs); err != nil {
|
||||
return fmt.Errorf("cannot load attendees: %w", err)
|
||||
return fmt.Errorf("cannot load attendee profiles: %w", err)
|
||||
}
|
||||
|
||||
var attendees coredata.MeetingAttendees
|
||||
@@ -221,13 +221,13 @@ func (s MeetingService) Create(
|
||||
func (s MeetingService) GetAttendees(
|
||||
ctx context.Context,
|
||||
meetingID gid.GID,
|
||||
) (coredata.Peoples, error) {
|
||||
var people coredata.Peoples
|
||||
) (coredata.MembershipProfiles, error) {
|
||||
var attendees coredata.MembershipProfiles
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return people.LoadByMeetingID(ctx, conn, s.svc.scope, meetingID)
|
||||
return attendees.LoadByMeetingID(ctx, conn, s.svc.scope, meetingID)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -235,7 +235,7 @@ func (s MeetingService) GetAttendees(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return people, nil
|
||||
return attendees, nil
|
||||
}
|
||||
|
||||
func (s MeetingService) Update(
|
||||
@@ -272,9 +272,9 @@ func (s MeetingService) Update(
|
||||
}
|
||||
|
||||
if req.AttendeeIDs != nil {
|
||||
var attendeePeople coredata.Peoples
|
||||
if err := attendeePeople.LoadByIDs(ctx, conn, s.svc.scope, req.AttendeeIDs); err != nil {
|
||||
return fmt.Errorf("cannot load attendees: %w", err)
|
||||
var attendeeProfiles coredata.MembershipProfiles
|
||||
if err := attendeeProfiles.LoadByIDs(ctx, conn, s.svc.scope, req.AttendeeIDs); err != nil {
|
||||
return fmt.Errorf("cannot load attendee profiles: %w", err)
|
||||
}
|
||||
|
||||
var attendees coredata.MeetingAttendees
|
||||
|
||||
@@ -69,7 +69,7 @@ func (cnr *CreateNonconformityRequest) Validate() error {
|
||||
v.Check(cnr.AuditID, "audit_id", validator.GID(coredata.AuditEntityType))
|
||||
v.Check(cnr.RootCause, "root_cause", validator.Required(), validator.SafeText(ContentMaxLength))
|
||||
v.Check(cnr.CorrectiveAction, "corrective_action", validator.SafeText(ContentMaxLength))
|
||||
v.Check(cnr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(cnr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(cnr.Status, "status", validator.OneOfSlice(coredata.NonconformityStatuses()))
|
||||
v.Check(cnr.EffectivenessCheck, "effectiveness_check", validator.SafeText(ContentMaxLength))
|
||||
|
||||
@@ -84,7 +84,7 @@ func (unr *UpdateNonconformityRequest) Validate() error {
|
||||
v.Check(unr.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(unr.RootCause, "root_cause", validator.SafeText(ContentMaxLength))
|
||||
v.Check(unr.CorrectiveAction, "corrective_action", validator.SafeText(ContentMaxLength))
|
||||
v.Check(unr.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(unr.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(unr.Status, "status", validator.OneOfSlice(coredata.NonconformityStatuses()))
|
||||
v.Check(unr.EffectivenessCheck, "effectiveness_check", validator.SafeText(ContentMaxLength))
|
||||
|
||||
@@ -156,9 +156,9 @@ func (s *NonconformityService) Create(
|
||||
}
|
||||
}
|
||||
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
|
||||
if err := nonconformity.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
@@ -209,9 +209,9 @@ func (s *NonconformityService) Update(
|
||||
nonconformity.CorrectiveAction = *req.CorrectiveAction
|
||||
}
|
||||
if req.OwnerID != nil {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
nonconformity.OwnerID = *req.OwnerID
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func (cor *CreateObligationRequest) Validate() error {
|
||||
v.Check(cor.Requirement, "requirement", validator.SafeText(ContentMaxLength))
|
||||
v.Check(cor.ActionsToBeImplemented, "actions_to_be_implemented", validator.SafeText(ContentMaxLength))
|
||||
v.Check(cor.Regulator, "regulator", validator.SafeText(TitleMaxLength))
|
||||
v.Check(cor.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(cor.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(cor.Status, "status", validator.OneOfSlice(coredata.ObligationStatuses()))
|
||||
v.Check(cor.Type, "type", validator.OneOfSlice(coredata.ObligationTypes()))
|
||||
|
||||
@@ -85,7 +85,7 @@ func (uor *UpdateObligationRequest) Validate() error {
|
||||
v.Check(uor.Requirement, "requirement", validator.SafeText(ContentMaxLength))
|
||||
v.Check(uor.ActionsToBeImplemented, "actions_to_be_implemented", validator.SafeText(ContentMaxLength))
|
||||
v.Check(uor.Regulator, "regulator", validator.SafeText(NameMaxLength))
|
||||
v.Check(uor.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(uor.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(uor.Status, "status", validator.OneOfSlice(coredata.ObligationStatuses()))
|
||||
v.Check(uor.Type, "type", validator.OneOfSlice(coredata.ObligationTypes()))
|
||||
|
||||
@@ -151,9 +151,9 @@ func (s *ObligationService) Create(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
owner := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
|
||||
if err := obligation.Insert(ctx, conn, s.svc.scope); err != nil {
|
||||
@@ -209,9 +209,9 @@ func (s *ObligationService) Update(
|
||||
}
|
||||
|
||||
if req.OwnerID != nil {
|
||||
owner := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
obligation.OwnerID = *req.OwnerID
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ func (cpr *CreatePeopleRequest) Validate() error {
|
||||
func (upr *UpdatePeopleRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(upr.ID, "id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
// v.Check(upr.ID, "id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(upr.Kind, "kind", validator.OneOfSlice(coredata.PeopleKinds()))
|
||||
v.Check(upr.FullName, "full_name", validator.SafeTextNoNewLine(NameMaxLength))
|
||||
v.Check(upr.PrimaryEmailAddress, "primary_email_address", validator.NotEmpty())
|
||||
@@ -261,7 +261,7 @@ func (s PeopleService) Create(
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
peopleID := gid.New(s.svc.scope.GetTenantID(), coredata.PeopleEntityType)
|
||||
peopleID := gid.New(s.svc.scope.GetTenantID(), 8)
|
||||
|
||||
organization := &coredata.Organization{}
|
||||
people := &coredata.People{
|
||||
|
||||
@@ -105,7 +105,7 @@ func (cpar *CreateProcessingActivityRequest) Validate() error {
|
||||
v.Check(cpar.DataProtectionImpactAssessmentNeeded, "data_protection_impact_assessment_needed", validator.Required(), validator.OneOfSlice(coredata.ProcessingActivityDataProtectionImpactAssessments()))
|
||||
v.Check(cpar.TransferImpactAssessmentNeeded, "transfer_impact_assessment_needed", validator.Required(), validator.OneOfSlice(coredata.ProcessingActivityTransferImpactAssessments()))
|
||||
v.Check(cpar.Role, "role", validator.Required(), validator.OneOfSlice(coredata.ProcessingActivityRoles()))
|
||||
v.Check(cpar.DataProtectionOfficerID, "data_protection_officer_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(cpar.DataProtectionOfficerID, "data_protection_officer_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.CheckEach(cpar.VendorIDs, "vendor_ids", func(index int, item any) {
|
||||
v.Check(item, fmt.Sprintf("vendor_ids[%d]", index), validator.Required(), validator.GID(coredata.VendorEntityType))
|
||||
})
|
||||
@@ -132,7 +132,7 @@ func (upar *UpdateProcessingActivityRequest) Validate() error {
|
||||
v.Check(upar.DataProtectionImpactAssessmentNeeded, "data_protection_impact_assessment_needed", validator.OneOfSlice(coredata.ProcessingActivityDataProtectionImpactAssessments()))
|
||||
v.Check(upar.TransferImpactAssessmentNeeded, "transfer_impact_assessment_needed", validator.OneOfSlice(coredata.ProcessingActivityTransferImpactAssessments()))
|
||||
v.Check(upar.Role, "role", validator.OneOfSlice(coredata.ProcessingActivityRoles()))
|
||||
v.Check(upar.DataProtectionOfficerID, "data_protection_officer_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(upar.DataProtectionOfficerID, "data_protection_officer_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.CheckEach(upar.VendorIDs, "vendor_ids", func(index int, item any) {
|
||||
v.Check(item, fmt.Sprintf("vendor_ids[%d]", index), validator.GID(coredata.VendorEntityType))
|
||||
})
|
||||
@@ -462,7 +462,7 @@ func (s *ProcessingActivityService) ExportPDF(
|
||||
for i, pa := range processingActivities {
|
||||
dpoFullName := (*string)(nil)
|
||||
if pa.DataProtectionOfficerID != nil {
|
||||
dpo := &coredata.People{}
|
||||
dpo := &coredata.MembershipProfile{}
|
||||
if err := dpo.LoadByID(ctx, conn, s.svc.scope, *pa.DataProtectionOfficerID); err == nil {
|
||||
dpoFullName = &dpo.FullName
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (crr *CreateRiskRequest) Validate() error {
|
||||
v.Check(crr.Description, "description", validator.Required(), validator.SafeText(ContentMaxLength))
|
||||
v.Check(crr.Category, "category", validator.Required(), validator.SafeText(TitleMaxLength))
|
||||
v.Check(crr.Treatment, "treatment", validator.Required(), validator.OneOfSlice(coredata.RiskTreatments()))
|
||||
v.Check(crr.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(crr.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(crr.InherentLikelihood, "inherent_likelihood", validator.Required(), validator.Min(1), validator.Max(5))
|
||||
v.Check(crr.InherentImpact, "inherent_impact", validator.Required(), validator.Min(1), validator.Max(5))
|
||||
v.Check(crr.ResidualLikelihood, "residual_likelihood", validator.Min(1), validator.Max(5))
|
||||
@@ -86,7 +86,7 @@ func (urr *UpdateRiskRequest) Validate() error {
|
||||
v.Check(urr.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(urr.Category, "category", validator.SafeText(TitleMaxLength))
|
||||
v.Check(urr.Treatment, "treatment", validator.OneOfSlice(coredata.RiskTreatments()))
|
||||
v.Check(urr.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(urr.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(urr.InherentLikelihood, "inherent_likelihood", validator.Min(1), validator.Max(5))
|
||||
v.Check(urr.InherentImpact, "inherent_impact", validator.Min(1), validator.Max(5))
|
||||
v.Check(urr.ResidualLikelihood, "residual_likelihood", validator.Min(1), validator.Max(5))
|
||||
@@ -419,7 +419,7 @@ func (s RiskService) Create(
|
||||
req CreateRiskRequest,
|
||||
) (*coredata.Risk, error) {
|
||||
now := time.Now()
|
||||
people := coredata.People{}
|
||||
owner := coredata.MembershipProfile{}
|
||||
organization := coredata.Organization{}
|
||||
|
||||
risk := &coredata.Risk{
|
||||
@@ -458,8 +458,8 @@ func (s RiskService) Create(
|
||||
}
|
||||
|
||||
if req.OwnerID != nil {
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, *req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,9 +537,9 @@ func (s RiskService) Update(
|
||||
|
||||
if req.OwnerID != nil {
|
||||
if *req.OwnerID != nil {
|
||||
people := coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, **req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
owner := coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, **req.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
risk.OwnerID = *req.OwnerID
|
||||
} else {
|
||||
|
||||
@@ -53,7 +53,7 @@ func (csr *CreateStateOfApplicabilityRequest) Validate() error {
|
||||
|
||||
v.Check(csr.OrganizationID, "organization_id", validator.Required(), validator.GID(coredata.OrganizationEntityType))
|
||||
v.Check(csr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(csr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(csr.OwnerID, "owner_id", validator.Required(), validator.GID(coredata.MembershipProfileEntityType))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func (usr *UpdateStateOfApplicabilityRequest) Validate() error {
|
||||
|
||||
v.Check(usr.StateOfApplicabilityID, "state_of_applicability_id", validator.Required(), validator.GID(coredata.StateOfApplicabilityEntityType))
|
||||
v.Check(usr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(usr.OwnerID, "owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(usr.OwnerID, "owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -445,9 +445,9 @@ func (s StateOfApplicabilityService) ExportPDF(
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
owner := &coredata.People{}
|
||||
owner := &coredata.MembershipProfile{}
|
||||
if err := owner.LoadByID(ctx, conn, s.svc.scope, stateOfApplicability.OwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load owner: %w", err)
|
||||
return fmt.Errorf("cannot load owner profile: %w", err)
|
||||
}
|
||||
|
||||
// Load applicability statements
|
||||
|
||||
@@ -62,7 +62,7 @@ func (ctr *CreateTaskRequest) Validate() error {
|
||||
v.Check(ctr.Name, "name", validator.SafeTextNoNewLine(TitleMaxLength))
|
||||
v.Check(ctr.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(ctr.TimeEstimate, "time_estimate", validator.RangeDuration(0, 1000*time.Hour))
|
||||
v.Check(ctr.AssignedToID, "assigned_to_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(ctr.AssignedToID, "assigned_to_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (utr *UpdateTaskRequest) Validate() error {
|
||||
v.Check(utr.Description, "description", validator.SafeText(ContentMaxLength))
|
||||
v.Check(utr.TimeEstimate, "time_estimate", validator.RangeDuration(0, 1000*time.Hour))
|
||||
v.Check(utr.State, "state", validator.OneOfSlice(coredata.TaskStates()))
|
||||
v.Check(utr.AssignedToID, "assigned_to_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(utr.AssignedToID, "assigned_to_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(utr.MeasureID, "measure_id", validator.GID(coredata.MeasureEntityType))
|
||||
|
||||
return v.Error()
|
||||
@@ -123,9 +123,9 @@ func (s TaskService) Create(
|
||||
}
|
||||
|
||||
if req.AssignedToID != nil {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, *req.AssignedToID); err != nil {
|
||||
return fmt.Errorf("cannot load assignee: %w", err)
|
||||
assignee := &coredata.MembershipProfile{}
|
||||
if err := assignee.LoadByID(ctx, conn, s.svc.scope, *req.AssignedToID); err != nil {
|
||||
return fmt.Errorf("cannot load assignee profile: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,9 +176,9 @@ func (s TaskService) Assign(
|
||||
return fmt.Errorf("cannot load task %q: %w", taskID, err)
|
||||
}
|
||||
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, assignedToID); err != nil {
|
||||
return fmt.Errorf("cannot load assignee: %w", err)
|
||||
assignee := &coredata.MembershipProfile{}
|
||||
if err := assignee.LoadByID(ctx, conn, s.svc.scope, assignedToID); err != nil {
|
||||
return fmt.Errorf("cannot load assignee profile: %w", err)
|
||||
}
|
||||
|
||||
task.AssignedToID = &assignedToID
|
||||
@@ -269,9 +269,9 @@ func (s TaskService) Update(
|
||||
if *req.AssignedToID == nil {
|
||||
task.AssignedToID = nil
|
||||
} else {
|
||||
people := &coredata.People{}
|
||||
if err := people.LoadByID(ctx, conn, s.svc.scope, **req.AssignedToID); err != nil {
|
||||
return fmt.Errorf("cannot load assignee: %w", err)
|
||||
assignee := &coredata.MembershipProfile{}
|
||||
if err := assignee.LoadByID(ctx, conn, s.svc.scope, **req.AssignedToID); err != nil {
|
||||
return fmt.Errorf("cannot load assignee profile: %w", err)
|
||||
}
|
||||
task.AssignedToID = *req.AssignedToID
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ func (cvr *CreateVendorRequest) Validate() error {
|
||||
v.Check(cvr.TrustPageURL, "trust_page_url", validator.SafeText(2048))
|
||||
v.Check(cvr.TermsOfServiceURL, "terms_of_service_url", validator.SafeText(2048))
|
||||
v.Check(cvr.StatusPageURL, "status_page_url", validator.SafeText(2048))
|
||||
v.Check(cvr.BusinessOwnerID, "business_owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(cvr.SecurityOwnerID, "security_owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(cvr.BusinessOwnerID, "business_owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(cvr.SecurityOwnerID, "security_owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -136,8 +136,8 @@ func (uvr *UpdateVendorRequest) Validate() error {
|
||||
v.Check(uvr.TrustPageURL, "trust_page_url", validator.SafeText(2048))
|
||||
v.Check(uvr.TermsOfServiceURL, "terms_of_service_url", validator.SafeText(2048))
|
||||
v.Check(uvr.StatusPageURL, "status_page_url", validator.SafeText(2048))
|
||||
v.Check(uvr.BusinessOwnerID, "business_owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(uvr.SecurityOwnerID, "security_owner_id", validator.GID(coredata.PeopleEntityType))
|
||||
v.Check(uvr.BusinessOwnerID, "business_owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
v.Check(uvr.SecurityOwnerID, "security_owner_id", validator.GID(coredata.MembershipProfileEntityType))
|
||||
|
||||
return v.Error()
|
||||
}
|
||||
@@ -364,9 +364,9 @@ func (s VendorService) Update(
|
||||
|
||||
if req.BusinessOwnerID != nil {
|
||||
if *req.BusinessOwnerID != nil {
|
||||
businessOwner := &coredata.People{}
|
||||
businessOwner := &coredata.MembershipProfile{}
|
||||
if err := businessOwner.LoadByID(ctx, conn, s.svc.scope, **req.BusinessOwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load business owner: %w", err)
|
||||
return fmt.Errorf("cannot load business owner profile: %w", err)
|
||||
}
|
||||
vendor.BusinessOwnerID = &businessOwner.ID
|
||||
} else {
|
||||
@@ -376,9 +376,9 @@ func (s VendorService) Update(
|
||||
|
||||
if req.SecurityOwnerID != nil {
|
||||
if *req.SecurityOwnerID != nil {
|
||||
securityOwner := &coredata.People{}
|
||||
securityOwner := &coredata.MembershipProfile{}
|
||||
if err := securityOwner.LoadByID(ctx, conn, s.svc.scope, **req.SecurityOwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load security owner: %w", err)
|
||||
return fmt.Errorf("cannot load security owner profile: %w", err)
|
||||
}
|
||||
vendor.SecurityOwnerID = &securityOwner.ID
|
||||
} else {
|
||||
@@ -479,17 +479,17 @@ func (s VendorService) Create(
|
||||
vendor.OrganizationID = organization.ID
|
||||
|
||||
if req.BusinessOwnerID != nil {
|
||||
businessOwner := &coredata.People{}
|
||||
businessOwner := &coredata.MembershipProfile{}
|
||||
if err := businessOwner.LoadByID(ctx, conn, s.svc.scope, *req.BusinessOwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load business owner: %w", err)
|
||||
return fmt.Errorf("cannot load business owner profile: %w", err)
|
||||
}
|
||||
vendor.BusinessOwnerID = &businessOwner.ID
|
||||
}
|
||||
|
||||
if req.SecurityOwnerID != nil {
|
||||
securityOwner := &coredata.People{}
|
||||
securityOwner := &coredata.MembershipProfile{}
|
||||
if err := securityOwner.LoadByID(ctx, conn, s.svc.scope, *req.SecurityOwnerID); err != nil {
|
||||
return fmt.Errorf("cannot load security owner: %w", err)
|
||||
return fmt.Errorf("cannot load security owner profile: %w", err)
|
||||
}
|
||||
vendor.SecurityOwnerID = &securityOwner.ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user