Stop using coredata.People except for people service and people page resolvers
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
26
pkg/server/api/console/v1/types/profile.go
Normal file
26
pkg/server/api/console/v1/types/profile.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package 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,
|
||||
}
|
||||
}
|
||||
@@ -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"`
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user