@ezs/conditor
Advanced tools
@@ -6,2 +6,14 @@ # Change Log | ||
## [2.2.1](https://github.com/Inist-CNRS/ezs/compare/@ezs/conditor@2.2.0...@ezs/conditor@2.2.1) (2021-06-07) | ||
### Bug Fixes | ||
* **conditor:** Fix followsNumeroLabel ([b64c53c](https://github.com/Inist-CNRS/ezs/commit/b64c53c5333bc88428a3b15d1d4efc5c6cf41cae)) | ||
* **conditor:** Fix wrongly assigned RNSR ID ([365ad69](https://github.com/Inist-CNRS/ezs/commit/365ad69d788e276524181bb30d8b19b7a50c3bb8)), closes [#152](https://github.com/Inist-CNRS/ezs/issues/152) | ||
# [2.2.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/conditor@2.1.2...@ezs/conditor@2.2.0) (2021-06-04) | ||
@@ -8,0 +20,0 @@ |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.isIn = isIn; | ||
exports.hasLabelAndNumero = void 0; | ||
exports.hasLabelAndNumero = exports.followsNumeroLabel = void 0; | ||
@@ -16,5 +16,6 @@ /** | ||
/** | ||
* @typedef {Object<string, any>} Structures | ||
* @property {Object} origineDonnees | ||
* @property {Structure[]} structure | ||
* @typedef {{ | ||
* origineDonnees: object, | ||
* structure: Structure[] | ||
* }} Structures | ||
* @private | ||
@@ -24,15 +25,16 @@ */ | ||
/** | ||
* @typedef {Object<string, any>} Structure | ||
* @property {string} num_nat_struct | ||
* @property {string} intitule | ||
* @property {string} intituleAppauvri | ||
* @property {string} sigle | ||
* @property {string} sigleAppauvri | ||
* @property {number} [annee_creation] | ||
* @property {number} [an_der_rec] | ||
* @property {number} [an_fermeture] | ||
* @property {number} code_postal | ||
* @property {string} ville_postale | ||
* @property {string} ville_postale_appauvrie | ||
* @property {EtabAssoc[]} etabAssoc | ||
* @typedef {{ | ||
* num_nat_struct: string, | ||
* intitule: string, | ||
* intituleAppauvri: string, | ||
* sigle: string, | ||
* sigleAppauvri: string, | ||
* annee_creation?: number, | ||
* an_der_rec?: number, | ||
* an_fermeture?: number, | ||
* code_postal: number, | ||
* ville_postale: string, | ||
* ville_postale_appauvrie: string, | ||
* etabAssoc: EtabAssoc[] | ||
* }} Structure | ||
* @private | ||
@@ -42,11 +44,12 @@ */ | ||
/** | ||
* @typedef {Object<string, any>} EtabAssoc | ||
* @property {"TUTE"|"PART"} [natTutEtab] | ||
* @property {Etab} etab | ||
* @property {number} [anDebut] | ||
* @property {number} [anFin] | ||
* @property {string} [idStructEtab] | ||
* @property {string} label | ||
* @property {string} labelAppauvri | ||
* @property {number} numero | ||
* @typedef {{ | ||
* natTutEtab?: "TUTE"|"PART", | ||
* etab: Etab, | ||
* anDebut?: number, | ||
* anFin?: number, | ||
* idStructEtab: string, | ||
* label: string, | ||
* labelAppauvri: string, | ||
* numero: number | ||
* }} EtabAssoc | ||
* @private | ||
@@ -56,10 +59,11 @@ */ | ||
/** | ||
* @typedef {Object<string, any>} Etab | ||
* @property {string} [cleEtab] | ||
* @property {string} sigle | ||
* @property {string} sigleAppauvri | ||
* @property {string} libelle | ||
* @property {string} libelleAppauvri | ||
* @property {string} [numUAI] | ||
* @property {string} [SirenSiret] | ||
* @typedef {{ | ||
* cleEtab?: string, | ||
* sigle: string, | ||
* sigleAppauvri: string, | ||
* libelle: string, | ||
* libelleAppauvri: string, | ||
* numUAI: string, | ||
* SirenSiret: string | ||
* }} Etab | ||
* @private | ||
@@ -85,2 +89,3 @@ */ | ||
} = etabAssoc; | ||
if (label === '' || String(numero) === '') return false; | ||
if (tokens.includes(`${label}${numero}`)) return true; | ||
@@ -92,6 +97,8 @@ const labelIndex = tokens.indexOf(label.toLowerCase()); | ||
if (numeroIndex < labelIndex) return false; | ||
if (numeroIndex - labelIndex > 1) return false; | ||
if (numeroIndex - labelIndex > 2) return false; | ||
return true; | ||
}); | ||
exports.followsNumeroLabel = followsNumeroLabel; | ||
const hasPostalAddress = (address, structure) => address.includes((structure.ville_postale_appauvrie || '**').split(' cedex')[0]) || address.includes(String(structure.code_postal) || '**'); | ||
@@ -136,3 +143,3 @@ /** | ||
const tutelles = structure.etabAssoc.map(ea => ea.etab); | ||
return tutelles.reduce((keep, etab) => { | ||
const structureHasTutelle = tutelles.reduce((keep, etab) => { | ||
if (etab.libelleAppauvri.startsWith('universit')) { | ||
@@ -148,2 +155,3 @@ if (address.includes(etab.libelleAppauvri || '**')) { | ||
}, false); | ||
return structureHasTutelle; | ||
}; | ||
@@ -203,3 +211,4 @@ /** | ||
function isInAddress(structure) { | ||
return hasEtabAssocs(structure) && hasPostalAddress(address, structure) && hasTutelle(address, structure) && (hasSigle(address, structure) || hasIntitule(address, structure) || hasLabelAndNumero(address, structure)); | ||
const result = hasEtabAssocs(structure) && hasPostalAddress(address, structure) && hasTutelle(address, structure) && (hasSigle(address, structure) || hasIntitule(address, structure) || hasLabelAndNumero(address, structure)); | ||
return result; | ||
} | ||
@@ -206,0 +215,0 @@ |
{ | ||
"name": "@ezs/conditor", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "ezs statements for Conditor", | ||
@@ -54,3 +54,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "76e1c7e5e206e4d8b8ed168241ced52ca9fd1fe0" | ||
"gitHead": "57cb535a647e53af262091196704461afc6dc245" | ||
} |
44930
0.72%754
1.07%