types/chapter.types.ts

types/chapter.types.ts is a file in Bane's Lab Content. 54 lines of code and 13 definitions.

import type { ReadmeInputs } from "#types/readme.types";

export interface Chapter {
    readonly body: string;
    readonly file: string;
    readonly label: string;
}

export interface ChapterSource {
    readonly first: boolean;
    readonly label: string;
    readonly markdown: string;
    readonly tab: string;
}

export type LinkResolver = (page: string, tab: string | null) => string | null;

export interface SiteOnlyTab {
    readonly page: string;
    readonly tab: string;
}

export interface Attribution {
    readonly author: string;
    readonly copyright: string;
    readonly coveredBy: string;
    readonly licenseName: string;
    readonly licenseUrl: string;
    readonly work: string;
}

export type ChapterShape = "repository" | "wiki";

export interface WikiPage {
    readonly group: string;
    readonly hosted: boolean;
    readonly href: string;
    readonly page: string;
    readonly source: ChapterSource;
}

export interface PageSources {
    readonly label: string;
    readonly page: string;
    readonly sources: readonly ChapterSource[];
}

export interface ShapeInput {
    readonly pages: readonly PageSources[];
    readonly readme: ReadmeInputs | null;
}

export type ShapeRenderer = (input: ShapeInput, attribution: Attribution) => Chapter[];

export interface SurfaceRendered {
    readonly chapters: readonly Chapter[];
    readonly ok: true;
    readonly out: string;
    readonly removed: readonly string[];
}

export interface SurfaceRefused {
    readonly ok: false;
    readonly reason: string;
}

export type SurfaceResult = SurfaceRefused | SurfaceRendered;