Type Alias MetadataSource

MetadataSource: StepSource | EmitterSource

Who set an entry of global metadata: a step, a hook or a service provider.

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;
}