PLACE_KINDSconstconst PLACE_KINDS: readonly ["memory", "file", "ssh", "git", "github", "gitlab", "s3", "onedrive", "gdrive", "sql"]The kinds of place.
The address of a store: a place, one of ten kinds, written as a URI and made only by parsePlace. A place names the root of a store (a folder, a repository at a ref, a host and a folder, a bucket and a prefix, a drive, a database) and never a file in it: the files are the paths of the store. memory and file are the places the library has stores for; the others parse, format and say that they are planned, so that a mount can be written before the backend exists. Credentials are never part of a place.
import { availability, formatPlace, parsePlace } from "./place.ts";
const p = parsePlace("github://intellectual-frontiers/fleet@main/hosts");
p.kind === "ok" && formatPlace(p.value); // "github://intellectual-frontiers/fleet@main/hosts"
p.kind === "ok" && availability(p.value.kind); // "planned"PLACE_KINDSconstconst PLACE_KINDS: readonly ["memory", "file", "ssh", "git", "github", "gitlab", "s3", "onedrive", "gdrive", "sql"]The kinds of place.
PlaceKindtypeno test imports ittype PlaceKind = (typeof PLACE_KINDS)[number];One kind of place.
Placetypeno test imports ittype Place =
| { readonly kind: "memory"; readonly name: string }
| { readonly kind: "file"; readonly path: string }… (873 characters)type Place =
| { readonly kind: "memory"; readonly name: string }
| { readonly kind: "file"; readonly path: string }
| { readonly kind: "ssh"; readonly host: string; readonly port?: number; readonly user?: string; readonly path: string }
| { readonly kind: "git"; readonly repo: string; readonly ref?: string }
| { readonly kind: "github"; readonly owner: string; readonly repo: string; readonly ref?: string; readonly prefix: Prefix }
| { readonly kind: "gitlab"; readonly host: string; readonly project: string; readonly ref?: string; readonly prefix: Prefix }
| { readonly kind: "s3"; readonly bucket: string; readonly prefix: Prefix }
| { readonly kind: "onedrive"; readonly drive: string; readonly prefix: Prefix }
| { readonly kind: "gdrive"; readonly folder: string }
| { readonly kind: "sql"; readonly dialect: string; readonly target: string };The address of a store.
AVAILABILITYconstno test imports itconst AVAILABILITY: Readonly<Record<"file" | "gdrive" | "git" | "github" | "gitlab" | "memory" | "onedrive" | "s3" | "sql" | "ssh", "implemented" | "planned">>Whether the library has a store for a kind of place. A registry with one entry for each kind, which the compiler holds.
availabilityconstconst availability: (kind: "file" | "gdrive" | "git" | "github" | "gitlab" | "memory" | "onedrive" | "s3" | "sql" | "ssh") => "implemented" | "planned"Whether the library has a store for a kind of place.
parsePlacefunctionfunction parsePlace(text: string): Result<Place, string>A place from text, or the part that is wrong with it.
formatPlacefunctionfunction formatPlace(place: Place): stringA place as text: what parsePlace reads back as the same place.