- 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.
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { BaseModel } from '#database/base_model'
|
|
import { type FirmwareEntry } from '#domain/firmware/firmware_catalog'
|
|
|
|
export default class FirmwareEntryModel extends BaseModel {
|
|
static collectionName = 'firmware_entries'
|
|
|
|
static async findByIdentifier(identifier: string): Promise<FirmwareEntry | null> {
|
|
return this.findOne({ identifier }) as Promise<FirmwareEntry | null>
|
|
}
|
|
|
|
static async findByProductClass(productClass: string): Promise<FirmwareEntry[]> {
|
|
const collection = this.getCollection()
|
|
return collection.find({ productClass }).toArray() as unknown as Promise<FirmwareEntry[]>
|
|
}
|
|
|
|
static async findByProductClassAndVersion(
|
|
productClass: string,
|
|
version: string
|
|
): Promise<FirmwareEntry | null> {
|
|
return this.findOne({ productClass, version }) as Promise<FirmwareEntry | null>
|
|
}
|
|
|
|
static async createIfNotExists(data: Partial<FirmwareEntry>): Promise<FirmwareEntry> {
|
|
const existing = await this.findOne({ identifier: data.identifier })
|
|
if (existing) {
|
|
throw new Error(`Firmware entry with identifier '${data.identifier}' already exists`)
|
|
}
|
|
return this.create(data) as Promise<FirmwareEntry>
|
|
}
|
|
|
|
static async deleteByIdentifier(identifier: string): Promise<boolean> {
|
|
return this.deleteOne({ identifier })
|
|
}
|
|
}
|