@gouvfr-anct/mednum
Version:
✨ Permet de transformer une source de données vers le schéma des lieux de mediation numerique
59 lines (58 loc) • 3.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeStructureAndService = void 0;
const dataInclusionMergedGeneral = (structure, service) => ({
id: structure.source === 'dora' ? structure.id : `${structure.source}-${structure.id}`,
nom: structure.nom,
pivot: structure.siret ?? '',
...(structure.structure_parente == null ? {} : { structure_parente: structure.structure_parente }),
thematiques: service.thematiques?.join(',') ?? '',
...(structure.typologie == null ? {} : { typologie: structure.typologie }),
...(structure.accessibilite == null ? {} : { accessibilite: structure.accessibilite })
});
const dataInclusionMergedAddress = (structure) => ({
adresse: structure.adresse,
code_postal: structure.code_postal,
commune: structure.commune,
...(structure.code_insee == null ? {} : { code_insee: structure.code_insee }),
...(structure.complement_adresse == null ? {} : { complement_adresse: structure.complement_adresse })
});
const dataInclusionMergedLocalisation = (structure) => ({
...(structure.latitude == null ? {} : { latitude: structure.latitude }),
...(structure.longitude == null ? {} : { longitude: structure.longitude })
});
const dataInclusionMergedContact = (structure, service) => ({
...(structure.courriel == null ? {} : { courriel: structure.courriel }),
...(structure.telephone == null ? {} : { telephone: structure.telephone }),
...(structure.site_web == null ? {} : { site_web: structure.site_web }),
...(service.prise_rdv == null ? {} : { prise_rdv: service.prise_rdv })
});
const dataInclusionMergedCollecte = (structure) => ({
date_maj: new Date(structure.date_maj).toISOString(),
source: structure.source?.replace('mediation-numerique-', '') ?? ''
});
const dataInclusionMergedPresentation = (structure) => ({
...(structure.presentation_detail == null ? {} : { presentation_detail: structure.presentation_detail }),
...(structure.presentation_resume == null ? {} : { presentation_resume: structure.presentation_resume })
});
const dataInclusionMergedLabels = (structure) => ({
...(structure.labels_autres == null ? {} : { labels_autres: structure.labels_autres.join(',') }),
...(structure.labels_nationaux == null ? {} : { labels_nationaux: structure.labels_nationaux.join(',') })
});
const dataInclusionMergedAcces = (structure, service) => ({
...(service.frais == null || service.frais.length === 0 ? {} : { frais: service.frais.join(',') }),
...(service.profils == null || service.profils.length === 0 ? {} : { profils: service.profils.join(',') }),
...(service.types == null || service.types.length === 0 ? {} : { types: service.types.join(',') }),
...(structure.horaires_ouverture == null ? {} : { horaires: structure.horaires_ouverture })
});
const mergeStructureAndService = (structure, service) => ({
...dataInclusionMergedGeneral(structure, service),
...dataInclusionMergedAddress(structure),
...dataInclusionMergedLocalisation(structure),
...dataInclusionMergedContact(structure, service),
...dataInclusionMergedCollecte(structure),
...dataInclusionMergedPresentation(structure),
...dataInclusionMergedLabels(structure),
...dataInclusionMergedAcces(structure, service)
});
exports.mergeStructureAndService = mergeStructureAndService;