- Add admin dashboard with sync controls and data browser - Implement RMM, Auvik, and Addigy organization mappings - Add chunked ticket sync with progress tracking - Implement entity sync service with rate limiting - Add analytics engine and performance optimizer - Create data browser for all PSA entities - Add navigation components and UI improvements - Implement background processing and sync services - Add comprehensive documentation and migration scripts - Update configuration items with multi-system support - Enhance contact management and purchase history - Add issue type assignment and LLM analyzer - Improve error handling and logging utilities
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { getAutotaskClient } from '@/lib/services/autotask-factory';
|
|
|
|
/**
|
|
* Lightweight endpoint that only fetches the PSA configuration item
|
|
* without any RMM or Auvik matching. Used when devices are already known.
|
|
*/
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
try {
|
|
const { id } = await params;
|
|
const autotaskClient = getAutotaskClient();
|
|
|
|
// Fetch only the configuration item
|
|
const autotaskDevice = await autotaskClient.getConfigurationItemById(parseInt(id));
|
|
|
|
if (!autotaskDevice) {
|
|
return NextResponse.json(
|
|
{ error: 'Configuration item not found' },
|
|
{ status: 404 }
|
|
);
|
|
}
|
|
|
|
// Get company name
|
|
let companyName: string | null = null;
|
|
try {
|
|
const company = await autotaskClient.getCompanyById(autotaskDevice.companyID);
|
|
companyName = company?.companyName || null;
|
|
} catch (err) {
|
|
console.error('Failed to fetch company name:', err);
|
|
}
|
|
|
|
return NextResponse.json({
|
|
autotaskDevice,
|
|
companyName
|
|
});
|
|
} catch (error) {
|
|
console.error('Error fetching configuration item:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch configuration item' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|