IF Commons GitHub

governance/estate

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-estate-governance FR-006

The typed estate: the assets of an organization written as data in which every reference is derived from the data. A link between assets names its ends by the keys of the assets, so that an unknown asset is a compile error the editor shows, and defineEstate also refuses it as a value where the data came from a place the compiler did not see.

import { defineEstate } from "./estate.ts";
const estate = defineEstate(
  { olympia: { kind: "server", state: "adopted", owners: { observe: "archon", verify: "archon", access: "archon" } } },
  [],
);
estate.kind; // "ok"

Source: commons/estate/src/governance/estate.ts

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

AssetSpectypeno test imports it
type AssetSpec = Omit<AssetInput, "id">;

The input for an asset, whose identity is its key.

Linktypeno test imports it
type Link<K extends string> = { readonly from: K; readonly to: K; readonly kind: string };

A link between two assets, by their keys.

Estatetypeno test imports it
type Estate<K extends string> = {
  readonly assets: { readonly [P in K]: Asset };
  readonly links: readonly Link<K>[];
  /** The keys, in order. */
  readonly ids: readonly K[];
};

A typed estate: the assets by key, and the links between them.

defineEstatefunction
function defineEstate<const A extends Readonly<Record<string, AssetSpec>>>(assets: A, links: readonly Link<Extract<keyof A, string>>[]): Result<Estate<Extract<keyof A, string>>, readonly string[]>

An estate from its assets (the key of each is its id) and links, or every reason it is refused; a link whose end is not a key of the assets does not compile.

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

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