Skip to content

workspaces.read_file

A file of a workspace with its hash and HEAD text (DMN-1442).

/** `workspaces.read_file` params (DMN-1442). */
export type ReadFileParams = {
/**
* The `hash` the client already shows: while the file still has it, the result is `unchanged` and carries
* neither its content nor its `HEAD` text.
*/
knownHash?: string | null;
/**
* With `knownHash`: the `headHash` the client shows (`""` for none); `unchanged` also needs the file's version at
* `HEAD` to be the same, so a commit made anywhere refreshes it (DMN-1442).
*/
knownHeadHash?: string | null;
/**
* Relative to the workspace folder, or absolute inside the workspace folder.
*/
path: string;
workspaceId: string;
};
/** A file of a workspace (DMN-1442). */
export type FileContent = {
/**
* `text`: the text (its first 2 MiB, cut at a line end, when `truncated`); `image`: the bytes in base64 (absent
* over 8 MiB); absent for `binary` and when `unchanged`.
*/
content?: string | null;
/** Hex SHA-1 of the file's bytes: the `expectedHash` of `workspaces.write_file`. */
hash: string;
/**
* The file's text at `HEAD` of that repository; absent for a file `HEAD` does not have (new, untracked), for
* binary, truncated or `unchanged` files and outside repositories.
*/
head?: string | null;
/**
* For a text or an image: the hex SHA-1 of its bytes at `HEAD` of that repository (DMN-255), an image's whatever
* its size; absent for a file `HEAD` does not have, for binary and truncated text files, when `unchanged` and
* outside repositories.
*/
headHash?: string | null;
kind: FileKind;
/** The MIME type of an image. */
mime?: string | null;
/**
* The file is outside the workspace folder, read by its absolute path (DMN-310, PRT-195): read-only,
* `workspaces.write_file` refuses it (DMN-313).
*/
outside?: boolean;
/**
* Relative to the workspace folder, `..` resolved (symbolic links kept as they are); for a file `outside` the
* folder, the absolute path, `..` resolved.
*/
path: string;
/**
* The name of the git working tree holding the file (DMN-1442, DMN-311): the workspace's top-level folder when
* it is that working tree, else the working tree's folder name; absent outside every repository and when
* `unchanged`.
*/
repo?: string | null;
/** Size in bytes. */
size: number;
/** The text was cut (DMN-1442's cap). */
truncated?: boolean;
/** The `knownHash` of the request still matches: no `content`, no `head` and no `headHash`. */
unchanged?: boolean;
};
/** What a file of a workspace holds, as `workspaces.read_file` shows it (DMN-1442). */
export type FileKind =
/** UTF-8 text without NUL bytes. */
| "text"
/** An image by its extension (`png`, `jpg`, `jpeg`, `gif`, `webp`, `avif`, `bmp`, `ico`, `svg`). */
| "image"
/** Anything else: named, never shown. */
| "binary";