@proconnect-gouv/proconnect.identite 1.1.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.
Files changed (119) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/data/certification/commune-code-conversion.d.ts +13 -0
  3. package/dist/data/certification/commune-code-conversion.d.ts.map +1 -0
  4. package/dist/data/certification/commune-code-conversion.js +5188 -0
  5. package/dist/data/certification/country-iso-to-cog.d.ts +12 -0
  6. package/dist/data/certification/country-iso-to-cog.d.ts.map +1 -0
  7. package/dist/data/certification/country-iso-to-cog.js +438 -0
  8. package/dist/data/certification/index.d.ts +3 -0
  9. package/dist/data/certification/index.d.ts.map +1 -0
  10. package/dist/data/certification/index.js +3 -0
  11. package/dist/{mappers/certification/index.d.ts → managers/certification/adapters/api_entreprise.d.ts} +2 -2
  12. package/dist/managers/certification/adapters/api_entreprise.d.ts.map +1 -0
  13. package/dist/managers/certification/adapters/api_entreprise.js +14 -0
  14. package/dist/managers/certification/adapters/franceconnect.d.ts +3 -0
  15. package/dist/managers/certification/adapters/franceconnect.d.ts.map +1 -0
  16. package/dist/managers/certification/adapters/franceconnect.js +15 -0
  17. package/dist/managers/certification/adapters/insee.d.ts +4 -0
  18. package/dist/managers/certification/adapters/insee.d.ts.map +1 -0
  19. package/dist/managers/certification/adapters/insee.js +29 -0
  20. package/dist/managers/certification/adapters/rne.d.ts +4 -0
  21. package/dist/managers/certification/adapters/rne.d.ts.map +1 -0
  22. package/dist/managers/certification/adapters/rne.js +45 -0
  23. package/dist/managers/certification/birthplace-conversion.d.ts +27 -0
  24. package/dist/managers/certification/birthplace-conversion.d.ts.map +1 -0
  25. package/dist/managers/certification/birthplace-conversion.js +45 -0
  26. package/dist/managers/certification/certification-score.d.ts +22 -0
  27. package/dist/managers/certification/certification-score.d.ts.map +1 -0
  28. package/dist/managers/certification/certification-score.js +72 -0
  29. package/dist/managers/certification/index.d.ts +1 -1
  30. package/dist/managers/certification/index.d.ts.map +1 -1
  31. package/dist/managers/certification/index.js +1 -1
  32. package/dist/managers/certification/is-organization-dirigeant.d.ts +38 -8
  33. package/dist/managers/certification/is-organization-dirigeant.d.ts.map +1 -1
  34. package/dist/managers/certification/is-organization-dirigeant.js +89 -52
  35. package/dist/managers/certification/normalize.d.ts +21 -0
  36. package/dist/managers/certification/normalize.d.ts.map +1 -0
  37. package/dist/managers/certification/normalize.js +64 -0
  38. package/dist/managers/franceconnect/openid-client.d.ts +1 -0
  39. package/dist/managers/franceconnect/openid-client.d.ts.map +1 -1
  40. package/dist/managers/organization/adapters/api_entreprise.d.ts +25 -0
  41. package/dist/managers/organization/adapters/api_entreprise.d.ts.map +1 -0
  42. package/dist/{mappers/organization/from-siret.js → managers/organization/adapters/api_entreprise.js} +25 -2
  43. package/dist/managers/organization/get-organization-info.d.ts.map +1 -1
  44. package/dist/managers/organization/get-organization-info.js +3 -3
  45. package/dist/repositories/organization/upsert.d.ts +1 -1
  46. package/dist/repositories/organization/upsert.d.ts.map +1 -1
  47. package/dist/repositories/organization/upsert.js +26 -1
  48. package/dist/repositories/user/get-franceconnect-user-info.d.ts +1 -0
  49. package/dist/repositories/user/get-franceconnect-user-info.d.ts.map +1 -1
  50. package/dist/repositories/user/upsert-franceconnect-userinfo.d.ts +1 -0
  51. package/dist/repositories/user/upsert-franceconnect-userinfo.d.ts.map +1 -1
  52. package/dist/services/organization/is-syndicat-communal.d.ts.map +1 -1
  53. package/dist/services/organization/is-syndicat-communal.js +2 -0
  54. package/dist/types/dirigeant.d.ts +5 -0
  55. package/dist/types/dirigeant.d.ts.map +1 -1
  56. package/dist/types/dirigeant.js +2 -0
  57. package/dist/types/franceconnect.d.ts +2 -0
  58. package/dist/types/franceconnect.d.ts.map +1 -1
  59. package/dist/types/franceconnect.js +1 -0
  60. package/dist/types/organization.d.ts +2 -2
  61. package/dist/types/organization.d.ts.map +1 -1
  62. package/package.json +6 -6
  63. package/src/data/certification/commune-code-conversion.ts +5189 -0
  64. package/src/data/certification/country-iso-to-cog.ts +439 -0
  65. package/src/data/certification/index.ts +4 -0
  66. package/src/managers/certification/adapters/api_entreprise.test.ts +68 -0
  67. package/src/managers/certification/adapters/api_entreprise.test.ts.snapshot +109 -0
  68. package/src/{mappers/certification/index.ts → managers/certification/adapters/api_entreprise.ts} +7 -4
  69. package/src/managers/certification/adapters/franceconnect.ts +21 -0
  70. package/src/managers/certification/adapters/insee.test.ts +18 -0
  71. package/src/managers/certification/adapters/insee.test.ts.snapshot +21 -0
  72. package/src/managers/certification/adapters/insee.ts +39 -0
  73. package/src/managers/certification/adapters/rne.test.ts +276 -0
  74. package/src/managers/certification/adapters/rne.ts +64 -0
  75. package/src/managers/certification/birthplace-conversion.test.ts +76 -0
  76. package/src/managers/certification/birthplace-conversion.ts +58 -0
  77. package/src/managers/certification/certification-score.test.ts +309 -0
  78. package/src/managers/certification/certification-score.ts +97 -0
  79. package/src/managers/certification/index.ts +1 -1
  80. package/src/managers/certification/is-organization-dirigeant.test.ts +139 -48
  81. package/src/managers/certification/is-organization-dirigeant.ts +132 -106
  82. package/src/managers/certification/normalize.test.ts +71 -0
  83. package/src/managers/certification/normalize.ts +72 -0
  84. package/src/managers/organization/adapters/api_entreprise.test.ts +31 -0
  85. package/src/{mappers/organization/from-siret.test.ts.snapshot → managers/organization/adapters/api_entreprise.test.ts.snapshot} +26 -3
  86. package/src/{mappers/organization/from-siret.ts → managers/organization/adapters/api_entreprise.ts} +53 -3
  87. package/src/managers/organization/get-organization-info.test.ts +1 -1
  88. package/src/managers/organization/get-organization-info.ts +3 -3
  89. package/src/repositories/organization/upsert.ts +69 -19
  90. package/src/repositories/user/get-franceconnect-user-info.test.ts +1 -0
  91. package/src/repositories/user/upsert-franceconnect-userinfo.test.ts +2 -0
  92. package/src/services/organization/is-syndicat-communal.ts +2 -0
  93. package/src/types/dirigeant.ts +3 -0
  94. package/src/types/franceconnect.ts +1 -0
  95. package/src/types/organization.ts +2 -2
  96. package/testing/seed/franceconnect/index.ts +12 -9
  97. package/testing/seed/organizations/index.ts +34 -0
  98. package/tsconfig.json +5 -2
  99. package/tsconfig.lib.tsbuildinfo +1 -1
  100. package/dist/managers/certification/distance.d.ts +0 -4
  101. package/dist/managers/certification/distance.d.ts.map +0 -1
  102. package/dist/managers/certification/distance.js +0 -16
  103. package/dist/mappers/certification/index.d.ts.map +0 -1
  104. package/dist/mappers/certification/index.js +0 -11
  105. package/dist/mappers/index.d.ts +0 -2
  106. package/dist/mappers/index.d.ts.map +0 -1
  107. package/dist/mappers/index.js +0 -2
  108. package/dist/mappers/organization/from-siret.d.ts +0 -5
  109. package/dist/mappers/organization/from-siret.d.ts.map +0 -1
  110. package/dist/mappers/organization/index.d.ts +0 -2
  111. package/dist/mappers/organization/index.d.ts.map +0 -1
  112. package/dist/mappers/organization/index.js +0 -2
  113. package/src/managers/certification/distance.test.ts +0 -109
  114. package/src/managers/certification/distance.ts +0 -41
  115. package/src/mappers/index.ts +0 -3
  116. package/src/mappers/organization/from-siret.test.ts +0 -26
  117. package/src/mappers/organization/index.ts +0 -3
  118. package/testing/seed/insee/index.ts +0 -22
  119. package/testing/seed/mandataires/index.ts +0 -32
