Add comprehensive admin features and multi-system integration
- 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
This commit is contained in:
parent
e8462ef301
commit
6eee14f8af
171 changed files with 32671 additions and 621 deletions
100
dev/test-time-entries-sync.ts
Normal file
100
dev/test-time-entries-sync.ts
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
* Test script for syncing time entries from Autotask
|
||||
* Run with: npx tsx dev/test-time-entries-sync.ts
|
||||
*/
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { AutotaskClient } from '@/lib/services/autotask-client';
|
||||
import { EntitySyncService } from '@/lib/services/entity-sync';
|
||||
import { EntityType } from '@/lib/types/sync';
|
||||
|
||||
// Load environment variables
|
||||
dotenv.config({ path: path.resolve(__dirname, '../.env.local') });
|
||||
|
||||
async function testTimeEntriesSync() {
|
||||
console.log('🔍 Testing Time Entries Sync\n');
|
||||
|
||||
// Validate environment variables
|
||||
const requiredEnvVars = [
|
||||
'AUTOTASK_API_URL',
|
||||
'AUTOTASK_USERNAME',
|
||||
'AUTOTASK_SECRET',
|
||||
'AUTOTASK_API_INTEGRATION_CODE',
|
||||
];
|
||||
|
||||
const missingVars = requiredEnvVars.filter(v => !process.env[v]);
|
||||
if (missingVars.length > 0) {
|
||||
console.error('❌ Missing required environment variables:', missingVars.join(', '));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
// Initialize Autotask client
|
||||
console.log('Initializing Autotask client...');
|
||||
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!,
|
||||
});
|
||||
console.log('✅ Autotask client initialized\n');
|
||||
|
||||
// Initialize entity sync service
|
||||
console.log('Initializing entity sync service...');
|
||||
const syncService = new EntitySyncService(autotaskClient);
|
||||
console.log('✅ Entity sync service initialized\n');
|
||||
|
||||
// Test sync with a small date range (last 7 days)
|
||||
console.log('Starting time entries sync (last 7 days)...');
|
||||
console.log('This will sync time entries from the last 7 days only.\n');
|
||||
|
||||
const startTime = Date.now();
|
||||
|
||||
try {
|
||||
const result = await syncService.syncEntity(
|
||||
EntityType.TIME_ENTRIES,
|
||||
false, // Full sync (not incremental)
|
||||
0.019 // 7 days in years
|
||||
);
|
||||
|
||||
const duration = Date.now() - startTime;
|
||||
|
||||
console.log('\n✅ Sync completed successfully!');
|
||||
console.log(`Duration: ${(duration / 1000).toFixed(2)}s`);
|
||||
console.log('\nResults:');
|
||||
console.log(` Records added: ${result.recordsAdded}`);
|
||||
console.log(` Records updated: ${result.recordsUpdated}`);
|
||||
console.log(` Records deleted: ${result.recordsDeleted}`);
|
||||
console.log(` Total processed: ${result.recordsAdded + result.recordsUpdated}`);
|
||||
|
||||
} catch (syncError) {
|
||||
console.error('\n❌ Sync failed with error:');
|
||||
console.error(syncError);
|
||||
|
||||
// Try to provide more details
|
||||
if (syncError instanceof Error) {
|
||||
console.error('\nError details:');
|
||||
console.error(' Message:', syncError.message);
|
||||
console.error(' Stack:', syncError.stack);
|
||||
}
|
||||
|
||||
throw syncError;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('\n❌ Test failed:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Run the test
|
||||
testTimeEntriesSync()
|
||||
.then(() => {
|
||||
console.log('\n✅ Test completed successfully');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('\n❌ Test failed:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue