import type { ObjectPreview } from '@/modules/previews/domain/types' import type { MaybeNullOrUndefined, Nullable, Optional, PartialBy } from '@speckle/shared' import type { Request, Response } from 'express' import { PreviewStatus } from '@/modules/previews/domain/consts' import type { Logger } from '@/observability/logging' import { PreviewResultPayload } from '@speckle/shared/workers/previews' export type GetObjectPreviewInfo = (params: { streamId: string objectId: string }) => Promise> export type GetPaginatedObjectPreviewsInErrorState = (params: { limit: number cursor?: MaybeNullOrUndefined }) => Promise<{ totalCount: number items: ObjectPreview[] cursor: string | null }> export type PaginatedObjectPreviewsParams = { limit: number cursor?: MaybeNullOrUndefined filter?: MaybeNullOrUndefined<{ status?: (typeof PreviewStatus)[keyof typeof PreviewStatus] maxNumberOfAttempts?: number }> } export type GetPaginatedObjectPreviewsPage = ( params: PaginatedObjectPreviewsParams ) => Promise<{ items: ObjectPreview[] cursor: string | null }> export type GetPaginatedObjectPreviewsTotalCount = ( params: Omit ) => Promise export type CreateObjectPreview = ( params: Pick ) => Promise export type ObjectPreviewInput = Pick< ObjectPreview, 'streamId' | 'objectId' | 'priority' > export type StoreObjectPreview = (params: ObjectPreviewInput) => Promise export type UpsertObjectPreview = (params: { objectPreview: PartialBy }) => Promise export type UpdateObjectPreview = (params: { objectPreview: PartialBy< Omit, 'preview' | 'priority' | 'previewStatus' > & { incrementAttempts?: boolean } }) => Promise export type ObjectPreviewRequest = { url: string token: string jobId: string } export type Preview = { id: string data: Buffer } export type StorePreview = (params: { preview: Preview }) => Promise export type RequestObjectPreview = (params: ObjectPreviewRequest) => Promise export type GetPreviewImage = (params: { previewId: string }) => Promise> export type GetObjectPreviewBufferOrFilepath = (params: { streamId: string objectId: string angle?: string }) => Promise< | { type: 'file' file: string error?: true errorCode?: string } | { type: 'buffer'; buffer: Buffer; error?: true; errorCode?: string } > export type SendObjectPreview = ( req: Request, res: Response, streamId: string, objectId: string, angle?: string ) => Promise export type CheckStreamPermissions = ( req: Request ) => Promise<{ hasPermissions: boolean; httpErrorCode: number }> export type ConsumePreviewResult = ({ projectId, objectId, previewResult }: { projectId: string objectId: string previewResult: PreviewResultPayload }) => Promise export type BuildConsumePreviewResult = (deps: { logger: Logger projectId: string }) => Promise export type BuildUpdateObjectPreview = (params: { projectId: string }) => Promise export type ObserveMetrics = (params: { payload: PreviewResultPayload }) => void