import { AthenaIntelligenceClient, AthenaIntelligenceError } from '@athenaintel/sdk';
async function workWithAssets() {
try {
const client = new AthenaIntelligenceClient({
apiKey: process.env.ATHENA_API_KEY,
});
// List recent assets
console.log('Listing recent assets...');
const assets = await client.assets.list({
limit: 10,
sort: JSON.stringify([
{ field: 'updated_at', direction: 'desc' },
]),
});
console.log(`Found ${assets.total} total assets`);
for (const asset of assets.items) {
const assetId = asset.tags?.asset_id?.[0];
const customTags = asset.tags?.custom_tags || [];
console.log(`\nAsset: ${asset.title}`);
console.log(` ID: ${assetId}`);
console.log(` Type: ${asset.athena_original_type}`);
console.log(` Media Type: ${asset.media_type}`);
console.log(` Custom Tags: ${customTags.length > 0 ? customTags.join(', ') : 'none'}`);
console.log(` Summary Ready: ${asset.summary_ready}`);
}
// Find all folders
console.log('\n\nSearching for folders...');
const folders = await client.assets.list({
limit: 50,
filters: JSON.stringify({
media_type: 'athena/folder',
}),
});
console.log(`Found ${folders.total} folders`);
for (const folder of folders.items) {
const folderId = folder.tags?.asset_id?.[0];
console.log(` - ${folder.title} (${folderId})`);
}
} catch (error) {
if (error instanceof AthenaIntelligenceError) {
console.error(`Athena API error (${error.statusCode}): ${error.message}`);
} else {
console.error('Unexpected error:', error);
}
}
}
workWithAssets();