refactor: migrate all internal imports to package.json subpath aliases
- Add #domain, #protocol, #utils aliases to package.json imports map - Replace all relative imports (./, ../, ../..) in app/ and database/mongo_migrations/ with the corresponding #alias imports, eliminating relative path traversal across the codebase - Remove dead code: ConfigurationVersionModel.findByConfigurationIdentifier (unused, superseded by paginateVersions) and unused exception classes (NotFoundException, UnprocessableEntityException, DatabaseException) from app/exceptions/index.ts, keeping only BadRequestException - Fix pre-existing syntax error in configuration_version.ts (mismatched parenthesis) that broke tsc - Fix eqeqeq violation in configuration_service.ts and isNaN -> Number.isNaN in configuration_engine.ts / cwmp-1-0.ts / exchange_controller.ts - Fix no-shadow violation in cwmp-1-0.ts EventStruct constructor - Prettier formatting pass on touched files Validated: tsc --noEmit clean, eslint app/ clean, full test suite green.
This commit is contained in:
1 parent
4177f1adbd
commit
f9e56c78b1
74 files changed
+1243
-863
No files matched your search
@@ -1,18 +1,20 @@
|
||||
import { createRequire } from 'node:module'
|
||||
import type { DeviceSnapshot } from '../domain/device/device.js'
|
||||
import type { Device } from '../domain/device/device.js'
|
||||
import { DeviceParameter } from '../domain/device/device_parameter.js'
|
||||
import type { DeviceSnapshot } from '#domain/device/device'
|
||||
import type { Device } from '#domain/device/device'
|
||||
import { DeviceParameter } from '#domain/device/device_parameter'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const tr181Catalog: Array<{ path: string; writable: boolean; deviceClass: string; type?: string }> =
|
||||
require('../../config/tr181-catalog.json')
|
||||
const tr181Catalog: Array<{
|
||||
path: string
|
||||
writable: boolean
|
||||
deviceClass: string
|
||||
type?: string
|
||||
}> = require('../../config/tr181-catalog.json')
|
||||
|
||||
// Index chargé une fois au démarrage — O(1) lookup
|
||||
const catalogIndex = new Map(tr181Catalog.map((e) => [e.path, e.writable]))
|
||||
const catalogTypeIndex = new Map(tr181Catalog.map((e) => [e.path, e.type || 'xsd:string']))
|
||||
const catalogWritableIndex = new Set(
|
||||
tr181Catalog.filter((e) => e.writable).map((e) => e.path)
|
||||
)
|
||||
const catalogWritableIndex = new Set(tr181Catalog.filter((e) => e.writable).map((e) => e.path))
|
||||
|
||||
/** Remplace les segments numériques par {i} pour matcher les entrées du catalogue */
|
||||
export function normalizePath(path: string): string {
|
||||
@@ -69,7 +71,15 @@ export function reclassifyDeviceFromCatalog(device: Device): number {
|
||||
const snap = prop.toSnapshot()
|
||||
const catalogType = catalogTypeIndex.get(normalized) || snap.type
|
||||
device.setParameter(
|
||||
new DeviceParameter(snap.name, snap.value, catalogType as any, snap.createdAt, snap.updatedAt, snap.notification, snap.accessList)
|
||||
new DeviceParameter(
|
||||
snap.name,
|
||||
snap.value,
|
||||
catalogType as any,
|
||||
snap.createdAt,
|
||||
snap.updatedAt,
|
||||
snap.notification,
|
||||
snap.accessList
|
||||
)
|
||||
)
|
||||
;(device as any)._properties.delete(prop.name)
|
||||
reclassified++
|
||||
|
||||
Reference in new issue
Block a user