@socialgouv/legi-data
Extracted with dila-api-client from DILA API API using unist (Univeral Syntax Tree) structure.
Usage
Getting started
npm i @socialgouv/legi-data
# or if you only need the Typescript types
npm i -D @socialgouv/legi-data-types
Definitions
Code
A code is a French code of law (i.e.: "Labor Code", "Social Security Code"). Each code is made up of articles wrapped within sections.
Article
An article always refers to a code article.
API
This package is typed with Typescript, you can check the returns type details there.
Data
It's possible to require any of the available codes JSON unist tree straight from the data directory:
const LaborCode = require("@socialgouv/legi-data/data/LEGITEXT000006072050.json");
And the list of available codes with:
const codes = require("@socialgouv/legi-data/data/index.json");
Return Type
LegiData.Code;
getArticleWithParentSections()
Get a code article unist node with its parent sections.
Parameter | Type | Default | Description |
---|---|---|---|
articleIdOrCid |
string |
required | Article ID or CID |
Return Type
LegiData.CodeArticleWithParentSections;
getCode()
Get a full code unist node with its sections and articles.
Parameter | Type | Default | Description |
---|---|---|---|
codeId |
string |
required | Code ID |
Return Type
LegiData.Code;
getCodeWithParents()
Get a full code unist node with its sections and articles.
Each node has a
parent
property with a pointer to its parent node.
Parameter | Type | Default | Description |
---|---|---|---|
codeId |
string |
required | Code ID |
Return Type
LegiData.CodeWithParents;
getIndexedArticle()
Get an indexed articles.
Parameter | Type | Default | Description |
---|---|---|---|
articleIdOrCid |
string |
required | Article ID or CID |
Return Type
LegiData.IndexedArticle;
getIndexedArticles()
Get the full list of indexed articles.
Return Type
LegiData.IndexedArticle[]
getIndexedCodes()
Get the full list of indexed codes.
Return Type
LegiData.IndexedCode[]
hasArticle()
Check if an article is available.
Parameter | Type | Default | Description |
---|---|---|---|
articleIdOrCid |
string |
required | Article ID or CID |
Return Type
boolean;
hasCode()
Check if an code is available.
Parameter | Type | Default | Description |
---|---|---|---|
codeId |
string |
required | Code ID |
Return Type
boolean;
Contributing
Getting started
First, you'll need to create an application on PISTE and select DILA - Légifrance Beta API.
Then:
yarn
yarn setup
This will automatically prompt and store your OAuth Client ID & Secret.
Data Generation
yarn data:update
will automatically fetch, list and match data package codes with their
articles.
yarn data:fetch
: Update codes articles from DILA API.yarn data:match
: Update codes articles index (matching articles ID & CID with their codes ID).yarn data:list
UpdateREFERENCES.md
file.
Tests
yarn test:lint
: Lint codebase.yarn test:type
: Check typings.yarn test:unit
Launch unit tests.yarn test:update
Update unit tests snapshots.yarn test:watch
Launch unit tests in watching mode.
References
The agreement references list is available here.
Also
- Code du travail numérique
- dila-api-client : Client JavaScript pour l'API DILA AIFE
- kali-data : base conventions collectives KALI
- fiches-vdd : Fiches vos droits et démarches