MANIFESTconstno test imports itconst MANIFEST: "library.ts"The name of a library's manifest in its folder.
The host side of the check of Kanon (commons 0033-kanon FR-012, FR-014): it reads a library's manifest for its table, the exports of its package and its .ts files, and gives the findings of the import check over them, judged against a baseline of findings that only shrinks. The pure check is importFindings; this is the only module of the package that reads files.
Effects are at the edge and behind a port: every function here takes Files, a typed record of the four functions it reads with, and systemFiles is the real one; a failure the host can cause (a missing file, a package that is not JSON) is a Result, never a throw. Every .ts file under the library's root is read but node_modules, dist and the spec kit's folder, so that a file that no unit of the table holds is found (layers/unclassified).
MANIFESTconstno test imports itconst MANIFEST: "library.ts"The name of a library's manifest in its folder.
CONSUMER_MANIFESTconstno test imports itconst CONSUMER_MANIFEST: "kanon.ts"The name of the manifest of a consumer, a package that is not a library of commons (0033-kanon FR-027): the export kanon, a table in the form of the field kanon of library.ts.
BASELINEconstconst BASELINE: "kanon.baseline.txt"The name of the baseline of findings a library holds, in its folder.
Filestypetype Files = {
readonly exists: (path: string) => boolean;
readonly readDir: (path: string) => readonly { readonly name: string; readonly isDirectory: boolean }[];
readonly readText: (path: string) => string;
/** The bytes of a file, for a bundle (0002-kanon-content-checks FR-011). */
readonly readBytes?: (path: string) => Uint8Array;
};What the host reads with: a port, a record of functions, so that a test or another host may give its own.
systemFilesconstno test imports itconst systemFiles: FilesThe real file system.
Exportstypeno test imports ittype Exports = ExportsMap;An exports map: each subpath to its target, a string or an object of conditions of strings.
readTablefunctionfunction readTable(root: string, files?: Files): Result<Table, string>The table of the library at root, from the field kanon of its manifest; an error as a sentence where there is none or it is not a table.
readTableOffunctionfunction readTableOf(root: string, files?: Files): Result<{ readonly table: Table; readonly manifest: "kanon.ts" | "library.ts"; }, string>The table of a package and the manifest it was read from: library.ts (its field kanon) or, where there is none, the consumer's kanon.ts (0002-kanon-content-checks FR-007).
readBundlefunctionfunction readBundle(dir: string, files?: Files): Result<{ readonly manifest: string; readonly files: ReadonlyMap<string, Uint8Array<ArrayBufferLike>>; }, string>The files of a bundle in a folder, and the text of its manifest, read and nothing written: every file under the folder but the manifest, by its path from the folder with / (0002-kanon-content-checks FR-011).
readSourcesfunctionfunction readSources(root: string, files?: Files, dir?: string): Result<readonly SourceFile[], string>The .ts files under dir, as paths from root with /, in the order of their names.
readExportsfunctionfunction readExports(root: string, files?: Files): Result<Readonly<Record<string, string | { readonly [condition: string]: string; }>>, string>The exports of the package at root, each subpath to its target.
findingsfunctionfunction findings(root: string, files?: Files): Result<readonly Finding[], string>Every finding of the import check over the library at root, or why its table, its package or its files cannot be read.
parseBaselinefunctionno test imports itfunction parseBaseline(text: string): ReadonlySet<string>A baseline's keys, from its text: a line that is not a comment or blank.
judgefunctionno test imports itfunction judge(found: readonly Finding[], baseline: ReadonlySet<string>): { readonly fresh: readonly Finding[]; readonly stale: readonly string[]; }The judgement of findings against a baseline: the new ones, and the lines of the baseline that no longer occur (both fail the check).