@atomist/sdm-pack-aspect
Version:
an Atomist SDM Extension Pack for visualizing drift across an organization
80 lines • 2.79 kB
TypeScript
import { PlantedTree, SunburstLeaf } from "./sunburst";
/**
* Implemented by types that can create JSON usable to back a d3 sunburst
* or other displayable formats from a set of repositories.
*/
export interface ReportBuilder<ROOT> {
/**
* Construct a PlantedTree from the given data.
* @param {() => (ROOT[] | AsyncIterable<ROOT>)} query
* @return {Promise<SunburstTree>}
*/
toPlantedTree(query: () => ROOT[] | AsyncIterable<ROOT>): Promise<PlantedTree>;
}
export declare type Renderer<T> = (t: T) => SunburstLeaf;
/**
* Access analysis data to emit a sunburst tree. All calculations will
* be performed in memory once an initial cohort of repo analyses is provided.
* All methods cause a tree layer to be emitted except for map
*/
export interface TreeBuilder<ROOT, T> {
/**
* Name of the tree rout
*/
readonly rootName: string;
/**
* Group values in the present layer by classifying each individual value.
* Return undefined to exclude a value
*/
group(groupStep: GroupStep<T>): TreeBuilder<ROOT, T>;
/**
* Group all values in the present layer in one go
* @param {CustomGroupStep<T, Q>} customGroupStep
* @return {TreeBuilder<Q>}
*/
customGroup<Q>(customGroupStep: CustomGroupStep<T, Q>): TreeBuilder<ROOT, Q>;
/**
* Split each T into multiple Qs, emitting a layer
*/
split<Q>(splitStep: SplitStep<T, Q>): TreeBuilder<ROOT, Q>;
/**
* Map or suppress values. Does not emit a layer.
* Can be used to filter as undefined values will be excluded
*/
map<Q>(mapStep: MapStep<ROOT, T, Q>): TreeBuilder<ROOT, Q>;
/**
* Setting the renderer for leaf nodes gives us a ReportBuilder we can
* use to transform passed in data.
* @param {(t: T) => SunburstLeaf} renderer
* @return {SunburstTree}
*/
renderWith(renderer: Renderer<T>): ReportBuilder<ROOT>;
}
/**
* Group records in this layer by a string
*/
export interface GroupStep<T> {
name: string;
by: (t: T) => string | Promise<string>;
flattenSingle?: boolean;
}
export interface CustomGroupStep<T, Q> {
name: string;
to: (t: T[] | AsyncIterable<T>) => Promise<Record<string, Q[]>> | Record<string, Q[]>;
flattenSingle?: boolean;
}
/**
* Map all the n records in this layer to m Qs
*/
export interface MapStep<ROOT, T, Q> {
mapping: (t: AsyncIterable<T> | T[], originalQuery: () => ROOT[] | AsyncIterable<ROOT>) => AsyncIterable<Q>;
}
/**
* Split every record T in this layer into n Qs
*/
export interface SplitStep<T, Q> {
splitter: (t: T) => Promise<Q[]> | Q[];
namer: (t: T) => string;
}
export declare function treeBuilder<ROOT, T = ROOT>(rootName: string): TreeBuilder<ROOT, T>;
//# sourceMappingURL=TreeBuilder.d.ts.map