From 0e40abfbe2ccdbf962a3f4489c63ceb12b88a86f Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Mon, 13 May 2024 07:42:18 +0000 Subject: [PATCH] chore(type): add response types --- .vscode/settings.json | 5 ++++- src/index.js | 3 ++- src/types.ts | 47 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 622625e..74d5c0c 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 4bee5e9..843e5ee 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 6dc1cbd..8a70b52 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 +} -- GitLab