Skip to content

SocialGouv/kali-data

Repository files navigation

@socialgouv/kali-data

License NPM Version Code Coverage


Dump JSON régulier des conventions collectives publiées par l'API DILA.

⚠️ Experimental, for internal usage only ⚠️


Extracted with dila-api-client from DILA API API using unist (Univeral Syntax Tree) structure.

Usage

Getting started

npm i @socialgouv/kali-data

Definitions

Agreement

An agreement is a labor agreement (convention collective in French). Only national agreements are available at the moment. Each agreement is made up of articles wrapped within sections.

Article

An article always refers to an agreement 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 agreements JSON unist tree straight from the data directory:

const JournalismAgreement = require("@socialgouv/kali-data/data/KALITEXT000005652402.json");

And the list of available agreements with :

const agreements = require("@socialgouv/kali-data/data/index.json");

Return Type

KaliData.Agreement

getAgreement()

Get a full agreement unist tree with its sections and articles.

Parameter Type Default Description
agreementIdOrIdcc number | string required Agreement ID or IDCC

Return Type

KaliData.Agreement

getAgreementArticlesWithParentSections()

⚠️ Deprecated: Use getAgreementArticlesWithPath() instead.

Get a flat unist array of all the articles an agreement contains.

Each article includes a list of its parent sections.

Parameter Type Default Description
agreementIdOrIdcc number | string required Agreement ID or IDCC

Return Type

KaliData.AgreementArticleWithParentSections[]

getAgreementArticlesWithPath()

Get a flat unist array of all the articles an agreement contains.

Each article includes its parent sections path, as an ordered list of their titles.

Parameter Type Default Description
agreementIdOrIdcc number | string required Agreement ID or IDCC

Return Type

KaliData.AgreementArticleWithPath[]

getAgreementIdFromIdOrIdcc()

Convert any agreement ID or IDCC into a normalized agreement ID.

Parameter Type Default Description
agreementIdOrIdcc number | string required Agreement ID or IDCC

Return Type

string

getAgreements()

Get the full list of indexed agreements.

Return Type

KaliData.IndexedAgreement[]

getArticles()

Get the full list of indexed articles.

Return Type

KaliData.IndexedArticle[]

getArticleWithParentSections()

⚠️ Deprecated: Use getArticleWithPath() instead.

Get an agreement article unist node with its parent sections.

Parameter Type Default Description
articleIdOrCid string required Article ID or CID

Return Type

KaliData.AgreementArticleWithParentSections

getArticleWithPath()

Get an agreement article unist node with its parent sections path.

The parent sections path is represented as an ordered array of their titles.

Parameter Type Default Description
articleIdOrCid string required Article ID or CID

Return Type

KaliData.AgreementArticleWithPath

getIndexedArticle()

Get an indexed article.

Parameter Type Default Description
articleIdOrCid string required Article ID or CID

Return Type

KaliData.IndexedArticle

hasAgreement()

Check if an agreement is available.

Parameter Type Default Description
agreementIdOrIdcc number | string required Agreement ID or IDCC

Return Type

boolean

hasArticle()

Check if an article is available.

Parameter Type Default Description
articleIdOrCid string required Article ID or CID

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, match, list and check data package agreements with their articles.

  • yarn data:check Check agreements consistency.
  • yarn data:fetch: Update agreements articles from DILA API.
  • yarn data:match: Update agreements articles index (matching articles ID & CID with their agreements ID).
  • yarn data:list Update REFERENCES.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.

See Also