@proconnect-gouv/proconnect.identite 1.0.0 → 1.2.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 +22 -0
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/data/certification/commune-code-conversion.d.ts +13 -0
- package/dist/data/certification/commune-code-conversion.d.ts.map +1 -0
- package/dist/data/certification/commune-code-conversion.js +5188 -0
- package/dist/data/certification/country-iso-to-cog.d.ts +12 -0
- package/dist/data/certification/country-iso-to-cog.d.ts.map +1 -0
- package/dist/data/certification/country-iso-to-cog.js +438 -0
- package/dist/data/certification/index.d.ts +3 -0
- package/dist/data/certification/index.d.ts.map +1 -0
- package/dist/data/certification/index.js +3 -0
- package/dist/managers/certification/adapters/api_entreprise.d.ts +4 -0
- package/dist/managers/certification/adapters/api_entreprise.d.ts.map +1 -0
- package/dist/managers/certification/adapters/api_entreprise.js +14 -0
- package/dist/managers/certification/adapters/franceconnect.d.ts +3 -0
- package/dist/managers/certification/adapters/franceconnect.d.ts.map +1 -0
- package/dist/managers/certification/adapters/franceconnect.js +15 -0
- package/dist/managers/certification/adapters/insee.d.ts +4 -0
- package/dist/managers/certification/adapters/insee.d.ts.map +1 -0
- package/dist/managers/certification/adapters/insee.js +29 -0
- package/dist/managers/certification/adapters/rne.d.ts +4 -0
- package/dist/managers/certification/adapters/rne.d.ts.map +1 -0
- package/dist/managers/certification/adapters/rne.js +45 -0
- package/dist/managers/certification/birthplace-conversion.d.ts +27 -0
- package/dist/managers/certification/birthplace-conversion.d.ts.map +1 -0
- package/dist/managers/certification/birthplace-conversion.js +45 -0
- package/dist/managers/certification/certification-score.d.ts +22 -0
- package/dist/managers/certification/certification-score.d.ts.map +1 -0
- package/dist/managers/certification/certification-score.js +72 -0
- package/dist/managers/certification/index.d.ts +1 -1
- package/dist/managers/certification/index.d.ts.map +1 -1
- package/dist/managers/certification/index.js +1 -1
- package/dist/managers/certification/is-organization-dirigeant.d.ts +38 -8
- package/dist/managers/certification/is-organization-dirigeant.d.ts.map +1 -1
- package/dist/managers/certification/is-organization-dirigeant.js +89 -52
- package/dist/managers/certification/normalize.d.ts +21 -0
- package/dist/managers/certification/normalize.d.ts.map +1 -0
- package/dist/managers/certification/normalize.js +64 -0
- package/dist/managers/franceconnect/openid-client.d.ts +1 -0
- package/dist/managers/franceconnect/openid-client.d.ts.map +1 -1
- package/dist/managers/organization/adapters/api_entreprise.d.ts +25 -0
- package/dist/managers/organization/adapters/api_entreprise.d.ts.map +1 -0
- package/dist/{mappers/organization/from-siret.js → managers/organization/adapters/api_entreprise.js} +26 -3
- package/dist/managers/organization/get-organization-info.d.ts +2 -2
- package/dist/managers/organization/get-organization-info.d.ts.map +1 -1
- package/dist/managers/organization/get-organization-info.js +6 -6
- package/dist/repositories/organization/upsert.d.ts +1 -1
- package/dist/repositories/organization/upsert.d.ts.map +1 -1
- package/dist/repositories/organization/upsert.js +26 -1
- package/dist/repositories/user/get-franceconnect-user-info.d.ts +1 -0
- package/dist/repositories/user/get-franceconnect-user-info.d.ts.map +1 -1
- package/dist/repositories/user/upsert-franceconnect-userinfo.d.ts +1 -0
- package/dist/repositories/user/upsert-franceconnect-userinfo.d.ts.map +1 -1
- package/dist/services/organization/index.d.ts +2 -0
- package/dist/services/organization/index.d.ts.map +1 -1
- package/dist/services/organization/index.js +2 -0
- package/dist/services/organization/is-public-service.d.ts +3 -0
- package/dist/services/organization/is-public-service.d.ts.map +1 -0
- package/dist/services/organization/is-public-service.js +19 -0
- package/dist/services/organization/is-syndicat-communal.d.ts +3 -0
- package/dist/services/organization/is-syndicat-communal.d.ts.map +1 -0
- package/dist/services/organization/is-syndicat-communal.js +13 -0
- package/dist/types/dirigeant.d.ts +5 -0
- package/dist/types/dirigeant.d.ts.map +1 -1
- package/dist/types/dirigeant.js +2 -0
- package/dist/types/franceconnect.d.ts +2 -0
- package/dist/types/franceconnect.d.ts.map +1 -1
- package/dist/types/franceconnect.js +1 -0
- package/dist/types/organization.d.ts +3 -3
- package/dist/types/organization.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/data/certification/commune-code-conversion.ts +5189 -0
- package/src/data/certification/country-iso-to-cog.ts +439 -0
- package/src/data/certification/index.ts +4 -0
- package/src/managers/certification/adapters/api_entreprise.test.ts +68 -0
- package/src/managers/certification/adapters/api_entreprise.test.ts.snapshot +109 -0
- package/src/{mappers/certification/index.ts → managers/certification/adapters/api_entreprise.ts} +8 -5
- package/src/managers/certification/adapters/franceconnect.ts +21 -0
- package/src/managers/certification/adapters/insee.test.ts +18 -0
- package/src/managers/certification/adapters/insee.test.ts.snapshot +21 -0
- package/src/managers/certification/adapters/insee.ts +39 -0
- package/src/managers/certification/adapters/rne.test.ts +276 -0
- package/src/managers/certification/adapters/rne.ts +64 -0
- package/src/managers/certification/birthplace-conversion.test.ts +76 -0
- package/src/managers/certification/birthplace-conversion.ts +58 -0
- package/src/managers/certification/certification-score.test.ts +309 -0
- package/src/managers/certification/certification-score.ts +97 -0
- package/src/managers/certification/index.ts +1 -1
- package/src/managers/certification/is-organization-dirigeant.test.ts +144 -53
- package/src/managers/certification/is-organization-dirigeant.ts +132 -106
- package/src/managers/certification/normalize.test.ts +71 -0
- package/src/managers/certification/normalize.ts +72 -0
- package/src/managers/organization/adapters/api_entreprise.test.ts +31 -0
- package/src/{mappers/organization/from-siret.test.ts.snapshot → managers/organization/adapters/api_entreprise.test.ts.snapshot} +26 -3
- package/src/{mappers/organization/from-siret.ts → managers/organization/adapters/api_entreprise.ts} +55 -5
- package/src/managers/organization/get-organization-info.test.ts +2 -2
- package/src/managers/organization/get-organization-info.ts +10 -10
- package/src/repositories/organization/get-users-by-organization.test.ts.snapshot +1 -1
- package/src/repositories/organization/upsert.ts +69 -19
- package/src/repositories/user/find-by-email.test.ts +1 -1
- package/src/repositories/user/find-by-id.test.ts +1 -1
- package/src/repositories/user/get-by-id.test.ts +1 -1
- package/src/repositories/user/get-franceconnect-user-info.test.ts +1 -0
- package/src/repositories/user/upsert-franceconnect-userinfo.test.ts +2 -0
- package/src/services/organization/index.ts +2 -0
- package/src/services/organization/is-public-service.test.ts +99 -0
- package/src/services/organization/is-public-service.ts +35 -0
- package/src/services/organization/is-syndicat-communal.test.ts +31 -0
- package/src/services/organization/is-syndicat-communal.ts +18 -0
- package/src/types/dirigeant.ts +3 -0
- package/src/types/franceconnect.ts +1 -0
- package/src/types/organization-info.ts +1 -1
- package/src/types/organization.ts +3 -3
- package/testing/seed/franceconnect/index.ts +12 -9
- package/testing/seed/organizations/index.ts +108 -0
- package/tsconfig.json +6 -2
- package/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/managers/certification/distance.d.ts +0 -4
- package/dist/managers/certification/distance.d.ts.map +0 -1
- package/dist/managers/certification/distance.js +0 -16
- package/dist/mappers/certification/index.d.ts +0 -4
- package/dist/mappers/certification/index.d.ts.map +0 -1
- package/dist/mappers/certification/index.js +0 -11
- package/dist/mappers/index.d.ts +0 -2
- package/dist/mappers/index.d.ts.map +0 -1
- package/dist/mappers/index.js +0 -2
- package/dist/mappers/organization/from-siret.d.ts +0 -5
- package/dist/mappers/organization/from-siret.d.ts.map +0 -1
- package/dist/mappers/organization/index.d.ts +0 -2
- package/dist/mappers/organization/index.d.ts.map +0 -1
- package/dist/mappers/organization/index.js +0 -2
- package/src/managers/certification/distance.test.ts +0 -109
- package/src/managers/certification/distance.ts +0 -41
- package/src/mappers/index.ts +0 -3
- package/src/mappers/organization/from-siret.test.ts +0 -26
- package/src/mappers/organization/index.ts +0 -3
- package/testing/seed/insee/index.ts +0 -22
- package/testing/seed/mandataires/index.ts +0 -32
|
@@ -12,29 +12,31 @@ import type { QueryResult } from "pg";
|
|
|
12
12
|
export function upsertFactory({ pg }: DatabaseContext) {
|
|
13
13
|
return async function upsert({
|
|
14
14
|
siret,
|
|
15
|
-
organizationInfo
|
|
16
|
-
libelle: cached_libelle,
|
|
17
|
-
nomComplet: cached_nom_complet,
|
|
18
|
-
enseigne: cached_enseigne,
|
|
19
|
-
trancheEffectifs: cached_tranche_effectifs,
|
|
20
|
-
trancheEffectifsUniteLegale: cached_tranche_effectifs_unite_legale,
|
|
21
|
-
libelleTrancheEffectif: cached_libelle_tranche_effectif,
|
|
22
|
-
etatAdministratif: cached_etat_administratif,
|
|
23
|
-
estActive: cached_est_active,
|
|
24
|
-
statutDiffusion: cached_statut_diffusion,
|
|
25
|
-
estDiffusible: cached_est_diffusible,
|
|
26
|
-
adresse: cached_adresse,
|
|
27
|
-
codePostal: cached_code_postal,
|
|
28
|
-
codeOfficielGeographique: cached_code_officiel_geographique,
|
|
29
|
-
activitePrincipale: cached_activite_principale,
|
|
30
|
-
libelleActivitePrincipale: cached_libelle_activite_principale,
|
|
31
|
-
categorieJuridique: cached_categorie_juridique,
|
|
32
|
-
libelleCategorieJuridique: cached_libelle_categorie_juridique,
|
|
33
|
-
},
|
|
15
|
+
organizationInfo,
|
|
34
16
|
}: {
|
|
35
17
|
siret: string;
|
|
36
18
|
organizationInfo: OrganizationInfo;
|
|
37
19
|
}) {
|
|
20
|
+
const {
|
|
21
|
+
cached_libelle,
|
|
22
|
+
cached_nom_complet,
|
|
23
|
+
cached_enseigne,
|
|
24
|
+
cached_tranche_effectifs,
|
|
25
|
+
cached_tranche_effectifs_unite_legale,
|
|
26
|
+
cached_libelle_tranche_effectif,
|
|
27
|
+
cached_etat_administratif,
|
|
28
|
+
cached_est_active,
|
|
29
|
+
cached_statut_diffusion,
|
|
30
|
+
cached_est_diffusible,
|
|
31
|
+
cached_adresse,
|
|
32
|
+
cached_code_postal,
|
|
33
|
+
cached_code_officiel_geographique,
|
|
34
|
+
cached_activite_principale,
|
|
35
|
+
cached_libelle_activite_principale,
|
|
36
|
+
cached_categorie_juridique,
|
|
37
|
+
cached_libelle_categorie_juridique,
|
|
38
|
+
} = toPartialOrganization(organizationInfo);
|
|
39
|
+
|
|
38
40
|
const { rows }: QueryResult<Organization> = await pg.query(
|
|
39
41
|
`
|
|
40
42
|
INSERT INTO organizations
|
|
@@ -140,3 +142,51 @@ export function upsertFactory({ pg }: DatabaseContext) {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
export type UpsertHandler = ReturnType<typeof upsertFactory>;
|
|
145
|
+
|
|
146
|
+
//
|
|
147
|
+
|
|
148
|
+
function toPartialOrganization(organization_info: OrganizationInfo) {
|
|
149
|
+
const {
|
|
150
|
+
activitePrincipale: cached_activite_principale,
|
|
151
|
+
adresse: cached_adresse,
|
|
152
|
+
categorieJuridique: cached_categorie_juridique,
|
|
153
|
+
codeOfficielGeographique: cached_code_officiel_geographique,
|
|
154
|
+
codePostal: cached_code_postal,
|
|
155
|
+
enseigne: cached_enseigne,
|
|
156
|
+
estActive: cached_est_active,
|
|
157
|
+
estDiffusible: cached_est_diffusible,
|
|
158
|
+
etatAdministratif: cached_etat_administratif,
|
|
159
|
+
libelle: cached_libelle,
|
|
160
|
+
libelleActivitePrincipale: cached_libelle_activite_principale,
|
|
161
|
+
libelleCategorieJuridique: cached_libelle_categorie_juridique,
|
|
162
|
+
libelleTrancheEffectif: cached_libelle_tranche_effectif,
|
|
163
|
+
nomComplet: cached_nom_complet,
|
|
164
|
+
siret,
|
|
165
|
+
statutDiffusion: cached_statut_diffusion,
|
|
166
|
+
trancheEffectifs: cached_tranche_effectifs,
|
|
167
|
+
trancheEffectifsUniteLegale: cached_tranche_effectifs_unite_legale,
|
|
168
|
+
} = organization_info;
|
|
169
|
+
return {
|
|
170
|
+
cached_activite_principale,
|
|
171
|
+
cached_adresse,
|
|
172
|
+
cached_categorie_juridique,
|
|
173
|
+
cached_code_officiel_geographique,
|
|
174
|
+
cached_code_postal,
|
|
175
|
+
cached_enseigne,
|
|
176
|
+
cached_est_active,
|
|
177
|
+
cached_est_diffusible,
|
|
178
|
+
cached_etat_administratif,
|
|
179
|
+
cached_libelle_activite_principale,
|
|
180
|
+
cached_libelle_categorie_juridique,
|
|
181
|
+
cached_libelle_tranche_effectif,
|
|
182
|
+
cached_libelle,
|
|
183
|
+
cached_nom_complet,
|
|
184
|
+
cached_statut_diffusion,
|
|
185
|
+
cached_tranche_effectifs_unite_legale,
|
|
186
|
+
cached_tranche_effectifs,
|
|
187
|
+
siret,
|
|
188
|
+
} satisfies Omit<
|
|
189
|
+
Organization,
|
|
190
|
+
"created_at" | "id" | "updated_at" | "organization_info_fetched_at"
|
|
191
|
+
>;
|
|
192
|
+
}
|
|
@@ -31,7 +31,7 @@ suite("findByEmailFactory", () => {
|
|
|
31
31
|
email: "lion.eljonson@darkangels.world",
|
|
32
32
|
email_verified: false,
|
|
33
33
|
email_verified_at: null,
|
|
34
|
-
encrypted_password:
|
|
34
|
+
encrypted_password: null,
|
|
35
35
|
encrypted_totp_key: null,
|
|
36
36
|
family_name: "el'jonson",
|
|
37
37
|
force_2fa: false,
|
|
@@ -33,7 +33,7 @@ suite("findByIdFactory", () => {
|
|
|
33
33
|
email: "lion.eljonson@darkangels.world",
|
|
34
34
|
email_verified: false,
|
|
35
35
|
email_verified_at: null,
|
|
36
|
-
encrypted_password:
|
|
36
|
+
encrypted_password: null,
|
|
37
37
|
encrypted_totp_key: null,
|
|
38
38
|
family_name: "el'jonson",
|
|
39
39
|
force_2fa: false,
|
|
@@ -34,7 +34,7 @@ suite("getByIdFactory", () => {
|
|
|
34
34
|
email: "lion.eljonson@darkangels.world",
|
|
35
35
|
email_verified: false,
|
|
36
36
|
email_verified_at: null,
|
|
37
|
-
encrypted_password:
|
|
37
|
+
encrypted_password: null,
|
|
38
38
|
encrypted_totp_key: null,
|
|
39
39
|
family_name: "el'jonson",
|
|
40
40
|
force_2fa: false,
|
|
@@ -37,6 +37,7 @@ describe("getFranceConnectUserInfo", () => {
|
|
|
37
37
|
const user = await getFranceConnectUserInfo(1);
|
|
38
38
|
assert.ok(user);
|
|
39
39
|
assert.deepEqual(user, {
|
|
40
|
+
birthcountry: null,
|
|
40
41
|
birthdate: new Date("8888-08-08"),
|
|
41
42
|
birthplace: "Caliban",
|
|
42
43
|
created_at: new Date("4444-04-04"),
|
|
@@ -41,6 +41,7 @@ describe("upsertFranceconnectUserinfo", () => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
assert.deepEqual(user, {
|
|
44
|
+
birthcountry: null,
|
|
44
45
|
birthdate: new Date("8888-08-08"),
|
|
45
46
|
birthplace: "Caliban",
|
|
46
47
|
created_at: new Date("4444-04-01"),
|
|
@@ -76,6 +77,7 @@ describe("upsertFranceconnectUserinfo", () => {
|
|
|
76
77
|
});
|
|
77
78
|
|
|
78
79
|
assert.deepEqual(user, {
|
|
80
|
+
birthcountry: null,
|
|
79
81
|
birthdate: null,
|
|
80
82
|
birthplace: null,
|
|
81
83
|
created_at: new Date("4444-04-01"),
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { Organization } from "#src/types";
|
|
4
|
+
import {
|
|
5
|
+
association_org_info,
|
|
6
|
+
bpifrance_org_info,
|
|
7
|
+
dinum_org_info,
|
|
8
|
+
entreprise_unipersonnelle_org_info,
|
|
9
|
+
lamalou_org_info,
|
|
10
|
+
onf_org_info,
|
|
11
|
+
trackdechets_public_org_info,
|
|
12
|
+
whitelisted_org_info,
|
|
13
|
+
} from "#testing/seed/organizations";
|
|
14
|
+
import assert from "node:assert/strict";
|
|
15
|
+
import { describe, it } from "node:test";
|
|
16
|
+
import { isPublicService } from "./is-public-service.js";
|
|
17
|
+
|
|
18
|
+
describe("isPublicService", () => {
|
|
19
|
+
it("should return false for bad call", () => {
|
|
20
|
+
assert.equal(isPublicService({} as Organization), false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should return true for collectivite territoriale", () => {
|
|
24
|
+
assert.equal(isPublicService(lamalou_org_info), true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should return true for administration centrale", () => {
|
|
28
|
+
assert.equal(isPublicService(dinum_org_info), true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should return false for unipersonnelle organization", () => {
|
|
32
|
+
assert.equal(isPublicService(entreprise_unipersonnelle_org_info), false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should return false for association", () => {
|
|
36
|
+
assert.equal(isPublicService(association_org_info), false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should return true for établissement public à caractère industriel et commercial", () => {
|
|
40
|
+
assert.equal(isPublicService(onf_org_info), true);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
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);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should return true for public etablissement", () => {
|
|
52
|
+
assert.equal(isPublicService(trackdechets_public_org_info), true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should return false for blacklisted SIREN", () => {
|
|
56
|
+
const blacklisted_org = {
|
|
57
|
+
siret: "34867901000123",
|
|
58
|
+
cached_categorie_juridique: "7120",
|
|
59
|
+
cached_etat_administratif: "A",
|
|
60
|
+
} as Organization;
|
|
61
|
+
assert.equal(isPublicService(blacklisted_org), false);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("should return false for closed entities", () => {
|
|
65
|
+
const closed_org = {
|
|
66
|
+
siret: "12345678900123",
|
|
67
|
+
cached_categorie_juridique: "7120",
|
|
68
|
+
cached_etat_administratif: "C",
|
|
69
|
+
} as Organization;
|
|
70
|
+
assert.equal(isPublicService(closed_org), false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should return true for entities with exact nature juridique codes", () => {
|
|
74
|
+
const exact_nature_org = {
|
|
75
|
+
siret: "12345678900123",
|
|
76
|
+
cached_categorie_juridique: "7111",
|
|
77
|
+
cached_etat_administratif: "A",
|
|
78
|
+
} 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: "13003013300123",
|
|
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);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("should return true for CARSAT BRETAGNE (annuaire-entreprises whitelist)", () => {
|
|
92
|
+
const carsat_bretagne_org = {
|
|
93
|
+
siret: "77774932600123",
|
|
94
|
+
cached_categorie_juridique: "8110", // Régime général de la Sécurité Sociale
|
|
95
|
+
cached_etat_administratif: "A",
|
|
96
|
+
} as Organization;
|
|
97
|
+
assert.equal(isPublicService(carsat_bretagne_org), true);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
NATURE_JURIDIQUE_SERVICE_PUBLIC,
|
|
5
|
+
SERVICE_PUBLIC_BLACKLIST,
|
|
6
|
+
SERVICE_PUBLIC_WHITELIST,
|
|
7
|
+
} from "@proconnect-gouv/proconnect.annuaire_entreprises";
|
|
8
|
+
import type { Organization } from "@proconnect-gouv/proconnect.identite/types";
|
|
9
|
+
|
|
10
|
+
// inspired from https://github.com/annuaire-entreprises-data-gouv-fr/search-infra/blob/f1e56ac476b0b1730115f7b1f0667e8509ee5379/workflows/data_pipelines/elasticsearch/data_enrichment.py#L155-L189
|
|
11
|
+
export const isPublicService = ({
|
|
12
|
+
cached_categorie_juridique,
|
|
13
|
+
cached_etat_administratif,
|
|
14
|
+
siret,
|
|
15
|
+
}: Organization): boolean => {
|
|
16
|
+
const siren = (siret || "").substring(0, 9);
|
|
17
|
+
|
|
18
|
+
// Entities in the blacklist are never considered public services
|
|
19
|
+
if (SERVICE_PUBLIC_BLACKLIST.includes(siren)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Closed entities are not considered public services
|
|
24
|
+
if (cached_etat_administratif === "C") {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Check if entity is in whitelist or has a public service legal nature code
|
|
29
|
+
const cat_jur_ok =
|
|
30
|
+
cached_categorie_juridique &&
|
|
31
|
+
NATURE_JURIDIQUE_SERVICE_PUBLIC.includes(cached_categorie_juridique);
|
|
32
|
+
const whitelist_ok = SERVICE_PUBLIC_WHITELIST.includes(siren);
|
|
33
|
+
|
|
34
|
+
return cat_jur_ok || whitelist_ok;
|
|
35
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Organization } from "#src/types";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
|
+
import { isSyndicatCommunal } from "./is-syndicat-communal.js";
|
|
5
|
+
|
|
6
|
+
describe("isSyndicatCommunal", () => {
|
|
7
|
+
it("should return false when cached_libelle_categorie_juridique is undefined", () => {
|
|
8
|
+
const org = {} as Organization;
|
|
9
|
+
assert.equal(isSyndicatCommunal(org), false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should return false when cached_libelle_categorie_juridique is null", () => {
|
|
13
|
+
const org = { cached_activite_principale: null } as Organization;
|
|
14
|
+
assert.equal(isSyndicatCommunal(org), false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should return false for a categorie juridique not in the list", () => {
|
|
18
|
+
const org = {
|
|
19
|
+
cached_libelle_categorie_juridique:
|
|
20
|
+
"cette catégorie juridique n'existe pas",
|
|
21
|
+
} as Organization;
|
|
22
|
+
assert.equal(isSyndicatCommunal(org), false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should return true for categorie juridique 'Syndicat mixte fermé' ", () => {
|
|
26
|
+
const org = {
|
|
27
|
+
cached_libelle_categorie_juridique: "Syndicat mixte fermé",
|
|
28
|
+
} as Organization;
|
|
29
|
+
assert.equal(isSyndicatCommunal(org), true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Organization } from "#src/types";
|
|
2
|
+
|
|
3
|
+
const cat_jur = [
|
|
4
|
+
"Centre communal d'action sociale",
|
|
5
|
+
"Établissement public local social et médico-social",
|
|
6
|
+
"Syndicat intercommunal à vocation multiple (SIVOM)",
|
|
7
|
+
"Syndicat intercommunal à vocation unique (SIVU)",
|
|
8
|
+
"Syndicat mixte fermé",
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export const isSyndicatCommunal = ({
|
|
12
|
+
cached_libelle_categorie_juridique,
|
|
13
|
+
}: Pick<Organization, "cached_libelle_categorie_juridique">): boolean => {
|
|
14
|
+
if (!cached_libelle_categorie_juridique) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return cat_jur.includes(cached_libelle_categorie_juridique);
|
|
18
|
+
};
|
package/src/types/dirigeant.ts
CHANGED
|
@@ -5,9 +5,12 @@ import { z } from "zod";
|
|
|
5
5
|
//
|
|
6
6
|
|
|
7
7
|
export const IdentityVectorSchema = z.object({
|
|
8
|
+
birthcountry: z.string().nullable(),
|
|
8
9
|
birthdate: z.date().nullable(),
|
|
9
10
|
birthplace: z.string().nullable(),
|
|
10
11
|
family_name: z.string().nullable(),
|
|
12
|
+
gender: z.enum(["male", "female"]).nullable(),
|
|
11
13
|
given_name: z.string().nullable(),
|
|
12
14
|
});
|
|
15
|
+
|
|
13
16
|
export type IdentityVector = z.output<typeof IdentityVectorSchema>;
|
|
@@ -8,6 +8,7 @@ import { z } from "zod";
|
|
|
8
8
|
* @see https://docs.partenaires.franceconnect.gouv.fr/fs/fs-technique/fs-technique-scope-fc/#liste-des-claims
|
|
9
9
|
*/
|
|
10
10
|
export const FranceConnectUserInfoResponseSchema = z.object({
|
|
11
|
+
birthcountry: z.string(),
|
|
11
12
|
birthdate: z.coerce.date(),
|
|
12
13
|
birthplace: z.string(),
|
|
13
14
|
family_name: z.string(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
import type { TrancheEffectifs } from "@proconnect-gouv/proconnect.
|
|
3
|
+
import type { TrancheEffectifs } from "@proconnect-gouv/proconnect.api_entreprise/types";
|
|
4
4
|
|
|
5
5
|
//
|
|
6
6
|
|
|
@@ -16,9 +16,9 @@ export interface Organization {
|
|
|
16
16
|
cached_tranche_effectifs_unite_legale: string | null;
|
|
17
17
|
cached_libelle_tranche_effectif: string | null;
|
|
18
18
|
cached_etat_administratif: string | null;
|
|
19
|
-
cached_est_active:
|
|
19
|
+
cached_est_active: boolean | null;
|
|
20
20
|
cached_statut_diffusion: string | null;
|
|
21
|
-
cached_est_diffusible:
|
|
21
|
+
cached_est_diffusible: boolean | null;
|
|
22
22
|
cached_adresse: string | null;
|
|
23
23
|
cached_code_postal: string | null;
|
|
24
24
|
cached_code_officiel_geographique: string | null;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import type { FranceConnectUserInfo } from "#src/types";
|
|
2
2
|
|
|
3
3
|
export const LiElJonsonFranceConnectUserInfo: FranceConnectUserInfo = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
birthcountry: "99100",
|
|
5
|
+
birthdate: new Date(Date.UTC(28500, 1, 5)),
|
|
6
|
+
birthplace: "75056",
|
|
6
7
|
created_at: new Date("4444-04-04"),
|
|
7
|
-
family_name: "
|
|
8
|
+
family_name: "EL'JONSON",
|
|
8
9
|
gender: "male",
|
|
9
|
-
given_name: "
|
|
10
|
-
preferred_username: "
|
|
10
|
+
given_name: "LION",
|
|
11
|
+
preferred_username: "Lion",
|
|
11
12
|
sub: "abcdefghijklmnopqrstuvwxyz",
|
|
12
13
|
updated_at: new Date("4444-04-05"),
|
|
13
14
|
user_id: NaN,
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export const BelisariusCawlFranceConnectUserInfo: FranceConnectUserInfo = {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
birthcountry: "99100",
|
|
19
|
+
birthdate: new Date(Date.UTC(28500, 1, 5)),
|
|
20
|
+
birthplace: "13055",
|
|
19
21
|
created_at: new Date("2023-04-10"),
|
|
20
22
|
family_name: "CAWL",
|
|
21
23
|
gender: "male",
|
|
@@ -27,8 +29,9 @@ export const BelisariusCawlFranceConnectUserInfo: FranceConnectUserInfo = {
|
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export const RogalDornFranceConnectUserInfo: FranceConnectUserInfo = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
birthcountry: "99102",
|
|
33
|
+
birthdate: new Date(Date.UTC(29000, 0, 7)),
|
|
34
|
+
birthplace: "",
|
|
32
35
|
created_at: new Date("2023-04-10"),
|
|
33
36
|
family_name: "DORN",
|
|
34
37
|
gender: "male",
|
|
@@ -39,3 +39,111 @@ export const entreprise_unipersonnelle_org_info = {
|
|
|
39
39
|
cached_categorie_juridique: "1000",
|
|
40
40
|
cached_libelle_categorie_juridique: "Entrepreneur individuel",
|
|
41
41
|
} as Organization;
|
|
42
|
+
|
|
43
|
+
export const lamalou_org_info = {
|
|
44
|
+
siret: "21340126800130",
|
|
45
|
+
cached_tranche_effectifs: "12",
|
|
46
|
+
cached_tranche_effectifs_unite_legale: "21",
|
|
47
|
+
cached_libelle_tranche_effectif: "20 à 49 salariés, en 2020",
|
|
48
|
+
cached_activite_principale: "84.11Z",
|
|
49
|
+
cached_libelle_activite_principale:
|
|
50
|
+
"84.11Z - Administration publique générale",
|
|
51
|
+
cached_categorie_juridique: "7210",
|
|
52
|
+
cached_libelle_categorie_juridique: "Commune et commune nouvelle",
|
|
53
|
+
} as Organization;
|
|
54
|
+
|
|
55
|
+
export const dinum_org_info = {
|
|
56
|
+
siret: "13002526500013",
|
|
57
|
+
cached_tranche_effectifs: "22",
|
|
58
|
+
cached_tranche_effectifs_unite_legale: "22",
|
|
59
|
+
cached_libelle_tranche_effectif: "100 à 199 salariés, en 2020",
|
|
60
|
+
cached_activite_principale: "84.11Z",
|
|
61
|
+
cached_libelle_activite_principale:
|
|
62
|
+
"84.11Z - Administration publique générale",
|
|
63
|
+
cached_categorie_juridique: "7120",
|
|
64
|
+
cached_libelle_categorie_juridique: "Service central d'un ministère",
|
|
65
|
+
} as Organization;
|
|
66
|
+
|
|
67
|
+
export const onf_org_info = {
|
|
68
|
+
siret: "66204311604119",
|
|
69
|
+
cached_tranche_effectifs: null,
|
|
70
|
+
cached_tranche_effectifs_unite_legale: "52",
|
|
71
|
+
cached_libelle_tranche_effectif: null,
|
|
72
|
+
cached_activite_principale: "02.40Z",
|
|
73
|
+
cached_libelle_activite_principale:
|
|
74
|
+
"02.40Z - Services de soutien à l'exploitation forestière",
|
|
75
|
+
cached_categorie_juridique: "4110",
|
|
76
|
+
cached_libelle_categorie_juridique:
|
|
77
|
+
"Établissement public national à caractère industriel ou commercial doté d'un comptable public",
|
|
78
|
+
} as Organization;
|
|
79
|
+
|
|
80
|
+
export const bpifrance_org_info = {
|
|
81
|
+
siret: "32025248901075",
|
|
82
|
+
cached_tranche_effectifs: "42",
|
|
83
|
+
cached_tranche_effectifs_unite_legale: "51",
|
|
84
|
+
cached_libelle_tranche_effectif: "1 000 à 1 999 salariés, en 2021",
|
|
85
|
+
cached_activite_principale: "64.92Z",
|
|
86
|
+
cached_libelle_activite_principale: "64.92Z - Autre distribution de crédit",
|
|
87
|
+
cached_categorie_juridique: "5599",
|
|
88
|
+
cached_libelle_categorie_juridique: "SA à conseil d'administration (s.a.i.)",
|
|
89
|
+
} as Organization;
|
|
90
|
+
|
|
91
|
+
export const whitelisted_org_info = {
|
|
92
|
+
siret: "18000001000017",
|
|
93
|
+
cached_tranche_effectifs: "22",
|
|
94
|
+
cached_tranche_effectifs_unite_legale: "32",
|
|
95
|
+
cached_libelle_tranche_effectif: "100 à 199 salariés, en 2022",
|
|
96
|
+
cached_activite_principale: "84.11Z",
|
|
97
|
+
cached_libelle_activite_principale:
|
|
98
|
+
"84.11Z - Administration publique générale",
|
|
99
|
+
cached_categorie_juridique: "7490",
|
|
100
|
+
cached_libelle_categorie_juridique:
|
|
101
|
+
"Autre personne morale de droit administratif",
|
|
102
|
+
} as Organization;
|
|
103
|
+
|
|
104
|
+
export const trackdechets_public_org_info = {
|
|
105
|
+
siret: "25680169700010",
|
|
106
|
+
cached_tranche_effectifs: "NN",
|
|
107
|
+
cached_tranche_effectifs_unite_legale: "NN",
|
|
108
|
+
cached_libelle_tranche_effectif:
|
|
109
|
+
"Unité non employeuse (pas de salarié au cours de l'année de référence et pas d'effectif au 31/12)",
|
|
110
|
+
cached_activite_principale: "38.21Z",
|
|
111
|
+
cached_libelle_activite_principale:
|
|
112
|
+
"38.21Z - Traitement et élimination des déchets non dangereux",
|
|
113
|
+
cached_categorie_juridique: "7354",
|
|
114
|
+
cached_libelle_categorie_juridique: "Syndicat mixte fermé",
|
|
115
|
+
} as Organization;
|
|
116
|
+
|
|
117
|
+
export const rogal_dorn_org_info = {
|
|
118
|
+
siret: "94957325700019",
|
|
119
|
+
cached_tranche_effectifs: null,
|
|
120
|
+
cached_tranche_effectifs_unite_legale: null,
|
|
121
|
+
cached_libelle_tranche_effectif: "",
|
|
122
|
+
cached_activite_principale: "62.02A",
|
|
123
|
+
cached_libelle_activite_principale:
|
|
124
|
+
"62.02A - Conseil en systèmes et logiciels informatiques",
|
|
125
|
+
cached_categorie_juridique: "1000",
|
|
126
|
+
cached_libelle_categorie_juridique: "Entrepreneur individuel",
|
|
127
|
+
} as Organization;
|
|
128
|
+
|
|
129
|
+
export const papillon_org_info = {
|
|
130
|
+
cached_activite_principale: "47.59A",
|
|
131
|
+
cached_adresse:
|
|
132
|
+
"5-7, 5 rue du moulin aux moines, 72650 La chapelle-saint-aubin",
|
|
133
|
+
cached_categorie_juridique: "5710",
|
|
134
|
+
cached_code_officiel_geographique: "72065",
|
|
135
|
+
cached_code_postal: "72650",
|
|
136
|
+
cached_enseigne: "",
|
|
137
|
+
cached_est_active: true,
|
|
138
|
+
cached_est_diffusible: true,
|
|
139
|
+
cached_etat_administratif: "A",
|
|
140
|
+
cached_libelle_activite_principale: "47.59A - Commerce de détail de meubles",
|
|
141
|
+
cached_libelle_categorie_juridique: "SAS, société par actions simplifiée",
|
|
142
|
+
cached_libelle_tranche_effectif: "3 à 5 salariés, en 2022",
|
|
143
|
+
cached_libelle: "Papillon",
|
|
144
|
+
cached_nom_complet: "Papillon",
|
|
145
|
+
cached_statut_diffusion: "diffusible",
|
|
146
|
+
cached_tranche_effectifs_unite_legale: "11",
|
|
147
|
+
cached_tranche_effectifs: "02",
|
|
148
|
+
siret: "39234600300198",
|
|
149
|
+
} as Organization;
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"baseUrl": "./src",
|
|
4
3
|
"declaration": true,
|
|
5
4
|
"declarationMap": true,
|
|
6
5
|
"outDir": "./dist",
|
|
7
6
|
"resolveJsonModule": true,
|
|
8
|
-
"types": ["node"]
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"paths": {
|
|
9
|
+
"#src/*": ["./src/*/index.ts"],
|
|
10
|
+
"#testing/*": ["./testing/*/index.ts"]
|
|
11
|
+
}
|
|
9
12
|
},
|
|
10
13
|
"extends": "@proconnect-gouv/proconnect.devtools.typescript/base/tsconfig.json",
|
|
11
14
|
"references": [
|
|
15
|
+
{ "path": "../annuaire_entreprises/tsconfig.lib.json" },
|
|
12
16
|
{ "path": "../core/tsconfig.lib.json" },
|
|
13
17
|
{ "path": "../entreprise/tsconfig.lib.json" },
|
|
14
18
|
{ "path": "../insee/tsconfig.lib.json" }
|