Navigate

API reference

pyric/sandbox/branches/store

13 published symbols from pyric

Generated from the TypeScript declarations shipped at this import path.

Classes

BranchNameError

A branch name the store refuses. Thrown rather than returned: it is a caller mistake.

Extends

  • Error

Constructors

Constructor
new BranchNameError(name: string): BranchNameError;
Parameters
ParameterType
namestring
Returns

BranchNameError

Overrides
Error.constructor

Interfaces

BranchListing

One entry of a branch listing: the manifest plus the name the directory carries.

Extends

Properties

PropertyTypeDescription
basestringlive, or the name of the checkpoint the fork was taken from.
createdstringWhen the branch was forked, as an ISO 8601 instant.
eventCountnumberHow many events have been applied to the branch.
format"pyric-branch-v2"-
namestring-

BranchManifest

The manifest a branch directory carries, without the name its directory already states.

Extended by

Properties

PropertyTypeDescription
basestringlive, or the name of the checkpoint the fork was taken from.
createdstringWhen the branch was forked, as an ISO 8601 instant.
eventCountnumberHow many events have been applied to the branch.
format"pyric-branch-v2"-

LoadedBranch

A loaded branch: the rebuilt in-memory branch plus what the manifest recorded.

Properties

PropertyType
branchBranch
manifestBranchManifest
namestring

SaveBranchOptions

What a save records beyond the branch itself.

Properties

PropertyTypeDescription
basestringlive, or the name of the checkpoint the fork was taken from.
created?stringThe creation instant to record. Defaults to now, which is what a fork wants.

Variables

BRANCH_FORMAT

const BRANCH_FORMAT: "pyric-branch-v2" = "pyric-branch-v2";

The tag every branch manifest carries, so an unrelated directory is not read as one.


BRANCH_NAME_PATTERN

const BRANCH_NAME_PATTERN: RegExp;

The names a branch may take: one path segment, so a name can never escape the store.


BRANCH_STORE_RELATIVE

const BRANCH_STORE_RELATIVE: string;

Where branches live, relative to the project directory.

Functions

branchDirectory()

function branchDirectory(projectDir: string, name: string): string;

The directory one branch occupies.

Parameters

ParameterType
projectDirstring
namestring

Returns

string


listBranches()

function listBranches(projectDir: string): BranchListing[];

Every branch the project holds, ordered by name. A directory that carries no manifest this store wrote is skipped rather than failing the listing, so an unrelated file under the branch directory does not take the listing down.

Parameters

ParameterType
projectDirstring

Returns

BranchListing[]


loadBranch()

function loadBranch(projectDir: string, name: string): Promise<LoadedBranch>;

Rebuild one branch from its directory, or null when the project has no branch by that name. The branch’s sandbox is forked onto the stored current state, and the stored base and event log are restored beside it, so a loaded branch and a branch that never left memory are the same value in every service rather than only in the one the event log records.

Parameters

ParameterType
projectDirstring
namestring

Returns

Promise<LoadedBranch>


removeBranch()

function removeBranch(projectDir: string, name: string): boolean;

Remove one branch directory. Returns whether there was one to remove.

Parameters

ParameterType
projectDirstring
namestring

Returns

boolean


saveBranch()

function saveBranch(
   projectDir: string,
   name: string,
   branch: Branch,
options: SaveBranchOptions): Promise<BranchManifest>;

Write one branch to its own directory, replacing whatever was there. The base, the current state, and the event log are all written from the branch itself, so a save after an apply or after a write on any service records exactly what the engine holds.

Parameters

ParameterType
projectDirstring
namestring
branchBranch
optionsSaveBranchOptions

Returns

Promise<BranchManifest>