Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/trello

src/scheduled-account-health.ts

29 lines · 802 B · TypeScript
import { getViewer } from './viewer.ts'
import { listBoards } from './boards.ts'

/**
 * No-argument scheduled wrapper. Reads member and open boards only — no writes.
 * The `account-health` job is **disabled** by default.
 * @example
 * import scheduledAccountHealth from 'kody:@kody/trello/scheduled-account-health'
 * const snapshot = await scheduledAccountHealth()
 */
export default async function scheduledAccountHealth() {
	const [viewer, boards] = await Promise.all([
		getViewer(),
		listBoards({ filter: 'open', limit: 25 }),
	])
	return {
		viewer: {
			id: viewer.id,
			username: viewer.username,
			fullName: viewer.fullName,
		},
		openBoardCount: boards.length,
		sampleBoards: boards.slice(0, 5).map((board) => ({
			id: board.id,
			name: board.name,
			url: board.url,
		})),
	}
}