#!/usr/bin/env npx tsx
import { UmbrellaAuth } from './src/auth.js';
import { UmbrellaApiClient } from './src/api-client.js';
async function analyzeAugustData() {
console.log('๐ ANALYZING AUGUST AWS DATA FOR elisha@umbrellacost.net');
console.log('=====================================================');
const auth = new UmbrellaAuth('https://api.umbrellacost.io/api/v1');
const apiClient = new UmbrellaApiClient('https://api.umbrellacost.io/api/v1');
console.log('\n๐ Authenticating...');
const authResult = await auth.authenticate({
username: 'elisha@umbrellacost.net',
password: 'G37oi57Kp@cNzx'
});
apiClient.setAuthToken(authResult);
console.log('โ
Authentication successful');
// Test specific AWS account instead of MultiCloud
console.log('\n๐ Testing AWS account specifically...');
// Test 1: Try with AWS account ID directly
console.log('\n๐ Test 1: Direct AWS account query (August 2025)');
const awsAugust = await apiClient.makeRequest('/invoices/caui', {
startDate: '2025-08-01',
endDate: '2025-08-16',
accountId: '322609219825' // AWSTest_3226 account
});
// Test 2: Try AWS ALL ACCOUNTS
console.log('\n๐ Test 2: AWS ALL ACCOUNTS query (August 2025)');
const awsAllAugust = await apiClient.makeRequest('/invoices/caui', {
startDate: '2025-08-01',
endDate: '2025-08-16',
accountId: 'umbrellatestnet_tenant_aws' // AWS ALL ACCOUNTS
});
// Test 3: Different date ranges for AWS
console.log('\n๐ Test 3: AWS July 2025');
const awsJuly = await apiClient.makeRequest('/invoices/caui', {
startDate: '2025-07-01',
endDate: '2025-07-31',
accountId: '322609219825'
});
// Test 4: AWS with service grouping (successful pattern from earlier)
console.log('\n๐ Test 4: AWS with groupBy=service');
const awsGrouped = await apiClient.makeRequest('/invoices/caui', {
startDate: '2025-08-01',
endDate: '2025-08-16',
accountId: '322609219825',
groupBy: 'service',
costType: 'cost'
});
// Test 5: Check what working call from Test 3 earlier actually contained
console.log('\n๐ Test 5: Recreate successful call (353 records)');
const successful = await apiClient.makeRequest('/invoices/caui', {
startDate: '2025-08-01',
endDate: '2025-08-16',
groupBy: 'service',
costType: 'cost',
periodGranLevel: 'day'
});
console.log('\n๐ DETAILED DATA ANALYSIS:');
console.log('==========================');
function analyzeResponse(testName: string, response: any) {
console.log(`\n๐ ${testName}:`);
console.log(` Success: ${response.success}`);
if (response.success && response.data) {
console.log(` Data Type: ${Array.isArray(response.data) ? 'Array' : typeof response.data}`);
console.log(` Data Length: ${Array.isArray(response.data) ? response.data.length : 'N/A'}`);
if (Array.isArray(response.data) && response.data.length > 0) {
const firstItem = response.data[0];
console.log(` First Item Keys: ${Object.keys(firstItem)}`);
console.log(` Cost Fields: ${Object.keys(firstItem).filter(k => k.toLowerCase().includes('cost'))}`);
// Look for cost values
const costFields = Object.keys(firstItem).filter(k =>
k.toLowerCase().includes('cost') ||
k.toLowerCase().includes('total') ||
k.toLowerCase().includes('amount')
);
costFields.forEach(field => {
console.log(` ${field}: ${firstItem[field]}`);
});
} else if (response.data.totalCost !== undefined) {
console.log(` Total Cost: ${response.data.totalCost}`);
}
} else {
console.log(` Error: ${response.error}`);
}
}
analyzeResponse('AWS Direct', awsAugust);
analyzeResponse('AWS All Accounts', awsAllAugust);
analyzeResponse('AWS July', awsJuly);
analyzeResponse('AWS Grouped', awsGrouped);
analyzeResponse('Successful Call (353 records)', successful);
console.log('\n๐ฏ WHY ZERO COSTS ANALYSIS:');
console.log('===========================');
console.log('1. Check if API returns empty arrays vs non-zero cost values');
console.log('2. Verify which parameters are required for cost data');
console.log('3. Compare successful call (353 records) vs failed calls (0 records)');
console.log('4. Identify required vs optional parameters for cost APIs');
}
analyzeAugustData().catch(console.error);