forked from Legilibre/legi.py
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dila.js): add examples (Legilibre#31)
- Loading branch information
1 parent
3dfe178
commit 28f5f62
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/dila.js/examples/kali/convention-collective-full.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const dila = require("../dila"); | ||
const { JSONlog } = require("../../src/utils"); | ||
|
||
/* | ||
renvoie la structure de base d'une convention collective et de tous ses textes attachés en JSON | ||
ex: KALICONT000005635807: Convention collective nationale des salariés du particulier employeur du 24 novembre 1999. | ||
*/ | ||
|
||
const flatify = arr => arr.reduce((a, c) => [...a, ...c], []); | ||
|
||
dila | ||
// récupère le conteneur principal | ||
.getConteneur({ id: "KALICONT000005635807", date: "2019-01-01" }) | ||
// récupère le texte du conteneur principal | ||
.then(({ data }) => dila.getTexte({ id: data.texte_de_base, date: "2019-01-01" })) | ||
.then(texte => | ||
// récupères tous les textes attachés | ||
Promise.all( | ||
["extensions", "attaches", "salaires"].map(typeTextes => | ||
dila | ||
.getConventionTextes({ | ||
conteneurId: "KALICONT000005635807", | ||
typeTextes, | ||
date: "2019-01-01" | ||
}) | ||
.then(data => | ||
// recupère la structure de chaque texte attaché | ||
Promise.all( | ||
data.textes.map(texte => dila.getTexte({ id: texte.id, date: "2019-01-01" })) | ||
) | ||
) | ||
) | ||
) | ||
.then(flatify) | ||
.then(attaches => ({ | ||
id: "KALICONT000005635807", | ||
date: "2019-01-01", | ||
base: texte, | ||
attaches | ||
})) | ||
) | ||
|
||
.then(JSONlog) | ||
.catch(console.log) | ||
.then(dila.close); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const dila = require("../dila"); | ||
const html = require("../../src/html"); | ||
|
||
/* | ||
renvoie le texte de base d'une convention collective en HTML | ||
ex: KALICONT000005635807: Convention collective nationale des salariés du particulier employeur du 24 novembre 1999. | ||
*/ | ||
|
||
dila | ||
.getConteneur({ id: "KALICONT000005635807", date: "2019-01-01" }) | ||
.then(({ data }) => dila.getTexte({ id: data.texte_de_base, date: "2019-01-01" })) | ||
.then(html) | ||
.then(console.log) | ||
.catch(console.log) | ||
.then(dila.close); | ||
|
14 changes: 14 additions & 0 deletions
14
packages/dila.js/examples/kali/liste-conventions-collectives.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const dila = require("../dila"); | ||
const { JSONlog } = require("../../src/utils"); | ||
|
||
/* | ||
liste les conventions actives en JSON | ||
actives = selon le fichier publié sur le site de la DGT à une url type https://travail-emploi.gouv.fr/IMG/xls/idccjuin19.xls | ||
*/ | ||
|
||
dila | ||
.getConteneursList({ nature: "IDCC", active: true }) | ||
.then(JSONlog) | ||
.catch(console.log) | ||
.then(dila.close); |