Skip to content

src/brain.ts

15 lines · 670 B · TypeScript
Raw
import { fetchSnapshot } from './github.ts'
import type { PrLocator } from './input.ts'
import { computeShip, type ComputeOptions } from './status.ts'
import { listDecisions, listEvents } from './storage.ts'

/** Fetch PR state + active decisions/events and compute the progressive report. */
export async function loadShip(locator: PrLocator, options: Omit<ComputeOptions, 'now'>) {
	const [snapshot, decisions, events] = await Promise.all([
		fetchSnapshot(locator),
		listDecisions(locator.key),
		listEvents(locator.key),
	])
	const report = computeShip(snapshot, decisions, events, { ...options, now: Date.now() })
	return { snapshot, decisions, events, report }
}