SPB Git

Repository Public

types.ts 4.5 KB 45 lines typescript

1// Shapes returned by the API (see services/api/src). Keep in step with the server serialisers.2import type { PreviewKind, RequestFields } from '@spd/shared';34export interface User { id: string; email: string; display_name: string; role: 'admin' | 'user'; locale: string }5export interface AuthState { authenticated: boolean; recovery?: boolean; user?: User; quota?: { limit: number; used: number }; freshAuth?: boolean }6export interface Folder { id: string; type: 'folder'; name: string; parentId: string | null; starred: boolean; createdAt: string; updatedAt: string; trashedAt: string | null }7export interface FileItem {8  id: string; type: 'file'; name: string; folderId: string; size: number; sha256: string; kind: PreviewKind; origin: 'upload' | 'request' | 'copy'; starred: boolean;9  createdAt: string; updatedAt: string; trashedAt: string | null; scan: 'pending' | 'clean' | 'infected' | 'error'; thumb: boolean; tagIds: string[]; versions: number;10}11export type Item = Folder | FileItem;12export interface Crumb { id: string; name: string }13export interface Listing { folder?: Folder; breadcrumbs?: Crumb[]; folders: Folder[]; files: FileItem[] }14export interface Version { id: string; seq: number; size: number; sha256: string; createdAt: string; note: string; current: boolean }15export interface FileDetail { file: FileItem; path: Crumb[]; shares: number; versions: Version[]; previews: Record<string, 'pending' | 'ready' | 'failed' | 'unsupported'> }16export interface Tag { id: string; name: string; color: string; files: number }17export interface UploadState { id: string; name: string; size: number; received: number; status: 'active' | 'completing' | 'done' | 'aborted'; fileId: string | null }18export interface Share {19  id: string; type: 'file' | 'folder'; targetId: string; targetName: string; label: string; canDownload: boolean; hasPassword: boolean; expiresAt: string | null;20  maxViews: number | null; viewCount: number; maxDownloads: number | null; downloadCount: number; singleUse: boolean; revokedAt: string | null; createdAt: string; lastAccessAt: string | null;21  status: 'active' | 'revoked' | 'expired' | 'exhausted' | 'target_missing';22}23export interface ShareEvent { id: string; at: string; kind: 'open' | 'password' | 'download'; ok: boolean; ip: string; userAgent: string; detail: string }24export interface Portal {25  id: string; folderId: string; folderName?: string; title: string; description: string; instructions: string; confirmationMessage: string; brandName: string; brandColor: string; hasPassword: boolean;26  expiresAt: string | null; active: boolean; revokedAt: string | null; maxFileBytes: number; maxTotalBytes: number; maxFilesPerSubmission: number; maxSubmissions: number | null; submissionsPerHour: number;27  allowedExtensions: string[]; fields: RequestFields; requireConsent: boolean; consentText: string; retentionNote: string; subfolderPerSubmission: boolean; notifyOwner: boolean;28  bytesReceived: number; submissions: number; createdAt: string; state: 'open' | 'paused' | 'revoked' | 'expired' | 'full' | 'target_missing';29}30export interface Submission { id: string; ref: string; status: 'open' | 'processing' | 'completed' | 'rejected' | 'expired'; name: string; email: string; reference: string; createdAt: string; completedAt: string | null; folderId: string | null; files: number; placed: number; rejected: number; bytes: number }31export interface SubmissionDetail extends Omit<Submission, 'files' | 'placed' | 'rejected' | 'bytes'> {32  requestId: string; meta: Record<string, string>; consentAt: string | null; ip: string; userAgent: string;33  items: { id: string; name: string; originalName: string; size: number; sha256: string | null; mime: string | null; status: 'uploading' | 'quarantined' | 'placed' | 'rejected'; rejectCode: string | null; fileId: string | null }[];34  events: { id: string; at: string; action: string; meta: Record<string, unknown> }[];35}36export interface Notification { id: string; kind: string; data: Record<string, any>; read: boolean; createdAt: string }37/** What the preview viewer needs to show one file, whoever serves it (owner API or a public share). */38export interface PreviewSource {39  id: string; name: string; size: number; kind: PreviewKind; canDownload: boolean;40  /** Original bytes. `text` asks for a text/plain answer; `download` for an attachment. */41  contentUrl(o?: { download?: boolean; text?: boolean }): string;42  /** Derived preview: 'thumb' | 'image' (HEIC as JPEG) | 'pdf' (office document as PDF) | 'sheet' | 'archive' (JSON). 202 = not ready yet, 422 = failed. */43  previewUrl(kind: 'thumb' | 'image' | 'pdf' | 'sheet' | 'archive'): string;44}45
Files main
Menu

Theme