- 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
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
/**
|
|
* Sync History API Endpoint
|
|
* GET /api/sync/history - Get sync history records
|
|
*/
|
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { AutotaskClient } from '@/lib/services/autotask-client';
|
|
import { createSyncService } from '@/lib/services/sync-service';
|
|
import { EntityType } from '@/lib/types/sync';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const searchParams = request.nextUrl.searchParams;
|
|
const limit = parseInt(searchParams.get('limit') || '50');
|
|
const entityType = searchParams.get('entityType') as EntityType | null;
|
|
|
|
// Initialize Autotask client (needed for service instantiation)
|
|
const autotaskClient = new AutotaskClient({
|
|
apiUrl: process.env.AUTOTASK_API_URL || '',
|
|
username: process.env.AUTOTASK_USERNAME || '',
|
|
password: process.env.AUTOTASK_SECRET || '',
|
|
apiIntegrationCode: process.env.AUTOTASK_API_INTEGRATION_CODE || '',
|
|
});
|
|
|
|
// Create sync service
|
|
const syncService = createSyncService(autotaskClient);
|
|
|
|
// Get sync history
|
|
const history = await syncService.getSyncHistory(
|
|
limit,
|
|
entityType || undefined
|
|
);
|
|
|
|
return NextResponse.json({
|
|
history,
|
|
count: history.length,
|
|
});
|
|
} catch (error) {
|
|
console.error('Failed to fetch sync history:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch sync history' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|