diff --git a/.vscode/settings.json b/.vscode/settings.json index 742ce80e76842e6513d3b1e44af055e8d3a5860e..622625e36be54b7b28166854d93c0e029a097a81 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,6 +33,7 @@ "camelcase", "cicid", "coeff", + "controle", "ecolyo", "ecolyodemo", "energie", @@ -49,5 +50,6 @@ "perim", "periode", "publiees" - ] + ], + "prettier.semi": true } diff --git a/package.json b/package.json index a271c32b854ecdd559031ff0d40de0386c45b0d1..d5415d5429a3e26d6f4027900566aef6008d4655 100755 --- a/package.json +++ b/package.json @@ -16,6 +16,12 @@ "eslintConfig": { "extends": [ "cozy-app" + ], + "prettier/prettier": [ + "error", + { + "semi": true + } ] }, "eslintIgnore": [ diff --git a/src/core/core.js b/src/core/core.js index ba7b22b35a8a79b527fd4c128611188ac9d83842..14326439f8315ceabe0d22017ff70b7c2995b2d8 100644 --- a/src/core/core.js +++ b/src/core/core.js @@ -14,7 +14,7 @@ const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'grdfgrandlyon' const manualExecution = process.env.COZY_JOB_MANUAL_EXECUTION === 'true' /** - * @param {GRDFConsent[]} consents + * @param {import('../types').GRDFConsent[]} consents * @param {string} boUrlGRDF * @param {string} boToken * @returns {Promise<boolean>} Returns true if consent needs to be created. Returns false if consent is valid diff --git a/src/index.js b/src/index.js index b4c147e97f3be94ce09e128e50b386b1cf0a993c..6433d47ce8fdde7adbf568d4b7c4a79d028d58a5 100755 --- a/src/index.js +++ b/src/index.js @@ -52,8 +52,8 @@ module.exports = new BaseKonnector(start) * the account information come from ./konnector-dev-config.json file * cozyParameters are static parameters, independents from the account. Most often, it can be a * secret api key. - * @param {fields} fields - * @param {{secret: parameters}} cozyParameters + * @param {import('./types').fields} fields + * @param {{secret: import('./types').parameters}} cozyParameters */ async function start(fields, cozyParameters) { log('info', `isManual execution: ${manualExecution}`) diff --git a/src/requests/cozy.js b/src/requests/cozy.js index 96b9091e3ffc7967d610bb818fcb26e6c1fe6e5a..0c9e450e61508411eb2074c98e269cabce309813 100644 --- a/src/requests/cozy.js +++ b/src/requests/cozy.js @@ -5,7 +5,7 @@ const cozyClient = require('cozy-konnector-libs/dist/libs/cozyclient') /** * Return account * @param {string} accountId - * @returns {Promise<Account>} + * @returns {Promise<import('../types').Account>} */ async function getAccount(accountId) { log('info', `getAccount: ${accountId}`) diff --git a/src/requests/grdf.js b/src/requests/grdf.js index bbcf009a64b6049893204e90efe8924fa95ea97d..235e5f2885a4818d041622d86c817fd99b8c6dce 100644 --- a/src/requests/grdf.js +++ b/src/requests/grdf.js @@ -43,7 +43,7 @@ async function getAuthToken(client_id, client_secret) { * * @param {string} bearerToken * @param {string} pce - * @returns {Promise<GRDFConsent[]>} + * @returns {Promise<import('../types').GRDFConsent[]>} */ async function getConsents(bearerToken, pce) { try { diff --git a/src/types.js b/src/types.js deleted file mode 100644 index a55917f3fa7be8693726005cec7ce611abd64393..0000000000000000000000000000000000000000 --- a/src/types.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Cozy Fields definition - * @typedef {object} fields - * @property {string} pce - * @property {string} email - * @property {string} lastname - * @property {string} firstname - * @property {string} postalCode - */ - -/** - * Cozy parameters definition - * @typedef {object} parameters - * @property {string} boBaseUrl - * @property {string} boToken - * @property {string} client_id - * @property {string} client_secret - */ - -/** - * Account definition - * @typedef {object} Account - * @property {AccountData} data - * @property {object} auth - * @property {object} cozyMetadata - */ - -/** - * AccountData definition - * @typedef {object} AccountData - * @property {string | undefined} consentId - */ - -/** - * GRDF Consents - * Can be null but containing code_statut_traitement and message_retour_traitement if no consents - * @typedef {Object} GRDFConsent - * @property {string} id_droit_acces - * @property {string} id_pce - * @property {string} role_tiers - * @property {string} raison_sociale_du_tiers - * @property {string} nom_titulaire - * @property {string} courriel_titulaire - * @property {string} code_postal - * @property {boolean} perim_donnees_contractuelles - * @property {boolean} perim_donnees_techniques - * @property {boolean} perim_donnees_informatives - * @property {boolean} perim_donnees_publiees - * @property {string} date_creation - * @property {string} etat_droit_acces - * @property {string|null} date_revocation - * @property {string|null} source_revocation - * @property {string|null} date_passage_a_obsolete - * @property {string|null} source_passage_a_obsolete - * @property {string|null} date_passage_a_refuse - * @property {string} date_debut_droit_acces - * @property {string} date_fin_droit_acces - * @property {string} perim_donnees_conso_debut - * @property {string} perim_donnees_conso_fin - * @property {string|null} source_passage_a_refuse - * @property {string} parcours - * @property {string|null} statut_controle_preuve - * @property {string|null} date_limite_transmission_preuve - * @property {string|null} numero_telephone_mobile_titulaire - * Default response from GRDF - * @property {string} code_statut_traitement - * @property {string} message_retour_traitement - */ diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a804275945b7f41a97cc6195f60002054363371 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,67 @@ +/* eslint-disable prettier/prettier */ + +/** + * GRDF Consents + * Can be null but containing code_statut_traitement and message_retour_traitement if no consents + * */ +export type GRDFConsent = { + id_droit_acces: string + id_pce: string + role_tiers: string + raison_sociale_du_tiers: string + nom_titulaire: string + courriel_titulaire: string + code_postal: string + perim_donnees_contractuelles: boolean + perim_donnees_techniques: boolean + perim_donnees_informatives: boolean + perim_donnees_publiees: boolean + date_creation: string + etat_droit_acces: string + date_revocation: string | null + source_revocation: string | null + date_passage_a_obsolete: string | null + source_passage_a_obsolete: string | null + date_passage_a_refuse: string | null + date_debut_droit_acces: string + date_fin_droit_acces: string + perim_donnees_conso_debut: string + perim_donnees_conso_fin: string + source_passage_a_refuse: string | null + parcours: string + statut_controle_preuve: string | null + date_limite_transmission_preuve: string | null + numero_telephone_mobile_titulaire: string | null + /** Default response from GRDF */ + code_statut_traitement: string + message_retour_traitement: string +} + +/** Cozy Fields definition*/ +export type fields = { + pce: string + email: string + lastname: string + firstname: string + postalCode: string +} + +/** Cozy parameters definition */ +export type parameters = { + boBaseUrl: string + boToken: string + client_id: string + client_secret: string +} + +/** Account definition */ +export type Account = { + data: AccountData + auth: object + cozyMetadata: object +} + +/** AccountData definition */ +export type AccountData = { + consentId: string | undefined +}