import type { Id, Disposable, Emitter } from "@codesandbox/pitcher-common"; import type { fs as fsProtocol, PitcherRequest, PitcherResponse, PitcherResponseStatus } from "@codesandbox/pitcher-protocol"; import type { MemoryFS } from "../../common/MemoryFS"; import type { AbsoluteWorkspacePath, RawFsResult, RelativeWorkspacePath } from "../../types"; export type PickRawFsResult = RawFsResult["result"]>; export interface FSSyncEvent { opCount: number; } export interface FSErrorEvent { message: string; } export interface IFSClient { memoryFS: MemoryFS; onFSError: Emitter["event"]; onFSSync: Emitter["event"]; onPendingOperationsChange: Emitter["event"]; readyPromise: Promise; /** * When you have a path you know is relative, but you want to to ensure the correct format with * prefixed "/" and type safety */ asRelativeWorkspacePath(path: string): RelativeWorkspacePath; /** * When you know you have an absolute path, but want to ensure it to be this users workspace and have type safety */ asAbsoluteWorkspacePath(path: string): AbsoluteWorkspacePath; /** * When you have a type safe absolute path and want to make it relative */ absoluteToRelativeWorkspacePath(path: AbsoluteWorkspacePath): RelativeWorkspacePath; /** * When you have a tpe safe relative path and want to make it absolute to this users workspace path */ relativeToAbsoluteWorkspacePath(path: RelativeWorkspacePath): AbsoluteWorkspacePath; resolveRelativeWorkspacePath(path: string): RelativeWorkspacePath; resolveAbsoluteWorkspacePath(path: string): AbsoluteWorkspacePath; resync(): Promise; /** * Create a file with the provided name within the directory of the given * parent id. * */ createFile(name: string, parentId: Id): Promise<{ id: Id; filepath: string; }>; isFile(id: Id): boolean; /** * Create a directory with the provided name within the directory of the * given parent id. * */ createDirectory(name: string, parentId: Id): Id; /** * delete a node from the FS * */ deleteNode(id: Id): void; /** * rename a node from the FS * */ move(id: Id, opts: { newName?: string; newParentId?: Id; }): void; /** * Searches for a string literal within the files of a workspace. * Doesn't search the contents of gitignored files. */ search(params: fsProtocol.FSSearchParams): Promise; /** * Searches for a string literal within the files of a workspace. * Doesn't search the contents of gitignored files. * @returns true if there are more results */ streamingSearch(params: fsProtocol.FSSearchParams, onMatches: (matches: fsProtocol.StreamingSearchResult[]) => void, abort: Disposable): Promise<{ hitLimit: boolean; }>; /** * Searches for a filepath within the project * Query can be a literal string or a unix-like pattern e.g. *.test.ts */ pathSearch(params: fsProtocol.PathSearchParams): Promise; uploadFile(name: string, content: Uint8Array, parentId: Id): Promise<{ id: Id; filepath: RelativeWorkspacePath; }>; download(path?: string): Promise<{ downloadUrl: string; }>; getPathFromId: MemoryFS["getPathFromId"]; getIdFromPath: MemoryFS["getIdFromPath"]; readFile(path: string): Promise>; readdir(path: string): Promise>; writeFile(path: string, content: Uint8Array, create?: boolean, overwrite?: boolean): Promise>; stat(path: string): Promise>; copy(from: string, to: string, recursive?: boolean, overwrite?: boolean): Promise>; rename(from: string, to: string, overwrite?: boolean): Promise>; remove(path: string, recursive?: boolean): Promise>; mkdir(path: string, recursive?: boolean): Promise>; watch(path: string, options: { readonly recursive?: boolean; readonly excludes?: readonly string[]; }, onEvent: (watchEvent: fsProtocol.FSWatchEvent) => void): Promise<(PickRawFsResult<"fs/watch"> & { type: "error"; }) | { type: "success"; dispose(): void; }>; } //# sourceMappingURL=IFSClient.d.ts.map