ede566eed9
* prep for new resources algo * typescriptifying stuff * minor types fix * migrate to resources col * repo & creation updated, WIP processing/retrieval * WIP invite processing * finished finalization refactor * project invite management * transformed all invites services * fixed up projects & core serverinvites resolvers * test fixes * WIP workspace create GQL & test * basic invite creation test works * a buncha working tests * more tests * cancelation tests * minor invite use refactor * invite retrieval tasks * invite use() works as expected * filtering out broken invites * enabled invite retrieval by token irregardless of who is it for * minor adjustments * tests fix * test config improvements * test env adjustment * extra test case * making resource access limits harder to ignore * linter fixes * eventBus type cleanup * better generic names * refactored serverinvites resource migration * fix(server): better error message in project invite edge case
106 lines
3.1 KiB
TypeScript
106 lines
3.1 KiB
TypeScript
import { UserWithOptionalRole } from '@/modules/core/repositories/users'
|
|
import {
|
|
InviteResourceTarget,
|
|
InviteResourceTargetType,
|
|
ServerInviteRecord
|
|
} from '@/modules/serverinvites/domain/types'
|
|
import { ServerInviteResourceFilter } from '@/modules/serverinvites/repositories/serverInvites'
|
|
|
|
export type FindUserByTarget = (target: string) => Promise<UserWithOptionalRole | null>
|
|
|
|
export type ServerInviteRecordInsertModel = Omit<ServerInviteRecord, 'createdAt'>
|
|
|
|
export type InsertInviteAndDeleteOld = (
|
|
invite: ServerInviteRecordInsertModel,
|
|
alternateTargets?: string[]
|
|
) => Promise<{ deleted: number; invite: ServerInviteRecord }>
|
|
|
|
export type FindServerInvite = (
|
|
email?: string,
|
|
token?: string
|
|
) => Promise<ServerInviteRecord | null>
|
|
|
|
export type DeleteServerOnlyInvites = (email?: string) => Promise<number | undefined>
|
|
|
|
export type UpdateAllInviteTargets = (
|
|
oldTargets?: string | string[],
|
|
newTarget?: string
|
|
) => Promise<void>
|
|
|
|
export type CountServerInvites = (searchQuery: string | null) => Promise<number>
|
|
|
|
export type FindServerInvites = (
|
|
searchQuery: string | null,
|
|
limit: number,
|
|
offset: number
|
|
) => Promise<ServerInviteRecord[]>
|
|
|
|
export type QueryServerInvites = (
|
|
searchQuery: string | null,
|
|
limit: number,
|
|
cursor: Date | null
|
|
) => Promise<ServerInviteRecord[]>
|
|
|
|
export type QueryAllUserResourceInvites = <
|
|
TargetType extends InviteResourceTargetType = InviteResourceTargetType,
|
|
RoleType extends string = string
|
|
>(params: {
|
|
userId: string
|
|
resourceType: TargetType
|
|
}) => Promise<ServerInviteRecord<InviteResourceTarget<TargetType, RoleType>>[]>
|
|
|
|
export type QueryAllResourceInvites = <
|
|
TargetType extends InviteResourceTargetType = InviteResourceTargetType,
|
|
RoleType extends string = string
|
|
>(
|
|
filter: Pick<
|
|
InviteResourceTarget<TargetType, RoleType>,
|
|
'resourceId' | 'resourceType'
|
|
>
|
|
) => Promise<ServerInviteRecord<InviteResourceTarget<TargetType, RoleType>>[]>
|
|
|
|
export type DeleteAllResourceInvites = <
|
|
TargetType extends InviteResourceTargetType = InviteResourceTargetType,
|
|
RoleType extends string = string
|
|
>(
|
|
filter: Pick<
|
|
InviteResourceTarget<TargetType, RoleType>,
|
|
'resourceId' | 'resourceType'
|
|
>
|
|
) => Promise<boolean>
|
|
|
|
export type FindInvite = <
|
|
TargetType extends InviteResourceTargetType = InviteResourceTargetType,
|
|
RoleType extends string = string
|
|
>(params: {
|
|
inviteId?: string
|
|
token?: string
|
|
target?: string
|
|
resourceFilter?: ServerInviteResourceFilter<TargetType, RoleType>
|
|
}) => Promise<ServerInviteRecord<InviteResourceTarget<TargetType, RoleType>> | null>
|
|
|
|
export type FindInviteByToken = (params: {
|
|
token: string
|
|
}) => Promise<ServerInviteRecord | null>
|
|
|
|
export type DeleteInvite = (inviteId?: string) => Promise<boolean>
|
|
|
|
export type DeleteInvitesByTarget = (
|
|
targets: string | string[],
|
|
resourceType: InviteResourceTargetType,
|
|
resourceId: string
|
|
) => Promise<boolean>
|
|
|
|
export type QueryInvites = (
|
|
inviteIds?: readonly string[]
|
|
) => Promise<ServerInviteRecord[]>
|
|
|
|
export type DeleteAllUserInvites = (userId: string) => Promise<boolean>
|
|
|
|
export type CreateInviteParams = {
|
|
target: string
|
|
inviterId: string
|
|
message?: string | null
|
|
primaryResourceTarget: InviteResourceTarget
|
|
}
|