import { UserWithOptionalRole } from '@/modules/core/repositories/users' import { ExtendedInvite, InviteResourceTarget, InviteResourceTargetType, PrimaryInviteResourceTarget, ProjectInviteResourceTarget, ServerInviteRecord } from '@/modules/serverinvites/domain/types' import { ServerInviteResourceFilter } from '@/modules/serverinvites/repositories/serverInvites' import { WorkspaceInviteResourceType } from '@/modules/workspacesCore/domain/constants' /** * Then looking for Workspace target invites, we also return workspace project invites, which are implicitly * workspace invites */ type ImplicitTarget = Target['resourceType'] extends typeof WorkspaceInviteResourceType ? Target | ProjectInviteResourceTarget : Target 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 = < Target extends InviteResourceTarget = InviteResourceTarget >(params: { userId: string resourceType: Target['resourceType'] }) => Promise>[]> export type QueryAllResourceInvites = < Target extends InviteResourceTarget = InviteResourceTarget >( filter: Pick & { search?: string } ) => Promise>[]> /** * Only deletes explicit invites */ export type DeleteAllResourceInvites = < Target extends InviteResourceTarget = InviteResourceTarget >( filter: Pick ) => Promise export type FindInvite = < Target extends InviteResourceTarget = InviteResourceTarget >(params: { inviteId?: string token?: string target?: string resourceFilter?: ServerInviteResourceFilter }) => Promise> | null> export type FindInviteByToken = (params: { token: string }) => Promise export type DeleteInvite = (inviteId?: string) => Promise /** * Only deletes explicit invites */ 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