@@ -0,0 +1,439 @@
1
+ //
2
+
3
+ /**
4
+ * Country code conversion table from ISO 3166 (2 or 3-letter) to COG format (5-digit).
5
+ *
6
+ * Maps: ISO 3166 code → COG code (99XXX format)
7
+ *
8
+ * Example: IRL → 99136 (Ireland)
9
+ *
10
+ * This table should be updated annually from:
11
+ * https://www.insee.fr/fr/information/2560452
12
+ */
13
+ export const COUNTRY_ISO_TO_COG: Record<string, string> = {
14
+ FRA: "99100", // France,
15
+ DNK: "99101", // Danemark,
16
+ ISL: "99102", // Islande,
17
+ NOR: "99103", // Norvège,
18
+ SWE: "99104", // Suède,
19
+ FIN: "99105", // Finlande,
20
+ EST: "99106", // Estonie,
21
+ LVA: "99107", // Lettonie,
22
+ LTU: "99108", // Lituanie,
23
+ DEU: "99109", // Allemagne,
24
+ AUT: "99110", // Autriche,
25
+ BGR: "99111", // Bulgarie,
26
+ HUN: "99112", // Hongrie,
27
+ LIE: "99113", // Liechtenstein,
28
+ ROU: "99114", // Roumanie,
29
+ CZE: "99116", // Tchéquie,
30
+ SVK: "99117", // Slovaquie,
31
+ BIH: "99118", // Bosnie-Herzégovine,
32
+ HRV: "99119", // Croatie,
33
+ MNE: "99120", // Monténégro,
34
+ SRB: "99121", // Serbie,
35
+ POL: "99122", // Pologne,
36
+ RUS: "99123", // Russie,
37
+ ALB: "99125", // Albanie,
38
+ GRC: "99126", // Grèce,
39
+ ITA: "99127", // Italie,
40
+ SMR: "99128", // Saint-Marin,
41
+ VAT: "99129", // Vatican,
42
+ AND: "99130", // Andorre,
43
+ BEL: "99131", // Belgique,
44
+ GBR: "99132", // Royaume-Uni,
45
+ GIB: "99133", // Territoires britanniques en Méditerranée,
46
+ ESP: "99134", // Espagne,
47
+ NLD: "99135", // Pays-Bas,
48
+ IRL: "99136", // Irlande,
49
+ LUX: "99137", // Luxembourg,
50
+ MCO: "99138", // Monaco,
51
+ PRT: "99139", // Portugal,
52
+ CHE: "99140", // Suisse,
53
+ MLT: "99144", // Malte,
54
+ SVN: "99145", // Slovénie,
55
+ BLR: "99148", // Biélorussie,
56
+ MDA: "99151", // Moldavie,
57
+ UKR: "99155", // Ukraine,
58
+ MKD: "99156", // Macédoine du Nord,
59
+ FRO: "99158", // Féroé,
60
+ ALA: "99160", // Åland,
61
+ SAU: "99201", // Arabie saoudite,
62
+ IRQ: "99203", // Irak,
63
+ IRN: "99204", // Iran,
64
+ LBN: "99205", // Liban,
65
+ SYR: "99206", // Syrie,
66
+ ISR: "99207", // Israël,
67
+ TUR: "99208", // Turquie,
68
+ AFG: "99212", // Afghanistan,
69
+ PAK: "99213", // Pakistan,
70
+ BTN: "99214", // Bhoutan,
71
+ NPL: "99215", // Népal,
72
+ CHN: "99216", // Chine,
73
+ JPN: "99217", // Japon,
74
+ THA: "99219", // Thaïlande,
75
+ PHL: "99220", // Philippines,
76
+ JOR: "99222", // Jordanie,
77
+ IND: "99223", // Inde,
78
+ MMR: "99224", // Birmanie,
79
+ BRN: "99225", // Brunei,
80
+ SGP: "99226", // Singapour,
81
+ MYS: "99227", // Malaisie,
82
+ MDV: "99229", // Maldives,
83
+ HKG: "99230", // Hong Kong,
84
+ IDN: "99231", // Indonésie,
85
+ MAC: "99232", // Macao,
86
+ KHM: "99234", // Cambodge,
87
+ LKA: "99235", // Sri Lanka,
88
+ TWN: "99236", // Taïwan,
89
+ PRK: "99238", // Corée du Nord,
90
+ KOR: "99239", // Corée du Sud,
91
+ KWT: "99240", // Koweït,
92
+ LAO: "99241", // Laos,
93
+ MNG: "99242", // Mongolie,
94
+ VNM: "99243", // Vietnam,
95
+ BGD: "99246", // Bangladesh,
96
+ ARE: "99247", // Émirats arabes unis,
97
+ QAT: "99248", // Qatar,
98
+ BHR: "99249", // Bahreïn,
99
+ OMN: "99250", // Oman,
100
+ YEM: "99251", // Yémen,
101
+ ARM: "99252", // Arménie,
102
+ AZE: "99253", // Azerbaïdjan,
103
+ CYP: "99254", // Chypre,
104
+ GEO: "99255", // Géorgie,
105
+ KAZ: "99256", // Kazakhstan,
106
+ KGZ: "99257", // Kirghizstan,
107
+ UZB: "99258", // Ouzbékistan,
108
+ TJK: "99259", // Tadjikistan,
109
+ TKM: "99260", // Turkménistan,
110
+ PSE: "99261", // Palestine,
111
+ TLS: "99262", // Timor oriental,
112
+ EGY: "99301", // Égypte,
113
+ LBR: "99302", // Libéria,
114
+ ZAF: "99303", // Afrique du Sud,
115
+ GMB: "99304", // Gambie,
116
+ SHN: "99306", // Territoires britanniques de l’océan Atlantique,
117
+ IOT: "99308", // Territoire britannique de l’océan Indien,
118
+ TZA: "99309", // Tanzanie,
119
+ ZWE: "99310", // Zimbabwe,
120
+ NAM: "99311", // Namibie,
121
+ COD: "99312", // République démocratique du Congo,
122
+ GNQ: "99314", // Guinée équatoriale,
123
+ ETH: "99315", // Éthiopie,
124
+ LBY: "99316", // Libye,
125
+ ERI: "99317", // Érythrée,
126
+ SOM: "99318", // Somalie,
127
+ BDI: "99321", // Burundi,
128
+ CMR: "99322", // Cameroun,
129
+ CAF: "99323", // Centrafrique,
130
+ COG: "99324", // Congo,
131
+ CIV: "99326", // Côte d’Ivoire,
132
+ BEN: "99327", // Bénin,
133
+ GAB: "99328", // Gabon,
134
+ GHA: "99329", // Ghana,
135
+ GIN: "99330", // Guinée,
136
+ BFA: "99331", // Burkina,
137
+ KEN: "99332", // Kenya,
138
+ MDG: "99333", // Madagascar,
139
+ MWI: "99334", // Malawi,
140
+ MLI: "99335", // Mali,
141
+ MRT: "99336", // Mauritanie,
142
+ NER: "99337", // Niger,
143
+ NGA: "99338", // Nigéria,
144
+ UGA: "99339", // Ouganda,
145
+ RWA: "99340", // Rwanda,
146
+ SEN: "99341", // Sénégal,
147
+ SLE: "99342", // Sierra Leone,
148
+ SDN: "99343", // Soudan,
149
+ TCD: "99344", // Tchad,
150
+ TGO: "99345", // Togo,
151
+ ZMB: "99346", // Zambie,
152
+ BWA: "99347", // Botswana,
153
+ LSO: "99348", // Lesotho,
154
+ SSD: "99349", // Soudan du Sud,
155
+ MAR: "99350", // Maroc,
156
+ TUN: "99351", // Tunisie,
157
+ DZA: "99352", // Algérie,
158
+ ESH: "99389", // Sahara occidental,
159
+ MUS: "99390", // Maurice,
160
+ SWZ: "99391", // Swaziland,
161
+ GNB: "99392", // Guinée-Bissao,
162
+ MOZ: "99393", // Mozambique,
163
+ STP: "99394", // Sao Tomé-et-Principe,
164
+ AGO: "99395", // Angola,
165
+ CPV: "99396", // Cap-Vert,
166
+ COM: "99397", // Comores,
167
+ SYC: "99398", // Seychelles,
168
+ DJI: "99399", // Djibouti,
169
+ CAN: "99401", // Canada,
170
+ USA: "99404", // États-Unis,
171
+ MEX: "99405", // Mexique,
172
+ CRI: "99406", // Costa Rica,
173
+ CUB: "99407", // Cuba,
174
+ DOM: "99408", // République dominicaine,
175
+ GTM: "99409", // Guatémala,
176
+ HTI: "99410", // Haïti,
177
+ HND: "99411", // Honduras,
178
+ NIC: "99412", // Nicaragua,
179
+ PAN: "99413", // Panama,
180
+ SLV: "99414", // Salvador,
181
+ ARG: "99415", // Argentine,
182
+ BRA: "99416", // Brésil,
183
+ CHL: "99417", // Chili,
184
+ BOL: "99418", // Bolivie,
185
+ COL: "99419", // Colombie,
186
+ ECU: "99420", // Équateur,
187
+ PRY: "99421", // Paraguay,
188
+ PER: "99422", // Pérou,
189
+ URY: "99423", // Uruguay,
190
+ VEN: "99424", // Vénézuéla,
191
+ JAM: "99426", // Jamaïque,
192
+ GUY: "99428", // Guyana,
193
+ BLZ: "99429", // Bélize,
194
+ GRL: "99430", // Groenland,
195
+ ABW: "99431", // Aruba,
196
+ TTO: "99433", // Trinité-et-Tobago,
197
+ BRB: "99434", // Barbade,
198
+ GRD: "99435", // Grenade,
199
+ BHS: "99436", // Bahamas,
200
+ SUR: "99437", // Suriname,
201
+ DMA: "99438", // Dominique,
202
+ LCA: "99439", // Sainte-Lucie,
203
+ VCT: "99440", // Saint-Vincent-et-les-Grenadines,
204
+ ATG: "99441", // Antigua-et-Barbuda,
205
+ KNA: "99442", // Saint-Christophe-et-Niévès,
206
+ BES: "99443", // Bonaire, Saint-Eustache, Saba,
207
+ CUW: "99444", // Curaçao,
208
+ SXM: "99445", // Saint-Martin (partie néerlandaise),
209
+ AUS: "99501", // Australie,
210
+ NZL: "99502", // Nouvelle-Zélande,
211
+ PCN: "99503", // Pitcairn,
212
+ WSM: "99506", // Samoa,
213
+ NRU: "99507", // Nauru,
214
+ FJI: "99508", // Fidji,
215
+ TON: "99509", // Tonga,
216
+ PNG: "99510", // Papouasie-Nouvelle-Guinée,
217
+ TUV: "99511", // Tuvalu,
218
+ SLB: "99512", // Salomon,
219
+ KIR: "99513", // Kiribati,
220
+ VUT: "99514", // Vanuatu,
221
+ MHL: "99515", // Marshall,
222
+ FSM: "99516", // Micronésie,
223
+ PLW: "99517", // Palaos,
224
+ COK: "99520", // Cook,
225
+ NIU: "99521", // Niue,
226
+ ATA: "99699", // Antarctique
227
+ FR: "99100", // France,
228
+ DK: "99101", // Danemark,
229
+ IS: "99102", // Islande,
230
+ NO: "99103", // Norvège,
231
+ SE: "99104", // Suède,
232
+ FI: "99105", // Finlande,
233
+ EE: "99106", // Estonie,
234
+ LV: "99107", // Lettonie,
235
+ LT: "99108", // Lituanie,
236
+ DE: "99109", // Allemagne,
237
+ AT: "99110", // Autriche,
238
+ BG: "99111", // Bulgarie,
239
+ HU: "99112", // Hongrie,
240
+ LI: "99113", // Liechtenstein,
241
+ RO: "99114", // Roumanie,
242
+ CZ: "99116", // Tchéquie,
243
+ SK: "99117", // Slovaquie,
244
+ BA: "99118", // Bosnie-Herzégovine,
245
+ HR: "99119", // Croatie,
246
+ ME: "99120", // Monténégro,
247
+ RS: "99121", // Serbie,
248
+ PL: "99122", // Pologne,
249
+ RU: "99123", // Russie,
250
+ AL: "99125", // Albanie,
251
+ GR: "99126", // Grèce,
252
+ IT: "99127", // Italie,
253
+ SM: "99128", // Saint-Marin,
254
+ VA: "99129", // Vatican,
255
+ AD: "99130", // Andorre,
256
+ BE: "99131", // Belgique,
257
+ GB: "99132", // Royaume-Uni,
258
+ GI: "99133", // Territoires britanniques en Méditerranée,
259
+ ES: "99134", // Espagne,
260
+ NL: "99135", // Pays-Bas,
261
+ IE: "99136", // Irlande,
262
+ LU: "99137", // Luxembourg,
263
+ MC: "99138", // Monaco,
264
+ PT: "99139", // Portugal,
265
+ CH: "99140", // Suisse,
266
+ MT: "99144", // Malte,
267
+ SI: "99145", // Slovénie,
268
+ BY: "99148", // Biélorussie,
269
+ MD: "99151", // Moldavie,
270
+ UA: "99155", // Ukraine,
271
+ MK: "99156", // Macédoine du Nord,
272
+ FO: "99158", // Féroé,
273
+ AX: "99160", // Åland,
274
+ SA: "99201", // Arabie saoudite,
275
+ IQ: "99203", // Irak,
276
+ IR: "99204", // Iran,
277
+ LB: "99205", // Liban,
278
+ SY: "99206", // Syrie,
279
+ IL: "99207", // Israël,
280
+ TR: "99208", // Turquie,
281
+ AF: "99212", // Afghanistan,
282
+ PK: "99213", // Pakistan,
283
+ BT: "99214", // Bhoutan,
284
+ NP: "99215", // Népal,
285
+ CN: "99216", // Chine,
286
+ JP: "99217", // Japon,
287
+ TH: "99219", // Thaïlande,
288
+ PH: "99220", // Philippines,
289
+ JO: "99222", // Jordanie,
290
+ IN: "99223", // Inde,
291
+ MM: "99224", // Birmanie,
292
+ BN: "99225", // Brunei,
293
+ SG: "99226", // Singapour,
294
+ MY: "99227", // Malaisie,
295
+ MV: "99229", // Maldives,
296
+ HK: "99230", // Hong Kong,
297
+ ID: "99231", // Indonésie,
298
+ MO: "99232", // Macao,
299
+ KH: "99234", // Cambodge,
300
+ LK: "99235", // Sri Lanka,
301
+ TW: "99236", // Taïwan,
302
+ KP: "99238", // Corée du Nord,
303
+ KR: "99239", // Corée du Sud,
304
+ KW: "99240", // Koweït,
305
+ LA: "99241", // Laos,
306
+ MN: "99242", // Mongolie,
307
+ VN: "99243", // Vietnam,
308
+ BD: "99246", // Bangladesh,
309
+ AE: "99247", // Émirats arabes unis,
310
+ QA: "99248", // Qatar,
311
+ BH: "99249", // Bahreïn,
312
+ OM: "99250", // Oman,
313
+ YE: "99251", // Yémen,
314
+ AM: "99252", // Arménie,
315
+ AZ: "99253", // Azerbaïdjan,
316
+ CY: "99254", // Chypre,
317
+ GE: "99255", // Géorgie,
318
+ KZ: "99256", // Kazakhstan,
319
+ KG: "99257", // Kirghizstan,
320
+ UZ: "99258", // Ouzbékistan,
321
+ TJ: "99259", // Tadjikistan,
322
+ TM: "99260", // Turkménistan,
323
+ PS: "99261", // Palestine,
324
+ TL: "99262", // Timor oriental,
325
+ EG: "99301", // Égypte,
326
+ LR: "99302", // Libéria,
327
+ ZA: "99303", // Afrique du Sud,
328
+ GM: "99304", // Gambie,
329
+ SH: "99306", // Territoires britanniques de l’océan Atlantique,
330
+ IO: "99308", // Territoire britannique de l’océan Indien,
331
+ TZ: "99309", // Tanzanie,
332
+ ZW: "99310", // Zimbabwe,
333
+ CD: "99312", // République démocratique du Congo,
334
+ GQ: "99314", // Guinée équatoriale,
335
+ ET: "99315", // Éthiopie,
336
+ LY: "99316", // Libye,
337
+ ER: "99317", // Érythrée,
338
+ SO: "99318", // Somalie,
339
+ BI: "99321", // Burundi,
340
+ CM: "99322", // Cameroun,
341
+ CF: "99323", // Centrafrique,
342
+ CG: "99324", // Congo,
343
+ CI: "99326", // Côte d’Ivoire,
344
+ BJ: "99327", // Bénin,
345
+ GA: "99328", // Gabon,
346
+ GH: "99329", // Ghana,
347
+ GN: "99330", // Guinée,
348
+ BF: "99331", // Burkina,
349
+ KE: "99332", // Kenya,
350
+ MG: "99333", // Madagascar,
351
+ MW: "99334", // Malawi,
352
+ ML: "99335", // Mali,
353
+ MR: "99336", // Mauritanie,
354
+ NE: "99337", // Niger,
355
+ NG: "99338", // Nigéria,
356
+ UG: "99339", // Ouganda,
357
+ RW: "99340", // Rwanda,
358
+ SN: "99341", // Sénégal,
359
+ SL: "99342", // Sierra Leone,
360
+ SD: "99343", // Soudan,
361
+ TD: "99344", // Tchad,
362
+ TG: "99345", // Togo,
363
+ ZM: "99346", // Zambie,
364
+ BW: "99347", // Botswana,
365
+ LS: "99348", // Lesotho,
366
+ SS: "99349", // Soudan du Sud,
367
+ MA: "99350", // Maroc,
368
+ TN: "99351", // Tunisie,
369
+ DZ: "99352", // Algérie,
370
+ EH: "99389", // Sahara occidental,
371
+ MU: "99390", // Maurice,
372
+ SZ: "99391", // Swaziland,
373
+ GW: "99392", // Guinée-Bissao,
374
+ MZ: "99393", // Mozambique,
375
+ ST: "99394", // Sao Tomé-et-Principe,
376
+ AO: "99395", // Angola,
377
+ CV: "99396", // Cap-Vert,
378
+ KM: "99397", // Comores,
379
+ SC: "99398", // Seychelles,
380
+ DJ: "99399", // Djibouti,
381
+ CA: "99401", // Canada,
382
+ US: "99404", // États-Unis,
383
+ MX: "99405", // Mexique,
384
+ CR: "99406", // Costa Rica,
385
+ CU: "99407", // Cuba,
386
+ DO: "99408", // République dominicaine,
387
+ GT: "99409", // Guatémala,
388
+ HT: "99410", // Haïti,
389
+ HN: "99411", // Honduras,
390
+ NI: "99412", // Nicaragua,
391
+ PA: "99413", // Panama,
392
+ SV: "99414", // Salvador,
393
+ AR: "99415", // Argentine,
394
+ BR: "99416", // Brésil,
395
+ CL: "99417", // Chili,
396
+ BO: "99418", // Bolivie,
397
+ CO: "99419", // Colombie,
398
+ EC: "99420", // Équateur,
399
+ PY: "99421", // Paraguay,
400
+ PE: "99422", // Pérou,
401
+ UY: "99423", // Uruguay,
402
+ VE: "99424", // Vénézuéla,
403
+ JM: "99426", // Jamaïque,
404
+ GY: "99428", // Guyana,
405
+ BZ: "99429", // Bélize,
406
+ GL: "99430", // Groenland,
407
+ AW: "99431", // Aruba,
408
+ TT: "99433", // Trinité-et-Tobago,
409
+ BB: "99434", // Barbade,
410
+ GD: "99435", // Grenade,
411
+ BS: "99436", // Bahamas,
412
+ SR: "99437", // Suriname,
413
+ DM: "99438", // Dominique,
414
+ LC: "99439", // Sainte-Lucie,
415
+ VC: "99440", // Saint-Vincent-et-les-Grenadines,
416
+ AG: "99441", // Antigua-et-Barbuda,
417
+ KN: "99442", // Saint-Christophe-et-Niévès,
418
+ BQ: "99443", // Bonaire, Saint-Eustache, Saba,
419
+ CW: "99444", // Curaçao,
420
+ SX: "99445", // Saint-Martin (partie néerlandaise),
421
+ AU: "99501", // Australie,
422
+ NZ: "99502", // Nouvelle-Zélande,
423
+ PN: "99503", // Pitcairn,
424
+ WS: "99506", // Samoa,
425
+ NR: "99507", // Nauru,
426
+ FJ: "99508", // Fidji,
427
+ TO: "99509", // Tonga,
428
+ PG: "99510", // Papouasie-Nouvelle-Guinée,
429
+ TV: "99511", // Tuvalu,
430
+ SB: "99512", // Salomon,
431
+ KI: "99513", // Kiribati,
432
+ VU: "99514", // Vanuatu,
433
+ MH: "99515", // Marshall,
434
+ FM: "99516", // Micronésie,
435
+ PW: "99517", // Palaos,
436
+ CK: "99520", // Cook,
437
+ NU: "99521", // Niue,
438
+ AQ: "99699", // Antarctique
439
+ };
@@ -0,0 +1,4 @@
1
+ //
2
+
3
+ export * from "./commune-code-conversion.js";
4
+ export * from "./country-iso-to-cog.js";
@@ -0,0 +1,68 @@
1
+ //
2
+
3
+ import {
4
+ CommissaireComptesMandataire,
5
+ JohnSmithMandataire,
6
+ KarimaAknineMandataire,
7
+ MarieLeblancMandataire,
8
+ PierreDurandMandataire,
9
+ RogalDornMandataire,
10
+ SocietePresidenteMandataire,
11
+ SophieMartinMandataire,
12
+ StevensCheronMandataire,
13
+ UlysseToriMandataire,
14
+ } from "@proconnect-gouv/proconnect.api_entreprise/testing/seed/v3-infogreffe-rcs-unites_legales-siren-mandataires_sociaux";
15
+ import { suite, test } from "node:test";
16
+ import { toIdentityVector } from "./api_entreprise.js";
17
+
18
+ suite("toIdentityVector", () => {
19
+ test("UlysseToriMandataire - French DIRIGEANT", (t) => {
20
+ const identity = toIdentityVector(UlysseToriMandataire);
21
+ t.assert.snapshot(identity);
22
+ });
23
+
24
+ test("StevensCheronMandataire - French DIRIGEANT", (t) => {
25
+ const identity = toIdentityVector(StevensCheronMandataire);
26
+ t.assert.snapshot(identity);
27
+ });
28
+
29
+ test("KarimaAknineMandataire - French DIRIGEANT", (t) => {
30
+ const identity = toIdentityVector(KarimaAknineMandataire);
31
+ t.assert.snapshot(identity);
32
+ });
33
+
34
+ test("MarieLeblancMandataire - French PRESIDENT", (t) => {
35
+ const identity = toIdentityVector(MarieLeblancMandataire);
36
+ t.assert.snapshot(identity);
37
+ });
38
+
39
+ test("JohnSmithMandataire - US COMMISSAIRE", (t) => {
40
+ const identity = toIdentityVector(JohnSmithMandataire);
41
+ t.assert.snapshot(identity);
42
+ });
43
+
44
+ test("PierreDurandMandataire - French DIRECTEUR GENERAL", (t) => {
45
+ const identity = toIdentityVector(PierreDurandMandataire);
46
+ t.assert.snapshot(identity);
47
+ });
48
+
49
+ test("SophieMartinMandataire - French GERANT", (t) => {
50
+ const identity = toIdentityVector(SophieMartinMandataire);
51
+ t.assert.snapshot(identity);
52
+ });
53
+
54
+ test("RogalDornMandataire - Edge case (futuristic)", (t) => {
55
+ const identity = toIdentityVector(RogalDornMandataire);
56
+ t.assert.snapshot(identity);
57
+ });
58
+
59
+ test("SocietePresidenteMandataire - Personne morale PRESIDENT", (t) => {
60
+ const identity = toIdentityVector(SocietePresidenteMandataire);
61
+ t.assert.snapshot(identity);
62
+ });
63
+
64
+ test("CommissaireComptesMandataire - Personne morale COMMISSAIRE", (t) => {
65
+ const identity = toIdentityVector(CommissaireComptesMandataire);
66
+ t.assert.snapshot(identity);
67
+ });
68
+ });
@@ -0,0 +1,109 @@
1
+ exports[`toIdentityVector > CommissaireComptesMandataire - Personne morale COMMISSAIRE 1`] = `
2
+ {
3
+ "birthcountry": null,
4
+ "birthdate": null,
5
+ "birthplace": null,
6
+ "family_name": null,
7
+ "gender": null,
8
+ "given_name": null
9
+ }
10
+ `;
11
+
12
+ exports[`toIdentityVector > JohnSmithMandataire - US COMMISSAIRE 1`] = `
13
+ {
14
+ "birthcountry": "99404",
15
+ "birthdate": "1985-01-01T00:00:00.000Z",
16
+ "birthplace": null,
17
+ "family_name": "SMITH",
18
+ "gender": null,
19
+ "given_name": "John"
20
+ }
21
+ `;
22
+
23
+ exports[`toIdentityVector > KarimaAknineMandataire - French DIRIGEANT 1`] = `
24
+ {
25
+ "birthcountry": "99100",
26
+ "birthdate": "1999-07-15T00:00:00.000Z",
27
+ "birthplace": null,
28
+ "family_name": "AKNINE",
29
+ "gender": null,
30
+ "given_name": "Karima"
31
+ }
32
+ `;
33
+
34
+ exports[`toIdentityVector > MarieLeblancMandataire - French PRESIDENT 1`] = `
35
+ {
36
+ "birthcountry": "99100",
37
+ "birthdate": "1988-01-01T00:00:00.000Z",
38
+ "birthplace": null,
39
+ "family_name": "LEBLANC",
40
+ "gender": null,
41
+ "given_name": "Marie"
42
+ }
43
+ `;
44
+
45
+ exports[`toIdentityVector > PierreDurandMandataire - French DIRECTEUR GENERAL 1`] = `
46
+ {
47
+ "birthcountry": "99100",
48
+ "birthdate": "1991-01-01T00:00:00.000Z",
49
+ "birthplace": null,
50
+ "family_name": "DURAND",
51
+ "gender": null,
52
+ "given_name": "Pierre"
53
+ }
54
+ `;
55
+
56
+ exports[`toIdentityVector > RogalDornMandataire - Edge case (futuristic) 1`] = `
57
+ {
58
+ "birthcountry": "99102",
59
+ "birthdate": "+029000-01-07T00:00:00.000Z",
60
+ "birthplace": null,
61
+ "family_name": "DORN",
62
+ "gender": null,
63
+ "given_name": "ROGAL"
64
+ }
65
+ `;
66
+
67
+ exports[`toIdentityVector > SocietePresidenteMandataire - Personne morale PRESIDENT 1`] = `
68
+ {
69
+ "birthcountry": null,
70
+ "birthdate": null,
71
+ "birthplace": null,
72
+ "family_name": null,
73
+ "gender": null,
74
+ "given_name": null
75
+ }
76
+ `;
77
+
78
+ exports[`toIdentityVector > SophieMartinMandataire - French GERANT 1`] = `
79
+ {
80
+ "birthcountry": "99100",
81
+ "birthdate": "1996-01-01T00:00:00.000Z",
82
+ "birthplace": null,
83
+ "family_name": "MARTIN",
84
+ "gender": null,
85
+ "given_name": "Sophie"
86
+ }
87
+ `;
88
+
89
+ exports[`toIdentityVector > StevensCheronMandataire - French DIRIGEANT 1`] = `
90
+ {
91
+ "birthcountry": "99100",
92
+ "birthdate": "1979-11-12T00:00:00.000Z",
93
+ "birthplace": null,
94
+ "family_name": "CHERON",
95
+ "gender": null,
96
+ "given_name": "Stevens"
97
+ }
98
+ `;
99
+
100
+ exports[`toIdentityVector > UlysseToriMandataire - French DIRIGEANT 1`] = `
101
+ {
102
+ "birthcountry": "99100",
103
+ "birthdate": "1992-09-07T00:00:00.000Z",
104
+ "birthplace": null,
105
+ "family_name": "TOSI",
106
+ "gender": null,
107
+ "given_name": "Ulysse"
108
+ }
109
+ `;
@@ -1,18 +1,21 @@
1
- //
2
-
3
1
  import type { IdentityVector } from "#src/types";
