/** * Shared constants used across the bot, integrations, and services. */ const STORE_MODES = Object.freeze({ INFO: 'info', // bare `st ` — just the Store header (location + general) NETWORK: 'network', // switches, APs, and store server(s) POS: 'pos', // store server + registers + mobile registers + printers + payment terminals IOS: 'ios', // iOS devices (iPhones) PHONE: 'phone', // placeholder — simplified phone-device view (CollabSupport-style) AV: 'av', // placeholder — simplified A/V-device view (CollabSupport-style) }); /** * 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', }); /** * MDM-side AV hardware buckets. Names are matched (case-insensitive) against * the device's friendly name. AppleTV is checked first because the others * are short substrings that could appear inside an Apple TV's name. * Mirrors collabFinder `STRICT_AV_PATTERN` (services/enrichment/filters.js). */ const AV_CATEGORIES = Object.freeze({ APPLE_TV: 'AppleTV', VIDEO_WALL: 'VW', MUSIC: 'MSC', LED: 'LED', }); const AV_FRIENDLY_NAME_PATTERN = /(VW|MSC|LED|AppleTV)/i; /** * 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)); } /** * Classify an MDM device into one of the AV categories, or null if it is * not an AV device. Order of checks matters: AppleTV is most specific, so * if a device name accidentally contains both "AppleTV" and one of the * short markers, it's still classified as an Apple TV. */ function classifyMdmAvDevice(deviceOrName) { const name = typeof deviceOrName === 'string' ? deviceOrName : mdmDeviceName(deviceOrName); if (!name) return null; if (/AppleTV/i.test(name)) return AV_CATEGORIES.APPLE_TV; if (/VW/.test(name)) return AV_CATEGORIES.VIDEO_WALL; if (/MSC/.test(name)) return AV_CATEGORIES.MUSIC; if (/LED/.test(name)) return AV_CATEGORIES.LED; return null; } module.exports = { STORE_MODES, MDM_DEVICE_TYPES, AV_CATEGORIES, AV_FRIENDLY_NAME_PATTERN, mdmDeviceName, filterMdmByType, classifyMdmAvDevice, };