IF Commons GitHub

governance/capability

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-governance FR-005, 0002-anyfs-governance FR-006

What a store can do, as a closed union: five core capabilities every store has and nine optional ones a store says it has, each with one sentence. The capabilities of a store are in its type, so that code which needs one cannot be given a store without it. A store also declares how consistent it is and two traits that code cannot discover any other way.

import { isCapability } from "./capability.ts";
isCapability("cas"); // true
isCapability("chmod"); // false

Source: commons/anyfs/src/governance/capability.ts

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

CORE_CAPABILITIESconst
const CORE_CAPABILITIES: readonly ["read", "write", "list", "stat", "delete"]

The capabilities every store has.

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

OPTIONAL_CAPABILITIESconst
const OPTIONAL_CAPABILITIES: readonly ["cas", "batch", "rename", "watch", "lock", "history", "rangeRead", "append", "search", "merge"]

The capabilities a store may have.

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

CAPABILITIESconst
const CAPABILITIES: readonly ["read", "write", "list", "stat", "delete", "cas", "batch", "rename", "watch", "lock", "history", "rangeRead", "append", "search", "merge"]

Every capability, the core ones first.

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

CoreCapabilitytype
type CoreCapability = (typeof CORE_CAPABILITIES)[number];

One of the core capabilities.

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

Capabilitytypeno test imports it
type Capability = (typeof CAPABILITIES)[number];

One capability of a store: a closed union.

CAPABILITY_SUMMARYconst
const CAPABILITY_SUMMARY: Readonly<Record<"append" | "batch" | "cas" | "delete" | "history" | "list" | "lock" | "merge" | "rangeRead" | "read" | "rename" | "search" | "stat" | "watch" | "write", string>>

What each capability adds, in a sentence: a registry with one entry for each capability, which the compiler holds.

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

isCapabilityfunction
function isCapability(text: string): text is "append" | "batch" | "cas" | "delete" | "history" | "list" | "lock" | "merge" | "rangeRead" | "read" | "rename" | "search" | "stat" | "watch" | "write"

Whether a text is the name of a capability.

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

CONSISTENCIESconst
const CONSISTENCIES: readonly ["strong", "read-your-writes", "eventual-listing", "eventual-merge"]

How consistent a store is: strong (every read sees the last write and a list sees every object), read-your-writes (a writer sees its own writes) eventual-listing (a list may lag behind the objects) or eventual-merge (a replica holds what it has made and taken, and every two replicas that have taken each other's changes hold the same).

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

Consistencytypeno test imports it
type Consistency = (typeof CONSISTENCIES)[number];

One way a store is consistent.

Traitstypeno test imports it
type Traits = { readonly caseSensitive: boolean; readonly maxObject?: number };

What a caller cannot discover any other way: whether the store tells paths apart by case, and the largest object it holds where it has a limit (in bytes).

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