#!/usr/bin/env node
/**
* Debug script to examine full task structure from API
*/
import { LiteFarmClient } from './dist/litefarm-client.js';
import dotenv from 'dotenv';
dotenv.config();
const client = new LiteFarmClient(process.env.LITEFARM_EMAIL, process.env.LITEFARM_PASSWORD);
await client.login();
const farmId = '15758606-cb0d-11f0-a430-eed6bc26dc01';
console.log('π Fetching all tasks for farm:', farmId);
console.log('');
const tasks = await client.getTasks({ farm_id: farmId });
if (tasks.length === 0) {
console.log('β No tasks found');
process.exit(0);
}
console.log(`Found ${tasks.length} task(s):\n`);
// Output full structure of first task
console.log('=== FULL STRUCTURE OF FIRST TASK ===');
console.log(JSON.stringify(tasks[0], null, 2));
console.log('\n=== TASK SUMMARY ===\n');
tasks.forEach((t, idx) => {
console.log(`Task #${idx + 1}:`);
console.log(` task_id: ${t.task_id}`);
console.log(` type: ${t.type}`);
console.log(` task_type_id: ${t.task_type_id}`);
console.log(` due_date: ${t.due_date}`);
console.log(` status: ${t.status || 'planned'}`);
console.log(` notes: ${t.notes || 'N/A'}`);
// Check for task-specific nested objects
if (t.field_work_task) {
console.log(` β
Has field_work_task object:`, JSON.stringify(t.field_work_task));
}
if (t.cleaning_task) {
console.log(` β
Has cleaning_task object:`, JSON.stringify(t.cleaning_task));
}
if (t.harvest_task) {
console.log(` β
Has harvest_task object:`, JSON.stringify(t.harvest_task));
}
// Check locations
if (t.locations && t.locations.length > 0) {
console.log(` π Locations:`, t.locations.map(l => l.location_id || l).join(', '));
}
console.log('');
});