netanalyzer/models/Store.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

39 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Domain model for a Store.
* Normalizes location data coming from SIW.
*/
class Store {
constructor(data = {}, storeNumber) {
this.number = String(storeNumber || data.store_number || '').trim();
this.name = data.name || data.store_name || `Store ${this.number}`;
this.address = data.address || '';
this.address2 = data.address2 || '';
this.address3 = data.address3 || '';
this.city = data.city || '';
this.state = data.state || '';
this.postalCode = data.postal_code || '';
this.countryCode = data.country_code || 'US';
this.phone = data.phone || '';
this.districtId = data.district_id || null;
this.regionId = data.region_id || null;
}
get fullAddress() {
const parts = [this.address, this.address2, this.address3].filter(Boolean);
const cityState = `${this.city}, ${this.state} ${this.postalCode}`.trim();
return [...parts, cityState, this.phone ? `Phone: ${this.phone}` : '']
.filter(Boolean)
.join('\n');
}
toSummary() {
return `### Store ${this.number} - ${this.name}\n\n** Details**\n${this.fullAddress}\nDistrict ID: ${this.districtId || 'N/A'} Region ID: ${this.regionId || 'N/A'}`;
}
}
function createStore(data, storeNumber) {
return new Store(data, storeNumber);
}
module.exports = { Store, createStore };