import { AbstractRepository } from '@crosslab/service-common';
import { deviceUrlFromId } from '../../../methods/urlFromId.js';
import { DeviceOverviewModel } from '../../model.js';
export class DeviceOverviewRepository extends AbstractRepository {
    dependencies = {};
    constructor() {
        super('Device Overview');
    }
    dependenciesMet() {
        return true;
    }
    initialize(entityManager) {
        this.repository = entityManager.getRepository(DeviceOverviewModel);
    }
    async write(model, data) {
        if (data.name !== undefined)
            model.name = data.name;
        if (data.description !== undefined)
            model.description = data.description;
        if (data.isPublic !== undefined)
            model.isPublic = data.isPublic;
    }
    async format(model) {
        return {
            url: deviceUrlFromId(model.uuid),
            type: model.type,
            name: model.name,
            description: model.description ?? undefined,
            isPublic: model.isPublic,
        };
    }
}
//# sourceMappingURL=deviceOverview.js.map