AssetSpectypeno test imports ittype AssetSpec = Omit<AssetInput, "id">;The input for an asset, whose identity is its key.
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"AssetSpectypeno test imports ittype AssetSpec = Omit<AssetInput, "id">;The input for an asset, whose identity is its key.
Linktypeno test imports ittype Link<K extends string> = { readonly from: K; readonly to: K; readonly kind: string };A link between two assets, by their keys.
Estatetypeno test imports ittype 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.
defineEstatefunctionfunction 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.