configuration/strings/ontology.fragment.strings.ts

configuration/strings/ontology.fragment.strings.ts is a file in Bane's Lab Site. 75 lines of code and 6 definitions.

import {
    ALGORITHMS_LABEL,
    GRAMMAR_LABEL,
    LEXICON_LABEL,
    PRINCIPLES_LABEL,
    REASONING_LABEL,
    SCHEMA_LABEL,
    resolutionNoteOf,
} from "#configuration/strings/ontology.strings";
import {
    ALGORITHMS_TAB,
    GRAMMAR_TAB,
    LEXICON_TAB,
    ONTOLOGY_PRINCIPLES_TAB,
    REASONING_TAB,
    SCHEMA_TAB,
} from "#core/ids/ontology.ids";
import {
    ONTOLOGY_ALGORITHMS_ICON,
    ONTOLOGY_GRAMMAR_ICON,
    ONTOLOGY_LEXICON_ICON,
    ONTOLOGY_PRINCIPLES_ICON,
    ONTOLOGY_REASONING_ICON,
    ONTOLOGY_SCHEMA_ICON,
} from "#configuration/icons/ontology.icons";
import type { Section, Tab } from "#types/document.types";
import { ONTOLOGY } from "#core/generated/ontology.generated";
import { catalogSections } from "#domain/converters/catalog.converter";
import { contractSections } from "#domain/converters/contract.converter";
import { grammarSections } from "#domain/converters/grammar.section.converter";
import { kindSections } from "#domain/converters/kind.converter";
import { lexiconSections } from "#domain/converters/lexicon.converter";
import { principleSections } from "#domain/converters/principle.converter";
import { spineSections } from "#domain/converters/reason.converter";
import { tensionSections } from "#domain/converters/tension.converter";

const RESOLUTION_NOTE = resolutionNoteOf(ONTOLOGY.resolution.records, ONTOLOGY.resolution.defects);

const lazyTab = function lazyTab(icon: string, id: string, label: string, build: () => readonly Section[]): Tab {
    let held: readonly Section[] | null = null;
    return {
        icon,
        id,
        label,
        layout: "ontology",
        get sections(): readonly Section[] {
            held ??= build();
            return held;
        },
    };
};

const { resolution } = ONTOLOGY;

export const ONTOLOGY_TABS: readonly Tab[] = [
    lazyTab(ONTOLOGY_PRINCIPLES_ICON, ONTOLOGY_PRINCIPLES_TAB, PRINCIPLES_LABEL, () =>
        principleSections(ONTOLOGY.principles, resolution),
    ),
    lazyTab(ONTOLOGY_LEXICON_ICON, LEXICON_TAB, LEXICON_LABEL, () => lexiconSections(ONTOLOGY.terms, resolution)),
    lazyTab(ONTOLOGY_ALGORITHMS_ICON, ALGORITHMS_TAB, ALGORITHMS_LABEL, () =>
        contractSections(ONTOLOGY.contracts, resolution),
    ),
    lazyTab(ONTOLOGY_REASONING_ICON, REASONING_TAB, REASONING_LABEL, () => [
        ...spineSections(ONTOLOGY.reason, resolution),
        ...catalogSections(ONTOLOGY.reason, resolution),
    ]),
    lazyTab(ONTOLOGY_GRAMMAR_ICON, GRAMMAR_TAB, GRAMMAR_LABEL, () => grammarSections(ONTOLOGY.grammar, resolution)),
    lazyTab(ONTOLOGY_SCHEMA_ICON, SCHEMA_TAB, SCHEMA_LABEL, () => [
        ...kindSections({
            coverage: resolution.coverage,
            forces: ONTOLOGY.forces,
            kinds: ONTOLOGY.kinds,
            note: RESOLUTION_NOTE,
            ranges: ONTOLOGY.ranges,
            vocabularies: ONTOLOGY.vocabularies,
        }),
        ...tensionSections(ONTOLOGY.layers),
    ]),
];