c6cd4c311d
* chore(serverinvites): repository refactor for multiregion * chore(serverinvites): remove migrated functions from old repository * chore(serverinvites): refactor serverInviteForToken resolver for multiregion * chore(serverinvites): invite processing service refactor for multiregion * chore(serverinvites): subscription refactor for multiregion * chore(serverinvites): move buildEmailContents to dedicated file * chore(serverinvites): deleteAllStreamInvites function multiregion refactor * chore(serverinvites): refactor deleteServerOnlyInvites multiregion repository * chore(serverinvites): complete repository refactor for multiregion * feat(serverinvites): create domain module in server invites * fix(serverinvites): no relative imports * feat(serverinvites): extract individual types from repository * feat(serverinvites): move interfaces to operations * fix(serverinvites): update imports referencing old interfaces file * fix(serverinvites): type mismatch for insert invite and delete old * chore(serverinvites): refactor to single repo function * test(serverinvites): fix tests * fix(serverinvites): use domain types in all places * feat(serverinvites): WIP unity * feat(serverinvites): move to new facory names and types * feat(serverinvites): fix tests * fix(serverinvites): use factory name --------- Co-authored-by: Alessandro Magionami <alessandro.magionami@gmail.com>
115 lines
3.0 KiB
TypeScript
115 lines
3.0 KiB
TypeScript
import { ServerRoles, StreamRoles } from '@speckle/shared'
|
|
import { UserWithOptionalRole } from '@/modules/core/repositories/users'
|
|
import { ResourceTargets } from '@/modules/serverinvites/helpers/inviteHelper'
|
|
import {
|
|
ServerInviteRecord,
|
|
StreamInviteRecord
|
|
} from '@/modules/serverinvites/domain/types'
|
|
import { StreamWithOptionalRole } from '@/modules/core/repositories/streams'
|
|
|
|
export type QueryAllUserStreamInvites = (
|
|
userId: string
|
|
) => Promise<StreamInviteRecord[]>
|
|
|
|
type FindStreamInviteArgs = {
|
|
target?: string | null
|
|
token?: string | null
|
|
inviteId?: string | null
|
|
}
|
|
|
|
export type FindStreamInvite = (
|
|
streamId: string,
|
|
args: FindStreamInviteArgs
|
|
) => Promise<StreamInviteRecord | null>
|
|
|
|
export type FindUserByTarget = (target: string) => Promise<UserWithOptionalRole | null>
|
|
|
|
type Invite = {
|
|
resourceId?: string | null
|
|
resourceTarget?: typeof ResourceTargets.Streams | null
|
|
}
|
|
|
|
export type FindResource = (
|
|
args: Invite
|
|
) => Promise<StreamWithOptionalRole | undefined | null>
|
|
|
|
type ServerInviteRecordInsertModel = Pick<
|
|
ServerInviteRecord,
|
|
| 'id'
|
|
| 'target'
|
|
| 'inviterId'
|
|
| 'message'
|
|
| 'resourceTarget'
|
|
| 'resourceId'
|
|
| 'role'
|
|
| 'token'
|
|
| 'serverRole'
|
|
>
|
|
|
|
export type InsertInviteAndDeleteOld = (
|
|
invite: ServerInviteRecordInsertModel,
|
|
alternateTargets: string[]
|
|
) => Promise<number[]>
|
|
|
|
export type FindServerInvite = (
|
|
email?: string,
|
|
token?: string
|
|
) => Promise<ServerInviteRecord | null>
|
|
|
|
export type QueryAllStreamInvites = (streamId: string) => Promise<StreamInviteRecord[]>
|
|
|
|
export type DeleteAllStreamInvites = (streamId: string) => Promise<boolean>
|
|
|
|
export type DeleteServerOnlyInvites = (email?: string) => Promise<number | undefined>
|
|
|
|
export type UpdateAllInviteTargets = (
|
|
oldTargets?: string | string[],
|
|
newTarget?: string
|
|
) => Promise<void>
|
|
|
|
export type DeleteStreamInvite = (inviteId?: string) => Promise<number | undefined>
|
|
|
|
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 FindInvite = (inviteId?: string) => Promise<ServerInviteRecord | null>
|
|
|
|
export type DeleteInvite = (inviteId?: string) => Promise<boolean>
|
|
|
|
export type DeleteInvitesByTarget = (
|
|
targets?: string | string[],
|
|
resourceTarget?: string,
|
|
resourceId?: string
|
|
) => Promise<boolean>
|
|
|
|
export type QueryInvites = (
|
|
inviteIds?: readonly string[]
|
|
) => Promise<ServerInviteRecord[]>
|
|
|
|
export type DeleteAllUserInvites = (userId: string) => Promise<boolean>
|
|
|
|
export type FindInviteByToken = (
|
|
inviteToken?: string
|
|
) => Promise<ServerInviteRecord | null>
|
|
|
|
export type CreateInviteParams = {
|
|
target: string
|
|
inviterId: string
|
|
message?: string | null
|
|
resourceTarget?: typeof ResourceTargets.Streams
|
|
resourceId?: string
|
|
role?: StreamRoles
|
|
serverRole?: ServerRoles | null
|
|
}
|