basePrefixfunctionfunction basePrefix(prefix: Prefix): stringThe text a key begins with for everything below a prefix: nothing for the root, the prefix and a / for any other.
The keys of a bucket and the paths of a store. A store lives below a prefix of a bucket: the key of a path is the prefix, a / and the path, and the path of a key is the key below the prefix. The key is written in a URL by encoding each segment as RFC 3986 says and keeping the /. A key that is not the key of a path (one that parses to another text, as text not in normalization form C does, or to none) is a finding and never an object of the store, and so is a key whose name begins with .anyfs-, which the store keeps for itself.
import { keyOf, pathOfKey } from "./keys.ts";
import { parsePath, parsePrefix } from "@intellectual-frontiers/anyfs/governance";
const base = parsePrefix("fleet");
const p = parsePath("hosts/alpha.json");
base.kind === "ok" && p.kind === "ok" && keyOf(base.value, p.value); // "fleet/hosts/alpha.json"basePrefixfunctionfunction basePrefix(prefix: Prefix): stringThe text a key begins with for everything below a prefix: nothing for the root, the prefix and a / for any other.
decodeListedKeyfunctionfunction decodeListedKey(text: string): Result<string, string>What a key listed with encoding-type=url says: + is a space and each %XX is a byte of UTF-8. The reason it is not that where it is not.
describeFindingfunctionfunction describeFinding(f: KeyFinding): stringA finding in one sentence.
encodeKeyfunctionfunction encodeKey(key: string): stringThe key written in the path of a URL: each segment encoded as RFC 3986 says, the / kept.
isOwnconstconst isOwn: (path: string) => booleanWhether a path has a segment that begins with the names the store keeps for itself.
keyOffunctionfunction keyOf(prefix: Prefix, path: Path): Result<string, string>The key of a path below a prefix of the bucket, or why it is too long for a key.
KeyFindingtypeno test imports ittype KeyFinding =
| { readonly kind: "outside"; readonly key: string }
| { readonly kind: "not-a-path"; readonly key: string; readonly why: string }
| { readonly kind: "not-normalized"; readonly key: string }
| { readonly kind: "own"; readonly key: string };Why a key is not a path of the store.
OWNconstno test imports itconst OWN: ".anyfs-"The names the store keeps for itself: it makes none below a prefix and shows none.
pathOfKeyfunctionfunction pathOfKey(prefix: Prefix, key: string): Result<Path, KeyFinding>The path of a key below a prefix, or the finding that says why the key is not one.