Files
adam-acs/app/domain/device/device_parameter.ts
T
Kevin L'HereecandCopilot d1c65dbf1e chore: initial commit — AdonisJS v7 TR-069 ACS
- Docker infrastructure (Dockerfile, docker-compose.yml, genieacs-sim)
- AdonisJS v7 app with Inertia.js + Vue 3
- MongoDB integration
- CWMP/TR-069 state machine engine
- Configuration engine with compliance tracking
- Branding: ADAM ACS (favicon, navbar, locales)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 16:46:37 +02:00

111 lines
2.5 KiB
TypeScript

import { ParameterType } from '../shared/types.js'
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,
}
}
}