netanalyzer/constants.js
Joseph McQueen 0a46d25bd6 chore: project cleanup — dead code, logging, tests, WS hardening
- 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>
2026-06-24 17:21:22 -04:00

43 lines
1.1 KiB
JavaScript

/**
* Shared constants used across the bot, integrations, and services.
*/
const STORE_MODES = Object.freeze({
DEFAULT: 'default', // store info + active network devices + store server
POS: 'pos', // store server + registers + mobile registers + printers + payment terminals
IOS: 'ios', // all iOS devices
});
/**
* MDM (Workspace ONE) device-name conventions.
* Devices are classified by substring on UserName or DeviceFriendlyName.
*/
const MDM_DEVICE_TYPES = Object.freeze({
SERVER: 'SRV',
MOBILE_REGISTER: 'MR',
CUSTOMER_DISPLAY: 'CD',
IPHONE: 'IPH',
});
/**
* Return the canonical device-name string used to classify an MDM device.
*/
function mdmDeviceName(device) {
if (!device) return '';
return (device.UserName || device.DeviceFriendlyName || '').toString();
}
/**
* Filter MDM devices whose name contains the given marker (SRV/MR/CD/IPH).
*/
function filterMdmByType(devices, marker) {
if (!Array.isArray(devices) || !marker) return [];
return devices.filter(d => mdmDeviceName(d).includes(marker));
}
module.exports = {
STORE_MODES,
MDM_DEVICE_TYPES,
mdmDeviceName,
filterMdmByType,
};