npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@socialgouv/legi-data-types

v2.391.0

Published

[![License][img-license]][link-license] [![NPM Version][img-npm]][link-npm] [![Code Coverage][img-coverage]][link-coverage]

Downloads

1,361

Readme

@socialgouv/legi-data

License NPM Version Code Coverage


:warning: Experimental, for internal usage only :warning:


Extractions quotidiennes des codes de loi de la base LEGI depuis l'API legifrance.gouv.fr

Les données sont disponibles au format JSON ou via une API TypeScript.

ex pour récupérer le "code du travail" complet :

const code = require("@socialgouv/legi-data/data/LEGITEXT000006072050.json");

La structure du JSON est basée sur unified


Actuellement, seuls 4 codes sont versionnés ici :

| Id | Description | | -------------------- | ------------------------------------------------------ | | LEGITEXT000006072050 | Code du travail | | LEGITEXT000022197698 | Code de la sécurité sociale | | LEGITEXT000022197698 | Code rural et de la pêche maritime | | LEGITEXT000031366350 | Code des relations entre le public et l'administration |

Postez une issue si vous souhaitez en voir d'autres.


API TypeScript

Getting started

npm i @socialgouv/legi-data

# or if you only need the Typescript types
npm i -D @socialgouv/legi-data-types

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 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.

Also