@socialgouv/kali-data 2.615.0 → 2.616.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/data/KALICONT000005635472.json +0 -1
  2. package/data/KALICONT000005635905.json +0 -1
  3. package/data/index.json +14 -42
  4. package/package.json +78 -77
  5. package/src/__tests__/index.test.js +15 -15
  6. package/src/helpers/__tests__/checkArticleIdOrCid.test.js +8 -8
  7. package/src/helpers/__tests__/isFile.test.js +14 -14
  8. package/src/helpers/checkArticleIdOrCid.js +6 -6
  9. package/src/helpers/isFile.js +1 -1
  10. package/src/helpers/withArticleIdOrCid.js +2 -2
  11. package/src/index.js +11 -11
  12. package/src/libs/__tests__/getAgreement.test.js +28 -28
  13. package/src/libs/__tests__/getAgreementArticlesWithParentSections.test.js +13 -13
  14. package/src/libs/__tests__/getAgreementArticlesWithPath.test.js +13 -13
  15. package/src/libs/__tests__/getAgreementIdFromIdOrIdcc.test.js +17 -17
  16. package/src/libs/__tests__/getAgreements.test.js +3 -3
  17. package/src/libs/__tests__/getArticleWithParentSections.test.js +19 -19
  18. package/src/libs/__tests__/getArticleWithPath.test.js +19 -19
  19. package/src/libs/__tests__/getArticles.test.js +3 -3
  20. package/src/libs/__tests__/getIndexedArticle.test.js +19 -19
  21. package/src/libs/__tests__/hasAgreement.test.js +23 -23
  22. package/src/libs/__tests__/hasArticle.test.js +14 -14
  23. package/src/libs/getAgreement.js +7 -7
  24. package/src/libs/getAgreementArticlesWithParentSections.js +22 -22
  25. package/src/libs/getAgreementArticlesWithPath.js +11 -11
  26. package/src/libs/getAgreementIdFromIdOrIdcc.js +18 -18
  27. package/src/libs/getAgreements.js +3 -3
  28. package/src/libs/getArticleWithParentSections.js +34 -34
  29. package/src/libs/getArticleWithPath.js +25 -25
  30. package/src/libs/getArticles.js +3 -3
  31. package/src/libs/getIndexedArticle.js +6 -6
  32. package/src/libs/hasAgreement.js +10 -9
  33. package/src/libs/hasArticle.js +6 -6
@@ -12,10 +12,10 @@ const getIndexedArticle = require("./getIndexedArticle");
12
12
  * @returns {KaliData.AgreementArticle=}
13
13
  */
14
14
  const findArticleWithData = (agreement, data) =>
15
- unistUtilFind(agreement, {
16
- data,
17
- type: "article",
18
- });
15
+ unistUtilFind(agreement, {
16
+ data,
17
+ type: "article",
18
+ });
19
19
 
20
20
  /**
21
21
  * Get an agreement article unist node with its parent sections path.
@@ -26,32 +26,32 @@ const findArticleWithData = (agreement, data) =>
26
26
  * @returns {KaliData.AgreementArticleWithPath}
27
27
  */
28
28
  function getArticleWithPath(articleIdOrCid) {
29
- const { agreementId, path } = getIndexedArticle(articleIdOrCid);
30
- const agreement = getAgreement(agreementId);
29
+ const { agreementId, path } = getIndexedArticle(articleIdOrCid);
30
+ const agreement = getAgreement(agreementId);
31
+
32
+ // First attempt with an article ID:
33
+ const maybeArticleWithId = findArticleWithData(agreement, { id: articleIdOrCid });
34
+ if (maybeArticleWithId !== undefined) {
35
+ const articleWithPath = {
36
+ ...maybeArticleWithId,
37
+ path,
38
+ };
39
+
40
+ return articleWithPath;
41
+ }
42
+
43
+ // Second attempt with an article CID:
44
+ const maybeArticleWithCid = findArticleWithData(agreement, { cid: articleIdOrCid });
45
+ if (maybeArticleWithCid === undefined) {
46
+ throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
47
+ }
31
48
 
32
- // First attempt with an article ID:
33
- const maybeArticleWithId = findArticleWithData(agreement, { id: articleIdOrCid });
34
- if (maybeArticleWithId !== undefined) {
35
49
  const articleWithPath = {
36
- ...maybeArticleWithId,
37
- path,
50
+ ...maybeArticleWithCid,
51
+ path,
38
52
  };
39
53
 
40
54
  return articleWithPath;
41
- }
42
-
43
- // Second attempt with an article CID:
44
- const maybeArticleWithCid = findArticleWithData(agreement, { cid: articleIdOrCid });
45
- if (maybeArticleWithCid === undefined) {
46
- throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
47
- }
48
-
49
- const articleWithPath = {
50
- ...maybeArticleWithCid,
51
- path,
52
- };
53
-
54
- return articleWithPath;
55
55
  }
