const todoistPackage = await npm("todoist");
const dayjs = await npm("dayjs");
const token = await env("TODOIST_TOKEN");
const client = todoistPackage.v8(token);
await client.sync();
let items = client.items.get();
items = items.filter((item) => {
let dueDate = dayjs(item.due.date);
return dueDate.diff(dayjs(), "day") <= 7;
});
await arg(
"View this week's tasks",
items.map((item) => {
return {
name: item.content,
description: `Due: ${item.due.date}`,
};
})
);