IF Commons GitHub

physical/file-source

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0004-planning-sources FR-005

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/" })

Source: commons/planning/src/physical/file-source.ts

0 of 8 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.FileReadtypeno test imports it
type 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 it
type 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 it
const folderOf: (place: string) => string

The 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 it
function 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 it
type FileRead = { readonly path: string; readonly text: string; readonly rev: string; readonly observations: readonly Observation[] };

A file as the source read it.

FileLenstypeno test imports it
type 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 it
const folderOf: (place: string) => string

The 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 it
function 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.

Titles, headings, exports, tables, columns and requirements. Esc closes.