#!/usr/bin/env node
/**
* Extract all bank customers from AllCloud account list
*/
const { spawn } = require('child_process');
async function extractBankCustomers() {
console.log('🏦 EXTRACTING ALL BANK CUSTOMERS FROM ALLCLOUD');
console.log('=' .repeat(60));
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe'],
env: process.env
});
let responses = {};
let responseBuffer = '';
let allAccounts = [];
server.stdout.on('data', (data) => {
responseBuffer += data.toString();
const lines = responseBuffer.split('\n');
for (let i = 0; i < lines.length - 1; i++) {
const line = lines[i].trim();
if (line) {
try {
const response = JSON.parse(line);
if (response.id) {
responses[response.id] = response;
}
} catch (e) {
// Not JSON, continue
}
}
}
responseBuffer = lines[lines.length - 1];
});
server.stderr.on('data', (data) => {
const msg = data.toString();
// Capture all account info from debug output
const accountMatch = msg.match(/Key: (\d+), Name: ([^,]+), Type:/);
if (accountMatch) {
allAccounts.push({
key: accountMatch[1],
name: accountMatch[2].trim()
});
}
if (msg.includes('started successfully')) {
console.log('✅ Server started');
}
if (msg.includes('authentication successful')) {
console.log('✅ Authentication successful');
}
});
await new Promise(resolve => setTimeout(resolve, 3000));
// Initialize
console.log('📡 Initializing...');
server.stdin.write(JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: "0.1.0",
capabilities: {},
clientInfo: { name: "bank-extract", version: "1.0.0" }
}
}) + '\n');
await new Promise(resolve => setTimeout(resolve, 2000));
// Authenticate with AllCloud
console.log('🔐 Authenticating with AllCloud...');
server.stdin.write(JSON.stringify({
jsonrpc: "2.0",
id: 2,
method: "tools/call",
params: {
name: "authenticate_user",
arguments: {
username: "david+allcloud@umbrellacost.com",
password: "B4*zcI7#F7poEC"
}
}
}) + '\n');
// Wait for all account data to be captured
await new Promise(resolve => setTimeout(resolve, 8000));
console.log(`📊 Captured ${allAccounts.length} accounts from debug output`);
// Extract bank customers
console.log('\n🏦 FILTERING BANK CUSTOMERS:');
console.log('=' .repeat(60));
const bankKeywords = [
'bank', 'banco', 'banque', 'banca', 'banking',
'hapoalim', 'leumi', 'mizrahi', 'discount', 'igud',
'first international', 'jerusalem', 'mercantile',
'arab', 'union', 'massad', 'otsar', 'postal',
'citibank', 'hsbc', 'barclays', 'deutsche', 'bnp',
'santander', 'ing', 'abn', 'rabobank', 'commerzbank',
'unicredit', 'intesa', 'bbva', 'credit', 'wells fargo',
'jpmorgan', 'chase', 'goldman', 'morgan stanley'
];
const bankCustomers = [];
allAccounts.forEach(account => {
const nameLower = account.name.toLowerCase();
// Check if any bank keyword is in the account name
const matchedKeywords = bankKeywords.filter(keyword =>
nameLower.includes(keyword.toLowerCase())
);
if (matchedKeywords.length > 0) {
bankCustomers.push({
...account,
matchedKeywords
});
}
});
// Display results
console.log(`🎯 FOUND ${bankCustomers.length} BANK CUSTOMERS:`);
console.log('=' .repeat(60));
bankCustomers.forEach((customer, index) => {
console.log(`\n${index + 1}. 🏦 "${customer.name}"`);
console.log(` Account Key: ${customer.key}`);
console.log(` Matched Keywords: ${customer.matchedKeywords.join(', ')}`);
// Highlight specific Israeli banks
if (customer.name.toLowerCase().includes('hapoalim')) {
console.log(` ⭐ BANK HAPOALIM - Major Israeli Bank`);
}
if (customer.name.toLowerCase().includes('leumi')) {
console.log(` ⭐ BANK LEUMI - Major Israeli Bank`);
}
});
// Summary by bank type
console.log(`\n📊 BANK CUSTOMER SUMMARY:`);
console.log('=' .repeat(30));
console.log(`Total Bank Customers: ${bankCustomers.length}`);
const israeliBanks = bankCustomers.filter(c =>
['hapoalim', 'leumi', 'mizrahi', 'discount', 'jerusalem'].some(bank =>
c.name.toLowerCase().includes(bank)
)
);
console.log(`Israeli Banks: ${israeliBanks.length}`);
const internationalBanks = bankCustomers.filter(c =>
['citibank', 'hsbc', 'barclays', 'deutsche', 'jpmorgan', 'chase', 'wells'].some(bank =>
c.name.toLowerCase().includes(bank)
)
);
console.log(`International Banks: ${internationalBanks.length}`);
const otherBanks = bankCustomers.length - israeliBanks.length - internationalBanks.length;
console.log(`Other Banking: ${otherBanks}`);
// Check if we have the expected banks
console.log(`\n🎯 KEY ISRAELI BANKS STATUS:`);
const hapoalim = bankCustomers.find(c => c.name.toLowerCase().includes('hapoalim'));
const leumi = bankCustomers.find(c => c.name.toLowerCase().includes('leumi'));
console.log(`Bank Hapoalim: ${hapoalim ? `✅ FOUND (Key: ${hapoalim.key})` : '❌ NOT FOUND'}`);
console.log(`Bank Leumi: ${leumi ? `✅ FOUND (Key: ${leumi.key})` : '❌ NOT FOUND'}`);
if (hapoalim) {
console.log(`\n🏛️ BANK HAPOALIM DETAILS:`);
console.log(` Full Name: "${hapoalim.name}"`);
console.log(` Account Key: ${hapoalim.key}`);
console.log(` 🎯 This is the Bank Hapoalim customer for your detection system!`);
}
server.kill();
console.log('\n✅ Bank customer extraction complete');
}
extractBankCustomers().catch(console.error);