Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
declare namespace DpeValidator {
class DpeValidator {
validate(dpe: FullDpe): ValidationError[];
}
import { Dpe } from './src/dpe/domain/models/dpe.model';

class DpeComparator {
compare(firstDpe: FullDpe, secondDpe: FullDpe): ValidationError[];
declare namespace DpePreProcessor {
class DpePreProcessor {
preprocess(dpe: Dpe): void;
}
}

export = DpeValidator;
export = DpePreProcessor;
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { DpePreProcessor } from './src/index.js';

export { DpePreProcessor };
13 changes: 13 additions & 0 deletions src/core/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Retrieve a number describing a thickness from the description
* @param description string in which to get the number
* @returns {number} if found, 0 otherwise
*/
export function getThicknessFromDescription(description) {
if (!description) {
return 0;
}

const matching = description.match(/(\d+) cm/);
return matching && matching.length > 1 ? Number.parseFloat(matching[1]) : 0;
}
16 changes: 16 additions & 0 deletions src/core/utils.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { getThicknessFromDescription } from './utils.js';
import { describe, expect, it } from 'vitest';

describe('Utils unit tests', () => {
it.each([
[0, null],
[0, undefined],
[0, ''],
[0, 'Mur en blocs de béton creux'],
[0, "Mur en blocs de béton creux d'épaisseur xxx cm non isolé"],
[4, "Mur en blocs de béton creux d'épaisseur 4 cm non isolé"],
[25, "Mur en blocs de béton creux d'''épaisseur ≥ 25 cm non isolé"]
])('should get thickness %s from description %s', (thickness, description) => {
expect(getThicknessFromDescription(description)).toBe(thickness);
});
});
12 changes: 12 additions & 0 deletions src/dpe/domain/models/baie-ets.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface BaieEts {
donnee_entree?: BaieEtsDE;
}

export interface BaieEtsDE {
description?: string;
reference?: string;
enum_orientation_id?: number;
enum_inclinaison_vitrage_id?: number; // ENUM inclinaison_vitrage
surface_totale_baie?: number;
nb_baie?: number;
}
95 changes: 95 additions & 0 deletions src/dpe/domain/models/baie-vitree.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
export interface BaieVitree {
donnee_entree?: BaieVitreeDE;
donnee_intermediaire?: BaieVitreeDI;
baie_vitree_double_fenetre?: BaieVitreeDoubleFenetre;
}

export interface BaieVitreeDE {
description?: string;
reference?: string;
reference_paroi?: string;
reference_lnc?: string;
tv_coef_reduction_deperdition_id?: string; // TV
surface_aiu?: number;
surface_aue?: number;
enum_cfg_isolation_lnc_id?: string; // ENUM cfg_isolation_lnc
enum_type_adjacence_id?: string; // ENUM type_adjacence
surface_totale_baie?: number;
nb_baie?: number;
tv_ug_id?: string; // TV
enum_type_vitrage_id?: string; // ENUM type_vitrage
enum_inclinaison_vitrage_id?: string; // ENUM inclinaison_vitrage
enum_type_gaz_lame_id?: string; // ENUM type_gaz_lame
epaisseur_lame?: number;
vitrage_vir?: boolean;
enum_methode_saisie_perf_vitrage_id?: string; // ENUM methode_saisie_perf_vitrage
ug_saisi?: number;
tv_uw_id?: string;
enum_type_materiaux_menuiserie_id?: string; // ENUM type_materiaux_menuiserie
enum_type_baie_id?: string; // ENUM type_baie
uw_saisi?: number;
double_fenetre?: boolean;
uw_1?: number;
sw_1?: number;
uw_2?: number;
sw_2?: number;
tv_deltar_id?: string;
tv_ujn_id?: string;
enum_type_fermeture_id?: string;
presence_protection_solaire_hors_fermeture?: boolean;
ujn_saisi?: number;
presence_retour_isolation?: boolean;
presence_joint?: boolean;
largeur_dormant?: number;
tv_sw_id?: string;
sw_saisi?: number;
enum_type_pose_id?: string; // ENUM type_pose
enum_orientation_id?: string;
tv_coef_masque_proche_id?: string;
tv_coef_masque_lointain_homogene_id?: string;
masque_lointain_non_homogene_collection: {
masque_lointain_non_homogene: {
tv_coef_masque_lointain_non_homogene_id?: string; // TV
};
}[];
}

export interface BaieVitreeDI {
b: number;
ug?: number;
uw: number;
ujn?: number;
u_menuiserie: number;
sw: number;
fe1: number;
fe2: number;
}

export interface BaieVitreeDoubleFenetre {
donnee_entree?: BaieVitreeDoubleFenetreDE;
donnee_intermediaire?: BaieVitreeDoubleFenetreDI;
}

export interface BaieVitreeDoubleFenetreDE {
tv_ug_id?: string;
enum_type_vitrage_id: string;
enum_inclinaison_vitrage_id: string;
enum_type_gaz_lame_id?: string;
epaisseur_lame?: number;
vitrage_vir?: boolean;
enum_methode_saisie_perf_vitrage_id: string;
ug_saisi?: number;
tv_uw_id?: string;
enum_type_materiaux_menuiserie_id: string;
enum_type_baie_id: string;
uw_saisi?: number;
tv_sw_id?: string;
sw_saisi?: number;
enum_type_pose_id: string;
}

export interface BaieVitreeDoubleFenetreDI {
ug?: number;
uw: number;
sw: number;
}
25 changes: 25 additions & 0 deletions src/dpe/domain/models/climatisation.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export interface Climatisation {
donnee_entree?: ClimatisationDE;
donnee_intermediaire?: ClimatisationDI;
}

export interface ClimatisationDE {
description?: string;
reference: string;
tv_seer_id?: number;
nombre_logement_echantillon?: number;
enum_methode_calcul_conso_id: number;
enum_periode_installation_fr_id: number;
cle_repartition_clim?: number;
enum_type_generateur_fr_id: number;
enum_type_energie_id?: number;
enum_methode_saisie_carac_sys_id: number;
ref_produit_fr?: string;
}

export interface ClimatisationDI {
eer: number;
besoin_fr: number;
conso_fr: number;
conso_fr_depensier: number;
}
183 changes: 183 additions & 0 deletions src/dpe/domain/models/dpe.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import { Mur } from './mur.model';
import { Porte } from './porte.model';
import { PlancherBas } from './plancher-bas.model';
import { PlancherHaut } from './plancher-haut.model';
import { BaieVitree } from './baie-vitree.model';
import { Ets } from './ets.model';
import { PontThermique } from './pont-thermique.model';
import { Ventilation } from './ventilation.model';
import { Climatisation } from './climatisation.model';
import { ProductionElecEnr } from './production-elec-enr.model';
import { InstallationEcs } from './installation-ecs.model';
import { InstallationChauffage } from './installation-chauffage.model';
import { Sortie } from './sortie.model';

/**
* @see https://gitlab.com/observatoire-dpe/observatoire-dpe/-/blob/master/modele_donnee/DPE_complet.xsd?ref_type=heads
*/
export interface Dpe {
hashkey: string;
id: string;
version: string;
numero_dpe: string;
statut: string;
administratif: Administratif;
dpe_immeuble?: DpeImmeuble;
logement?: Logement;
tertiaire?: Tertiaire;
logement_neuf?: LogementNeuf;
descriptif_enr_collection: any; // Pas traité pour l'instant
descriptif_simplifie_collection: any; // Pas traité pour l'instant
fiche_technique_collection: any; // Pas traité pour l'instant
justificatif_collection: any; // Pas traité pour l'instant
descriptif_geste_entretien_collection: any; // Pas traité pour l'instant
descriptif_travaux: any; // Pas traité pour l'instant
}

export interface Administratif {
dpe_a_remplacer?: string;
reference_interne_projet?: string;
motif_remplacement?: string;
dpe_immeuble_associe?: string;
enum_version_id: string;
date_visite_diagnostiqueur: string;
nom_proprietaire?: string;
siren_proprietaire?: string;
nom_proprietaire_installation_commune?: string;
date_etablissement_dpe: string;
enum_modele_dpe_id: string;
diagnostiqueur: Diagnostiqueur;
geolocalisation: Geolocalisation;
consentement_proprietaire?: boolean;
information_consentement_proprietaire?: InformationConsentementProprietaire;
}

export interface Diagnostiqueur {
usr_logiciel_id: string;
version_logiciel: string;
version_moteur_calcul?: string;
nom_diagnostiqueur: string;
prenom_diagnostiqueur: string;
mail_diagnostiqueur: string;
telephone_diagnostiqueur: string;
adresse_diagnostiqueur: string;
entreprise_diagnostiqueur: string;
numero_certification_diagnostiqueur: string;
organisme_certificateur: string;
}

export interface DpeImmeuble {
logement_visite_collection: LogementVisite[];
}

export interface LogementVisite {
description: string;
enum_position_etage_logement_id: string;
enum_typologie_logement_id: string;
surface_habitable_logement: number;
}

export interface Geolocalisation {
invar_logement?: string;
numero_fiscal_local?: string;
id_batiment_rnb?: string;
rpls_log_id?: string;
rpls_org_id?: string;
idpar?: string;
immatriculation_copropriete?: string;
adresses?: {
adresse_bien: Adresse;
adresse_proprietaire: Adresse;
adresse_proprietaire_installation_commune: Adresse;
};
}

export interface Adresse {
adresse_brut: string;
code_postal_brut: string;
nom_commune_brut: string;
label_brut: string;
label_brut_avec_complement: string;
enum_statut_geocodage_ban_id: string;
ban_date_appel: string;
ban_id?: string;
ban_id_ban_adresse?: string;
ban_label?: string;
ban_housenumber?: string;
ban_street?: string;
ban_citycode?: string;
ban_postcode?: string;
ban_city?: string;
ban_type?: string;
ban_score?: string;
ban_x?: string;
compl_nom_residence?: string;
compl_ref_batiment?: string;
compl_etage_appartement?: string;
compl_ref_cage_escalier?: string;
compl_ref_logement?: string;
}

export interface InformationConsentementProprietaire {
nom_proprietaire: string;
personne_morale: boolean;
siren_proprietaire?: string;
telephone?: string;
mail?: string;
label_adresse: string;
label_adresse_avec_complement: string;
}

export interface CaracteristiqueGenerale {
annee_construction?: number;
enum_periode_construction_id: number;
enum_methode_application_dpe_log_id: number;
enum_calcul_echantillonnage_id?: number;
surface_habitable_logement?: number;
nombre_niveau_immeuble?: number;
nombre_niveau_logement?: number;
hsp: number;
surface_habitable_immeuble?: number;
surface_tertiaire_immeuble?: number;
nombre_appartement?: number;
appartement_non_visite: boolean;
}

export interface Meteo {
enum_zone_climatique_id?: number;
altitude: number;
enum_classe_altitude_id: number;
batiment_materiaux_anciens: boolean;
}

export interface Logement {
caracteristique_generale: CaracteristiqueGenerale;
meteo: Meteo;
enveloppe: Enveloppe;
ventilation_collection: { ventilation: Ventilation[] };
climatisation_collection: { climatisation: Climatisation[] };
production_elec_enr?: ProductionElecEnr;
installation_ecs_collection: { installation_ecs: InstallationEcs[] };
installation_chauffage_collection: { installation_chauffage: InstallationChauffage[] };
sortie: Sortie;
}

export interface Tertiaire extends Logement {}

export interface LogementNeuf extends Logement {}

export interface Enveloppe {
inertie: {
inertie_plancher_bas_lourd: boolean;
inertie_plancher_haut_lourd: boolean;
inertie_paroi_verticale_lourd: boolean;
enum_classe_inertie_id: number;
};
mur_collection: { mur: Mur[] };
plancher_bas_collection: { plancher_bas: PlancherBas[] };
plancher_haut_collection: { plancher_haut: PlancherHaut[] };
baie_vitree_collection: { baie_vitree: BaieVitree[] };
porte_collection: { porte: Porte[] };
ets_collection: { ets: Ets };
pont_thermique_collection: { pont_thermique: PontThermique[] };
}
20 changes: 20 additions & 0 deletions src/dpe/domain/models/ets.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { BaieEts } from './baie-ets.model';

export interface Ets {
donnee_entree?: EtsDE;
donnee_intermediaire?: EtsDI;
baie_ets_collection?: { baie_ets: BaieEts[] };
}

export interface EtsDE {
description?: string;
reference: string;
tv_coef_reduction_deperdition_id?: number; // TV
enum_cfg_isolation_lnc_id?: number; // ENUM cfg_isolation_lnc
tv_coef_transparence_ets_id: number; // TV
}

export interface EtsDI {
coef_transparence_ets: number;
bver: number;
}
Loading