Type Alias HookSource

A hook that was called: a hook of a step policy, with the step and attempt that triggered it, or a hook of a workflow policy.

import type { ContributionSource, Event } from "itinera/event";

function author(source: ContributionSource): string {
switch (source.kind) {
case "step":
return `${source.step}, attempt ${source.attempt.toString()}`;
case "step hook":
return `${source.policy}, ${source.hook}, for ${source.step}`;
case "workflow hook":
return `${source.policy}, ${source.hook}`;
}
}

export function committed(event: Event): string | undefined {
return event.kind === "contribution_committed"
? `${event.key} from ${author(event.source)}`
: undefined;
}