physical.FileReadtypeno test imports ittype FileRead = { readonly path: string; readonly text: string; readonly rev: string; readonly observations: readonly Observation[] };A file as the source read it.
A source over the files of an AnyFS store (0037-planning FR-029): it is written against a store that has read, write, list and cas, so the same source works over a folder, Git, S3, SSH, SQL or memory. A file lens says how a kind of file reads (parse) and how a patch changes it (edit, create); this makes the source of it: it lists and reads the files under a prefix, finds the file that holds the thing a patch is about, and writes the new text expecting the revision it read, so a file that changed in between is a conflict value and nothing is written.
import { fileSource } from "./file-source.ts";
// fileSource(memoryStore(), markdownLens(), { place: "docs/" })physical.FileReadtypeno test imports ittype FileRead = { readonly path: string; readonly text: string; readonly rev: string; readonly observations: readonly Observation[] };A file as the source read it.
physical.FileLenstypeno test imports ittype FileLens = {
readonly name: string;
readonly capabilities: readonly Capability[];
/** Whether a path is a fil… (1504 characters)type FileLens = {
readonly name: string;
readonly capabilities: readonly Capability[];
/** Whether a path is a file this source reads. */
reads(path: string): boolean;
/** The observations of a file and what could not be read in it. */
parse(path: string, text: string): Promise<{ readonly observations: readonly Observation[]; readonly findings: readonly SourceFinding[] }>;
/** The new text of a file for a patch about one of its observations: nothing where nothing changes. */
edit(file: FileRead, patch: Patch): Result<string | undefined, SourceProblem>;
/** The path and new text of a patch that names no observation (a new item), or an anchor for an item the place holds: nothing where nothing changes. */
create?(patch: Patch, files: readonly FileRead[]): Result<{ readonly path: string; readonly text: string } | undefined, SourceProblem>;
/** Reads the whole folder at once, where one thing is spread over files (an issue file and the event objects of its store): the observations, each with the path of the file it is written in as its locator. Used instead of `parse` and `across`. */
parseAll?(files: readonly { readonly path: string; readonly text: string }[]): Promise<{ readonly observations: readonly Observation[]; readonly findings: readonly SourceFinding[] }>;
/** Findings that need the whole folder (a barrel that lists a file that is not there). */
across?(files: readonly { readonly path: string; readonly text: string }[]): readonly SourceFinding[];
};What a kind of file is to the source.
physical.folderOfconstno test imports itconst folderOf: (place: string) => stringThe folder of a store that a place names: . is the root of the store, and a trailing slash is not part of it.
physical.fileSourcefunctionno test imports itfunction fileSource(backend: PlanningStoreBackend, lens: FileLens, place: string): Result<Source, DefineProblem>A source of the files under place (a prefix of the store, empty for its root) read by lens.
FileReadtypeno test imports ittype FileRead = { readonly path: string; readonly text: string; readonly rev: string; readonly observations: readonly Observation[] };A file as the source read it.
FileLenstypeno test imports ittype FileLens = {
readonly name: string;
readonly capabilities: readonly Capability[];
/** Whether a path is a fil… (1504 characters)type FileLens = {
readonly name: string;
readonly capabilities: readonly Capability[];
/** Whether a path is a file this source reads. */
reads(path: string): boolean;
/** The observations of a file and what could not be read in it. */
parse(path: string, text: string): Promise<{ readonly observations: readonly Observation[]; readonly findings: readonly SourceFinding[] }>;
/** The new text of a file for a patch about one of its observations: nothing where nothing changes. */
edit(file: FileRead, patch: Patch): Result<string | undefined, SourceProblem>;
/** The path and new text of a patch that names no observation (a new item), or an anchor for an item the place holds: nothing where nothing changes. */
create?(patch: Patch, files: readonly FileRead[]): Result<{ readonly path: string; readonly text: string } | undefined, SourceProblem>;
/** Reads the whole folder at once, where one thing is spread over files (an issue file and the event objects of its store): the observations, each with the path of the file it is written in as its locator. Used instead of `parse` and `across`. */
parseAll?(files: readonly { readonly path: string; readonly text: string }[]): Promise<{ readonly observations: readonly Observation[]; readonly findings: readonly SourceFinding[] }>;
/** Findings that need the whole folder (a barrel that lists a file that is not there). */
across?(files: readonly { readonly path: string; readonly text: string }[]): readonly SourceFinding[];
};What a kind of file is to the source.
folderOfconstno test imports itconst folderOf: (place: string) => stringThe folder of a store that a place names: . is the root of the store, and a trailing slash is not part of it.
fileSourcefunctionno test imports itfunction fileSource(backend: PlanningStoreBackend, lens: FileLens, place: string): Result<Source, DefineProblem>A source of the files under place (a prefix of the store, empty for its root) read by lens.