Add state to MCP profile and refactor contract filter
Add the profile state attribute (ACTIVE/INACTIVE) to the MCP Profile schema so listUsers and getUser tools expose it, and add a state filter to listUsers. Rename excludeContractEnded to contractEnded across the entire stack (MCP, GraphQL, CLI, frontend). The new boolean is two-way: true returns only users with ended contracts, false returns only users with active or no contract, and null returns all. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -65,7 +65,7 @@ enum ProfileOrderField
|
||||
}
|
||||
|
||||
input ProfileFilter {
|
||||
excludeContractEnded: Boolean
|
||||
contractEnded: Boolean
|
||||
state: ProfileState
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func (r *identityResolver) Profiles(ctx context.Context, obj *types.Identity, fi
|
||||
|
||||
filters := coredata.NewMembershipProfileFilter(nil).WithMembership()
|
||||
if filter != nil {
|
||||
filters = coredata.NewMembershipProfileFilter(filter.ExcludeContractEnded).WithMembership()
|
||||
filters = coredata.NewMembershipProfileFilter(filter.ContractEnded).WithMembership()
|
||||
if filter.State != nil {
|
||||
filters.WithState(*filter.State)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ input ProfileOrder
|
||||
}
|
||||
|
||||
input ProfileFilter {
|
||||
excludeContractEnded: Boolean
|
||||
contractEnded: Boolean
|
||||
}
|
||||
|
||||
type ProfileConnection
|
||||
|
||||
@@ -123,7 +123,7 @@ func (r *organizationResolver) Profiles(ctx context.Context, obj *types.Organiza
|
||||
|
||||
filters := coredata.NewMembershipProfileFilter(nil).WithMembership()
|
||||
if filter != nil {
|
||||
filters = coredata.NewMembershipProfileFilter(filter.ExcludeContractEnded).WithMembership()
|
||||
filters = coredata.NewMembershipProfileFilter(filter.ContractEnded).WithMembership()
|
||||
}
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.MembershipProfileOrderField]{
|
||||
|
||||
@@ -2491,7 +2491,10 @@ func (r *Resolver) ListUsersTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
|
||||
filter := coredata.NewMembershipProfileFilter(nil).WithMembership()
|
||||
if input.Filter != nil {
|
||||
filter = coredata.NewMembershipProfileFilter(input.Filter.ExcludeContractEnded).WithMembership()
|
||||
filter = coredata.NewMembershipProfileFilter(input.Filter.ContractEnded).WithMembership()
|
||||
if input.Filter.State != nil {
|
||||
filter.WithState(*input.Filter.State)
|
||||
}
|
||||
}
|
||||
|
||||
pageResult, err := r.iamSvc.OrganizationService.ListProfiles(ctx, input.OrganizationID, cursor, filter)
|
||||
|
||||
@@ -180,6 +180,13 @@ components:
|
||||
- AUDITOR
|
||||
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.MembershipRole
|
||||
|
||||
ProfileState:
|
||||
type: string
|
||||
enum:
|
||||
- ACTIVE
|
||||
- INACTIVE
|
||||
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.ProfileState
|
||||
|
||||
Profile:
|
||||
type: object
|
||||
required:
|
||||
@@ -189,6 +196,7 @@ components:
|
||||
- email_address
|
||||
- additional_email_addresses
|
||||
- kind
|
||||
- state
|
||||
- created_at
|
||||
- updated_at
|
||||
properties:
|
||||
@@ -214,6 +222,9 @@ components:
|
||||
- string
|
||||
- "null"
|
||||
description: Profile kind
|
||||
state:
|
||||
$ref: "#/components/schemas/ProfileState"
|
||||
description: Profile state (ACTIVE or INACTIVE)
|
||||
position:
|
||||
type:
|
||||
- string
|
||||
@@ -260,9 +271,12 @@ components:
|
||||
filter:
|
||||
type: object
|
||||
properties:
|
||||
exclude_contract_ended:
|
||||
contract_ended:
|
||||
type: boolean
|
||||
description: Exclude users with ended contracts
|
||||
description: Filter by contract status. True returns only users with ended contracts, false returns only users with active or no contract.
|
||||
state:
|
||||
$ref: "#/components/schemas/ProfileState"
|
||||
description: Filter by profile state (ACTIVE or INACTIVE)
|
||||
|
||||
ListUsersOutput:
|
||||
type: object
|
||||
|
||||
@@ -24,6 +24,7 @@ func NewProfile(p *coredata.MembershipProfile) *Profile {
|
||||
EmailAddress: p.EmailAddress,
|
||||
AdditionalEmailAddresses: p.AdditionalEmailAddresses,
|
||||
Kind: p.Kind,
|
||||
State: p.State,
|
||||
Position: p.Position,
|
||||
ContractStartDate: p.ContractStartDate,
|
||||
ContractEndDate: p.ContractEndDate,
|
||||
|
||||
Reference in New Issue
Block a user