archunit
Version:
ArchUnit TypeScript is an architecture testing library, to specify and assert architecture rules in your TypeScript app
92 lines (91 loc) • 3.94 kB
TypeScript
import { Edge } from '../common/extraction/graph';
import { Pattern } from '../common/type';
import { CheckOptions } from '../common/fluentapi';
export type GraphReportFormat = 'dot' | 'mermaid' | 'd2' | 'csv' | 'json' | 'html';
export interface GraphQueryOptions {
includeExternalDependencies?: boolean;
includeSelfDependencies?: boolean;
focus?: Pattern;
focusDepth?: number;
reachableFrom?: Pattern;
dependentsOf?: Pattern;
collapse?: GraphCollapseStrategy;
title?: string;
}
export type GraphCollapseStrategy = {
type: 'folder-depth';
depth: number;
} | {
type: 'pattern';
pattern: RegExp;
replacement: string;
};
export interface GraphReportNode {
id: string;
label: string;
}
export interface GraphReportEdge {
source: string;
target: string;
count: number;
external: boolean;
importKinds: string[];
}
export interface GraphReportSnapshot {
title: string;
nodes: GraphReportNode[];
edges: GraphReportEdge[];
summary: {
nodeCount: number;
edgeCount: number;
rawEdgeCount: number;
externalEdgeCount: number;
};
}
export declare const projectGraph: (tsConfigFilePath?: string) => ProjectGraphBuilder;
export declare const dependencyGraph: (tsConfigFilePath?: string) => ProjectGraphBuilder;
export declare class ProjectGraphBuilder {
readonly tsConfigFilePath?: string | undefined;
private readonly options;
private readonly checkOptions?;
constructor(tsConfigFilePath?: string | undefined, options?: GraphQueryOptions, checkOptions?: CheckOptions | undefined);
includeExternalDependencies(): ProjectGraphBuilder;
includeSelfDependencies(): ProjectGraphBuilder;
focusOn(pattern: Pattern, depth?: number): ProjectGraphBuilder;
reachableFrom(pattern: Pattern): ProjectGraphBuilder;
dependentsOf(pattern: Pattern): ProjectGraphBuilder;
collapseToFolderDepth(depth: number): ProjectGraphBuilder;
collapseByPattern(pattern: RegExp, replacement?: string): ProjectGraphBuilder;
titled(title: string): ProjectGraphBuilder;
withCheckOptions(checkOptions: CheckOptions): ProjectGraphBuilder;
snapshot(): Promise<GraphReportSnapshot>;
toDOT(): Promise<string>;
toMermaid(): Promise<string>;
toD2(): Promise<string>;
toCSV(): Promise<string>;
toJSON(): Promise<string>;
toHTML(): Promise<string>;
exportAsDOT(outputPath: string): Promise<void>;
exportAsMermaid(outputPath: string): Promise<void>;
exportAsD2(outputPath: string): Promise<void>;
exportAsCSV(outputPath: string): Promise<void>;
exportAsJSON(outputPath: string): Promise<void>;
exportAsHTML(outputPath: string): Promise<void>;
private withOptions;
private getGraph;
}
export declare class GraphReporter {
static createSnapshot(graph: Edge[], options?: GraphQueryOptions): GraphReportSnapshot;
static toDOT(graph: Edge[], options?: GraphQueryOptions): string;
static toMermaid(graph: Edge[], options?: GraphQueryOptions): string;
static toD2(graph: Edge[], options?: GraphQueryOptions): string;
static toCSV(graph: Edge[], options?: GraphQueryOptions): string;
static toJSON(graph: Edge[], options?: GraphQueryOptions): string;
static toHTML(graph: Edge[], options?: GraphQueryOptions): string;
static exportAsDOT(graph: Edge[], outputPath: string, options?: GraphQueryOptions): Promise<void>;
static exportAsMermaid(graph: Edge[], outputPath: string, options?: GraphQueryOptions): Promise<void>;
static exportAsD2(graph: Edge[], outputPath: string, options?: GraphQueryOptions): Promise<void>;
static exportAsCSV(graph: Edge[], outputPath: string, options?: GraphQueryOptions): Promise<void>;
static exportAsJSON(graph: Edge[], outputPath: string, options?: GraphQueryOptions): Promise<void>;
static exportAsHTML(graph: Edge[], outputPath: string, options?: GraphQueryOptions): Promise<void>;
}