Files
adam-acs/app/domain/device/device_parameter.ts
T
Kevin L'Hereec f9e56c78b1 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.
2026-07-22 11:45:14 +02:00

111 lines
2.5 KiB
TypeScript

import { ParameterType } from '#domain/shared/types'
export interface ParameterSnapshot {
name: string
value: any
type: ParameterType
createdAt?: Date
updatedAt?: Date
notification?: number
accessList?: string[]
}
export interface PropertySnapshot {
name: string
value: any
type: ParameterType
createdAt?: Date
updatedAt?: Date
notification?: number
accessList?: string[]
}
export class DeviceParameter {
constructor(
public readonly name: string,
private _value: any,
public type: ParameterType = ParameterType.UNKNOWN,
public createdAt: Date = new Date(),
public updatedAt: Date = new Date(),
public notification?: number,
public accessList?: string[]
) {}
get value(): any {
return this._value
}
updateValue(value: any): void {
this._value = value
this.updatedAt = new Date()
}
updateAttributes(notification?: number, accessList?: string[]): void {
if (notification !== undefined) this.notification = notification
if (accessList !== undefined) this.accessList = accessList
this.updatedAt = new Date()
}
toSnapshot(): ParameterSnapshot {
return {
name: this.name,
value: this._value,
type: this.type,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
notification: this.notification,
accessList: this.accessList,
}
}
}
export class DeviceProperty {
constructor(
public readonly name: string,
private _value: any,
public type: ParameterType = ParameterType.UNKNOWN,
public createdAt: Date = new Date(),
public updatedAt: Date = new Date(),
public notification?: number,
public accessList?: string[]
) {}
get value(): any {
return this._value
}
updateValue(value: any): void {
this._value = value
this.updatedAt = new Date()
}
updateAttributes(notification?: number, accessList?: string[]): void {
if (notification !== undefined) this.notification = notification
if (accessList !== undefined) this.accessList = accessList
this.updatedAt = new Date()
}
getConnectionRequestURL(): URL | null {
if (this.name.includes('ConnectionRequestURL') && this._value) {
try {
return new URL(this._value)
} catch {
return null
}
}
return null
}
toSnapshot(): PropertySnapshot {
return {
name: this.name,
value: this._value,
type: this.type,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
notification: this.notification,
accessList: this.accessList,
}
}
}