diff --git a/.vscode/settings.json b/.vscode/settings.json index 622625e36be54b7b28166854d93c0e029a097a81..74d5c0c6d8f059e287cba99dbe0b5661e9a35206 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -39,9 +39,11 @@ "energie", "etat", "firstname", + "gaziere", "grandlyon", "grdf", "grdfgrandlyon", + "journee", "konnector", "konnectors", "lastname", @@ -49,7 +51,8 @@ "numero", "perim", "periode", - "publiees" + "publiees", + "releve" ], "prettier.semi": true } diff --git a/src/index.js b/src/index.js index 4bee5e9919b05561fb06f535d5fa353fd2bbc992..843e5ee5ef7dfec6993d2581e6c8577e58ce3979 100755 --- a/src/index.js +++ b/src/index.js @@ -188,7 +188,8 @@ async function getData(token, idPCE, startDate, endDate) { }) .then(result => { return result.match(/.+/g).map(s => { - result = JSON.parse(s) + /** @type {import('./types').GRDFDataRange} */ + const result = JSON.parse(s) if (result.statut_restitution !== null) { /** * Handle no data issue when retrieving grdf data. diff --git a/src/types.ts b/src/types.ts index 6dc1cbd2e3d7afbfa645cf7115238d58585a7c2f..8a70b52d3d10321d5be796ebbf5515542e8a758d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -65,3 +65,50 @@ export type Account = { export type AccountData = { consentId: string | undefined } + +/** Data response for donnees_consos_informatives?date_debut=2023-05-03&date_fin=2024-05-03 */ +export type GRDFDataRange = { + pce: { id_pce: string } + periode: { + valeur: null + date_debut: Date + date_fin: Date + } + releve_debut: { + date_releve: Date + index_brut_debut: Index + index_converti_debut: Index + } + releve_fin: { + date_releve: Date + index_brut_fin: Index + index_converti_fin: Index + } + consommation: { + date_debut_consommation: Date + date_fin_consommation: Date + flag_retour_zero: boolean + volume_brut: number + coeff_calcul: { + coeff_pta: null + valeur_pcs: null + coeff_conversion: number + } + volume_converti: number + energie: number + type_qualif_conso: string + sens_flux_gaz: string + statut_conso: string + journee_gaziere: Date + type_conso: string + } + statut_restitution: null | { + code: string + message: string + } +} + +type Index = { + valeur_index: number + horodate_Index: Date +}