UNPKG

@tochii/vscode-file-recovery

Version:

Recover files and full project structures in bulk from VS Code's local history

152 lines (129 loc) 3.78 kB
// ---- index.d.mts ---- declare const defaultVsCodeFileRecoveryOptions: Required<VsCodeFileRecoveryOptions> & { rootDir: string; outDirName: string; }; declare function vscodeFileRecovery(search: string, options?: VsCodeFileRecoveryOptions, loggerOptions?: LoggerOptions<TransportOptions>): void; export { vscodeFileRecovery as default, defaultVsCodeFileRecoveryOptions, vscodeFileRecovery }; // ---- types.d.ts ---- /** * Represents a single version entry of a file in VS Code's local history. */ interface Entry { /** * Unique ID for the history entry. */ id: string; /** * Timestamp (in milliseconds) when the entry was created. */ timestamp: number; } /** * Metadata for a file's full history as tracked by VS Code. */ interface HistoryMetadata { /** * Metadata version (used by VS Code to manage structure). */ version: number; /** * URI or absolute path to the original file. */ resource: string; /** * List of version entries for the file. */ entries: Entry[]; } /** * Represents a parsed and formatted date range, useful for filtering. */ interface DateRange { /** * Formatted string representations of the start and end dates. */ formatted: [string, string]; /** * Start and end times in milliseconds since the Unix epoch. */ milliseconds: [number, number]; /** * Start and end as actual Date objects. */ date: [Date, Date]; } /** * A flexible value type for defining a time boundary. * Can be a timestamp, date string, Date object, or null. */ type TimeRangeValue = number | string | Date | null; /** * A tuple representing a time range, with a start and end value. */ type TimeRange = [TimeRangeValue, TimeRangeValue]; /** * Configuration options for the file recovery process. */ interface VsCodeFileRecoveryOptions { /** * Whether to clean the output directory before running. * * @default false */ clean?: boolean; /** * Date format to use when renaming recovered files. * Uses Luxon's format string. * * @default "yyyy LLL dd, hh:mm a" */ dateFormat?: string; /** * Time range for filtering which file versions to recover. * Format: [startDate, endDate], where either value can be null. * Dates can be passed as any compatible JavaScript Date input (eg. ISO strings), and they will be parsed as dates. * When no range is provided, the latest version will be recovered. * * @default [null, null] */ range?: TimeRange; /** * List of paths or directories to skip during recovery. * These are merged with some default internal skip paths. * * @default ["node_modules", outDirName] */ skip?: string[]; /** * Custom output directory for recovered files. * If relative, it's resolved against the root directory. * * @default "<rootDir>/vscode-file-recovery" */ outDir?: string; /** * The root directory of your project * * @default "resolve(process.cwd(), '.')" */ rootDir?: string; /** * The name of the output directory * * @default "vscode-file-recovery" */ outDirName?: string; /** * Custom path to the VS Code Local History directory. * * @default "<AppData>/Code/User/History" */ localHistoryDir?: string; /** * Whether to enable logging and which level * * @default `trace` */ verbose?: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'off'; }