Types

Type definitions exported by @catmint-fs/core.

Import

import type {
  ChangeEntry,
  ChangeDetail,
  ApplyResult,
  ApplyError,
  TransactionError,
  StatResult,
  DirentEntry,
  WriteOptions,
  MkdirOptions,
  RmOptions,
  PermissionOp,
  EntryType,
  AdapterCapabilities,
  CreateLayerOptions,
  FsAdapter,
} from "@catmint-fs/core";

Change Types

ChangeEntry

Represents a single pending change in the layer.

interface ChangeEntry {
  type: "create" | "update" | "delete" | "rename" | "chmod" | "chown";
  path: string;
  entryType: EntryType;
}
FieldTypeDescription
type"create" | "update" | "delete" | "rename" | "chmod" | "chown"The kind of change
pathstringAbsolute path (relative to layer root) of the affected entry
entryTypeEntryTypeWhether the entry is a file, directory, or symlink

ChangeDetail

Extended change information returned by getChangeDetail().

interface ChangeDetail extends ChangeEntry {
  renameTo?: string;
  mode?: number;
  uid?: number;
  gid?: number;
}
FieldTypeDescription
renameTostringFor rename changes, the destination path
modenumberFor chmod changes, the new permission mode
uidnumberFor chown changes, the new user ID
gidnumberFor chown changes, the new group ID

EntryType

type EntryType = "file" | "directory" | "symlink";

Apply Types

ApplyResult

Returned by layer.apply() in best-effort mode.

interface ApplyResult {
  applied: number;
  errors: ApplyError[];
}
FieldTypeDescription
appliednumberNumber of changes successfully applied
errorsApplyError[]Array of errors for changes that failed

ApplyError

Describes a single failure during apply().

interface ApplyError {
  path: string;
  error: Error;
}
FieldTypeDescription
pathstringThe path that failed to apply
errorErrorThe underlying error

TransactionError

Thrown by layer.apply({ transaction: true }) when a change fails. Extends Error.

class TransactionError extends Error {
  failedPath: string;
  revertedCount: number;
}
FieldTypeDescription
failedPathstringThe path where the transaction failed
revertedCountnumberNumber of changes that were reverted

Filesystem Types

StatResult

File or directory metadata returned by stat() and lstat().

interface StatResult {
  type: EntryType;
  size: number;
  mode: number;
  mtime: Date;
  uid?: number;
  gid?: number;
}
FieldTypeDescription
typeEntryType"file", "directory", or "symlink"
sizenumberSize in bytes (0 for directories)
modenumberPermission mode (e.g., 0o644)
mtimeDateLast modification time
uidnumberOwner user ID (if available)
gidnumberOwner group ID (if available)

DirentEntry

A directory entry returned by readdir().

interface DirentEntry {
  name: string;
  type: EntryType;
}
FieldTypeDescription
namestringEntry name (not the full path)
typeEntryType"file", "directory", or "symlink"

Option Types

WriteOptions

Options for writeFile().

interface WriteOptions {
  mode?: number;
}
FieldTypeDefaultDescription
modenumber0o644File permission mode

MkdirOptions

Options for mkdir().

interface MkdirOptions {
  recursive?: boolean;
}
FieldTypeDefaultDescription
recursivebooleanfalseCreate parent directories if they do not exist

RmOptions

Options for rm().

interface RmOptions {
  recursive?: boolean;
}
FieldTypeDefaultDescription
recursivebooleanfalseRemove directory contents recursively

Permission Types

PermissionOp

The type of permission check performed by checkPermission().

type PermissionOp = "read" | "write" | "execute";

Adapter Types

AdapterCapabilities

Declares what features an adapter supports.

interface AdapterCapabilities {
  permissions: boolean;
  symlinks: boolean;
  caseSensitive: boolean;
}
FieldTypeDescription
permissionsbooleanWhether chmod/chown/lchown are supported
symlinksbooleanWhether symlink/readlink are supported
caseSensitivebooleanWhether path matching is case-sensitive

CreateLayerOptions

Options passed to createLayer().

interface CreateLayerOptions {
  root: string;
  adapter?: FsAdapter;
}
FieldTypeRequiredDescription
rootstringYesAbsolute path for the layer root
adapterFsAdapterNoBacking filesystem adapter (defaults to LocalAdapter)

See Also