// How the CLI presents a file's identity in `files`, `get`, and `get-thumb`. // // These read the file's own decrypted metadata — the raw title and the // creationTime in microseconds — rather than the `PhotoRecord` projection the // rest of the library exposes. The projection prefers `editedName`/`editedTime` // and reports time in milliseconds, which is right for a photo browser but // would change the CLI's externally-visible output. The pre-library CLI printed // `metadata.title` and `metadata.creationTime` and named downloads after // `metadata.title`, and issue #52 requires that output stay byte-identical, so // the commands shape their output from the raw `EnteFile` through here. import type { EnteFile, FileType, Microseconds } from "./model/types.js"; // One row of `quak files --json`. export interface FileListRow { id: number; title: string; fileType: FileType; creationTime: Microseconds; collectionID: number; } export const fileListRow = (file: EnteFile): FileListRow => ({ id: file.id, title: file.metadata.title, fileType: file.metadata.fileType, creationTime: file.metadata.creationTime, collectionID: file.collectionID, }); // One line of `quak files` in its human, tab-separated form. export const fileListLine = (file: EnteFile): string => `${file.id}\t${file.metadata.fileType}\t${file.metadata.title}`; // Default output path for `quak get` when `--out` is not given. export const originalName = (file: EnteFile): string => file.metadata.title; // Default output path for `quak get-thumb` when `--out` is not given. export const thumbnailName = (file: EnteFile): string => `thumb_${file.metadata.title}`;