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
| Parameter | Type |
|---|---|
name | string |
Returns
Overrides
Error.constructor
Interfaces
BranchListing
One entry of a branch listing: the manifest plus the name the directory carries.
Extends
Properties
BranchManifest
The manifest a branch directory carries, without the name its directory already states.
Extended by
Properties
LoadedBranch
A loaded branch: the rebuilt in-memory branch plus what the manifest recorded.
Properties
| Property | Type |
|---|---|
branch | Branch |
manifest | BranchManifest |
name | string |
SaveBranchOptions
What a save records beyond the branch itself.
Properties
| Property | Type | Description |
|---|---|---|
base | string | live, or the name of the checkpoint the fork was taken from. |
created? | string | The 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
| Parameter | Type |
|---|---|
projectDir | string |
name | string |
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
| Parameter | Type |
|---|---|
projectDir | string |
Returns
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
| Parameter | Type |
|---|---|
projectDir | string |
name | string |
Returns
Promise<LoadedBranch>
removeBranch()
function removeBranch(projectDir: string, name: string): boolean;
Remove one branch directory. Returns whether there was one to remove.
Parameters
| Parameter | Type |
|---|---|
projectDir | string |
name | string |
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
| Parameter | Type |
|---|---|
projectDir | string |
name | string |
branch | Branch |
options | SaveBranchOptions |
Returns
Promise<BranchManifest>