REFUSALSconstconst REFUSALS: readonly ["read-only", "outside-scope", "unsupported-expectation", "capability-absent", "too-large", "unportable-path", "consent"]Why a store refused an operation: a closed list.
What a store reports when it does not do what it was asked: five kinds of problem, a closed union, each a value with one sentence. A conflict is not an error of the store: it is the answer to a write whose expectation did not hold, and says what was expected and what was found.
import { describeProblem, missing } from "./problem.ts";
import { parsePath } from "./path.ts";
const p = parsePath("a");
p.kind === "ok" && describeProblem(missing(p.value)); // "a is not in the store"REFUSALSconstconst REFUSALS: readonly ["read-only", "outside-scope", "unsupported-expectation", "capability-absent", "too-large", "unportable-path", "consent"]Why a store refused an operation: a closed list.
Refusaltypeno test imports ittype Refusal = (typeof REFUSALS)[number];One reason for a refusal.
Foundtypeno test imports ittype Found = { readonly kind: "absent" } | { readonly kind: "rev"; readonly rev: Revision };What a conflict found at the path: no object, or one at a revision.
Problemtypetype Problem =
| { readonly kind: "missing"; readonly path: Path }
| { readonly kind: "conflict"; readonly path: Pat… (473 characters)type Problem =
| { readonly kind: "missing"; readonly path: Path }
| { readonly kind: "conflict"; readonly path: Path; readonly expected: Expect; readonly found: Found }
| { readonly kind: "refused"; readonly reason: Refusal; readonly detail: string; readonly path?: Path }
| { readonly kind: "unavailable"; readonly detail: string; readonly retryable: boolean; readonly path?: Path }
| { readonly kind: "tampered"; readonly path: Path; readonly detail: string };What a store reports: a closed union of five kinds.
missingconstconst missing: (path: Path) => ProblemThere is no object at the path.
conflictconstconst conflict: (path: Path, expected: Expect, found: Found) => ProblemThe object was not as the write expected.
refusedconstconst refused: (reason: "capability-absent" | "consent" | "outside-scope" | "read-only" | "too-large" | "unportable-path" | "unsupported-expectation", detail: string, path?: Path | undefined) => ProblemThe store will not do it, and says why.
tamperedconstconst tampered: (path: Path, detail: string) => ProblemThe bytes are not what their revision says they are.
describeProblemfunctionfunction describeProblem(problem: Problem): stringA problem as one sentence.