UNPKG

@log4brains/core

Version:

Log4brains architecture knowledge base core API

121 lines 4.88 kB
import { Log4brainsConfig } from "../config"; import { AdrDto, AdrDtoStatus } from "./types"; import { FileWatcher } from "../file-watcher"; export declare type SearchAdrsFilters = { statuses?: AdrDtoStatus[]; }; /** * Log4brains core API. * Use {@link Log4brains.create} to build an instance. */ export declare class Log4brains { readonly config: Log4brainsConfig; readonly workdir: string; private readonly container; private readonly commandBus; private readonly queryBus; private readonly adrRepository; private constructor(); /** * Returns the ADRs which match the given search filters. * Returns all the ADRs of the project if no filter is given. * The results are sorted with this order priority (ASC): * 1. By the Date field from the markdown file (if available) * 2. By the Git creation date (does not follow renames) * 3. By slug * * @param filters Optional. Filters to apply to the search * * @throws {@link Log4brainsError} * In case of a non-recoverable error. */ searchAdrs(filters?: SearchAdrsFilters): Promise<AdrDto[]>; /** * Returns an ADR by its slug. * * @param slug ADR slug * * @throws {@link Log4brainsError} * In case of a non-recoverable error. */ getAdrBySlug(slug: string): Promise<AdrDto | undefined>; /** * Generates an available ADR slug for the given title and package. * Format: [package-name/]yyyymmdd-slugified-lowercased-title * * @param title The title of the ADR * @param packageName Optional. The package name of the ADR. * * @throws {@link Log4brainsError} * In case of a non-recoverable error. */ generateAdrSlug(title: string, packageName?: string): Promise<string>; /** * Creates a new ADR with the given slug and title with the default template. * @param slug The slug of the ADR * @param title The title of the ADR * * @throws {@link Log4brainsError} * In case of a non-recoverable error. */ createAdrFromTemplate(slug: string, title: string): Promise<AdrDto>; /** * Supersede an ADR with another one. * @param supersededSlug Slug of the superseded ADR * @param supersederSlug Slug of the superseder ADR * * @throws {@link Log4brainsError} * In case of a non-recoverable error. */ supersedeAdr(supersededSlug: string, supersederSlug: string): Promise<void>; /** * Opens the given ADR in an editor on the local machine. * Tries first to guess the preferred editor of the user thanks to https://github.com/yyx990803/launch-editor. * If impossible to guess, uses xdg-open (or similar, depending on the OS, thanks to https://github.com/sindresorhus/open) as a fallback. * The overall order is thus the following: * 1) The currently running editor among the supported ones by launch-editor * 2) The editor defined by the $VISUAL environment variable * 3) The editor defined by the $EDITOR environment variable * 4) Fallback: xdg-open or similar * * @param slug The ADR slug to open * @param onImpossibleToGuess Optional. Callback called when the fallback method is used. * Useful to display a warning to the user to tell him to set his $VISUAL environment variable for the next time. * * @throws {@link Log4brainsError} * If the ADR does not exist or if even the fallback method fails. */ openAdrInEditor(slug: string, onImpossibleToGuess?: () => void): Promise<void>; /** * Returns a singleton instance of FileWatcher. * Useful for Hot Reloading. * @see FileWatcher */ get fileWatcher(): FileWatcher; /** * Creates an instance of the Log4brains API. * * @param workdir Path to working directory (ie. where ".log4brains.yml" is located) * * @throws {@link Log4brainsConfigNotFoundError} * In case of missing config file. * * @throws {@link Log4brainsError} * In case of invalid config file or other domain error. */ static create(workdir?: string): Log4brains; /** * Creates an instance of the Log4brains API from a working directory. * The real working directory (ie. where ".log4brains.yml" is located) will be guessed looking in the parent directories. * * @param cwd Current working directory * * @throws {@link Log4brainsConfigNotFoundError} * In case of missing config file. * * @throws {@link Log4brainsError} * In case of invalid config file or other domain error. */ static createFromCwd(cwd?: string): Log4brains; } //# sourceMappingURL=Log4brains.d.ts.map