UNPKG

2.71 kBTypeScriptView Raw
1import { InterpretLog } from "../../../spi/log/InterpretedLog";
2import { RepoContext } from "../../context/SdmContext";
3import { PushListenerInvocation } from "../../listener/PushListener";
4import { PushTest } from "../../mapping/PushTest";
5import { Goal } from "../Goal";
6import { ExecuteGoal, GoalProjectListenerRegistration } from "../GoalInvocation";
7import { PlannedGoal } from "../GoalWithFulfillment";
8import { ReportProgress } from "../progress/ReportProgress";
9import { SdmGoalEvent } from "../SdmGoalEvent";
10export declare type GoalFulfillment = GoalImplementation | GoalSideEffect;
11export interface GoalImplementation {
12 implementationName: string;
13 goal: Goal;
14 goalExecutor: ExecuteGoal;
15 pushTest: PushTest;
16 logInterpreter: InterpretLog;
17 progressReporter?: ReportProgress;
18 projectListeners: GoalProjectListenerRegistration | GoalProjectListenerRegistration[];
19}
20export declare function isGoalImplementation(f: GoalFulfillment): f is GoalImplementation;
21/** Information needed to create a goal side effect. */
22export interface GoalSideEffect {
23 /** Name of goal side effect. It should be unique. */
24 sideEffectName: string;
25 /** Goal on which to associated the side effect. */
26 goal: Goal;
27 /**
28 * Push test that when true the side effect will be triggered. If
29 * not provided, [[AnyPush]] is used.
30 */
31 pushTest?: PushTest;
32 /**
33 * Name of SDM executing side effect. If not provided, the
34 * current SDM registration name will be used.
35 */
36 registration?: string;
37}
38export declare function isGoalSideEffect(f: GoalFulfillment): f is GoalSideEffect;
39export declare function isGoalFulfillment(g: {
40 fulfillment?: PlannedGoal["fulfillment"];
41}): g is {
42 fulfillment: PlannedGoal["fulfillment"];
43};
44/**
45 * Callback to allow changes to the goal before it gets fullfilled.
46 *
47 * This is useful to add goal specific information to the data field.
48 */
49export interface GoalFulfillmentCallback {
50 goal: Goal;
51 callback: (goal: SdmGoalEvent, context: RepoContext) => Promise<SdmGoalEvent>;
52}
53/**
54 * Registers and looks up goal implementations
55 */
56export interface GoalImplementationMapper {
57 hasImplementation(): boolean;
58 addSideEffect(sideEffect: GoalSideEffect): this;
59 addFulfillmentCallback(callback: GoalFulfillmentCallback): this;
60 findImplementationBySdmGoal(goal: SdmGoalEvent): GoalImplementation;
61 findFulfillmentByPush(goal: Goal, inv: PushListenerInvocation): Promise<GoalFulfillment | undefined>;
62 findFulfillmentCallbackForGoal(g: SdmGoalEvent): GoalFulfillmentCallback[];
63 findGoalBySdmGoal(g: SdmGoalEvent): Goal | undefined;
64}
65//# sourceMappingURL=GoalImplementationMapper.d.ts.map
\No newline at end of file