@proconnect-gouv/proconnect.identite 7.0.0 → 8.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @proconnect-gouv/proconnect.identite
2
2
 
3
+ ## 8.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1952](https://github.com/proconnect-gouv/proconnect-identite/pull/1952) [`969ed75`](https://github.com/proconnect-gouv/proconnect-identite/commit/969ed759bc129a2807074c50cba690cd47639bfc) Thanks [@BenoitSerrano](https://github.com/BenoitSerrano)! - - évolution du calcul du statut "administration" et ajout des statuts "collectivite territoriale", "administration d'état" et "service public administratif"
8
+ - renommage de la fonction `isPublicService` en `computeServicePublicInfo`
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [[`969ed75`](https://github.com/proconnect-gouv/proconnect-identite/commit/969ed759bc129a2807074c50cba690cd47639bfc)]:
13
+ - @proconnect-gouv/proconnect.annuaire_entreprises@2.0.0
14
+
15
+ ## 7.0.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`c7e2d88`](https://github.com/proconnect-gouv/proconnect-identite/commit/c7e2d8870de0da81999001100e39e321eaffe740) Thanks [@douglasduteil](https://github.com/douglasduteil)! - 🐛 Correction de l'import de `pg` en `import type` dans `contexts.ts` pour éviter que le barrel `types` n'embarque `pg` dans les bundles navigateur.
20
+
21
+ - Updated dependencies [[`144fbc3`](https://github.com/proconnect-gouv/proconnect-identite/commit/144fbc324c404bf505b379fdbaca1a5bac85adec)]:
22
+ - @proconnect-gouv/proconnect.annuaire_entreprises@1.1.5
23
+
3
24
  ## 7.0.0
4
25
 
5
26
  ### Patch Changes
package/README.md CHANGED
@@ -44,7 +44,7 @@ Stateless business logic for organization validation and PostgreSQL utilities.
44
44
  ```typescript
45
45
  import {
46
46
  isEntrepriseUnipersonnelle,
47
- isPublicService,
47
+ computeServicePublicInfo,
48
48
  } from "@proconnect-gouv/proconnect.identite/services/organization";
49
49
  import { hashToPostgresParams } from "@proconnect-gouv/proconnect.identite/services/postgres";
50
50
  ```
@@ -0,0 +1,8 @@
1
+ import type { Organization } from "#src/types";
2
+ export declare const computeServicePublicInfo: ({ cached_categorie_juridique, siret, cached_etat_administratif, }: Pick<Organization, "cached_categorie_juridique" | "cached_etat_administratif" | "siret">) => {
3
+ isServicePublic: boolean;
4
+ isAdministrationEtat?: boolean;
5
+ isCollectivite?: boolean;
6
+ isServicePublicAdministratif?: boolean;
7
+ };
8
+ //# sourceMappingURL=compute-service-public-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-service-public-info.d.ts","sourceRoot":"","sources":["../../../src/services/organization/compute-service-public-info.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO/C,eAAO,MAAM,wBAAwB,GAAI,mEAItC,IAAI,CACL,YAAY,EACZ,4BAA4B,GAAG,2BAA2B,GAAG,OAAO,CACrE,KAAG;IACF,eAAe,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,4BAA4B,CAAC,EAAE,OAAO,CAAC;CAwCxC,CAAC"}
@@ -0,0 +1,32 @@
1
+ //
2
+ import { ADMINISTRATION_BLACKLIST, ADMINISTRATION_WHITELIST, ADMINISTRATIONS, } from "@proconnect-gouv/proconnect.annuaire_entreprises";
3
+ export const computeServicePublicInfo = ({ cached_categorie_juridique, siret, cached_etat_administratif, }) => {
4
+ // Check if nature juridique is undefined/null
5
+ if (!cached_categorie_juridique) {
6
+ return { isServicePublic: false };
7
+ }
8
+ const siren = (siret || "").substring(0, 9);
9
+ // Entities in the blacklist are never considered public services
10
+ if (ADMINISTRATION_BLACKLIST.includes(siren)) {
11
+ return { isServicePublic: false };
12
+ }
13
+ // Closed entities are not considered public services
14
+ if (cached_etat_administratif === "C") {
15
+ return { isServicePublic: false };
16
+ }
17
+ // Check if entity is in whitelist (takes priority)
18
+ if (ADMINISTRATION_WHITELIST.includes(siren)) {
19
+ return { isServicePublic: true };
20
+ }
21
+ const ADMINISTRATION = ADMINISTRATIONS.find((ADMINISTRATION) => cached_categorie_juridique === `${ADMINISTRATION.codeJuridique}`);
22
+ if (!ADMINISTRATION) {
23
+ return { isServicePublic: false };
24
+ }
25
+ const { isAdministrationEtat, isCollectivite, isServicePublicAdministratif } = ADMINISTRATION;
26
+ return {
27
+ isServicePublic: true,
28
+ isAdministrationEtat,
29
+ isCollectivite,
30
+ isServicePublicAdministratif,
31
+ };
32
+ };
@@ -1,6 +1,6 @@
1
+ export * from "./compute-service-public-info.js";
1
2
  export * from "./is-domain-allowed-for-organization.js";
2
3
  export * from "./is-entreprise-unipersonnelle.js";
3
4
  export * from "./is-organization-covered-by-certification-dirigeant.js";
4
- export * from "./is-public-service.js";
5
5
  export * from "./is-small-etablissement-public.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/organization/index.ts"],"names":[],"mappings":"AAEA,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yDAAyD,CAAC;AACxE,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/organization/index.ts"],"names":[],"mappings":"AAEA,cAAc,kCAAkC,CAAC;AACjD,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yDAAyD,CAAC;AACxE,cAAc,oCAAoC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  //
2
+ export * from "./compute-service-public-info.js";
2
3
  export * from "./is-domain-allowed-for-organization.js";
3
4
  export * from "./is-entreprise-unipersonnelle.js";
4
5
  export * from "./is-organization-covered-by-certification-dirigeant.js";
5
- export * from "./is-public-service.js";
6
6
  export * from "./is-small-etablissement-public.js";
@@ -1,4 +1,4 @@
1
- import Pg from "pg";
1
+ import type Pg from "pg";
2
2
  export type DatabaseContext = {
3
3
  pg: Pg.Pool;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/types/contexts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;CACb,CAAC"}
1
+ {"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/types/contexts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAIzB,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;CACb,CAAC"}
@@ -1,2 +1,2 @@
1
1
  //
2
- import Pg from "pg";
2
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proconnect-gouv/proconnect.identite",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "homepage": "https://github.com/proconnect-gouv/proconnect-identite/tree/main/packages/identite#readme",
5
5
  "bugs": "https://github.com/proconnect-gouv/proconnect-identite/issues",
6
6
  "repository": {
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@electric-sql/pglite": "^0.3.12",
54
- "@proconnect-gouv/proconnect.annuaire_entreprises": "^1.1.4",
54
+ "@proconnect-gouv/proconnect.annuaire_entreprises": "^2.0.0",
55
55
  "@proconnect-gouv/proconnect.api_entreprise": "^2.2.0",
56
56
  "@proconnect-gouv/proconnect.core": "^1.0.0",
57
57
  "@proconnect-gouv/proconnect.devtools.typescript": "1.0.0",
@@ -65,7 +65,7 @@
65
65
  "tsx": "^4.20.3"
66
66
  },
67
67
  "peerDependencies": {
68
- "@proconnect-gouv/proconnect.annuaire_entreprises": "^1.1.4",
68
+ "@proconnect-gouv/proconnect.annuaire_entreprises": "^2.0.0",
69
69
  "@proconnect-gouv/proconnect.api_entreprise": "^2.2.0",
70
70
  "@proconnect-gouv/proconnect.core": "^1.0.0",
71
71
  "@proconnect-gouv/proconnect.insee": "^2.0.0",
@@ -9,47 +9,51 @@ import {
9
9
  lamalou_org_info,
10
10
  onf_org_info,
11
11
  trackdechets_public_org_info,
12
- whitelisted_org_info,
13
12
  } from "#testing/seed/organizations";
14
13
  import assert from "node:assert/strict";
15
14
  import { describe, it } from "node:test";
16
- import { isPublicService } from "./is-public-service.js";
15
+ import { computeServicePublicInfo } from "./compute-service-public-info.js";
17
16
 
18
- describe("isPublicService", () => {
17
+ describe("computeServicePublicInfo", () => {
19
18
  it("should return false for bad call", () => {
20
- assert.equal(isPublicService({} as Organization), false);
19
+ const result = computeServicePublicInfo({} as Organization);
20
+ assert.equal(result.isServicePublic, false);
21
21
  });
22
22
 
23
23
  it("should return true for collectivite territoriale", () => {
24
- assert.equal(isPublicService(lamalou_org_info), true);
24
+ const result = computeServicePublicInfo(lamalou_org_info);
25
+ assert.equal(result.isServicePublic, true);
25
26
  });
26
27
 
27
28
  it("should return true for administration centrale", () => {
28
- assert.equal(isPublicService(dinum_org_info), true);
29
+ const result = computeServicePublicInfo(dinum_org_info);
30
+ assert.equal(result.isServicePublic, true);
31
+ assert.equal(result.isAdministrationEtat, true);
29
32
  });
30
33
 
31
34
  it("should return false for unipersonnelle organization", () => {
32
- assert.equal(isPublicService(entreprise_unipersonnelle_org_info), false);
35
+ const result = computeServicePublicInfo(entreprise_unipersonnelle_org_info);
36
+ assert.equal(result.isServicePublic, false);
33
37
  });
34
38
 
35
39
  it("should return false for association", () => {
36
- assert.equal(isPublicService(association_org_info), false);
40
+ const result = computeServicePublicInfo(association_org_info);
41
+ assert.equal(result.isServicePublic, false);
37
42
  });
38
43
 
39
44
  it("should return true for établissement public à caractère industriel et commercial", () => {
40
- assert.equal(isPublicService(onf_org_info), true);
45
+ const result = computeServicePublicInfo(onf_org_info);
46
+ assert.equal(result.isServicePublic, true);
41
47
  });
42
48
 
43
49
  it.skip("should return true for whitelisted établissement (BIP)", () => {
44
- assert.equal(isPublicService(bpifrance_org_info), true);
45
- });
46
-
47
- it("should return true for whitelisted établissement", () => {
48
- assert.equal(isPublicService(whitelisted_org_info), true);
50
+ const result = computeServicePublicInfo(bpifrance_org_info);
51
+ assert.equal(result.isServicePublic, true);
49
52
  });
50
53
 
51
54
  it("should return true for public etablissement", () => {
52
- assert.equal(isPublicService(trackdechets_public_org_info), true);
55
+ const result = computeServicePublicInfo(trackdechets_public_org_info);
56
+ assert.equal(result.isServicePublic, true);
53
57
  });
54
58
 
55
59
  it("should return false for blacklisted SIREN", () => {
@@ -58,7 +62,8 @@ describe("isPublicService", () => {
58
62
  cached_categorie_juridique: "7120",
59
63
  cached_etat_administratif: "A",
60
64
  } as Organization;
61
- assert.equal(isPublicService(blacklisted_org), false);
65
+ const result = computeServicePublicInfo(blacklisted_org);
66
+ assert.equal(result.isServicePublic, false);
62
67
  });
63
68
 
64
69
  it("should return false for closed entities", () => {
@@ -67,7 +72,8 @@ describe("isPublicService", () => {
67
72
  cached_categorie_juridique: "7120",
68
73
  cached_etat_administratif: "C",
69
74
  } as Organization;
70
- assert.equal(isPublicService(closed_org), false);
75
+ const result = computeServicePublicInfo(closed_org);
76
+ assert.equal(result.isServicePublic, false);
71
77
  });
72
78
 
73
79
  it("should return true for entities with exact nature juridique codes", () => {
@@ -76,16 +82,8 @@ describe("isPublicService", () => {
76
82
  cached_categorie_juridique: "7111",
77
83
  cached_etat_administratif: "A",
78
84
  } as Organization;
79
- assert.equal(isPublicService(exact_nature_org), true);
80
- });
81
-
82
- it("should return true for whitelisted SIREN even with non-public nature juridique", () => {
83
- const whitelisted_siren_org = {
84
- siret: "33465403500123",
85
- cached_categorie_juridique: "5599", // Non-public nature juridique
86
- cached_etat_administratif: "A",
87
- } as Organization;
88
- assert.equal(isPublicService(whitelisted_siren_org), true);
85
+ const result = computeServicePublicInfo(exact_nature_org);
86
+ assert.equal(result.isServicePublic, true);
89
87
  });
90
88
 
91
89
  it("should return true for CARSAT BRETAGNE (annuaire-entreprises whitelist)", () => {
@@ -94,6 +92,7 @@ describe("isPublicService", () => {
94
92
  cached_categorie_juridique: "8110", // Régime général de la Sécurité Sociale
95
93
  cached_etat_administratif: "A",
96
94
  } as Organization;
97
- assert.equal(isPublicService(carsat_bretagne_org), true);
95
+ const result = computeServicePublicInfo(carsat_bretagne_org);
96
+ assert.equal(result.isServicePublic, true);
98
97
  });
99
98
  });
@@ -0,0 +1,61 @@
1
+ //
2
+
3
+ import type { Organization } from "#src/types";
4
+ import {
5
+ ADMINISTRATION_BLACKLIST,
6
+ ADMINISTRATION_WHITELIST,
7
+ ADMINISTRATIONS,
8
+ } from "@proconnect-gouv/proconnect.annuaire_entreprises";
9
+
10
+ export const computeServicePublicInfo = ({
11
+ cached_categorie_juridique,
12
+ siret,
13
+ cached_etat_administratif,
14
+ }: Pick<
15
+ Organization,
16
+ "cached_categorie_juridique" | "cached_etat_administratif" | "siret"
17
+ >): {
18
+ isServicePublic: boolean;
19
+ isAdministrationEtat?: boolean;
20
+ isCollectivite?: boolean;
21
+ isServicePublicAdministratif?: boolean;
22
+ } => {
23
+ // Check if nature juridique is undefined/null
24
+ if (!cached_categorie_juridique) {
25
+ return { isServicePublic: false };
26
+ }
27
+
28
+ const siren = (siret || "").substring(0, 9);
29
+
30
+ // Entities in the blacklist are never considered public services
31
+ if (ADMINISTRATION_BLACKLIST.includes(siren)) {
32
+ return { isServicePublic: false };
33
+ }
34
+
35
+ // Closed entities are not considered public services
36
+ if (cached_etat_administratif === "C") {
37
+ return { isServicePublic: false };
38
+ }
39
+
40
+ // Check if entity is in whitelist (takes priority)
41
+ if (ADMINISTRATION_WHITELIST.includes(siren)) {
42
+ return { isServicePublic: true };
43
+ }
44
+
45
+ const ADMINISTRATION = ADMINISTRATIONS.find(
46
+ (ADMINISTRATION) =>
47
+ cached_categorie_juridique === `${ADMINISTRATION.codeJuridique}`,
48
+ );
49
+ if (!ADMINISTRATION) {
50
+ return { isServicePublic: false };
51
+ }
52
+ const { isAdministrationEtat, isCollectivite, isServicePublicAdministratif } =
53
+ ADMINISTRATION;
54
+
55
+ return {
56
+ isServicePublic: true,
57
+ isAdministrationEtat,
58
+ isCollectivite,
59
+ isServicePublicAdministratif,
60
+ };
61
+ };
@@ -1,7 +1,7 @@
1
1
  //
2
2
 
3
+ export * from "./compute-service-public-info.js";
3
4
  export * from "./is-domain-allowed-for-organization.js";
4
5
  export * from "./is-entreprise-unipersonnelle.js";
5
6
  export * from "./is-organization-covered-by-certification-dirigeant.js";
6
- export * from "./is-public-service.js";
7
7
  export * from "./is-small-etablissement-public.js";
@@ -1,6 +1,6 @@
1
1
  //
2
2
 
3
- import Pg from "pg";
3
+ import type Pg from "pg";
4
4
 
5
5
  //
6
6