IF Commons GitHub

governance/model

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-governance FR-001, 0003-governance FR-003, 0003-governance FR-004

The model of governance (commons data 0003-governance FR-001, FR-003, FR-004): concepts with attributes, identifying attributes and relationships, code lists, and the domain that holds them. The constructors are total, they never fail; domain checks the whole and returns the domain or every error, as data. The names of a concept's attributes and relationships are literal types, so an identifying attribute the concept does not have does not compile.

const party = concept("party", {
  definition: "A person or an organization we deal with",
  attributes: { party_id: attribute(identifier(), { definition: "Its identifier" }), name: attribute(text(), { definition: "What it is called" }) },
  identifiedBy: ["party_id"],
});
const arca = domain("arca", { definition: "Parties", concepts: [party] });

Source: commons/data/governance/model.ts

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

Attributeinterfaceno test imports it
interface Attribute<T extends Datatype = Datatype, M extends Multiplicity = Multiplicity>

An attribute of a concept.

MemberTypeWhat it is
kind"attribute"
typeT
multiplicityM
definitionstring
annotationsreadonly Annotation[]
AttributeOptionsinterfaceno test imports it
interface AttributeOptions<M extends Multiplicity = Multiplicity>

What attribute is given besides the datatype.

MemberTypeWhat it is
definition?string
multiplicity?M
annotations?readonly Annotation[]
Attrstypeno test imports it
type Attrs = Readonly<Record<string, Attribute>>;

The attributes of a concept, by name.

AnyConcepttype
type AnyConcept = Concept<string, Attrs, Rels, string>;

A concept of any name, attributes and relationships.

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

attributefunction
function attribute: { <T extends Datatype>(type: T, options?: RequiredOptions | undefined): Attribute<T, "required">; <T extends Datatype, const M extends Multiplicity>(type: T, options: AttributeOptions<M> & { readonly multiplicity: M; }): Attribute<T, M>; }

Makes an attribute; total. It is required unless it says otherwise.

ParameterWhat it is
typewhat kind of fact it holds
optionsits definition, multiplicity and annotations

Returns: the attribute, frozen

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

Cardinalitytypeno test imports it
type Cardinality = "one" | "optional" | "many";

How many of the target a concept relates to: exactly one, at most one, or any number.

Conceptinterfaceno test imports it
interface Concept<N extends string = string, A extends Attrs = Attrs, R extends Rels = Rels, I extends string = string>

A concept: a thing the business talks about.

MemberTypeWhat it is
kind"concept"
nameN
definitionstring
attributesA
relationshipsR
identifiedByreadonly I[]The names of the attributes and relationships that identify it; concept checked them against its own, as literal types, when it was made.
annotationsreadonly Annotation[]
ConceptSpecinterfaceno test imports it
interface ConceptSpec<A extends Attrs, R extends Rels, I extends string>

What concept is given.

MemberTypeWhat it is
definition?string
attributesA
identifiedByreadonly I[]What identifies it: names of its own attributes, or of its own relationships of cardinality one, which make it a specialization of what they point to, or it does not compile.
relationships?R
annotations?readonly Annotation[]
conceptfunction
function concept<const N extends string, const A extends Attrs, const I extends (keyof NoInfer<A> | keyof NoInfer<R>) & string, const R extends Rels = Record<never, Relationship<Cardinality, Target>>>(name: N, spec: ConceptSpec<A, R, I>): Concept<N, A, R, I>

Makes a concept; total. Its attribute names, relationship names and identifying attributes are literal types.

ParameterWhat it is
nameits name
specits definition, attributes, identifying attributes, relationships and annotations

Returns: the concept, frozen

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

domainfunction
function domain(name: string, spec: DomainSpec): Result<Domain, readonly DomainError[]>

Makes a domain, or says everything that is wrong with it.

ParameterWhat it is
nameits name
specits definition, concepts, code lists and annotations

Returns: the domain, or every error

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

Domaininterface
interface Domain

A domain: a part of the business, with its concepts and code lists.

MemberTypeWhat it is
kind"domain"
namestring
definitionstring
conceptsreadonly AnyConcept[]
codeListsreadonly AnyCodeList[]
annotationsreadonly Annotation[]

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

DomainErrortypeno test imports it
type DomainError = | { readonly kind: "name"; readonly element: ElementId; readonly name: string } | { readonly kind… (692 characters)
type DomainError =
  | { readonly kind: "name"; readonly element: ElementId; readonly name: string }
  | { readonly kind: "duplicate"; readonly element: ElementId }
  | { readonly kind: "unresolved"; readonly from: ElementId; readonly to: string; readonly what: "concept" | "codelist" }
  | {
      readonly kind: "identifier";
      readonly concept: ElementId;
      readonly attribute?: string;
      readonly why: "missing" | "unknown" | "not-required";
    }
  | { readonly kind: "annotation"; readonly element: ElementId; readonly annotation: string; readonly about: readonly ElementKind[] }
  | { readonly kind: "dimensions"; readonly element: ElementId; readonly dimensions: number };

What is wrong with a domain; domain returns all of it together.

DomainSpecinterfaceno test imports it
interface DomainSpec

What domain is given.

MemberTypeWhat it is
definition?string
conceptsreadonly AnyConcept[]
codeLists?readonly AnyCodeList[]
annotations?readonly Annotation[]
Multiplicitytypeno test imports it
type Multiplicity = "required" | "optional" | "many";

Whether an attribute is held once and always, at most once, or any number of times.

membersOfconstno test imports it
const membersOf: (c: AnyConcept) => readonly string[]

The names of the members of a concept: its attributes, then its relationships.

Relationshipinterfaceno test imports it
interface Relationship<C extends Cardinality = Cardinality, T extends Target = Target>

A relationship from a concept to another.

MemberTypeWhat it is
kind"relationship"
toT
cardinalityC
definitionstring
annotationsreadonly Annotation[]
RelationshipOptionsinterfaceno test imports it
interface RelationshipOptions<C extends Cardinality = Cardinality>

What relationship is given besides the target.

MemberTypeWhat it is
cardinalityC
definition?string
annotations?readonly Annotation[]
relationshipfunction
function relationship<const T extends Target, const C extends Cardinality>(to: T, options: RelationshipOptions<C>): Relationship<C, T>

Makes a relationship; total.

ParameterWhat it is
tothe concept it points to, or a function that gives it
optionsits cardinality, definition and annotations

Returns: the relationship, frozen

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

resolvefunction
function resolve(target: Target): AnyConcept

The concept a target gives.

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

Relstypeno test imports it
type Rels = Readonly<Record<string, Relationship>>;

The relationships of a concept, by name.

Targettype
type Target = AnyConcept | (() => AnyConcept);

The concept a relationship points to: the concept, or a function that gives it, so that two concepts may refer to each other.

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

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