← Public packages
@charlesmatte/todos
Shared todo, task and reminder store that any of your Kody-connected agents can use.
src/get.ts
21 lines · 857 B · TypeScriptimport { parseInput } from './lib/validate.ts'
import { idField, tzField } from './lib/fields.ts'
import { line, normalizeId, requireTodo, isOverdue, resolveTimeZone } from './lib/store.ts'
/**
* Get one todo/task from the shared todo list by id, including its full change history.
*
* @param input - `{ id: string ("T12" or "12"), timeZone?: string }`
* @returns `{ todo, overdue, line }`
*
* @example
* import getTodo from 'kody:@charlesmatte/todos/get'
*
* const { todo } = await getTodo({ id: 'T12' })
*/
export default async function getTodo(input: unknown) {
const p = parseInput<{ id: string; timeZone?: string }>(input, { id: idField, timeZone: tzField }, 'todos/get')
const todo = await requireTodo(normalizeId(p.id))
const tz = await resolveTimeZone(p.timeZone)
return { todo, overdue: isOverdue(todo, tz), line: line(todo, tz) }
}