@proconnect-gouv/proconnect.api_entreprise 1.1.1 → 2.1.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,19 @@
1
1
  # @proconnect-gouv/proconnect.entreprise
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1897](https://github.com/proconnect-gouv/proconnect-identite/pull/1897) [`fff1869`](https://github.com/proconnect-gouv/proconnect-identite/commit/fff1869650e1c8e02e17671898a6e6d3217a15f2) Thanks [@rebeccadumazert](https://github.com/rebeccadumazert)! - Add tranche effect unite legale labels array
8
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [#1843](https://github.com/proconnect-gouv/proconnect-identite/pull/1843) [`c07b628`](https://github.com/proconnect-gouv/proconnect-identite/commit/c07b628d7daac833faa728d814132842a6518566) Thanks [@douglasduteil](https://github.com/douglasduteil)! - ♻️ Suppression de l'option additionnel car openapi-fetch support middlewares
14
+
15
+ - [#1843](https://github.com/proconnect-gouv/proconnect-identite/pull/1843) [`f0823f8`](https://github.com/proconnect-gouv/proconnect-identite/commit/f0823f88744cda92ffafe28314de9e337d275059) Thanks [@douglasduteil](https://github.com/douglasduteil)! - ♻️ Changement de pattern permettant une exposition totale
16
+
3
17
  ## 1.1.1
4
18
 
5
19
  ### Patch Changes
@@ -1,10 +1,204 @@
1
- import type { FindMandatairesSociauxBySirenHandler } from "./infogreffe/index.js";
2
- import type { FindBySirenHandler, FindBySiretHandler } from "./insee/index.js";
3
- export interface ApiEntrepriseInseeRepository {
4
- findBySiren: FindBySirenHandler;
5
- findBySiret: FindBySiretHandler;
6
- }
7
- export interface ApiEntrepriseInfogreffeRepository {
8
- findMandatairesSociauxBySiren: FindMandatairesSociauxBySirenHandler;
9
- }
1
+ import type { ApiEntrepriseOpenApiClient } from "#src/client";
2
+ export declare function createApiEntrepriseClient(client: ApiEntrepriseOpenApiClient, context: string, recipient: string): {
3
+ findBySiren: (siren: string) => Promise<{
4
+ siret: string;
5
+ siege_social: true | false;
6
+ etat_administratif: "A" | "F";
7
+ date_fermeture: number | null;
8
+ activite_principale: {
9
+ code: string | null;
10
+ libelle: string;
11
+ nomenclature: string | null;
12
+ };
13
+ tranche_effectif_salarie: {
14
+ code: "NN" | "00" | "01" | "02" | "03" | "11" | "12" | "21" | "22" | "31" | "32" | "41" | "42" | "51" | "52" | "53" | null;
15
+ intitule: string | null;
16
+ date_reference: string | null;
17
+ de: number | null;
18
+ a: number | null;
19
+ };
20
+ status_diffusion: "diffusible" | "partiellement_diffusible" | "non_diffusible";
21
+ diffusable_commercialement: boolean;
22
+ enseigne: string | null;
23
+ unite_legale: {
24
+ siren: string;
25
+ rna: string | null;
26
+ siret_siege_social: string;
27
+ type: "personne_physique" | "personne_morale";
28
+ personne_morale_attributs: {
29
+ raison_sociale: string | null;
30
+ sigle: string | null;
31
+ };
32
+ personne_physique_attributs: {
33
+ pseudonyme: string | null;
34
+ prenom_usuel: string | null;
35
+ prenom_1: string | null;
36
+ prenom_2: string | null;
37
+ prenom_3: string | null;
38
+ prenom_4: string | null;
39
+ nom_usage: string | null;
40
+ nom_naissance: string | null;
41
+ sexe: "M" | "F" | null;
42
+ };
43
+ categorie_entreprise: "GE" | "ETI" | "PME" | null;
44
+ status_diffusion: "diffusible" | "partiellement_diffusible" | "non_diffusible";
45
+ diffusable_commercialement: boolean;
46
+ forme_juridique: {
47
+ code: string;
48
+ libelle: string;
49
+ };
50
+ activite_principale: {
51
+ code: string | null;
52
+ libelle: string;
53
+ nomenclature: string | null;
54
+ };
55
+ tranche_effectif_salarie: {
56
+ code: "NN" | "00" | "01" | "02" | "03" | "11" | "12" | "21" | "22" | "31" | "32" | "41" | "42" | "51" | "52" | "53" | null;
57
+ intitule: string | null;
58
+ date_reference: string | null;
59
+ de: number | null;
60
+ a: number | null;
61
+ };
62
+ etat_administratif: "A" | "C";
63
+ economie_sociale_et_solidaire: true | false | null;
64
+ date_creation: number | null;
65
+ };
66
+ adresse: {
67
+ numero_voie: string;
68
+ indice_repetition_voie: "bis" | "ter" | "quarter" | "quinquies" | null;
69
+ type_voie: "ALL\u00C9E" | "AVENUE" | "BOULEVARD" | "CARREFOUR" | "CHEMIN" | "CHAUSS\u00C9E" | "CIT\u00C9" | "CORNICHE" | "COURS" | "DOMAINE" | "DESCENTE" | "ECART" | "ESPLANADE" | "FAUBOURG" | "GRANDE RUE" | "HAMEAU" | "HALLE" | "IMPASSE" | "LIEU-DIT" | "LOTISSEMENT" | "MARCH\u00C9" | "MONT\u00C9E" | "PASSAGE" | "PLACE" | "PLAINE" | "PLATEAU" | "PROMENADE" | "PARVIS" | "QUARTIER" | "QUAI" | "R\u00C9SIDENCE" | "RUELLE" | "ROCADE" | "ROND-POINT" | "ROUTE" | "RUE" | "SENTIER" | "SQUARE" | "TERRE-PLEIN" | "TRAVERSE" | "VILLA" | "VILLAGE" | null;
70
+ libelle_voie: string;
71
+ complement_adresse: string | null;
72
+ code_commune: string | null;
73
+ code_postal: string | null;
74
+ distribution_speciale: string | null;
75
+ code_cedex: string | null;
76
+ libelle_cedex: string | null;
77
+ libelle_commune: string | null;
78
+ libelle_commune_etranger: string | null;
79
+ code_pays_etranger: string | null;
80
+ libelle_pays_etranger: string | null;
81
+ status_diffusion: "diffusible" | "partiellement_diffusible" | "non_diffusible";
82
+ acheminement_postal: {
83
+ l1: string | null;
84
+ l2: string | null;
85
+ l3: string | null;
86
+ l4: string | null;
87
+ l5: string | null;
88
+ l6: string | null;
89
+ l7: string | null;
90
+ };
91
+ };
92
+ date_creation: number | null;
93
+ }>;
94
+ findBySiret: (siret: string) => Promise<{
95
+ siret: string;
96
+ siege_social: true | false;
97
+ etat_administratif: "A" | "F";
98
+ date_fermeture: number | null;
99
+ activite_principale: {
100
+ code: string | null;
101
+ libelle: string;
102
+ nomenclature: string | null;
103
+ };
104
+ tranche_effectif_salarie: {
105
+ code: "NN" | "00" | "01" | "02" | "03" | "11" | "12" | "21" | "22" | "31" | "32" | "41" | "42" | "51" | "52" | "53" | null;
106
+ intitule: string | null;
107
+ date_reference: string | null;
108
+ de: number | null;
109
+ a: number | null;
110
+ };
111
+ status_diffusion: "diffusible" | "partiellement_diffusible" | "non_diffusible";
112
+ diffusable_commercialement: boolean;
113
+ enseigne: string | null;
114
+ unite_legale: {
115
+ siren: string;
116
+ rna: string | null;
117
+ siret_siege_social: string;
118
+ type: "personne_physique" | "personne_morale";
119
+ personne_morale_attributs: {
120
+ raison_sociale: string | null;
121
+ sigle: string | null;
122
+ };
123
+ personne_physique_attributs: {
124
+ pseudonyme: string | null;
125
+ prenom_usuel: string | null;
126
+ prenom_1: string | null;
127
+ prenom_2: string | null;
128
+ prenom_3: string | null;
129
+ prenom_4: string | null;
130
+ nom_usage: string | null;
131
+ nom_naissance: string | null;
132
+ sexe: "M" | "F" | null;
133
+ };
134
+ categorie_entreprise: "GE" | "ETI" | "PME" | null;
135
+ status_diffusion: "diffusible" | "partiellement_diffusible" | "non_diffusible";
136
+ diffusable_commercialement: boolean;
137
+ forme_juridique: {
138
+ code: string;
139
+ libelle: string;
140
+ };
141
+ activite_principale: {
142
+ code: string | null;
143
+ libelle: string;
144
+ nomenclature: string | null;
145
+ };
146
+ tranche_effectif_salarie: {
147
+ code: "NN" | "00" | "01" | "02" | "03" | "11" | "12" | "21" | "22" | "31" | "32" | "41" | "42" | "51" | "52" | "53" | null;
148
+ intitule: string | null;
149
+ date_reference: string | null;
150
+ de: number | null;
151
+ a: number | null;
152
+ };
153
+ etat_administratif: "A" | "C";
154
+ economie_sociale_et_solidaire: true | false | null;
155
+ date_creation: number | null;
156
+ };
157
+ adresse: {
158
+ numero_voie: string;
159
+ indice_repetition_voie: "bis" | "ter" | "quarter" | "quinquies" | null;
160
+ type_voie: "ALL\u00C9E" | "AVENUE" | "BOULEVARD" | "CARREFOUR" | "CHEMIN" | "CHAUSS\u00C9E" | "CIT\u00C9" | "CORNICHE" | "COURS" | "DOMAINE" | "DESCENTE" | "ECART" | "ESPLANADE" | "FAUBOURG" | "GRANDE RUE" | "HAMEAU" | "HALLE" | "IMPASSE" | "LIEU-DIT" | "LOTISSEMENT" | "MARCH\u00C9" | "MONT\u00C9E" | "PASSAGE" | "PLACE" | "PLAINE" | "PLATEAU" | "PROMENADE" | "PARVIS" | "QUARTIER" | "QUAI" | "R\u00C9SIDENCE" | "RUELLE" | "ROCADE" | "ROND-POINT" | "ROUTE" | "RUE" | "SENTIER" | "SQUARE" | "TERRE-PLEIN" | "TRAVERSE" | "VILLA" | "VILLAGE" | null;
161
+ libelle_voie: string;
162
+ complement_adresse: string | null;
163
+ code_commune: string | null;
164
+ code_postal: string | null;
165
+ distribution_speciale: string | null;
166
+ code_cedex: string | null;
167
+ libelle_cedex: string | null;
168
+ libelle_commune: string | null;
169
+ libelle_commune_etranger: string | null;
170
+ code_pays_etranger: string | null;
171
+ libelle_pays_etranger: string | null;
172
+ status_diffusion: "diffusible" | "partiellement_diffusible" | "non_diffusible";
173
+ acheminement_postal: {
174
+ l1: string | null;
175
+ l2: string | null;
176
+ l3: string | null;
177
+ l4: string | null;
178
+ l5: string | null;
179
+ l6: string | null;
180
+ l7: string | null;
181
+ };
182
+ };
183
+ date_creation: number | null;
184
+ }>;
185
+ findMandatairesSociauxBySiren: (siren: string) => Promise<{
186
+ numero_identification?: string | undefined;
187
+ type?: "personne_morale" | "personne_physique" | undefined;
188
+ fonction: string | null;
189
+ nom?: string | null | undefined;
190
+ prenom?: string | null | undefined;
191
+ date_naissance?: string | null | undefined;
192
+ date_naissance_timestamp?: number | null | undefined;
193
+ lieu_naissance?: string | null | undefined;
194
+ pays_naissance?: string | null | undefined;
195
+ code_pays_naissance?: string | null | undefined;
196
+ nationalite?: string | null | undefined;
197
+ code_nationalite?: string | null | undefined;
198
+ raison_sociale?: string | null | undefined;
199
+ code_greffe?: string | null | undefined;
200
+ libelle_greffe?: string | null | undefined;
201
+ }[]>;
202
+ };
203
+ export type ApiEntrepriseClient = ReturnType<typeof createApiEntrepriseClient>;
10
204
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,kBAAkB,CAAC;IAChC,WAAW,EAAE,kBAAkB,CAAC;CACjC;AAED,MAAM,WAAW,iCAAiC;IAChD,6BAA6B,EAAE,oCAAoC,CAAC;CACrE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAK9D,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBlB;AACD,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
package/dist/api/index.js CHANGED
@@ -1,2 +1,23 @@
1
1
  //
2
- export {};
2
+ import { findMandatairesSociauxBySirenFactory } from "./infogreffe/index.js";
3
+ import { findBySirenFactory } from "./insee/find-by-siren.js";
4
+ import { findBySiretFactory } from "./insee/find-by-siret.js";
5
+ export function createApiEntrepriseClient(client, context, recipient) {
6
+ return {
7
+ findBySiren: findBySirenFactory(client, {
8
+ context,
9
+ object: "findEstablishmentBySiren",
10
+ recipient,
11
+ }),
12
+ findBySiret: findBySiretFactory(client, {
13
+ context,
14
+ object: "findEstablishmentBySiret",
15
+ recipient,
16
+ }),
17
+ findMandatairesSociauxBySiren: findMandatairesSociauxBySirenFactory(client, {
18
+ context,
19
+ object: "findMandatairesSociauxBySiren",
20
+ recipient,
21
+ }),
22
+ };
23
+ }
@@ -1,21 +1,20 @@
1
1
  import type { ApiEntrepriseOpenApiClient, ApiEntrepriseTrackingParams } from "#src/client";
2
- import type { FetchOptions } from "openapi-fetch";
3
- export declare function findMandatairesSociauxBySirenFactory(client: ApiEntrepriseOpenApiClient, trackingParams: ApiEntrepriseTrackingParams, optionsFn?: () => FetchOptions<unknown>): (siren: string) => Promise<{
4
- numero_identification?: string;
5
- type?: "personne_morale" | "personne_physique";
2
+ export declare function findMandatairesSociauxBySirenFactory(client: ApiEntrepriseOpenApiClient, trackingParams: ApiEntrepriseTrackingParams): (siren: string) => Promise<{
3
+ numero_identification?: string | undefined;
4
+ type?: "personne_morale" | "personne_physique" | undefined;
6
5
  fonction: string | null;
7
- nom?: string | null;
8
- prenom?: string | null;
9
- date_naissance?: string | null;
10
- date_naissance_timestamp?: number | null;
11
- lieu_naissance?: string | null;
12
- pays_naissance?: string | null;
13
- code_pays_naissance?: string | null;
14
- nationalite?: string | null;
15
- code_nationalite?: string | null;
16
- raison_sociale?: string | null;
17
- code_greffe?: string | null;
18
- libelle_greffe?: string | null;
6
+ nom?: string | null | undefined;
7
+ prenom?: string | null | undefined;
8
+ date_naissance?: string | null | undefined;
9
+ date_naissance_timestamp?: number | null | undefined;
10
+ lieu_naissance?: string | null | undefined;
11
+ pays_naissance?: string | null | undefined;
12
+ code_pays_naissance?: string | null | undefined;
13
+ nationalite?: string | null | undefined;
14
+ code_nationalite?: string | null | undefined;
15
+ raison_sociale?: string | null | undefined;
16
+ code_greffe?: string | null | undefined;
17
+ libelle_greffe?: string | null | undefined;
19
18
  }[]>;
20
19
  export type FindMandatairesSociauxBySirenHandler = ReturnType<typeof findMandatairesSociauxBySirenFactory>;
21
20
  //# sourceMappingURL=find-mandataires-sociaux-by-siren.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-mandataires-sociaux-by-siren.d.ts","sourceRoot":"","sources":["../../../src/api/infogreffe/find-mandataires-sociaux-by-siren.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,0BAA0B,EAClC,cAAc,EAAE,2BAA2B,EAC3C,SAAS,GAAE,MAAM,YAAY,CAAC,OAAO,CAAc,IAEC,OAAO,MAAM;;;;;;;;;;;;;;;;KAuBlE;AAED,MAAM,MAAM,oCAAoC,GAAG,UAAU,CAC3D,OAAO,oCAAoC,CAC5C,CAAC"}
1
+ {"version":3,"file":"find-mandataires-sociaux-by-siren.d.ts","sourceRoot":"","sources":["../../../src/api/infogreffe/find-mandataires-sociaux-by-siren.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAKrB,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,0BAA0B,EAClC,cAAc,EAAE,2BAA2B,IAES,OAAO,MAAM;;;;;;;;;;;;;;;;KAsBlE;AAED,MAAM,MAAM,oCAAoC,GAAG,UAAU,CAC3D,OAAO,oCAAoC,CAC5C,CAAC"}
@@ -1,10 +1,9 @@
1
1
  //
2
2
  import { ApiEntrepriseError } from "#src/types";
3
3
  //
4
- export function findMandatairesSociauxBySirenFactory(client, trackingParams, optionsFn = () => ({})) {
4
+ export function findMandatairesSociauxBySirenFactory(client, trackingParams) {
5
5
  return async function findMandatairesSociauxBySiren(siren) {
6
6
  const { data, error } = await client.GET("/v3/infogreffe/rcs/unites_legales/{siren}/mandataires_sociaux", {
7
- ...optionsFn(),
8
7
  params: {
9
8
  path: {
10
9
  siren,
@@ -1,6 +1,5 @@
1
1
  import type { ApiEntrepriseOpenApiClient, ApiEntrepriseTrackingParams } from "#src/client";
2
- import type { FetchOptions } from "openapi-fetch";
3
- export declare function findBySirenFactory(client: ApiEntrepriseOpenApiClient, trackingParams: ApiEntrepriseTrackingParams, optionsFn?: () => FetchOptions<unknown>): (siren: string) => Promise<{
2
+ export declare function findBySirenFactory(client: ApiEntrepriseOpenApiClient, trackingParams: ApiEntrepriseTrackingParams): (siren: string) => Promise<{
4
3
  siret: string;
5
4
  siege_social: true | false;
6
5
  etat_administratif: "A" | "F";
@@ -1 +1 @@
1
- {"version":3,"file":"find-by-siren.d.ts","sourceRoot":"","sources":["../../../src/api/insee/find-by-siren.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,0BAA0B,EAClC,cAAc,EAAE,2BAA2B,EAC3C,SAAS,GAAE,MAAM,YAAY,CAAC,OAAO,CAAc,IAEjB,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmBhD;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"find-by-siren.d.ts","sourceRoot":"","sources":["../../../src/api/insee/find-by-siren.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAKrB,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,0BAA0B,EAClC,cAAc,EAAE,2BAA2B,IAET,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkBhD;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,10 +1,9 @@
1
1
  //
2
2
  import { ApiEntrepriseError } from "#src/types";
3
3
  //
4
- export function findBySirenFactory(client, trackingParams, optionsFn = () => ({})) {
4
+ export function findBySirenFactory(client, trackingParams) {
5
5
  return async function findBySiren(siren) {
6
6
  const { data, error } = await client.GET("/v3/insee/sirene/unites_legales/{siren}/siege_social", {
7
- ...optionsFn(),
8
7
  params: {
9
8
  path: {
10
9
  siren,
@@ -1,6 +1,5 @@
1
1
  import type { ApiEntrepriseOpenApiClient, ApiEntrepriseTrackingParams } from "#src/client";
2
- import type { FetchOptions } from "openapi-fetch";
3
- export declare function findBySiretFactory(client: ApiEntrepriseOpenApiClient, trackingParams: ApiEntrepriseTrackingParams, optionsFn?: () => FetchOptions<unknown>): (siret: string) => Promise<{
2
+ export declare function findBySiretFactory(client: ApiEntrepriseOpenApiClient, trackingParams: ApiEntrepriseTrackingParams): (siret: string) => Promise<{
4
3
  siret: string;
5
4
  siege_social: true | false;
6
5
  etat_administratif: "A" | "F";
@@ -1 +1 @@
1
- {"version":3,"file":"find-by-siret.d.ts","sourceRoot":"","sources":["../../../src/api/insee/find-by-siret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,0BAA0B,EAClC,cAAc,EAAE,2BAA2B,EAC3C,SAAS,GAAE,MAAM,YAAY,CAAC,OAAO,CAAc,IAEjB,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmBhD;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"find-by-siret.d.ts","sourceRoot":"","sources":["../../../src/api/insee/find-by-siret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAKrB,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,0BAA0B,EAClC,cAAc,EAAE,2BAA2B,IAET,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkBhD;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,10 +1,9 @@
1
1
  //
2
2
  import { ApiEntrepriseError } from "#src/types";
3
3
  //
4
- export function findBySiretFactory(client, trackingParams, optionsFn = () => ({})) {
4
+ export function findBySiretFactory(client, trackingParams) {
5
5
  return async function findBySiret(siret) {
6
6
  const { data, error } = await client.GET("/v3/insee/sirene/etablissements/{siret}", {
7
- ...optionsFn(),
8
7
  params: {
9
8
  path: {
10
9
  siret,
@@ -0,0 +1,2 @@
1
+ export declare function formatTrancheEffectifsUniteLegale(code: string | null | undefined): string;
2
+ //# sourceMappingURL=tranche-effectifs-unite-legale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tranche-effectifs-unite-legale.d.ts","sourceRoot":"","sources":["../../src/formatters/tranche-effectifs-unite-legale.ts"],"names":[],"mappings":"AAqBA,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC9B,MAAM,CAGR"}
@@ -0,0 +1,24 @@
1
+ //
2
+ const TRANCHE_EFFECTIFS_UNITE_LEGALE_LABELS = {
3
+ NN: "Unité non employeuse",
4
+ "00": "0 salarié",
5
+ "01": "1 ou 2 salariés",
6
+ "02": "3 à 5 salariés",
7
+ "03": "6 à 9 salariés",
8
+ "11": "10 à 19 salariés",
9
+ "12": "20 à 49 salariés",
10
+ "21": "50 à 99 salariés",
11
+ "22": "100 à 199 salariés",
12
+ "31": "200 à 249 salariés",
13
+ "32": "250 à 499 salariés",
14
+ "41": "500 à 999 salariés",
15
+ "42": "1 000 à 1 999 salariés",
16
+ "51": "2 000 à 4 999 salariés",
17
+ "52": "5 000 à 9 999 salariés",
18
+ "53": "10 000 salariés et plus",
19
+ };
20
+ export function formatTrancheEffectifsUniteLegale(code) {
21
+ if (!code)
22
+ return "Non renseigné";
23
+ return TRANCHE_EFFECTIFS_UNITE_LEGALE_LABELS[code] ?? "Non renseigné";
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proconnect-gouv/proconnect.api_entreprise",
3
- "version": "1.1.1",
3
+ "version": "2.1.0",
4
4
  "homepage": "https://github.com/proconnect-gouv/proconnect-identite/tree/main/packages/entreprise#readme",
5
5
  "bugs": "https://github.com/proconnect-gouv/proconnect-identite/issues",
6
6
  "repository": {
@@ -44,7 +44,7 @@
44
44
  "test": "tsx --test --test-reporter=spec src/**/*.test.ts"
45
45
  },
46
46
  "dependencies": {
47
- "openapi-fetch": "^0.15.0"
47
+ "openapi-fetch": "^0.17.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@proconnect-gouv/proconnect.devtools.typescript": "1.0.0",
package/src/api/index.ts CHANGED
@@ -1,13 +1,34 @@
1
1
  //
2
2
 
3
- import type { FindMandatairesSociauxBySirenHandler } from "./infogreffe/index.js";
4
- import type { FindBySirenHandler, FindBySiretHandler } from "./insee/index.js";
3
+ import type { ApiEntrepriseOpenApiClient } from "#src/client";
4
+ import { findMandatairesSociauxBySirenFactory } from "./infogreffe/index.js";
5
+ import { findBySirenFactory } from "./insee/find-by-siren.js";
6
+ import { findBySiretFactory } from "./insee/find-by-siret.js";
5
7
 
6
- export interface ApiEntrepriseInseeRepository {
7
- findBySiren: FindBySirenHandler;
8
- findBySiret: FindBySiretHandler;
9
- }
10
-
11
- export interface ApiEntrepriseInfogreffeRepository {
12
- findMandatairesSociauxBySiren: FindMandatairesSociauxBySirenHandler;
8
+ export function createApiEntrepriseClient(
9
+ client: ApiEntrepriseOpenApiClient,
10
+ context: string,
11
+ recipient: string,
12
+ ) {
13
+ return {
14
+ findBySiren: findBySirenFactory(client, {
15
+ context,
16
+ object: "findEstablishmentBySiren",
17
+ recipient,
18
+ }),
19
+ findBySiret: findBySiretFactory(client, {
20
+ context,
21
+ object: "findEstablishmentBySiret",
22
+ recipient,
23
+ }),
24
+ findMandatairesSociauxBySiren: findMandatairesSociauxBySirenFactory(
25
+ client,
26
+ {
27
+ context,
28
+ object: "findMandatairesSociauxBySiren",
29
+ recipient,
30
+ },
31
+ ),
32
+ };
13
33
  }
34
+ export type ApiEntrepriseClient = ReturnType<typeof createApiEntrepriseClient>;
@@ -5,20 +5,17 @@ import type {
5
5
  ApiEntrepriseTrackingParams,
6
6
  } from "#src/client";
7
7
  import { ApiEntrepriseError } from "#src/types";
8
- import type { FetchOptions } from "openapi-fetch";
9
8
 
10
9
  //
11
10
 
12
11
  export function findMandatairesSociauxBySirenFactory(
13
12
  client: ApiEntrepriseOpenApiClient,
14
13
  trackingParams: ApiEntrepriseTrackingParams,
15
- optionsFn: () => FetchOptions<unknown> = () => ({}),
16
14
  ) {
17
15
  return async function findMandatairesSociauxBySiren(siren: string) {
18
16
  const { data, error } = await client.GET(
19
17
  "/v3/infogreffe/rcs/unites_legales/{siren}/mandataires_sociaux",
20
18
  {
21
- ...optionsFn(),
22
19
  params: {
23
20
  path: {
24
21
  siren,
@@ -5,20 +5,17 @@ import type {
5
5
  ApiEntrepriseTrackingParams,
6
6
  } from "#src/client";
7
7
  import { ApiEntrepriseError } from "#src/types";
8
- import type { FetchOptions } from "openapi-fetch";
9
8
 
10
9
  //
11
10
 
12
11
  export function findBySirenFactory(
13
12
  client: ApiEntrepriseOpenApiClient,
14
13
  trackingParams: ApiEntrepriseTrackingParams,
15
- optionsFn: () => FetchOptions<unknown> = () => ({}),
16
14
  ) {
17
15
  return async function findBySiren(siren: string) {
18
16
  const { data, error } = await client.GET(
19
17
  "/v3/insee/sirene/unites_legales/{siren}/siege_social",
20
18
  {
21
- ...optionsFn(),
22
19
  params: {
23
20
  path: {
24
21
  siren,
@@ -5,20 +5,17 @@ import type {
5
5
  ApiEntrepriseTrackingParams,
6
6
  } from "#src/client";
7
7
  import { ApiEntrepriseError } from "#src/types";
8
- import type { FetchOptions } from "openapi-fetch";
9
8
 
10
9
  //
11
10
 
12
11
  export function findBySiretFactory(
13
12
  client: ApiEntrepriseOpenApiClient,
14
13
  trackingParams: ApiEntrepriseTrackingParams,
15
- optionsFn: () => FetchOptions<unknown> = () => ({}),
16
14
  ) {
17
15
  return async function findBySiret(siret: string) {
18
16
  const { data, error } = await client.GET(
19
17
  "/v3/insee/sirene/etablissements/{siret}",
20
18
  {
21
- ...optionsFn(),
22
19
  params: {
23
20
  path: {
24
21
  siret,
@@ -0,0 +1,24 @@
1
+ //
2
+
3
+ import assert from "node:assert/strict";
4
+ import { suite, test } from "node:test";
5
+ import { formatTrancheEffectifsUniteLegale } from "./tranche-effectifs-unite-legale.js";
6
+
7
+ suite("formatTrancheEffectifsUniteLegale", { concurrency: true }, () => {
8
+ const cases: [string | null | undefined, string][] = [
9
+ ["NN", "Unité non employeuse"],
10
+ ["00", "0 salarié"],
11
+ ["01", "1 ou 2 salariés"],
12
+ ["11", "10 à 19 salariés"],
13
+ ["53", "10 000 salariés et plus"],
14
+ [null, "Non renseigné"],
15
+ [undefined, "Non renseigné"],
16
+ ["XX", "Non renseigné"],
17
+ ];
18
+
19
+ for (const [code, expected] of cases) {
20
+ test(`code "${code}" → "${expected}"`, () => {
21
+ assert.equal(formatTrancheEffectifsUniteLegale(code), expected);
22
+ });
23
+ }
24
+ });
@@ -0,0 +1,27 @@
1
+ //
2
+
3
+ const TRANCHE_EFFECTIFS_UNITE_LEGALE_LABELS: Record<string, string> = {
4
+ NN: "Unité non employeuse",
5
+ "00": "0 salarié",
6
+ "01": "1 ou 2 salariés",
7
+ "02": "3 à 5 salariés",
8
+ "03": "6 à 9 salariés",
9
+ "11": "10 à 19 salariés",
10
+ "12": "20 à 49 salariés",
11
+ "21": "50 à 99 salariés",
12
+ "22": "100 à 199 salariés",
13
+ "31": "200 à 249 salariés",
14
+ "32": "250 à 499 salariés",
15
+ "41": "500 à 999 salariés",
16
+ "42": "1 000 à 1 999 salariés",
17
+ "51": "2 000 à 4 999 salariés",
18
+ "52": "5 000 à 9 999 salariés",
19
+ "53": "10 000 salariés et plus",
20
+ };
21
+
22
+ export function formatTrancheEffectifsUniteLegale(
23
+ code: string | null | undefined,
24
+ ): string {
25
+ if (!code) return "Non renseigné";
26
+ return TRANCHE_EFFECTIFS_UNITE_LEGALE_LABELS[code] ?? "Non renseigné";
27
+ }