Refactor every /voicediag check to declare a top-level `standards` object so the desired state is legible without reading run() logic and can drive a documented reference table. Upgrade callForwarding to error severity, tighten voicemail with three send-to-VM error paths + a `stop_sending_to_voicemail` remediation, and add a `disable_hoteling` remediation. Add a port-hygiene check bucket under services/voiceDiag/checks/port (portType, portVlan, portPoe, portEnabled) that reuses the phone- status snapshot to enforce switchport standards. Configurable via VOICE_STANDARD_PHONE_VLAN (default 102) and VOICE_STANDARD_ENABLED (kill-switch). Preserve Meraki `portType`/`voiceVlan`/`dataVlan` through the enrichment chain so the checks have clean data to read. Add an "apply all N fixes" combined card that shows up when 2+ remediations are available. New confirm_voicediag_all / cancel_voicediag_all actions run each fix in sequence (readable audit trail, no per-person write-throttle stacking), accumulate individual failures into a summary rather than aborting. Adds regression tests asserting every check exposes .standards, plus coverage for port checks, kill-switch, and combined-card iteration. 63 tests in the checks file, 188 total, all green. Co-authored-by: Cursor <cursoragent@cursor.com>
86 lines
3.3 KiB
JavaScript
86 lines
3.3 KiB
JavaScript
// src/services/voiceDiag/checks/index.js
|
|
//
|
|
// Ordered registry of every /voicediag check. Order matters — the
|
|
// renderer walks this list to produce the output, so put the checks a
|
|
// human operator would notice first (DND, forwarding) at the top,
|
|
// then the deeper feature-config ones, then finally the online-device
|
|
// summary which is often the last thing they want to see.
|
|
//
|
|
// Adding a new check
|
|
// 1. Drop a new file next to this one (e.g. `myNewCheck.js`) that
|
|
// exports the check descriptor as its default export or a named
|
|
// export.
|
|
// 2. Add it to CHECKS below in the position you want it to render.
|
|
// 3. If it exports a `remediations: {actionId: handler}` map, the
|
|
// voiceDiagService remediation registry will pick it up
|
|
// automatically. Action ids must be globally unique across all
|
|
// checks — a collision throws at startup.
|
|
//
|
|
// Every check must export an object matching:
|
|
//
|
|
// {
|
|
// id: string, // stable, snake_case, globally unique
|
|
// label: string, // human-readable heading
|
|
// requires: string[], // subset of ['personId','phoneStatus',
|
|
// // 'telephonyProfile'] — runner skips
|
|
// // the check if any are missing on ctx
|
|
// scope: string, // primary Webex scope needed; surfaced
|
|
// // in the skipped message on 401/403/404
|
|
// run: async (ctx) => CheckResult,
|
|
// remediations?: { [actionId: string]: async (bot, data, requester) => void }
|
|
// }
|
|
|
|
import { dndCheck } from './dnd.js';
|
|
import { callForwardingCheck } from './callForwarding.js';
|
|
import { callWaitingCheck } from './callWaiting.js';
|
|
import { voicemailCheck } from './voicemail.js';
|
|
import { callInterceptCheck } from './callIntercept.js';
|
|
import { hotelingCheck } from './hoteling.js';
|
|
import { executiveAssistantCheck } from './executiveAssistant.js';
|
|
import { outgoingPermissionCheck } from './outgoingPermission.js';
|
|
import { phoneOnlineCheck } from './phoneOnline.js';
|
|
import { portTypeCheck } from './port/portType.js';
|
|
import { portVlanCheck } from './port/portVlan.js';
|
|
import { portPoeCheck } from './port/portPoe.js';
|
|
import { portEnabledCheck } from './port/portEnabled.js';
|
|
|
|
// Order: user-facing feature signals first (things an operator can
|
|
// see from the phone UI), then network-side port hygiene, then the
|
|
// broad-brush online summary last so it acts as a reachability
|
|
// closer.
|
|
export const CHECKS = [
|
|
dndCheck,
|
|
callForwardingCheck,
|
|
callInterceptCheck,
|
|
callWaitingCheck,
|
|
voicemailCheck,
|
|
hotelingCheck,
|
|
executiveAssistantCheck,
|
|
outgoingPermissionCheck,
|
|
portTypeCheck,
|
|
portVlanCheck,
|
|
portPoeCheck,
|
|
portEnabledCheck,
|
|
phoneOnlineCheck,
|
|
];
|
|
|
|
const _byId = new Map();
|
|
for (const c of CHECKS) {
|
|
if (!c || typeof c !== 'object') {
|
|
throw new Error('voicediag: encountered non-object check in registry');
|
|
}
|
|
if (!c.id || typeof c.id !== 'string') {
|
|
throw new Error('voicediag: check is missing required "id" string');
|
|
}
|
|
const key = c.id.toLowerCase();
|
|
if (_byId.has(key)) {
|
|
throw new Error(`voicediag: duplicate check id "${c.id}"`);
|
|
}
|
|
_byId.set(key, c);
|
|
}
|
|
|
|
/** Case-insensitive lookup so `--only DND` and `--only dnd` both work. */
|
|
export function getCheckById(id) {
|
|
if (!id) return null;
|
|
return _byId.get(String(id).toLowerCase().trim()) || null;
|
|
}
|