56
56
 
57
57
  module.exports = getArticleWithPath;
@@ -1,8 +1,8 @@
1
1
  // @ts-check
2
2
 
3
3
  const INDEXED_ARTICLES =
4
- /** @type {KaliData.IndexedArticle[]} */
5
- (require("../../data/articles/index.json"));
4
+ /** @type {KaliData.IndexedArticle[]} */
5
+ (require("../../data/articles/index.json"));
6
6
 
7
7
  /**
8
8
  * Get the full list of indexed articles.
@@ -10,7 +10,7 @@ const INDEXED_ARTICLES =
10
10
  * @returns {KaliData.IndexedArticle[]}
11
11
  */
12
12
  function getArticles() {
13
- return INDEXED_ARTICLES;
13
+ return INDEXED_ARTICLES;
14
14
  }
15
15
 
16
16
  module.exports = getArticles;
@@ -14,14 +14,14 @@ const INDEXED_ARTICLES = getArticles();
14
14
  * @returns {KaliData.IndexedArticle}
15
15
  */
16
16
  function getIndexedArticle(articleIdOrCid) {
17
- checkArticleIdOrCid(articleIdOrCid);
17
+ checkArticleIdOrCid(articleIdOrCid);
18
18
 
19
- const maybeIndexedArticle = INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid));
20
- if (maybeIndexedArticle === undefined) {
21
- throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
22
- }
19
+ const maybeIndexedArticle = INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid));
20
+ if (maybeIndexedArticle === undefined) {
21
+ throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
22
+ }
23
23
 
24
- return maybeIndexedArticle;
24
+ return maybeIndexedArticle;
25
25
  }
26
26
 
27
27
  module.exports = getIndexedArticle;
@@ -16,16 +16,17 @@ const INDEXED_AGREEMENTS = getAgreements();
16
16
  * @returns {boolean}
17
17
  */
18
18
  function hasAgreement(agreementIdOrIdcc) {
19
- try {
20
- const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
21
- const maybeFilePath = path.join(__dirname, `../../data/${agreementId}.json`);
19
+ try {
20
+ const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
21
+ const maybeFilePath = path.join(__dirname, `../../data/${agreementId}.json`);
22
22
 
23
- return (
24
- INDEXED_AGREEMENTS.find(({ id }) => id === agreementId) !== undefined && isFile(maybeFilePath)
25
- );
26
- } catch (err) {
27
- return false;
28
- }
23
+ return (
24
+ INDEXED_AGREEMENTS.find(({ id }) => id === agreementId) !== undefined &&
25
+ isFile(maybeFilePath)
26
+ );
27
+ } catch (err) {
28
+ return false;
29
+ }
29
30
  }
30
31
 
31
32
  module.exports = hasAgreement;
@@ -14,13 +14,13 @@ const INDEXED_ARTICLES = getArticles();
14
14
  * @returns {boolean}
15
15
  */
16
16
  function hasArticle(articleIdOrCid) {
17
- try {
18
- checkArticleIdOrCid(articleIdOrCid);
17
+ try {
18
+ checkArticleIdOrCid(articleIdOrCid);
19
19
 
20
- return INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid)) !== undefined;
21
- } catch (err) {
22
- return false;
23
- }
20
+ return INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid)) !== undefined;
21
+ } catch (err) {
22
+ return false;
23
+ }
24
24
  }
25
25
 
26
26
  module.exports = hasArticle;