- Delete unused dataMerger, formatter, Device model, dead service exports, and the empty agents/ + .gitkeep placeholders. - Extract STORE_MODES and MDM device-type filters into a shared constants.js. - Anchor bot regexes (^help|^store|^analyze) so "analyze store 305" no longer fires both handlers; replace catch-all noise. - Hoist inline require() calls in integrations to top-of-file imports. - Harden WebSocket server: Authorization header support, single-agent enforcement, bounded pending requests, server-level error handler, coalesced cache refresh in Meraki client. - Wrap Meraki/MDM network calls with withRetry; add request timeouts. - Migrate all console.* calls onto utils/logger.js (LOG_LEVEL aware); drive Webex framework logLevel from env. - Refactor storeDetail.js: shared renderClientLine + buildMdmSection helpers cut duplication roughly in half. - Refresh README structure, document LOG_LEVEL, add npm run agent script, add jest testMatch + new tests (handlers, HealthReport, Store, ws). Verified: npm run lint clean, 7 suites / 31 tests passing. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
/**
|
|
* Mock Meraki service for testing.
|
|
*/
|
|
|
|
const mockNetworks = [
|
|
{ id: 'N_001', name: 'Store 001', url: 'https://example.com/n/STORE001' },
|
|
{ id: 'N_305', name: 'Store 305 - Main', url: 'https://example.com/n/STORE305' },
|
|
];
|
|
|
|
function findMerakiNetwork(storeNum) {
|
|
const num = String(storeNum).padStart(3, '0');
|
|
return Promise.resolve(mockNetworks.find(n => n.name.includes(num)) || null);
|
|
}
|
|
|
|
function getMerakiClients(networkId) {
|
|
if (networkId === 'N_305') {
|
|
return Promise.resolve([
|
|
{ id: 'c1', description: 'Register 305', status: 'Online', lastSeen: new Date() },
|
|
{
|
|
id: 'c2',
|
|
description: 'Printer Front',
|
|
status: 'Offline',
|
|
lastSeen: Date.now() - 10 * 60 * 1000,
|
|
},
|
|
]);
|
|
}
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
function getMerakiDeviceAvailabilities(_networkId) {
|
|
return Promise.resolve([
|
|
{ serial: 'SW1', name: 'SWR-001', productType: 'switch', status: 'online' },
|
|
{ serial: 'AP1', name: 'AP-Front', productType: 'wireless', status: 'online' },
|
|
{ serial: 'AP2', name: 'AP-Back', productType: 'wireless', status: 'alerting' },
|
|
]);
|
|
}
|
|
|
|
module.exports = {
|
|
findMerakiNetwork,
|
|
getMerakiClients,
|
|
getMerakiDeviceAvailabilities,
|
|
};
|