@atomist/org-visualizer
Version:
Organization Visualizer using Atomist project scanning
114 lines • 3.84 kB
TypeScript
import { RemoteRepoRef } from "@atomist/automation-client";
import { Aspect, AtomicAspect, FP, Ideal } from "@atomist/sdm-pack-fingerprints";
/**
* Function that can return the desired ideal, if any, for a given fingerprint name.
* While an Aspect can suggest multiple ideals in the suggestedIdeals method,
* there can only be one ideal recommended at any time.
*/
export interface IdealStore {
storeIdeal(workspaceId: string, ideal: Ideal): Promise<void>;
/**
* Set the ideal to the given fingerprint id
* @param {string} workspaceId
* @param {string} fingerprintId
* @return {Promise<void>}
*/
setIdeal(workspaceId: string, fingerprintId: string): Promise<void>;
loadIdeal(workspaceId: string, type: string, name: string): Promise<Ideal | undefined>;
/**
* Load all ideals in this workspace
* @param {string} workspaceId
* @return {Promise<Ideal[]>}
*/
loadIdeals(workspaceId: string): Promise<Ideal[]>;
}
/**
* Flag for an undesirable usage
*/
export interface ProblemUsage {
readonly severity: "info" | "warn" | "error";
/**
* Authority this comes from
*/
readonly authority: string;
/**
* Message to the user
*/
readonly description?: string;
/**
* URL associated with this if one is available.
* For example, a security advisory.
*/
readonly url?: string;
readonly fingerprint: FP;
}
/**
* Store of problem fingerprints
*/
export interface ProblemStore {
noteProblem(workspaceId: string, fingerprintId: string): Promise<void>;
storeProblemFingerprint(workspaceId: string, problem: ProblemUsage): Promise<void>;
loadProblems(workspaceId: string): Promise<ProblemUsage[]>;
}
export declare type UndesirableUsageCheck = (workspaceId: string, fp: FP) => Promise<ProblemUsage | undefined>;
/**
* Function that can flag an issue with a fingerprint.
* This is a programmatic complement to ProblemStore.
*/
export interface UndesirableUsageChecker {
check: UndesirableUsageCheck;
}
export declare const PermitAllUsageChecker: UndesirableUsageChecker;
/**
* Implemented by ProjectAnalysis or any other structure
* representing a repo exposing fingerprint data
*/
export interface HasFingerprints {
fingerprints: FP[];
}
/**
* Result of an analysis. We must always have at least fingerprints and repo identification
*/
export declare type Analyzed = HasFingerprints & {
id: RemoteRepoRef;
};
/**
* Type of Aspect we can manage
*/
export declare type ManagedAspect<FPI extends FP = FP> = Aspect<FPI> | AtomicAspect<FPI>;
/**
* Manage a number of aspects.
*/
export interface AspectRegistry {
/**
* All the aspects we are managing
*/
readonly aspects: ManagedAspect[];
/**
* Find the aspect that manages fingerprints of this type
*/
aspectOf(type: string): ManagedAspect | undefined;
/**
* Function that can resolve ideal status for this aspect
*/
readonly idealStore: IdealStore;
readonly problemStore: ProblemStore;
/**
* Return an UndesirableUsageChecker for this workspace
*/
undesirableUsageCheckerFor(workspaceId: string): Promise<UndesirableUsageChecker>;
}
/**
* UndesirableUsageChecker from a list
* @param {(fp: FP) => Promise<Flag[]>} checkers
* @return {UndesirableUsageChecker}
*/
export declare function chainUndesirableUsageCheckers(...checkers: UndesirableUsageCheck[]): UndesirableUsageChecker;
/**
* Undesirable usageChecker backed by a ProblemStore
* @param {ProblemStore} problemStore
* @param {string} workspaceId
* @return {Promise<UndesirableUsageChecker>}
*/
export declare function problemStoreBackedUndesirableUsageCheckerFor(problemStore: ProblemStore, workspaceId: string): Promise<UndesirableUsageChecker>;
//# sourceMappingURL=AspectRegistry.d.ts.map