IF Commons GitHub

keys

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-s3-store FR-002

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"

Source: commons/anyfs-s3/src/keys.ts

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

basePrefixfunction
function basePrefix(prefix: Prefix): string

The text a key begins with for everything below a prefix: nothing for the root, the prefix and a / for any other.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

decodeListedKeyfunction
function 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.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

describeFindingfunction
function describeFinding(f: KeyFinding): string

A finding in one sentence.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

encodeKeyfunction
function encodeKey(key: string): string

The key written in the path of a URL: each segment encoded as RFC 3986 says, the / kept.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

isOwnconst
const isOwn: (path: string) => boolean

Whether a path has a segment that begins with the names the store keeps for itself.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

keyOffunction
function 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.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

KeyFindingtypeno test imports it
type 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 it
const OWN: ".anyfs-"

The names the store keeps for itself: it makes none below a prefix and shows none.

pathOfKeyfunction
function 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.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

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