Skip to main content
Read repository content without mounting MesaFS. Required scope: read
import { Buffer } from 'node:buffer';

const file = await mesa.content.get({ repo: 'app', path: 'README.md' });

if (file.type === 'file') {
  console.log(Buffer.from(file.content, 'base64').toString('utf8'));
}
Read a directory listing:
const root = await mesa.content.get({ repo: 'app', path: '', depth: 1 });
if (root.type === 'dir') {
  for (const entry of root.entries) console.log(entry.type, entry.path);
}

Options

repo
string
required
Repository name.
org
string | undefined
Organization override.
path
string | undefined
Repository-relative path. Omit or pass an empty string for the repository root.
change_id
string | undefined
Change to read from. Defaults to the current change at the default bookmark tip.
depth
number | undefined
Directory traversal depth from 0 to 10.

Response

type: 'file'
ContentFile
Regular file content.
Symbolic link content.
type: 'dir'
ContentDirectory
Directory listing.

ContentFile

type
'file'
Content variant discriminator.
name
string
Base name of the file.
path
string
Repository-relative path.
sha
string
Git object SHA.
is_conflicted
boolean | undefined
Whether this path is conflicted when known.
size
number
Size in bytes.
encoding
'base64'
Encoding used for content.
content
string
Base64-encoded file bytes.
mode
'100644' | '100755'
POSIX file mode.
xattrs
Record<string, string> | undefined
Extended attributes for this path. Values are base64-encoded.
type
'symlink'
Content variant discriminator.
name
string
Base name of the symlink.
path
string
Repository-relative path.
sha
string
Git object SHA.
is_conflicted
boolean | undefined
Whether this path is conflicted when known.
size
number
Size in bytes.
encoding
'base64'
Encoding used for content.
content
string
Base64-encoded symlink target bytes.
mode
'120000'
POSIX symlink mode.
xattrs
Record<string, string> | undefined
Extended attributes for this path. Values are base64-encoded.

ContentDirectory

type
'dir'
Content variant discriminator.
name
string
Base name of the directory.
path
string
Repository-relative path.
sha
string
Git object SHA.
child_count
number
Number of direct children in this directory.
entries
ContentDirectoryEntry[]
Directory entries returned for the requested depth.
xattrs
Record<string, string> | undefined
Extended attributes attached to this directory. Values are base64-encoded.

ContentDirectoryEntry

type
'file' | 'symlink' | 'dir'
Entry variant discriminator.
name
string
Base name of the entry.
path
string
Repository-relative path.
sha
string
Git object SHA.
size
number | undefined
Size in bytes for file and symlink entries.
mode
'100644' | '100755' | '120000' | undefined
POSIX mode for file and symlink entries.