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,13 +1,13 @@
|
||||
import type { DeviceRecord } from '../../domain/device/device_record.js'
|
||||
import type { DeviceRecord } from '#domain/device/device_record'
|
||||
import type {
|
||||
ReferenceProvider,
|
||||
ResolvedReference,
|
||||
InformContext,
|
||||
ProviderConfig,
|
||||
} from './types.js'
|
||||
import { TRIGGER_EVENT_MAP } from './types.js'
|
||||
import { loadReferencesConfig } from './config_loader.js'
|
||||
import { WassupProvider } from './providers/wassup_provider.js'
|
||||
} from '#services/references/types'
|
||||
import { TRIGGER_EVENT_MAP } from '#services/references/types'
|
||||
import { loadReferencesConfig } from '#services/references/config_loader'
|
||||
import { WassupProvider } from '#services/references/providers/wassup_provider'
|
||||
|
||||
export class ReferenceEngine {
|
||||
private providers: ReferenceProvider[] = []
|
||||
@@ -27,7 +27,10 @@ export class ReferenceEngine {
|
||||
const provider = this.createProvider(providerConfig)
|
||||
if (provider) {
|
||||
this.providers.push(provider)
|
||||
console.info({ name: providerConfig.name, type: providerConfig.type }, '[References] Provider registered')
|
||||
console.info(
|
||||
{ name: providerConfig.name, type: providerConfig.type },
|
||||
'[References] Provider registered'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,13 +44,19 @@ export class ReferenceEngine {
|
||||
console.warn({ name: config.name }, '[References] http-json provider not yet implemented')
|
||||
return null
|
||||
case 'http-properties':
|
||||
console.warn({ name: config.name }, '[References] http-properties provider not yet implemented')
|
||||
console.warn(
|
||||
{ name: config.name },
|
||||
'[References] http-properties provider not yet implemented'
|
||||
)
|
||||
return null
|
||||
case 'static':
|
||||
console.warn({ name: config.name }, '[References] static provider not yet implemented')
|
||||
return null
|
||||
default:
|
||||
console.error({ name: config.name, type: config.type }, '[References] Unknown provider type')
|
||||
console.error(
|
||||
{ name: config.name, type: config.type },
|
||||
'[References] Unknown provider type'
|
||||
)
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -60,9 +69,7 @@ export class ReferenceEngine {
|
||||
const applicable = this.getApplicableProviders(context.events)
|
||||
if (applicable.length === 0) return []
|
||||
|
||||
const results = await Promise.allSettled(
|
||||
applicable.map((p) => p.resolve(device, context))
|
||||
)
|
||||
const results = await Promise.allSettled(applicable.map((p) => p.resolve(device, context)))
|
||||
|
||||
const resolved: ResolvedReference[] = []
|
||||
for (const result of results) {
|
||||
@@ -79,7 +86,11 @@ export class ReferenceEngine {
|
||||
/**
|
||||
* Resolve a single provider by name.
|
||||
*/
|
||||
async resolveOne(providerName: string, device: DeviceRecord, context: InformContext): Promise<ResolvedReference | null> {
|
||||
async resolveOne(
|
||||
providerName: string,
|
||||
device: DeviceRecord,
|
||||
context: InformContext
|
||||
): Promise<ResolvedReference | null> {
|
||||
const provider = this.providers.find((p) => p.name === providerName)
|
||||
if (!provider) {
|
||||
console.warn({ providerName }, '[References] Provider not found')
|
||||
@@ -112,7 +123,11 @@ export class ReferenceEngine {
|
||||
/**
|
||||
* Extracts the resolve value from a device based on the resolveBy config.
|
||||
*/
|
||||
static extractResolveValue(device: DeviceRecord, resolveBy: string, context: InformContext): string | null {
|
||||
static extractResolveValue(
|
||||
device: DeviceRecord,
|
||||
resolveBy: string,
|
||||
context: InformContext
|
||||
): string | null {
|
||||
switch (resolveBy) {
|
||||
case 'ip':
|
||||
return context.remoteIp || null
|
||||
@@ -123,14 +138,14 @@ export class ReferenceEngine {
|
||||
case 'mac': {
|
||||
const allParams = [...(device.properties || []), ...(device.parameters || [])]
|
||||
const macParam = allParams.find((p) => p.name?.includes('MACAddress'))
|
||||
return macParam?.value as string || null
|
||||
return (macParam?.value as string) || null
|
||||
}
|
||||
default:
|
||||
if (resolveBy.startsWith('parameter:')) {
|
||||
const path = resolveBy.slice('parameter:'.length)
|
||||
const allParams = [...(device.properties || []), ...(device.parameters || [])]
|
||||
const param = allParams.find((p) => p.name === path)
|
||||
return param?.value as string || null
|
||||
return (param?.value as string) || null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user