import { UserWithOptionalRole } from '@/modules/core/repositories/users' import { InviteResourceTarget, InviteResourceTargetType, PrimaryInviteResourceTarget, ServerInviteRecord } from '@/modules/serverinvites/domain/types' import { ServerInviteResourceFilter } from '@/modules/serverinvites/repositories/serverInvites' export type FindUserByTarget = (target: string) => Promise export type ServerInviteRecordInsertModel = Omit< ServerInviteRecord, 'createdAt' | 'updatedAt' > export type InsertInviteAndDeleteOld = ( invite: ServerInviteRecordInsertModel, alternateTargets?: string[] ) => Promise<{ deleted: number; invite: ServerInviteRecord }> export type FindServerInvite = ( email?: string, token?: string ) => Promise export type DeleteServerOnlyInvites = (email?: string) => Promise export type UpdateAllInviteTargets = ( oldTargets?: string | string[], newTarget?: string ) => Promise export type CountServerInvites = (searchQuery: string | null) => Promise export type FindServerInvites = ( searchQuery: string | null, limit: number, offset: number ) => Promise export type QueryServerInvites = ( searchQuery: string | null, limit: number, cursor: Date | null ) => Promise export type QueryAllUserResourceInvites = < TargetType extends InviteResourceTargetType = InviteResourceTargetType, RoleType extends string = string >(params: { userId: string resourceType: TargetType }) => Promise>[]> export type QueryAllResourceInvites = < TargetType extends InviteResourceTargetType = InviteResourceTargetType, RoleType extends string = string >( filter: Pick< InviteResourceTarget, 'resourceId' | 'resourceType' > & { search?: string } ) => Promise>[]> export type DeleteAllResourceInvites = < TargetType extends InviteResourceTargetType = InviteResourceTargetType, RoleType extends string = string >( filter: Pick< InviteResourceTarget, 'resourceId' | 'resourceType' > ) => Promise export type FindInvite = < TargetType extends InviteResourceTargetType = InviteResourceTargetType, RoleType extends string = string >(params: { inviteId?: string token?: string target?: string resourceFilter?: ServerInviteResourceFilter }) => Promise> | null> export type FindInviteByToken = (params: { token: string }) => Promise export type DeleteInvite = (inviteId?: string) => Promise export type DeleteInvitesByTarget = ( targets: string | string[], resourceType: InviteResourceTargetType, resourceId: string ) => Promise export type QueryInvites = ( inviteIds?: readonly string[] ) => Promise export type DeleteAllUserInvites = (userId: string) => Promise export type CreateInviteParams = { target: string inviterId: string message?: string | null primaryResourceTarget: PrimaryInviteResourceTarget } export type MarkInviteUpdated = (params: { inviteId: string }) => Promise