import { MetabaseClient } from './src/metabase/client.js';
import dotenv from 'dotenv';
import { join } from 'path';
dotenv.config({ path: join(process.cwd(), '.env') });
async function main() {
console.log("๐ Probing Data Visibility...");
// Remove API KEY from options to FORCE Username/Password auth
const client = new MetabaseClient({
url: process.env.METABASE_URL,
username: process.env.METABASE_USERNAME,
password: process.env.METABASE_PASSWORD
});
try {
await client.authenticate();
console.log("โ
API Authenticated (User/Pass)");
} catch (e) {
console.error("โ Authentication Failed:", e.message);
process.exit(1);
}
const internalDbId = 6;
try {
console.log(`\n๐ Querying report_card on DB ${internalDbId}...`);
const res = await client.executeNativeQuery(internalDbId, "SELECT count(*) FROM report_card", { enforcePrefix: false });
if (res.rows && res.rows.length > 0) {
console.log(`โ
SUCCESS: Found ${res.rows[0][0]} cards in report_card!`);
} else {
console.log("โ ๏ธ Query success but returned 0 rows.");
}
} catch (e) {
console.error(`โ Failed to query Internal DB (ID ${internalDbId}):`, e.message);
}
}
main().catch(err => console.error(err));