import { ExtendedComment, ResourceIdentifier, ViewerResourceGroup, ViewerResourceItem } from '@/modules/comments/domain/types' import { CommentLinkRecord, CommentRecord, CommentViewRecord } from '@/modules/comments/helpers/types' import { BranchLatestCommit } from '@/modules/core/domain/commits/types' import { CreateCommentInput, CreateCommentReplyInput, EditCommentInput, LegacyCommentViewerData, ViewerUpdateTrackingTarget } from '@/modules/core/graph/generated/graphql' import { SmartTextEditorValueSchema } from '@/modules/core/services/richTextEditorService' import { BatchedSelectOptions } from '@/modules/shared/helpers/dbHelper' import { MarkNullableOptional, Optional } from '@/modules/shared/helpers/typeHelper' import { MaybeNullOrUndefined, SpeckleViewer } from '@speckle/shared' import { Knex } from 'knex' import { Merge } from 'type-fest' type SerializedViewerState = SpeckleViewer.ViewerState.SerializedViewerState type GetBatchedStreamCommentsOptions = BatchedSelectOptions & { /** * Filter out comments with parent comment references * Defaults to: false */ withoutParentCommentOnly: boolean /** * Filter out comments without parent comment references * Defaults to: false */ withParentCommentOnly: boolean } export type GetBatchedStreamComments = ( streamId: string, options?: Partial ) => AsyncGenerator export type GetCommentLinks = ( commentIds: string[], options?: Partial<{ trx: Knex.Transaction }> ) => Promise export type GetComment = (params: { id: string userId?: string }) => Promise> export type GetComments = (params: { ids: string[] }) => Promise export type CheckStreamResourceAccess = ( res: ResourceIdentifier, streamId: string ) => Promise export type InsertCommentPayload = MarkNullableOptional< Omit & { text: SmartTextEditorValueSchema archived?: boolean id?: string createdAt?: Date updatedAt?: Date } > export type InsertComments = ( comments: InsertCommentPayload[], options?: Partial<{ trx: Knex.Transaction }> ) => Promise export type InsertCommentLinks = ( commentLinks: CommentLinkRecord[], options?: Partial<{ trx: Knex.Transaction }> ) => Promise export type DeleteComment = (params: { commentId: string }) => Promise export type MarkCommentViewed = (commentId: string, userId: string) => Promise export type UpdateComment = ( id: string, input: Merge, { text?: SmartTextEditorValueSchema }> ) => Promise> export type MarkCommentUpdated = (commentId: string) => Promise export type GetCommentsResources = (commentIds: string[]) => Promise<{ [commentId: string]: { commentId: string resources: ResourceIdentifier[] } }> export type GetPaginatedCommitCommentsPage = ( params: PaginatedCommitCommentsParams ) => Promise<{ items: CommentRecord[] cursor: string | null }> export type GetPaginatedCommitCommentsTotalCount = ( params: Omit ) => Promise export type GetPaginatedBranchCommentsPage = ( params: PaginatedBranchCommentsParams ) => Promise<{ items: CommentRecord[] cursor: string | null }> export type GetPaginatedBranchCommentsTotalCount = ( params: Omit ) => Promise export type GetPaginatedProjectCommentsPage = ( params: PaginatedProjectCommentsParams, options?: { preloadedModelLatestVersions?: BranchLatestCommit[] } ) => Promise<{ items: CommentRecord[] cursor: string | null }> export type GetPaginatedProjectCommentsTotalCount = ( params: Omit, options?: { preloadedModelLatestVersions?: BranchLatestCommit[] } ) => Promise export type GetUserCommentsViewedAt = ( commentIds: string[], userId: string ) => Promise export type GetCommitCommentCounts = ( commitIds: string[], options?: Partial<{ threadsOnly: boolean includeArchived: boolean }> ) => Promise< { commitId: string count: number }[] > export type GetBranchCommentCounts = ( branchIds: string[], options?: Partial<{ threadsOnly: boolean includeArchived: boolean }> ) => Promise< { count: number id: string }[] > export type GetCommentReplyCounts = ( threadIds: string[], options?: Partial<{ includeArchived: boolean }> ) => Promise< { threadId: string count: number }[] > export type GetCommentReplyAuthorIds = ( threadIds: string[], options?: Partial<{ includeArchived: boolean }> ) => Promise<{ [parentCommentId: string]: string[] }> export type GetCommentParents = (replyIds: string[]) => Promise< (CommentRecord & { replyId: string })[] > export type ResolvePaginatedProjectCommentsLatestModelResources = ( resourceIdString: string | null | undefined ) => Promise export type CheckStreamResourcesAccess = (params: { streamId: string resources: ResourceIdentifier[] }) => Promise export type ValidateInputAttachments = ( streamId: string, blobIds: string[] ) => Promise export type GetViewerResourcesForComments = ( projectId: string, commentIds: string[] ) => Promise export type GetViewerResourcesForComment = ( projectId: string, commentId: string ) => Promise export type GetViewerResourcesFromLegacyIdentifiers = ( projectId: string, resources: Array ) => Promise export type GetViewerResourceGroups = ( target: ViewerUpdateTrackingTarget ) => Promise export type GetViewerResourceItemsUngrouped = ( target: ViewerUpdateTrackingTarget ) => Promise export type ConvertLegacyDataToState = ( data: Partial, comment: CommentRecord ) => Promise export type CreateCommentThreadAndNotify = ( input: CreateCommentInput, userId: string, options?: Partial<{ /** * Used in tests: Override createdAt date */ createdAt: Date }> ) => Promise export type CreateCommentReplyAndNotify = ( input: CreateCommentReplyInput, userId: string ) => Promise export type EditCommentAndNotify = ( input: EditCommentInput, userId: string ) => Promise> export type ArchiveCommentAndNotify = ( commentId: string, userId: string, archived?: boolean ) => Promise> export type PaginatedCommitCommentsParams = { commitId: string limit: number cursor?: MaybeNullOrUndefined filter?: MaybeNullOrUndefined<{ threadsOnly: boolean includeArchived: boolean }> } export type GetPaginatedCommitComments = ( params: PaginatedCommitCommentsParams ) => Promise<{ totalCount: number items: CommentRecord[] cursor: string | null }> export type PaginatedBranchCommentsParams = { branchId: string limit: number cursor?: MaybeNullOrUndefined filter?: MaybeNullOrUndefined<{ threadsOnly: boolean includeArchived: boolean }> } export type GetPaginatedBranchCommentsFactory = ( params: PaginatedBranchCommentsParams ) => Promise<{ totalCount: number items: CommentRecord[] cursor: string | null }> export type PaginatedProjectCommentsParams = { projectId: string limit?: MaybeNullOrUndefined cursor?: MaybeNullOrUndefined filter?: MaybeNullOrUndefined< Partial<{ threadsOnly: boolean | null includeArchived: boolean | null archivedOnly: boolean | null resourceIdString: string | null /** * If true, will ignore the version parts of `model@version` identifiers and look for comments of * all versions of any selected comments */ allModelVersions: boolean | null }> > } export type GetPaginatedProjectComments = ( params: PaginatedProjectCommentsParams ) => Promise<{ totalCount: number totalArchivedCount: number items: CommentRecord[] cursor: string | null }> export type GetStreamCommentCount = ( streamId: string, options?: Partial<{ threadsOnly: boolean; includeArchived: boolean }> ) => Promise