import { AutoCodeInspection, Autofix, AutofixRegistration, AutoInspectRegistration, Goals, PushListenerInvocation, PushTest, SdmContext } from "@atomist/sdm"; import { DeliveryPhases } from "./phases"; import { ProjectAnalysis } from "./ProjectAnalysis"; import { ProjectAnalyzer } from "./ProjectAnalyzer"; import { Scores } from "./Score"; import { HasMessages } from "./support/messageGoal"; /** * Consolidated interpretation. Unlike a ProjectAnalysis, an interpretation is not * intended to be persisted, but is only held in memory. * Interpreters add to an Interpretation's goals, considering what goals may already have been set. */ export interface Interpretation extends DeliveryPhases, HasMessages { /** * The data on which we arrived at this interpretation */ readonly reason: { /** * The analysis this Interpretation is based on */ readonly analysis: ProjectAnalysis; readonly availableInterpreters: Interpreter[]; readonly chosenInterpreters: Interpreter[]; /** * If this interpretation was initiated in response to * a push, the invocation that triggered it. This allows us to * look at information about the branch, committer etc. */ readonly pushListenerInvocation?: PushListenerInvocation; }; /** * List of push tests determining if a change is a material change. * Any one of these returning true will cause the change to be * deemed material. * This varies depending on the technology stack. * Allows consistent handling of non-material changes across * all technologies. */ readonly materialChangePushTests: PushTest[]; readonly autofixes: AutofixRegistration[]; /** * Inspections relevant to this Interpretation. */ readonly inspections: Array>; readonly autofixGoal: Autofix; readonly codeInspectionGoal: AutoCodeInspection; readonly scores: Scores; } /** * Implemented by types that can use a ProjectAnalysis-- * without access to the underlying project--to fill in how * the repo should be handled: checked, autofixed, built, deployed etc. */ export interface Interpreter { /** * Some interpreters need to create goals that invoke their own analysis. * This callback enables that. */ setAnalyzer?(analyzer: ProjectAnalyzer): void; /** * Enrich the given interpretation * @param {Interpretation} interpretation * @param sdmContext context to compute in * @return {Promise} whether enrichment was made */ enrich(interpretation: Interpretation, sdmContext: SdmContext): Promise; } /** * Extended by interpreters that can add autofixes. The enrich method should be * implemented to add to the Interpretation's autofixes, from those * return by the autofixes method. */ export interface AutofixRegisteringInterpreter extends Interpreter { /** * This must be a stable value for possible autofixes, returned on all calls */ readonly autofixes: AutofixRegistration[]; /** * Configure the autofix goal to add more listeners etc */ configureAutofixGoal?: (goal: Autofix) => void; } /** * Extended by interpreters that can add code inspections. The enrich method should be * implemented to add to the Interpretation's inspections, from those * return by the codeInspections method. */ export interface CodeInspectionRegisteringInterpreter extends Interpreter { /** * This must be a stable value for possible code inspections, returned on all calls */ readonly codeInspections: Array>; /** * Configure the code inspection goal to add more listeners etc */ configureCodeInspectionGoal?: (goal: AutoCodeInspection) => void; } export declare function isAutofixRegisteringInterpreter(a: Interpreter): a is AutofixRegisteringInterpreter; export declare function isCodeInspectionRegisteringInterpreter(a: Interpreter): a is CodeInspectionRegisteringInterpreter; export declare function controlGoals(interpretation: Interpretation): Goals; export declare function deliveryNotificationGoals(interpretation: Interpretation): Goals; export declare function checkGoals(interpretation: Interpretation, analyzer: ProjectAnalyzer): Goals; export declare function buildGoals(interpretation: Interpretation, analyzer: ProjectAnalyzer): Goals; /** * Messaging goals. Only set if there are messages in this interpretation. */ export declare function messagingGoals(hasMessages: HasMessages, analyzer: ProjectAnalyzer): Goals; export declare function testGoals(interpretation: Interpretation, analyzer: ProjectAnalyzer): Goals; export declare function containerGoals(interpretation: Interpretation, analyzer: ProjectAnalyzer): Goals; export declare function releaseGoals(interpretation: Interpretation, analyzer: ProjectAnalyzer): Goals; export declare function deployGoals(interpretation: Interpretation, analyzer: ProjectAnalyzer): Goals;