IF Commons GitHub

governance/kinds

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0007-estate-kinds FR-001, 0007-estate-kinds FR-002, 0007-estate-kinds FR-003

The kinds of asset that carry typed attributes, and the named kinds of link between assets. An asset of a kind in this catalog states its attributes as data, and each is checked: a required one is there, one that is there is of its type and, where the catalog lists the values, one of them. A kind that is not in the catalog (server, workstation, device) carries none, and still any word is a kind. The catalog is additive: a kind or an attribute is added, never renamed.

import { checkAttributes } from "./kinds.ts";
checkAttributes("endpoint", { scheme: "https", host: "api.example.test", port: 443 }); // []

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

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

AttributeValuetypeno test imports it
type AttributeValue = string | number | boolean | readonly string[];

The value of an attribute.

AttributeSpectypeno test imports it
type AttributeSpec = {
  readonly name: string;
  readonly type: "string" | "number" | "boolean" | "strings";
  readonly required?: boolean;
  /** The values it may have, for a string. */
  readonly values?: readonly string[];
  readonly summary: string;
};

One attribute of a kind.

KindSpectypeno test imports it
type KindSpec = { readonly kind: string; readonly summary: string; readonly attributes: readonly AttributeSpec[] };

A kind of asset that carries attributes.

DATA_CLASSESconstno test imports it
const DATA_CLASSES: readonly ["cui", "fci", "phi", "pii", "pci", "public"]

The data classes an application or a service may handle, in the words of a government contractor's scope.

KINDSconst
const KINDS: readonly KindSpec[]

The kinds with attributes.

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

kindSpecfunction
function kindSpec(kind: string): KindSpec | undefined

The kinds with attributes, by name.

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

checkAttributesfunction
function checkAttributes(kind: string, attributes: Readonly<Record<string, AttributeValue>> | undefined): readonly string[]

The reasons attributes are not right for a kind: nothing for a kind with no spec (it carries none that are checked), and for one with a spec an unknown attribute, a missing required one, a wrong type or a value that is not one of those listed.

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

LinkSpectypeno test imports it
type LinkSpec = { readonly kind: string; readonly from: readonly string[] | "any"; readonly to: readonly string[] | "any"; readonly summary: string };

A named kind of link. from and to are the kinds of asset the ends may be; any is any.

LINK_KINDSconst
const LINK_KINDS: readonly LinkSpec[]

The named kinds of link. A link of a kind that is not here is allowed and unchecked; one of these kinds is refused where an end is not of a kind it may join.

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

linkSpecfunctionno test imports it
function linkSpec(kind: string): LinkSpec | undefined

A named kind of link by its name.

checkLinkfunction
function checkLink(kind: string, fromKind: string, toKind: string): readonly string[]

The reasons a link of a kind may not join two assets of the given kinds, or nothing where it may (or where the link kind is not a named 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.