4
2
  import type { InfogreffeSirenMandatairesSociaux } from "@proconnect-gouv/proconnect.api_entreprise/types";
3
+ import { convertCountryIsoToCog } from "../birthplace-conversion.js";
5
4
 
6
5
  //
7
6
 
8
- export function fromInfogreffe(
7
+ export function toIdentityVector(
9
8
  mandataire: InfogreffeSirenMandatairesSociaux,
10
9
  ): IdentityVector {
10
+ const birthcountry = convertCountryIsoToCog(mandataire.code_pays_naissance);
11
11
  const birthdate = new Date(mandataire.date_naissance_timestamp || NaN);
12
+
12
13
  return {
13
- birthplace: mandataire.lieu_naissance ?? null,
14
+ birthcountry,
14
15
  birthdate: isNaN(birthdate.getTime()) ? null : birthdate,
16
+ birthplace: null, // API Entreprise Infogreffe doesn't provide Insee code for birthplace
15
17
  family_name: mandataire.nom ?? null,
18
+ gender: null, // API Entreprise Infogreffe doesn't provide gender
16
19
  given_name: mandataire.prenom ?? null,
17
20
  };
18
21
  }
@@ -0,0 +1,21 @@
1
+ //
2
+
3
+ import type { FranceConnectUserInfo, IdentityVector } from "#src/types";
4
+ import { match } from "ts-pattern";
5
+
6
+ //
7
+
8
+ export function toIdentityVector(
9
+ userInfo: FranceConnectUserInfo,
10
+ ): IdentityVector {
11
+ return {
12
+ birthcountry: userInfo.birthcountry,
13
+ birthdate: userInfo.birthdate,
14
+ birthplace: userInfo.birthplace,
15
+ family_name: userInfo.family_name,
16
+ gender: match(userInfo.gender.toLowerCase())
17
+ .with("male", "female", (value) => value)
18
+ .otherwise(() => null),
19
+ given_name: userInfo.given_name,
20
+ };
21
+ }
@@ -0,0 +1,18 @@
1
+ //
2
+
3
+ import {
4
+ LiElJonsonEstablishment,
5
+ RogalDornEstablishment,
6
+ } from "@proconnect-gouv/proconnect.insee/testing/seed";
7
+ import { suite, test } from "node:test";
8
+ import { toIdentityVector } from "./insee.js";
9
+
10
+ suite("toIdentityVector", () => {
11
+ test("LiElJonsonEstablishment", (t) => {
12
+ t.assert.snapshot(toIdentityVector(LiElJonsonEstablishment));
13
+ });
14
+
15
+ test("RogalDornEstablishment", (t) => {
16
+ t.assert.snapshot(toIdentityVector(RogalDornEstablishment));
17
+ });
18
+ });