diff --git a/pkg/coredata/asset.go b/pkg/coredata/asset.go index c09f25452..bd698485e 100644 --- a/pkg/coredata/asset.go +++ b/pkg/coredata/asset.go @@ -34,7 +34,7 @@ type ( SourceID *gid.GID `db:"source_id"` Name string `db:"name"` Amount int `db:"amount"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` OrganizationID gid.GID `db:"organization_id"` AssetType AssetType `db:"asset_type"` DataTypesStored string `db:"data_types_stored"` diff --git a/pkg/coredata/continual_improvements.go b/pkg/coredata/continual_improvements.go index c0fe6f4b9..020d34625 100644 --- a/pkg/coredata/continual_improvements.go +++ b/pkg/coredata/continual_improvements.go @@ -34,7 +34,7 @@ type ( ReferenceID string `db:"reference_id"` Description *string `db:"description"` Source *string `db:"source"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` TargetDate *time.Time `db:"target_date"` Status ContinualImprovementStatus `db:"status"` Priority ContinualImprovementPriority `db:"priority"` diff --git a/pkg/coredata/datum.go b/pkg/coredata/datum.go index 3f73fcd03..6ff2b2298 100644 --- a/pkg/coredata/datum.go +++ b/pkg/coredata/datum.go @@ -32,7 +32,7 @@ type ( ID gid.GID `db:"id"` Name string `db:"name"` OrganizationID gid.GID `db:"organization_id"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` DataClassification DataClassification `db:"data_classification"` SnapshotID *gid.GID `db:"snapshot_id"` SourceID *gid.GID `db:"source_id"` diff --git a/pkg/coredata/document.go b/pkg/coredata/document.go index e8a523794..6c91d2339 100644 --- a/pkg/coredata/document.go +++ b/pkg/coredata/document.go @@ -32,7 +32,7 @@ type ( Document struct { ID gid.GID `db:"id"` OrganizationID gid.GID `db:"organization_id"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` Title string `db:"title"` DocumentType DocumentType `db:"document_type"` Classification DocumentClassification `db:"classification"` diff --git a/pkg/coredata/document_version.go b/pkg/coredata/document_version.go index c2dbdf45c..bb499f311 100644 --- a/pkg/coredata/document_version.go +++ b/pkg/coredata/document_version.go @@ -34,7 +34,7 @@ type ( OrganizationID gid.GID `db:"organization_id"` DocumentID gid.GID `db:"document_id"` Title string `db:"title"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` VersionNumber int `db:"version_number"` Classification DocumentClassification `db:"classification"` Content string `db:"content"` diff --git a/pkg/coredata/document_version_signature.go b/pkg/coredata/document_version_signature.go index 3f1e00ab0..194eca0ad 100644 --- a/pkg/coredata/document_version_signature.go +++ b/pkg/coredata/document_version_signature.go @@ -35,7 +35,7 @@ type ( OrganizationID gid.GID `json:"-"` DocumentVersionID gid.GID `json:"document_version_id"` State DocumentVersionSignatureState `json:"state"` - SignedBy gid.GID `json:"signed_by"` + SignedBy gid.GID `json:"signed_by_profile_id"` SignedAt *time.Time `json:"signed_at"` RequestedAt time.Time `json:"requested_at"` CreatedAt time.Time `json:"created_at"` diff --git a/pkg/coredata/entity_type_reg.go b/pkg/coredata/entity_type_reg.go index 93262b342..5103faafa 100644 --- a/pkg/coredata/entity_type_reg.go +++ b/pkg/coredata/entity_type_reg.go @@ -31,7 +31,7 @@ const ( ConnectorEntityType uint16 = 5 VendorRiskAssessmentEntityType uint16 = 6 VendorEntityType uint16 = 7 - PeopleEntityType uint16 = 8 + _ uint16 = 8 // PeopleEntityType - removed VendorComplianceReportEntityType uint16 = 9 DocumentEntityType uint16 = 10 IdentityEntityType uint16 = 11 @@ -99,8 +99,6 @@ func NewEntityFromID(id gid.GID) (any, bool) { return &VendorRiskAssessment{ID: id}, true case VendorEntityType: return &Vendor{ID: id}, true - case PeopleEntityType: - return &People{ID: id}, true case VendorComplianceReportEntityType: return &VendorComplianceReport{ID: id}, true case DocumentEntityType: diff --git a/pkg/coredata/meeting_attendee.go b/pkg/coredata/meeting_attendee.go index cf41c26b0..bfa93ff93 100644 --- a/pkg/coredata/meeting_attendee.go +++ b/pkg/coredata/meeting_attendee.go @@ -29,7 +29,7 @@ type ( MeetingAttendee struct { MeetingID gid.GID `db:"meeting_id"` OrganizationID gid.GID `db:"organization_id"` - AttendeeID gid.GID `db:"attendee_id"` + AttendeeID gid.GID `db:"attendee_profile_id"` CreatedAt time.Time `db:"created_at"` } diff --git a/pkg/coredata/membership_profile.go b/pkg/coredata/membership_profile.go index 4a8629a23..f4964e92b 100644 --- a/pkg/coredata/membership_profile.go +++ b/pkg/coredata/membership_profile.go @@ -40,6 +40,8 @@ type ( CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } + + MembershipProfiles []*MembershipProfile ) func (p *MembershipProfile) AuthorizationAttributes(ctx context.Context, conn pg.Conn) (map[string]string, error) { @@ -156,6 +158,167 @@ LIMIT 1; return nil } +func (p *MembershipProfiles) LoadByIDs( + ctx context.Context, + conn pg.Conn, + scope Scoper, + profileIDs []gid.GID, +) error { + q := ` +SELECT + id, + membership_id, + full_name, + kind, + additionalEmailAddresses, + position, + contract_start_date, + contract_end_date, + created_at, + updated_at +FROM + iam_membership_profiles +WHERE + %s + AND id = ANY(@profile_ids) +` + + q = fmt.Sprintf(q, scope.SQLFragment()) + + args := pgx.NamedArgs{"profile_ids": profileIDs} + maps.Copy(args, scope.SQLArguments()) + + rows, err := conn.Query(ctx, q, args) + if err != nil { + return fmt.Errorf("cannot query profiles: %w", err) + } + + profiles, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[MembershipProfile]) + if err != nil { + return fmt.Errorf("cannot collect profiles: %w", err) + } + + *p = profiles + + return nil +} + +func (p *MembershipProfiles) LoadByMeetingID( + ctx context.Context, + conn pg.Conn, + scope Scoper, + meetingID gid.GID, +) error { + q := ` +WITH attendees AS ( + SELECT + p.id, + p.membership_id, + p.full_name, + p.kind, + p.additionalEmailAddresses, + p.position, + p.contract_start_date, + p.contract_end_date, + p.created_at, + p.updated_at, + ma.created_at AS attendee_created_at + FROM + iam_membership_profiles p + INNER JOIN + meeting_attendees ma ON p.id = ma.attendee_profile_id + WHERE + ma.meeting_id = @meeting_id +) +SELECT + id, + organization_id, + kind, + full_name, + additional_email_addresses, + position, + contract_start_date, + contract_end_date, + created_at, + updated_at +FROM + attendees +WHERE + %s +ORDER BY + attendee_created_at ASC +` + + q = fmt.Sprintf(q, scope.SQLFragment()) + + args := pgx.NamedArgs{"meeting_id": meetingID} + maps.Copy(args, scope.SQLArguments()) + + rows, err := conn.Query(ctx, q, args) + if err != nil { + return fmt.Errorf("cannot query profiles: %w", err) + } + + profiles, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[MembershipProfile]) + if err != nil { + return fmt.Errorf("cannot collect profiles: %w", err) + } + + *p = profiles + + return nil +} + +func (p *MembershipProfiles) LoadAwaitingSigning( + ctx context.Context, + conn pg.Conn, + scope Scoper, +) error { + q := ` +WITH signatories AS ( + SELECT + signed_by + FROM + document_version_signatures + WHERE + %s + AND state = 'REQUESTED' + GROUP BY + signed_by +) +SELECT + id, + organization_id, + kind, + full_name, + additional_email_addresses, + position, + contract_start_date, + contract_end_date, + created_at, + updated_at +FROM + iam_membership_profiles +INNER JOIN signatories ON iam_membership_profiles.id = signatories.signed_by_profile_id +` + + q = fmt.Sprintf(q, scope.SQLFragment()) + + rows, err := conn.Query(ctx, q, scope.SQLArguments()) + if err != nil { + return fmt.Errorf("cannot query profiles: %w", err) + } + + profiles, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[MembershipProfile]) + if err != nil { + return fmt.Errorf("cannot collect profiles: %w", err) + } + + *p = profiles + + return nil +} + func (p *MembershipProfile) Insert( ctx context.Context, conn pg.Conn, diff --git a/pkg/coredata/nonconformity.go b/pkg/coredata/nonconformity.go index df535399d..7b3c18943 100644 --- a/pkg/coredata/nonconformity.go +++ b/pkg/coredata/nonconformity.go @@ -39,7 +39,7 @@ type ( DateIdentified *time.Time `db:"date_identified"` RootCause string `db:"root_cause"` CorrectiveAction *string `db:"corrective_action"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` DueDate *time.Time `db:"due_date"` Status NonconformityStatus `db:"status"` EffectivenessCheck *string `db:"effectiveness_check"` diff --git a/pkg/coredata/obligation.go b/pkg/coredata/obligation.go index 153ebc6b5..3e15ff741 100644 --- a/pkg/coredata/obligation.go +++ b/pkg/coredata/obligation.go @@ -36,7 +36,7 @@ type ( Requirement *string `db:"requirement"` ActionsToBeImplemented *string `db:"actions_to_be_implemented"` Regulator *string `db:"regulator"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` LastReviewDate *time.Time `db:"last_review_date"` DueDate *time.Time `db:"due_date"` Status ObligationStatus `db:"status"` diff --git a/pkg/coredata/people.go b/pkg/coredata/people.go index 3186a5b0a..d16e3896b 100644 --- a/pkg/coredata/people.go +++ b/pkg/coredata/people.go @@ -74,108 +74,17 @@ func (p *People) AuthorizationAttributes(ctx context.Context, conn pg.Conn) (map return map[string]string{"organization_id": organizationID.String()}, nil } +// FIXME remove: only used in people_service func (p *People) LoadByID( ctx context.Context, conn pg.Conn, scope Scoper, peopleID gid.GID, ) error { - q := ` -SELECT - id, - organization_id, - kind, - full_name, - primary_email_address, - additional_email_addresses, - position, - contract_start_date, - contract_end_date, - created_at, - updated_at -FROM - peoples -WHERE - %s - AND id = @people_id -LIMIT 1; -` - - q = fmt.Sprintf(q, scope.SQLFragment()) - - args := pgx.StrictNamedArgs{"people_id": peopleID} - maps.Copy(args, scope.SQLArguments()) - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query people: %w", err) - } - - people, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[People]) - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - return ErrResourceNotFound - } - - return fmt.Errorf("cannot collect people: %w", err) - } - - *p = people - - return nil -} - -func (p *People) LoadByEmail( - ctx context.Context, - conn pg.Conn, - scope Scoper, - primaryEmailAddress string, -) error { - q := ` -SELECT - id, - organization_id, - kind, - full_name, - primary_email_address, - additional_email_addresses, - position, - contract_start_date, - contract_end_date, - created_at, - updated_at -FROM - peoples -WHERE - %s - AND primary_email_address = @primary_email_address -LIMIT 1; - ` - - q = fmt.Sprintf(q, scope.SQLFragment()) - - args := pgx.StrictNamedArgs{"primary_email_address": primaryEmailAddress} - maps.Copy(args, scope.SQLArguments()) - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query people: %w", err) - } - - people, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[People]) - if err != nil { - if errors.Is(err, pgx.ErrNoRows) { - return ErrResourceNotFound - } - - return fmt.Errorf("cannot collect people: %w", err) - } - - *p = people - return nil } +// FIXME remove: only used in document_service func (p *People) LoadByEmailAndOrganizationID( ctx context.Context, conn pg.Conn, @@ -232,52 +141,7 @@ LIMIT 1; return nil } -func (p *Peoples) LoadByIDs( - ctx context.Context, - conn pg.Conn, - scope Scoper, - peopleIDs []gid.GID, -) error { - q := ` -SELECT - id, - organization_id, - kind, - full_name, - primary_email_address, - additional_email_addresses, - position, - contract_start_date, - contract_end_date, - created_at, - updated_at -FROM - peoples -WHERE - %s - AND id = ANY(@people_ids) -` - - q = fmt.Sprintf(q, scope.SQLFragment()) - - args := pgx.NamedArgs{"people_ids": peopleIDs} - maps.Copy(args, scope.SQLArguments()) - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query people: %w", err) - } - - peoples, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[People]) - if err != nil { - return fmt.Errorf("cannot collect people: %w", err) - } - - *p = peoples - - return nil -} - +// FIXME remove: only used in people_service func (p People) Insert( ctx context.Context, conn pg.Conn, @@ -333,6 +197,7 @@ VALUES ( return err } +// FIXME remove: only used in people_service func (p People) Delete( ctx context.Context, conn pg.Conn, @@ -361,6 +226,7 @@ DELETE FROM peoples WHERE %s AND id = @people_id return nil } +// FIXME remove: only used in people_service func (p *Peoples) CountByOrganizationID( ctx context.Context, conn pg.Conn, @@ -396,6 +262,7 @@ WHERE return count, nil } +// FIXME remove: only used in people_service func (p *Peoples) LoadByOrganizationID( ctx context.Context, conn pg.Conn, @@ -448,6 +315,7 @@ WHERE return nil } +// FIXME remove: only used in people_service func (p *People) Update( ctx context.Context, conn pg.Conn, @@ -488,123 +356,3 @@ WHERE %s return nil } - -func (p *Peoples) LoadAwaitingSigning( - ctx context.Context, - conn pg.Conn, - scope Scoper, -) error { - q := ` -WITH signatories AS ( - SELECT - signed_by - FROM - document_version_signatures - WHERE - %s - AND state = 'REQUESTED' - GROUP BY - signed_by -) -SELECT - id, - organization_id, - kind, - full_name, - primary_email_address, - additional_email_addresses, - position, - contract_start_date, - contract_end_date, - created_at, - updated_at -FROM - peoples -INNER JOIN signatories ON peoples.id = signatories.signed_by -` - - q = fmt.Sprintf(q, scope.SQLFragment()) - - rows, err := conn.Query(ctx, q, scope.SQLArguments()) - if err != nil { - return fmt.Errorf("cannot query people: %w", err) - } - - peoples, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[People]) - if err != nil { - return fmt.Errorf("cannot collect people: %w", err) - } - - *p = peoples - - return nil -} - -func (p *Peoples) LoadByMeetingID( - ctx context.Context, - conn pg.Conn, - scope Scoper, - meetingID gid.GID, -) error { - q := ` -WITH people_attendees AS ( - SELECT - p.id, - p.organization_id, - p.kind, - p.full_name, - p.primary_email_address, - p.additional_email_addresses, - p.position, - p.contract_start_date, - p.contract_end_date, - p.created_at, - p.updated_at, - p.tenant_id, - ma.created_at AS attendee_created_at - FROM - peoples p - INNER JOIN - meeting_attendees ma ON p.id = ma.attendee_id - WHERE - ma.meeting_id = @meeting_id -) -SELECT - id, - organization_id, - kind, - full_name, - primary_email_address, - additional_email_addresses, - position, - contract_start_date, - contract_end_date, - created_at, - updated_at -FROM - people_attendees -WHERE - %s -ORDER BY - attendee_created_at ASC -` - - q = fmt.Sprintf(q, scope.SQLFragment()) - - args := pgx.NamedArgs{"meeting_id": meetingID} - maps.Copy(args, scope.SQLArguments()) - - rows, err := conn.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot query people: %w", err) - } - - peoples, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[People]) - if err != nil { - return fmt.Errorf("cannot collect people: %w", err) - } - - *p = peoples - - return nil -} diff --git a/pkg/coredata/processing_activities.go b/pkg/coredata/processing_activities.go index beed7170f..4cf6f9603 100644 --- a/pkg/coredata/processing_activities.go +++ b/pkg/coredata/processing_activities.go @@ -51,7 +51,7 @@ type ( LastReviewDate *time.Time `db:"last_review_date"` NextReviewDate *time.Time `db:"next_review_date"` Role ProcessingActivityRole `db:"role"` - DataProtectionOfficerID *gid.GID `db:"data_protection_officer_id"` + DataProtectionOfficerID *gid.GID `db:"dpo_profile_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } diff --git a/pkg/coredata/risk.go b/pkg/coredata/risk.go index 66a32d0dd..430eb3453 100644 --- a/pkg/coredata/risk.go +++ b/pkg/coredata/risk.go @@ -36,7 +36,7 @@ type ( Category string `db:"category"` Treatment RiskTreatment `db:"treatment"` Note string `db:"note"` - OwnerID *gid.GID `db:"owner_id"` + OwnerID *gid.GID `db:"owner_profile_id"` InherentLikelihood int `db:"inherent_likelihood"` InherentImpact int `db:"inherent_impact"` InherentRiskScore int `db:"inherent_risk_score"` diff --git a/pkg/coredata/state_of_applicability.go b/pkg/coredata/state_of_applicability.go index a766a7466..b2c944061 100644 --- a/pkg/coredata/state_of_applicability.go +++ b/pkg/coredata/state_of_applicability.go @@ -35,7 +35,7 @@ type ( Name string `db:"name"` SourceID *gid.GID `db:"source_id"` SnapshotID *gid.GID `db:"snapshot_id"` - OwnerID gid.GID `db:"owner_id"` + OwnerID gid.GID `db:"owner_profile_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } diff --git a/pkg/coredata/task.go b/pkg/coredata/task.go index a8aa3ef4b..e896e6500 100644 --- a/pkg/coredata/task.go +++ b/pkg/coredata/task.go @@ -39,7 +39,7 @@ type ( State TaskState `db:"state"` ReferenceID string `db:"reference_id"` TimeEstimate *time.Duration `db:"time_estimate"` - AssignedToID *gid.GID `db:"assigned_to"` + AssignedToID *gid.GID `db:"assigned_to_profile_id"` Deadline *time.Time `db:"deadline"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` diff --git a/pkg/coredata/vendor.go b/pkg/coredata/vendor.go index 9662c761a..f513d1e0f 100644 --- a/pkg/coredata/vendor.go +++ b/pkg/coredata/vendor.go @@ -45,8 +45,8 @@ type ( SubprocessorsListURL *string `db:"subprocessors_list_url"` Certifications []string `db:"certifications"` Countries CountryCodes `db:"countries"` - BusinessOwnerID *gid.GID `db:"business_owner_id"` - SecurityOwnerID *gid.GID `db:"security_owner_id"` + BusinessOwnerID *gid.GID `db:"business_owner_profile_id"` + SecurityOwnerID *gid.GID `db:"security_owner_profile_id"` StatusPageURL *string `db:"status_page_url"` TermsOfServiceURL *string `db:"terms_of_service_url"` SecurityPageURL *string `db:"security_page_url"` diff --git a/pkg/probo/asset_service.go b/pkg/probo/asset_service.go index c38ffa209..c3d6d9b7b 100644 --- a/pkg/probo/asset_service.go +++ b/pkg/probo/asset_service.go @@ -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 { diff --git a/pkg/probo/continual_improvement_service.go b/pkg/probo/continual_improvement_service.go index e5cca61b4..af08547e1 100644 --- a/pkg/probo/continual_improvement_service.go +++ b/pkg/probo/continual_improvement_service.go @@ -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 } diff --git a/pkg/probo/datum_service.go b/pkg/probo/datum_service.go index 481d36686..a2eaab688 100644 --- a/pkg/probo/datum_service.go +++ b/pkg/probo/datum_service.go @@ -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 { diff --git a/pkg/probo/document_service.go b/pkg/probo/document_service.go index 69e32553f..012d1b216 100644 --- a/pkg/probo/document_service.go +++ b/pkg/probo/document_service.go @@ -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 { diff --git a/pkg/probo/meeting_service.go b/pkg/probo/meeting_service.go index 7008865b6..866856079 100644 --- a/pkg/probo/meeting_service.go +++ b/pkg/probo/meeting_service.go @@ -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 diff --git a/pkg/probo/nonconformity_service.go b/pkg/probo/nonconformity_service.go index 8cc6e0ccc..ce9664754 100644 --- a/pkg/probo/nonconformity_service.go +++ b/pkg/probo/nonconformity_service.go @@ -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 } diff --git a/pkg/probo/obligation_service.go b/pkg/probo/obligation_service.go index cb8379b8c..6d1ed5a79 100644 --- a/pkg/probo/obligation_service.go +++ b/pkg/probo/obligation_service.go @@ -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 } diff --git a/pkg/probo/people_service.go b/pkg/probo/people_service.go index dc31d9c5e..cf6c63367 100644 --- a/pkg/probo/people_service.go +++ b/pkg/probo/people_service.go @@ -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{ diff --git a/pkg/probo/processing_activity_service.go b/pkg/probo/processing_activity_service.go index 07d51b43b..44b8f5d97 100644 --- a/pkg/probo/processing_activity_service.go +++ b/pkg/probo/processing_activity_service.go @@ -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 } diff --git a/pkg/probo/risk_service.go b/pkg/probo/risk_service.go index 679e564b5..6a1f3754d 100644 --- a/pkg/probo/risk_service.go +++ b/pkg/probo/risk_service.go @@ -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 { diff --git a/pkg/probo/state_of_applicability_service.go b/pkg/probo/state_of_applicability_service.go index 9d74a4ade..b8b67a5f0 100644 --- a/pkg/probo/state_of_applicability_service.go +++ b/pkg/probo/state_of_applicability_service.go @@ -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 diff --git a/pkg/probo/task_service.go b/pkg/probo/task_service.go index 46da68eed..b2709f363 100644 --- a/pkg/probo/task_service.go +++ b/pkg/probo/task_service.go @@ -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 } diff --git a/pkg/probo/vendor_service.go b/pkg/probo/vendor_service.go index 4c383aa2c..39dd33098 100644 --- a/pkg/probo/vendor_service.go +++ b/pkg/probo/vendor_service.go @@ -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 } diff --git a/pkg/server/api/console/v1/schema.graphql b/pkg/server/api/console/v1/schema.graphql index 543393492..5f10b622b 100644 --- a/pkg/server/api/console/v1/schema.graphql +++ b/pkg/server/api/console/v1/schema.graphql @@ -1841,6 +1841,21 @@ type SlackConnectionEdge { node: SlackConnection! } +type Profile implements Node { + id: ID! + fullName: String! + email_address: EmailAddr! + additionalEmailAddresses: [EmailAddr!]! + kind: PeopleKind! + position: String + contractStartDate: Datetime + contractEndDate: Datetime + createdAt: Datetime! + updatedAt: Datetime! + + permission(action: String!): Boolean! @goField(forceResolver: true) +} + type People implements Node { id: ID! fullName: String! @@ -2234,7 +2249,7 @@ type Meeting implements Node { name: String! date: Datetime! minutes: String - attendees: [People!]! @goField(forceResolver: true) + attendees: [Profile!]! @goField(forceResolver: true) organization: Organization! @goField(forceResolver: true) createdAt: Datetime! updatedAt: Datetime! @@ -2694,6 +2709,21 @@ type TrustCenterFileEdge { node: TrustCenterFile! } +type ProfileConnection + # @goModel( + # model: "go.probo.inc/probo/pkg/server/api/console/v1/types.ProfileConnection" + # ) { + # totalCount: Int! @goField(forceResolver: true) + { + edges: [ProfileEdge!]! + pageInfo: PageInfo! +} + +type ProfileEdge { + cursor: CursorKey! + node: Profile! +} + type PeopleConnection @goModel( model: "go.probo.inc/probo/pkg/server/api/console/v1/types.PeopleConnection" diff --git a/pkg/server/api/console/v1/schema/schema.go b/pkg/server/api/console/v1/schema/schema.go index 3e53cd02b..62e8acfea 100644 --- a/pkg/server/api/console/v1/schema/schema.go +++ b/pkg/server/api/console/v1/schema/schema.go @@ -87,6 +87,7 @@ type ResolverRoot interface { PeopleConnection() PeopleConnectionResolver ProcessingActivity() ProcessingActivityResolver ProcessingActivityConnection() ProcessingActivityConnectionResolver + Profile() ProfileResolver Query() QueryResolver Report() ReportResolver RightsRequest() RightsRequestResolver @@ -1260,6 +1261,30 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + Profile struct { + AdditionalEmailAddresses func(childComplexity int) int + ContractEndDate func(childComplexity int) int + ContractStartDate func(childComplexity int) int + CreatedAt func(childComplexity int) int + EmailAddress func(childComplexity int) int + FullName func(childComplexity int) int + ID func(childComplexity int) int + Kind func(childComplexity int) int + Permission func(childComplexity int, action string) int + Position func(childComplexity int) int + UpdatedAt func(childComplexity int) int + } + + ProfileConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + } + + ProfileEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + PublishDocumentVersionPayload struct { Document func(childComplexity int) int DocumentVersion func(childComplexity int) int @@ -2081,7 +2106,7 @@ type MeasureConnectionResolver interface { TotalCount(ctx context.Context, obj *types.MeasureConnection) (int, error) } type MeetingResolver interface { - Attendees(ctx context.Context, obj *types.Meeting) ([]*types.People, error) + Attendees(ctx context.Context, obj *types.Meeting) ([]*types.Profile, error) Organization(ctx context.Context, obj *types.Meeting) (*types.Organization, error) Permission(ctx context.Context, obj *types.Meeting, action string) (bool, error) @@ -2306,6 +2331,9 @@ type ProcessingActivityResolver interface { type ProcessingActivityConnectionResolver interface { TotalCount(ctx context.Context, obj *types.ProcessingActivityConnection) (int, error) } +type ProfileResolver interface { + Permission(ctx context.Context, obj *types.Profile, action string) (bool, error) +} type QueryResolver interface { Node(ctx context.Context, id gid.GID) (types.Node, error) Viewer(ctx context.Context) (*types.Viewer, error) @@ -7594,6 +7622,104 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.ProcessingActivityEdge.Node(childComplexity), true + case "Profile.additionalEmailAddresses": + if e.complexity.Profile.AdditionalEmailAddresses == nil { + break + } + + return e.complexity.Profile.AdditionalEmailAddresses(childComplexity), true + case "Profile.contractEndDate": + if e.complexity.Profile.ContractEndDate == nil { + break + } + + return e.complexity.Profile.ContractEndDate(childComplexity), true + case "Profile.contractStartDate": + if e.complexity.Profile.ContractStartDate == nil { + break + } + + return e.complexity.Profile.ContractStartDate(childComplexity), true + case "Profile.createdAt": + if e.complexity.Profile.CreatedAt == nil { + break + } + + return e.complexity.Profile.CreatedAt(childComplexity), true + case "Profile.email_address": + if e.complexity.Profile.EmailAddress == nil { + break + } + + return e.complexity.Profile.EmailAddress(childComplexity), true + case "Profile.fullName": + if e.complexity.Profile.FullName == nil { + break + } + + return e.complexity.Profile.FullName(childComplexity), true + case "Profile.id": + if e.complexity.Profile.ID == nil { + break + } + + return e.complexity.Profile.ID(childComplexity), true + case "Profile.kind": + if e.complexity.Profile.Kind == nil { + break + } + + return e.complexity.Profile.Kind(childComplexity), true + case "Profile.permission": + if e.complexity.Profile.Permission == nil { + break + } + + args, err := ec.field_Profile_permission_args(ctx, rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Profile.Permission(childComplexity, args["action"].(string)), true + case "Profile.position": + if e.complexity.Profile.Position == nil { + break + } + + return e.complexity.Profile.Position(childComplexity), true + case "Profile.updatedAt": + if e.complexity.Profile.UpdatedAt == nil { + break + } + + return e.complexity.Profile.UpdatedAt(childComplexity), true + + case "ProfileConnection.edges": + if e.complexity.ProfileConnection.Edges == nil { + break + } + + return e.complexity.ProfileConnection.Edges(childComplexity), true + case "ProfileConnection.pageInfo": + if e.complexity.ProfileConnection.PageInfo == nil { + break + } + + return e.complexity.ProfileConnection.PageInfo(childComplexity), true + + case "ProfileEdge.cursor": + if e.complexity.ProfileEdge.Cursor == nil { + break + } + + return e.complexity.ProfileEdge.Cursor(childComplexity), true + case "ProfileEdge.node": + if e.complexity.ProfileEdge.Node == nil { + break + } + + return e.complexity.ProfileEdge.Node(childComplexity), true + case "PublishDocumentVersionPayload.document": if e.complexity.PublishDocumentVersionPayload.Document == nil { break @@ -12194,6 +12320,21 @@ type SlackConnectionEdge { node: SlackConnection! } +type Profile implements Node { + id: ID! + fullName: String! + email_address: EmailAddr! + additionalEmailAddresses: [EmailAddr!]! + kind: PeopleKind! + position: String + contractStartDate: Datetime + contractEndDate: Datetime + createdAt: Datetime! + updatedAt: Datetime! + + permission(action: String!): Boolean! @goField(forceResolver: true) +} + type People implements Node { id: ID! fullName: String! @@ -12587,7 +12728,7 @@ type Meeting implements Node { name: String! date: Datetime! minutes: String - attendees: [People!]! @goField(forceResolver: true) + attendees: [Profile!]! @goField(forceResolver: true) organization: Organization! @goField(forceResolver: true) createdAt: Datetime! updatedAt: Datetime! @@ -13047,6 +13188,21 @@ type TrustCenterFileEdge { node: TrustCenterFile! } +type ProfileConnection + # @goModel( + # model: "go.probo.inc/probo/pkg/server/api/console/v1/types.ProfileConnection" + # ) { + # totalCount: Int! @goField(forceResolver: true) + { + edges: [ProfileEdge!]! + pageInfo: PageInfo! +} + +type ProfileEdge { + cursor: CursorKey! + node: Profile! +} + type PeopleConnection @goModel( model: "go.probo.inc/probo/pkg/server/api/console/v1/types.PeopleConnection" @@ -18766,6 +18922,17 @@ func (ec *executionContext) field_ProcessingActivity_vendors_args(ctx context.Co return args, nil } +func (ec *executionContext) field_Profile_permission_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { + var err error + args := map[string]any{} + arg0, err := graphql.ProcessArgField(ctx, rawArgs, "action", ec.unmarshalNString2string) + if err != nil { + return nil, err + } + args["action"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -32972,7 +33139,7 @@ func (ec *executionContext) _Meeting_attendees(ctx context.Context, field graphq return ec.resolvers.Meeting().Attendees(ctx, obj) }, nil, - ec.marshalNPeople2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeopleᚄ, + ec.marshalNProfile2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileᚄ, true, true, ) @@ -32987,29 +33154,29 @@ func (ec *executionContext) fieldContext_Meeting_attendees(_ context.Context, fi Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_People_id(ctx, field) + return ec.fieldContext_Profile_id(ctx, field) case "fullName": - return ec.fieldContext_People_fullName(ctx, field) - case "primaryEmailAddress": - return ec.fieldContext_People_primaryEmailAddress(ctx, field) + return ec.fieldContext_Profile_fullName(ctx, field) + case "email_address": + return ec.fieldContext_Profile_email_address(ctx, field) case "additionalEmailAddresses": - return ec.fieldContext_People_additionalEmailAddresses(ctx, field) + return ec.fieldContext_Profile_additionalEmailAddresses(ctx, field) case "kind": - return ec.fieldContext_People_kind(ctx, field) + return ec.fieldContext_Profile_kind(ctx, field) case "position": - return ec.fieldContext_People_position(ctx, field) + return ec.fieldContext_Profile_position(ctx, field) case "contractStartDate": - return ec.fieldContext_People_contractStartDate(ctx, field) + return ec.fieldContext_Profile_contractStartDate(ctx, field) case "contractEndDate": - return ec.fieldContext_People_contractEndDate(ctx, field) + return ec.fieldContext_Profile_contractEndDate(ctx, field) case "createdAt": - return ec.fieldContext_People_createdAt(ctx, field) + return ec.fieldContext_Profile_createdAt(ctx, field) case "updatedAt": - return ec.fieldContext_People_updatedAt(ctx, field) + return ec.fieldContext_Profile_updatedAt(ctx, field) case "permission": - return ec.fieldContext_People_permission(ctx, field) + return ec.fieldContext_Profile_permission(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type People", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name) }, } return fc, nil @@ -44913,6 +45080,493 @@ func (ec *executionContext) fieldContext_ProcessingActivityEdge_node(_ context.C return fc, nil } +func (ec *executionContext) _Profile_id(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_id, + func(ctx context.Context) (any, error) { + return obj.ID, nil + }, + nil, + ec.marshalNID2goᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_fullName(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_fullName, + func(ctx context.Context) (any, error) { + return obj.FullName, nil + }, + nil, + ec.marshalNString2string, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_fullName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + 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 fc, nil +} + +func (ec *executionContext) _Profile_email_address(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_email_address, + func(ctx context.Context) (any, error) { + return obj.EmailAddress, nil + }, + nil, + ec.marshalNEmailAddr2goᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddr, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_email_address(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type EmailAddr does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_additionalEmailAddresses(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_additionalEmailAddresses, + func(ctx context.Context) (any, error) { + return obj.AdditionalEmailAddresses, nil + }, + nil, + ec.marshalNEmailAddr2ᚕgoᚗproboᚗincᚋproboᚋpkgᚋmailᚐAddrᚄ, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_additionalEmailAddresses(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type EmailAddr does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_kind(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_kind, + func(ctx context.Context) (any, error) { + return obj.Kind, nil + }, + nil, + ec.marshalNPeopleKind2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐPeopleKind, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type PeopleKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_position(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_position, + func(ctx context.Context) (any, error) { + return obj.Position, nil + }, + nil, + ec.marshalOString2ᚖstring, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Profile_position(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + 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 fc, nil +} + +func (ec *executionContext) _Profile_contractStartDate(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_contractStartDate, + func(ctx context.Context) (any, error) { + return obj.ContractStartDate, nil + }, + nil, + ec.marshalODatetime2ᚖtimeᚐTime, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Profile_contractStartDate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Datetime does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_contractEndDate(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_contractEndDate, + func(ctx context.Context) (any, error) { + return obj.ContractEndDate, nil + }, + nil, + ec.marshalODatetime2ᚖtimeᚐTime, + true, + false, + ) +} + +func (ec *executionContext) fieldContext_Profile_contractEndDate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Datetime does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_createdAt, + func(ctx context.Context) (any, error) { + return obj.CreatedAt, nil + }, + nil, + ec.marshalNDatetime2timeᚐTime, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Datetime does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_updatedAt(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_updatedAt, + func(ctx context.Context) (any, error) { + return obj.UpdatedAt, nil + }, + nil, + ec.marshalNDatetime2timeᚐTime, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Datetime does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Profile_permission(ctx context.Context, field graphql.CollectedField, obj *types.Profile) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_Profile_permission, + func(ctx context.Context) (any, error) { + fc := graphql.GetFieldContext(ctx) + return ec.resolvers.Profile().Permission(ctx, obj, fc.Args["action"].(string)) + }, + nil, + ec.marshalNBoolean2bool, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_Profile_permission(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Profile", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Profile_permission_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _ProfileConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.ProfileConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ProfileConnection_edges, + func(ctx context.Context) (any, error) { + return obj.Edges, nil + }, + nil, + ec.marshalNProfileEdge2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileEdgeᚄ, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ProfileConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ProfileConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_ProfileEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_ProfileEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ProfileEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ProfileConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *types.ProfileConnection) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ProfileConnection_pageInfo, + func(ctx context.Context) (any, error) { + return obj.PageInfo, nil + }, + nil, + ec.marshalNPageInfo2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPageInfo, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ProfileConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ProfileConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ProfileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *types.ProfileEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ProfileEdge_cursor, + func(ctx context.Context) (any, error) { + return obj.Cursor, nil + }, + nil, + ec.marshalNCursorKey2goᚗproboᚗincᚋproboᚋpkgᚋpageᚐCursorKey, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ProfileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ProfileEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type CursorKey does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ProfileEdge_node(ctx context.Context, field graphql.CollectedField, obj *types.ProfileEdge) (ret graphql.Marshaler) { + return graphql.ResolveField( + ctx, + ec.OperationContext, + field, + ec.fieldContext_ProfileEdge_node, + func(ctx context.Context) (any, error) { + return obj.Node, nil + }, + nil, + ec.marshalNProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfile, + true, + true, + ) +} + +func (ec *executionContext) fieldContext_ProfileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ProfileEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Profile_id(ctx, field) + case "fullName": + return ec.fieldContext_Profile_fullName(ctx, field) + case "email_address": + return ec.fieldContext_Profile_email_address(ctx, field) + case "additionalEmailAddresses": + return ec.fieldContext_Profile_additionalEmailAddresses(ctx, field) + case "kind": + return ec.fieldContext_Profile_kind(ctx, field) + case "position": + return ec.fieldContext_Profile_position(ctx, field) + case "contractStartDate": + return ec.fieldContext_Profile_contractStartDate(ctx, field) + case "contractEndDate": + return ec.fieldContext_Profile_contractEndDate(ctx, field) + case "createdAt": + return ec.fieldContext_Profile_createdAt(ctx, field) + case "updatedAt": + return ec.fieldContext_Profile_updatedAt(ctx, field) + case "permission": + return ec.fieldContext_Profile_permission(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _PublishDocumentVersionPayload_documentVersion(ctx context.Context, field graphql.CollectedField, obj *types.PublishDocumentVersionPayload) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -69265,6 +69919,13 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Report(ctx, sel, obj) + case types.Profile: + return ec._Profile(ctx, sel, &obj) + case *types.Profile: + if obj == nil { + return graphql.Null + } + return ec._Profile(ctx, sel, obj) case types.ProcessingActivity: return ec._ProcessingActivity(ctx, sel, &obj) case *types.ProcessingActivity: @@ -82117,6 +82778,205 @@ func (ec *executionContext) _ProcessingActivityEdge(ctx context.Context, sel ast return out } +var profileImplementors = []string{"Profile", "Node"} + +func (ec *executionContext) _Profile(ctx context.Context, sel ast.SelectionSet, obj *types.Profile) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, profileImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Profile") + case "id": + out.Values[i] = ec._Profile_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "fullName": + out.Values[i] = ec._Profile_fullName(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "email_address": + out.Values[i] = ec._Profile_email_address(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "additionalEmailAddresses": + out.Values[i] = ec._Profile_additionalEmailAddresses(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "kind": + out.Values[i] = ec._Profile_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "position": + out.Values[i] = ec._Profile_position(ctx, field, obj) + case "contractStartDate": + out.Values[i] = ec._Profile_contractStartDate(ctx, field, obj) + case "contractEndDate": + out.Values[i] = ec._Profile_contractEndDate(ctx, field, obj) + case "createdAt": + out.Values[i] = ec._Profile_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updatedAt": + out.Values[i] = ec._Profile_updatedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "permission": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Profile_permission(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var profileConnectionImplementors = []string{"ProfileConnection"} + +func (ec *executionContext) _ProfileConnection(ctx context.Context, sel ast.SelectionSet, obj *types.ProfileConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, profileConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ProfileConnection") + case "edges": + out.Values[i] = ec._ProfileConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._ProfileConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var profileEdgeImplementors = []string{"ProfileEdge"} + +func (ec *executionContext) _ProfileEdge(ctx context.Context, sel ast.SelectionSet, obj *types.ProfileEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, profileEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ProfileEdge") + case "cursor": + out.Values[i] = ec._ProfileEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._ProfileEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var publishDocumentVersionPayloadImplementors = []string{"PublishDocumentVersionPayload"} func (ec *executionContext) _PublishDocumentVersionPayload(ctx context.Context, sel ast.SelectionSet, obj *types.PublishDocumentVersionPayload) graphql.Marshaler { @@ -95230,50 +96090,6 @@ func (ec *executionContext) marshalNPeople2goᚗproboᚗincᚋproboᚋpkgᚋserv return ec._People(ctx, sel, &v) } -func (ec *executionContext) marshalNPeople2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeopleᚄ(ctx context.Context, sel ast.SelectionSet, v []*types.People) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNPeople2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeople(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - func (ec *executionContext) marshalNPeople2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeople(ctx context.Context, sel ast.SelectionSet, v *types.People) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -95672,6 +96488,114 @@ var ( } ) +func (ec *executionContext) marshalNProfile2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileᚄ(ctx context.Context, sel ast.SelectionSet, v []*types.Profile) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfile(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfile(ctx context.Context, sel ast.SelectionSet, v *types.Profile) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Profile(ctx, sel, v) +} + +func (ec *executionContext) marshalNProfileEdge2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*types.ProfileEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNProfileEdge2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNProfileEdge2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileEdge(ctx context.Context, sel ast.SelectionSet, v *types.ProfileEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._ProfileEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNPublishDocumentVersionInput2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPublishDocumentVersionInput(ctx context.Context, v any) (types.PublishDocumentVersionInput, error) { res, err := ec.unmarshalInputPublishDocumentVersionInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) diff --git a/pkg/server/api/console/v1/types/profile.go b/pkg/server/api/console/v1/types/profile.go new file mode 100644 index 000000000..cc15333d9 --- /dev/null +++ b/pkg/server/api/console/v1/types/profile.go @@ -0,0 +1,26 @@ +// Copyright (c) 2025 Probo Inc . +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +// PERFORMANCE OF THIS SOFTWARE. + +package types + +import "go.probo.inc/probo/pkg/coredata" + +func NewProfile(profile *coredata.MembershipProfile) *Profile { + return &Profile{ + ID: profile.ID, + FullName: profile.FullName, + CreatedAt: profile.CreatedAt, + UpdatedAt: profile.UpdatedAt, + } +} diff --git a/pkg/server/api/console/v1/types/types.go b/pkg/server/api/console/v1/types/types.go index 50dfee29c..3f248f1a1 100644 --- a/pkg/server/api/console/v1/types/types.go +++ b/pkg/server/api/console/v1/types/types.go @@ -1406,7 +1406,7 @@ type Meeting struct { Name string `json:"name"` Date time.Time `json:"date"` Minutes *string `json:"minutes,omitempty"` - Attendees []*People `json:"attendees"` + Attendees []*Profile `json:"attendees"` Organization *Organization `json:"organization"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` @@ -1612,6 +1612,33 @@ type ProcessingActivityFilter struct { SnapshotID *gid.GID `json:"snapshotId,omitempty"` } +type Profile struct { + ID gid.GID `json:"id"` + FullName string `json:"fullName"` + EmailAddress mail.Addr `json:"email_address"` + AdditionalEmailAddresses []mail.Addr `json:"additionalEmailAddresses"` + Kind coredata.PeopleKind `json:"kind"` + Position *string `json:"position,omitempty"` + ContractStartDate *time.Time `json:"contractStartDate,omitempty"` + ContractEndDate *time.Time `json:"contractEndDate,omitempty"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + Permission bool `json:"permission"` +} + +func (Profile) IsNode() {} +func (this Profile) GetID() gid.GID { return this.ID } + +type ProfileConnection struct { + Edges []*ProfileEdge `json:"edges"` + PageInfo *PageInfo `json:"pageInfo"` +} + +type ProfileEdge struct { + Cursor page.CursorKey `json:"cursor"` + Node *Profile `json:"node"` +} + type PublishDocumentVersionInput struct { DocumentID gid.GID `json:"documentId"` Changelog *string `json:"changelog,omitempty"` diff --git a/pkg/server/api/console/v1/v1_resolver.go b/pkg/server/api/console/v1/v1_resolver.go index f4fd7fe82..a0bcaf52e 100644 --- a/pkg/server/api/console/v1/v1_resolver.go +++ b/pkg/server/api/console/v1/v1_resolver.go @@ -1620,7 +1620,7 @@ func (r *measureConnectionResolver) TotalCount(ctx context.Context, obj *types.M } // Attendees is the resolver for the attendees field. -func (r *meetingResolver) Attendees(ctx context.Context, obj *types.Meeting) ([]*types.People, error) { +func (r *meetingResolver) Attendees(ctx context.Context, obj *types.Meeting) ([]*types.Profile, error) { // TODO bug must be paginated if err := r.authorize(ctx, obj.ID, probo.ActionPeopleList); err != nil { @@ -1636,12 +1636,12 @@ func (r *meetingResolver) Attendees(ctx context.Context, obj *types.Meeting) ([] } if len(attendees) == 0 { - return []*types.People{}, nil + return []*types.Profile{}, nil } - people := make([]*types.People, len(attendees)) + people := make([]*types.Profile, len(attendees)) for i, attendee := range attendees { - people[i] = types.NewPeople(attendee) + people[i] = types.NewProfile(attendee) } return people, nil @@ -6595,6 +6595,11 @@ func (r *processingActivityConnectionResolver) TotalCount(ctx context.Context, o panic(fmt.Errorf("unsupported resolver: %T", obj.Resolver)) } +// Permission is the resolver for the permission field. +func (r *profileResolver) Permission(ctx context.Context, obj *types.Profile, action string) (bool, error) { + panic(fmt.Errorf("not implemented: Permission - permission")) +} + // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) { var ( @@ -6613,15 +6618,6 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error } return types.NewOrganization(organization), nil } - case coredata.PeopleEntityType: - action = probo.ActionPeopleGet - loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { - people, err := prb.Peoples.Get(ctx, id) - if err != nil { - return nil, err - } - return types.NewPeople(people), nil - } case coredata.VendorEntityType: action = probo.ActionVendorGet loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) { @@ -8769,6 +8765,9 @@ func (r *Resolver) ProcessingActivityConnection() schema.ProcessingActivityConne return &processingActivityConnectionResolver{r} } +// Profile returns schema.ProfileResolver implementation. +func (r *Resolver) Profile() schema.ProfileResolver { return &profileResolver{r} } + // Query returns schema.QueryResolver implementation. func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} } @@ -8943,6 +8942,7 @@ type peopleResolver struct{ *Resolver } type peopleConnectionResolver struct{ *Resolver } type processingActivityResolver struct{ *Resolver } type processingActivityConnectionResolver struct{ *Resolver } +type profileResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type reportResolver struct{ *Resolver } type rightsRequestResolver struct{ *Resolver } diff --git a/pkg/trust/document_service.go b/pkg/trust/document_service.go index 5fcb6b0d9..d14b017e8 100644 --- a/pkg/trust/document_service.go +++ b/pkg/trust/document_service.go @@ -142,7 +142,7 @@ func (s *DocumentService) exportPDFData( ) ([]byte, error) { document := &coredata.Document{} version := &coredata.DocumentVersion{} - owner := &coredata.People{} + owner := &coredata.MembershipProfile{} organization := &coredata.Organization{} err := s.svc.pg.WithConn( @@ -161,7 +161,7 @@ func (s *DocumentService) exportPDFData( } if err := owner.LoadByID(ctx, conn, s.svc.scope, document.OwnerID); err != nil { - return fmt.Errorf("cannot load document owner: %w", err) + return fmt.Errorf("cannot load document owner profile: %w", err) } if err := organization.LoadByID(ctx, conn, s.svc.scope, document.OrganizationID); err != nil {