types/block.types.ts

types/block.types.ts is a file in Bane's Lab Site. 174 lines of code and 27 definitions.

import type { GrammarBlock } from "#types/grammar.types";
import type { SurfaceFigureName } from "#types/surface.types";
import type { WalkRef } from "#types/anatomy.types";

export interface TextBlock {
    readonly kind: "text";
    readonly note?: boolean;
    readonly text: string;
}

export interface ListBlock {
    readonly items: readonly string[];
    readonly kind: "list";
    readonly label?: string;
    readonly ordered?: boolean;
}

export interface GlossaryEntry {
    readonly code?: string;
    readonly description: string;
    readonly domains?: readonly string[];
    readonly href?: string;
    readonly icon?: string;
    readonly id?: string;
    readonly term: string;
    readonly wide?: boolean;
}

export interface GlossaryBlock {
    readonly entries: readonly GlossaryEntry[];
    readonly kind: "glossary";
}

export type TableTone = "contrast" | "keyword" | "role";

export interface TableBlock {
    readonly headers: readonly string[];
    readonly kind: "table";
    readonly rows: readonly (readonly string[])[];
    readonly tone?: TableTone;
}

export interface GroupEntry {
    readonly content?: string;
    readonly entries?: readonly GlossaryEntry[];
    readonly items?: readonly string[];
    readonly title?: string;
}

export interface GroupBlock {
    readonly groups: readonly GroupEntry[];
    readonly kind: "group";
    readonly tone?: string;
}

export interface LinkEntry {
    readonly description?: string;
    readonly href: string;
    readonly icon?: string;
    readonly text: string;
}

export interface LinkBlock {
    readonly button?: boolean;
    readonly kind: "link";
    readonly links: readonly LinkEntry[];
}

export interface CodeBlock {
    readonly code: string;
    readonly kind: "code";
    readonly language: string;
    readonly title: string;
}

export interface CardAction {
    readonly href: string;
    readonly text: string;
}

export interface CardFile {
    readonly href: string;
    readonly icon: string;
    readonly name: string;
    readonly title: string;
}

export interface Card {
    readonly accent: string;
    readonly action?: CardAction;
    readonly description: string;
    readonly files?: readonly CardFile[];
    readonly icon: string;
    readonly id: string;
    readonly permitted: readonly string[];
    readonly restricted: readonly string[];
    readonly spdx: string;
    readonly status: string;
    readonly title: string;
}

export interface CardBlock {
    readonly cards: readonly Card[];
    readonly kind: "card";
}

export interface FigureBlock {
    readonly caption: string;
    readonly figure: CodeBlock | GrammarBlock;
    readonly kind: "figure";
}

export interface WidePanel {
    readonly wide?: boolean;
}

export interface MermaidBlock extends WidePanel {
    readonly caption?: string;
    readonly kind: "mermaid";
    readonly text: string;
}

export interface LessonBlock {
    readonly application: string;
    readonly boundary?: string;
    readonly cause: string;
    readonly decision: string;
    readonly failureMode: string;
    readonly kind: "lesson";
    readonly principle: string;
    readonly problem: string;
    readonly validation: string;
}

export interface WalkBlock extends WidePanel {
    readonly caption: string;
    readonly kind: "walk";
    readonly walk: WalkRef;
}

export interface SurfaceBlock extends WidePanel {
    readonly caption: string;
    readonly figure: SurfaceFigureName;
    readonly kind: "surface";
}

export interface Metric {
    readonly label: string;
    readonly value: string;
}

export interface MetricBlock extends WidePanel {
    readonly caption: string;
    readonly kind: "metric";
    readonly metrics: readonly Metric[];
}

export interface SourceBlock {
    readonly kind: "source";
    readonly language: string;
    readonly path: string;
    readonly references?: string;
    readonly source: string;
    readonly title: string;
}

export interface MarkdownBlock {
    readonly kind: "markdown";
    readonly path: string;
    readonly references?: string;
    readonly source: string;
    readonly title: string;
}

export interface DefinitionBlock {
    readonly file: string | null;
    readonly kind: "definition";
    readonly line: number | null;
    readonly name: string;
    readonly title: string;
}

export type Block =
    | CardBlock
    | CodeBlock
    | DefinitionBlock
    | FigureBlock
    | GlossaryBlock
    | GrammarBlock
    | GroupBlock
    | LessonBlock
    | LinkBlock
    | ListBlock
    | MarkdownBlock
    | MermaidBlock
    | MetricBlock
    | SourceBlock
    | SurfaceBlock
    | TableBlock
    | TextBlock
    | WalkBlock;