@proconnect-gouv/proconnect.api_entreprise 1.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +66 -0
  3. package/dist/api/index.d.ts +10 -0
  4. package/dist/api/index.d.ts.map +1 -0
  5. package/dist/api/index.js +2 -0
  6. package/dist/api/infogreffe/find-mandataires-sociaux-by-siren.d.ts +21 -0
  7. package/dist/api/infogreffe/find-mandataires-sociaux-by-siren.d.ts.map +1 -0
  8. package/dist/api/infogreffe/find-mandataires-sociaux-by-siren.js +20 -0
  9. package/dist/api/infogreffe/index.d.ts +2 -0
  10. package/dist/api/infogreffe/index.d.ts.map +1 -0
  11. package/dist/api/infogreffe/index.js +2 -0
  12. package/dist/api/insee/find-by-siren.d.ts +95 -0
  13. package/dist/api/insee/find-by-siren.d.ts.map +1 -0
  14. package/dist/api/insee/find-by-siren.js +20 -0
  15. package/dist/api/insee/find-by-siret.d.ts +95 -0
  16. package/dist/api/insee/find-by-siret.d.ts.map +1 -0
  17. package/dist/api/insee/find-by-siret.js +20 -0
  18. package/dist/api/insee/index.d.ts +3 -0
  19. package/dist/api/insee/index.d.ts.map +1 -0
  20. package/dist/api/insee/index.js +3 -0
  21. package/dist/client/index.d.ts +21 -0
  22. package/dist/client/index.d.ts.map +1 -0
  23. package/dist/client/index.js +21 -0
  24. package/dist/formatters/adresse-establishment.d.ts +3 -0
  25. package/dist/formatters/adresse-establishment.d.ts.map +1 -0
  26. package/dist/formatters/adresse-establishment.js +41 -0
  27. package/dist/formatters/index.d.ts +5 -0
  28. package/dist/formatters/index.d.ts.map +1 -0
  29. package/dist/formatters/index.js +5 -0
  30. package/dist/formatters/libelle-from-code-effectif.d.ts +2 -0
  31. package/dist/formatters/libelle-from-code-effectif.d.ts.map +1 -0
  32. package/dist/formatters/libelle-from-code-effectif.js +10 -0
  33. package/dist/formatters/main-activity.d.ts +3 -0
  34. package/dist/formatters/main-activity.d.ts.map +1 -0
  35. package/dist/formatters/main-activity.js +7 -0
  36. package/dist/formatters/nom-complet.d.ts +10 -0
  37. package/dist/formatters/nom-complet.d.ts.map +1 -0
  38. package/dist/formatters/nom-complet.js +22 -0
  39. package/dist/testing/index.d.ts +3 -0
  40. package/dist/testing/index.d.ts.map +1 -0
  41. package/dist/testing/index.js +7 -0
  42. package/dist/testing/seed/insee/siret/00557246600026.d.ts +4 -0
  43. package/dist/testing/seed/insee/siret/00557246600026.d.ts.map +1 -0
  44. package/dist/testing/seed/insee/siret/00557246600026.js +96 -0
  45. package/dist/testing/seed/insee/siret/20007184300060.d.ts +4 -0
  46. package/dist/testing/seed/insee/siret/20007184300060.d.ts.map +1 -0
  47. package/dist/testing/seed/insee/siret/20007184300060.js +91 -0
  48. package/dist/testing/seed/insee/siret/21920023500014.d.ts +4 -0
  49. package/dist/testing/seed/insee/siret/21920023500014.d.ts.map +1 -0
  50. package/dist/testing/seed/insee/siret/21920023500014.js +91 -0
  51. package/dist/testing/seed/insee/siret/32122785200019.d.ts +4 -0
  52. package/dist/testing/seed/insee/siret/32122785200019.d.ts.map +1 -0
  53. package/dist/testing/seed/insee/siret/32122785200019.js +95 -0
  54. package/dist/testing/seed/insee/siret/39234600300198.d.ts +4 -0
  55. package/dist/testing/seed/insee/siret/39234600300198.d.ts.map +1 -0
  56. package/dist/testing/seed/insee/siret/39234600300198.js +92 -0
  57. package/dist/testing/seed/insee/siret/41816609600069.d.ts +4 -0
  58. package/dist/testing/seed/insee/siret/41816609600069.d.ts.map +1 -0
  59. package/dist/testing/seed/insee/siret/41816609600069.js +91 -0
  60. package/dist/testing/seed/insee/siret/43841606700017.d.ts +4 -0
  61. package/dist/testing/seed/insee/siret/43841606700017.d.ts.map +1 -0
  62. package/dist/testing/seed/insee/siret/43841606700017.js +91 -0
  63. package/dist/testing/seed/insee/siret/78824266700020.d.ts +4 -0
  64. package/dist/testing/seed/insee/siret/78824266700020.d.ts.map +1 -0
  65. package/dist/testing/seed/insee/siret/78824266700020.js +91 -0
  66. package/dist/testing/seed/insee/siret/81104725700019.d.ts +4 -0
  67. package/dist/testing/seed/insee/siret/81104725700019.d.ts.map +1 -0
  68. package/dist/testing/seed/insee/siret/81104725700019.js +93 -0
  69. package/dist/testing/seed/insee/siret/82271212100018.d.ts +4 -0
  70. package/dist/testing/seed/insee/siret/82271212100018.d.ts.map +1 -0
  71. package/dist/testing/seed/insee/siret/82271212100018.js +95 -0
  72. package/dist/testing/seed/insee/siret/94957325700019.d.ts +4 -0
  73. package/dist/testing/seed/insee/siret/94957325700019.d.ts.map +1 -0
  74. package/dist/testing/seed/insee/siret/94957325700019.js +96 -0
  75. package/dist/testing/seed/insee/siret/index.d.ts +12 -0
  76. package/dist/testing/seed/insee/siret/index.d.ts.map +1 -0
  77. package/dist/testing/seed/insee/siret/index.js +14 -0
  78. package/dist/types/errors.d.ts +17 -0
  79. package/dist/types/errors.d.ts.map +1 -0
  80. package/dist/types/errors.js +37 -0
  81. package/dist/types/establishment.d.ts +8 -0
  82. package/dist/types/establishment.d.ts.map +1 -0
  83. package/dist/types/establishment.js +2 -0
  84. package/dist/types/index.d.ts +3 -0
  85. package/dist/types/index.d.ts.map +1 -0
  86. package/dist/types/index.js +3 -0
  87. package/openapi/index.d.ts +13652 -0
  88. package/package.json +50 -0
  89. package/src/api/index.ts +13 -0
  90. package/src/api/infogreffe/find-mandataires-sociaux-by-siren.test.ts +161 -0
  91. package/src/api/infogreffe/find-mandataires-sociaux-by-siren.ts +41 -0
  92. package/src/api/infogreffe/index.ts +3 -0
  93. package/src/api/insee/find-by-siren.test.ts +27 -0
  94. package/src/api/insee/find-by-siren.ts +38 -0
  95. package/src/api/insee/find-by-siret.test.ts +26 -0
  96. package/src/api/insee/find-by-siret.ts +38 -0
  97. package/src/api/insee/index.ts +4 -0
  98. package/src/client/index.ts +43 -0
  99. package/src/formatters/adresse-establishment.test.ts +55 -0
  100. package/src/formatters/adresse-establishment.ts +67 -0
  101. package/src/formatters/index.ts +6 -0
  102. package/src/formatters/libelle-from-code-effectif.test.ts +23 -0
  103. package/src/formatters/libelle-from-code-effectif.ts +16 -0
  104. package/src/formatters/main-activity.test.ts +33 -0
  105. package/src/formatters/main-activity.ts +10 -0
  106. package/src/formatters/nom-complet.test.ts +67 -0
  107. package/src/formatters/nom-complet.ts +47 -0
  108. package/src/testing/index.ts +11 -0
  109. package/src/testing/seed/insee/siret/00557246600026.ts +99 -0
  110. package/src/testing/seed/insee/siret/20007184300060.ts +93 -0
  111. package/src/testing/seed/insee/siret/21920023500014.ts +93 -0
  112. package/src/testing/seed/insee/siret/32122785200019.ts +97 -0
  113. package/src/testing/seed/insee/siret/39234600300198.ts +95 -0
  114. package/src/testing/seed/insee/siret/41816609600069.ts +93 -0
  115. package/src/testing/seed/insee/siret/43841606700017.ts +95 -0
  116. package/src/testing/seed/insee/siret/78824266700020.ts +93 -0
  117. package/src/testing/seed/insee/siret/81104725700019.ts +95 -0
  118. package/src/testing/seed/insee/siret/82271212100018.ts +98 -0
  119. package/src/testing/seed/insee/siret/94957325700019.ts +99 -0
  120. package/src/testing/seed/insee/siret/index.ts +15 -0
  121. package/src/types/errors.ts +48 -0
  122. package/src/types/establishment.ts +24 -0
  123. package/src/types/index.ts +4 -0
  124. package/tsconfig.json +12 -0
  125. package/tsconfig.lib.json +9 -0
  126. package/tsconfig.lib.tsbuildinfo +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @proconnect-gouv/proconnect.entreprise
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1497](https://github.com/proconnect-gouv/proconnect-identite/pull/1497) [`7d78714`](https://github.com/proconnect-gouv/proconnect-identite/commit/7d787149db88e8fcfeaeb840c8d6c15db72834b1) Thanks [@douglasduteil](https://github.com/douglasduteil)! - 📦 Renommé @proconnect-gouv/proconnect.api_entreprise
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [#1455](https://github.com/proconnect-gouv/proconnect-identite/pull/1455) [`38fffb0`](https://github.com/proconnect-gouv/proconnect-identite/commit/38fffb00ca5a5d2341a662f684d2555bbfb5ff02) Thanks [@douglasduteil](https://github.com/douglasduteil)! - 📦 Première version officiel des packages `@proconnect-gouv/*`
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # 📦 @proconnect-gouv/proconnect.api_entreprise
2
+
3
+ > ⚡ Typed entreprise.api.gouv.fr API for ProConnect
4
+
5
+ ## ⚙️ Installation
6
+
7
+ ```bash
8
+ npm install @proconnect-gouv/proconnect.api_entreprise
9
+ ```
10
+
11
+ ## 📖 Usage
12
+
13
+ ### `@proconnect-gouv/proconnect.api_entreprise/client"
14
+
15
+ Get full fetch client from `@proconnect-gouv/proconnect.api_entreprise/client`
16
+
17
+ ```ts
18
+ import { createApiEntrepriseOpenApiClient } from "@proconnect-gouv/proconnect.api_entreprise/client";
19
+
20
+ const apiEntrepriseOpenApiClient = createApiEntrepriseOpenApiClient(
21
+ "ENTREPRISE_API_TOKEN",
22
+ { baseUrl: "https://staging.entreprise.api.gouv.fr" },
23
+ );
24
+ ```
25
+
26
+ ### `@proconnect-gouv/proconnect.api_entreprise/api"
27
+
28
+ Get use case api factory functions from `@proconnect-gouv/proconnect.api_entreprise/api`
29
+
30
+ ```ts
31
+ import { findBySiretFactory } from "@proconnect-gouv/proconnect.api_entreprise/api/insee";
32
+
33
+ export const findBySiret = findBySiretFactory(apiEntrepriseOpenApiClient, {
34
+ context: "ProConnect",
35
+ object: "findEstablishmentBySiret",
36
+ recipient: "13002526500013",
37
+ });
38
+ ```
39
+
40
+ ### `@proconnect-gouv/proconnect.api_entreprise/types"
41
+
42
+ Get API Entreprise types and errors from `@proconnect-gouv/proconnect.api_entreprise/types`
43
+
44
+ ```ts
45
+ import type { InseeSiretEstablishment } from "@proconnect-gouv/proconnect.api_entreprise/types";
46
+
47
+ const establishment: InseeSiretEstablishment;
48
+ ```
49
+
50
+ ### `@proconnect-gouv/proconnect.api_entreprise/formatters"
51
+
52
+ Get models formatters from `@proconnect-gouv/proconnect.api_entreprise/formatters`
53
+
54
+ ```ts
55
+ import { formatMainActivity } from "@proconnect-gouv/proconnect.api_entreprise/formatters";
56
+
57
+ const libelleActivitePrincipale: formatMainActivity(activite_principale),
58
+ ```
59
+
60
+ ### `@proconnect-gouv/proconnect.api_entreprise/testing"
61
+
62
+ Used for internal tests
63
+
64
+ ## 📖 License
65
+
66
+ [MIT](./LICENSE.md)
@@ -0,0 +1,10 @@
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
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ //
2
+ export {};
@@ -0,0 +1,21 @@
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";
6
+ 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;
19
+ }[]>;
20
+ export type FindMandatairesSociauxBySirenHandler = ReturnType<typeof findMandatairesSociauxBySirenFactory>;
21
+ //# sourceMappingURL=find-mandataires-sociaux-by-siren.d.ts.map
@@ -0,0 +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;;;;;;;;;;;;;;;;KAoBlE;AAED,MAAM,MAAM,oCAAoC,GAAG,UAAU,CAC3D,OAAO,oCAAoC,CAC5C,CAAC"}
@@ -0,0 +1,20 @@
1
+ //
2
+ import { ApiEntrepriseError } from "#src/types";
3
+ //
4
+ export function findMandatairesSociauxBySirenFactory(client, trackingParams, optionsFn = () => ({})) {
5
+ return async function findMandatairesSociauxBySiren(siren) {
6
+ const { data, error } = await client.GET("/v3/infogreffe/rcs/unites_legales/{siren}/mandataires_sociaux", {
7
+ ...optionsFn(),
8
+ params: {
9
+ path: {
10
+ siren,
11
+ },
12
+ query: trackingParams,
13
+ },
14
+ });
15
+ if (error)
16
+ throw new ApiEntrepriseError(error);
17
+ const { data: peoples } = data;
18
+ return peoples.map(({ data }) => data).filter((data) => !!data);
19
+ };
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./find-mandataires-sociaux-by-siren.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/infogreffe/index.ts"],"names":[],"mappings":"AAEA,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,2 @@
1
+ //
2
+ export * from "./find-mandataires-sociaux-by-siren.js";
@@ -0,0 +1,95 @@
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<{
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
+ export type FindBySirenHandler = ReturnType<typeof findBySirenFactory>;
95
+ //# sourceMappingURL=find-by-siren.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,20 @@
1
+ //
2
+ import { ApiEntrepriseError } from "#src/types";
3
+ //
4
+ export function findBySirenFactory(client, trackingParams, optionsFn = () => ({})) {
5
+ return async function findBySiren(siren) {
6
+ const { data, error } = await client.GET("/v3/insee/sirene/unites_legales/{siren}/siege_social", {
7
+ ...optionsFn(),
8
+ params: {
9
+ path: {
10
+ siren,
11
+ },
12
+ query: trackingParams,
13
+ },
14
+ });
15
+ if (error)
16
+ throw new ApiEntrepriseError(error);
17
+ const { data: establishment } = data;
18
+ return establishment;
19
+ };
20
+ }
@@ -0,0 +1,95 @@
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<{
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
+ export type FindBySiretHandler = ReturnType<typeof findBySiretFactory>;
95
+ //# sourceMappingURL=find-by-siret.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,20 @@
1
+ //
2
+ import { ApiEntrepriseError } from "#src/types";
3
+ //
4
+ export function findBySiretFactory(client, trackingParams, optionsFn = () => ({})) {
5
+ return async function findBySiret(siret) {
6
+ const { data, error } = await client.GET("/v3/insee/sirene/etablissements/{siret}", {
7
+ ...optionsFn(),
8
+ params: {
9
+ path: {
10
+ siret,
11
+ },
12
+ query: trackingParams,
13
+ },
14
+ });
15
+ if (error)
16
+ throw new ApiEntrepriseError(error);
17
+ const { data: establishment } = data;
18
+ return establishment;
19
+ };
20
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./find-by-siren.js";
2
+ export * from "./find-by-siret.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/insee/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ //
2
+ export * from "./find-by-siren.js";
3
+ export * from "./find-by-siret.js";
@@ -0,0 +1,21 @@
1
+ import type { paths } from "#openapi";
2
+ import { type ClientOptions } from "openapi-fetch";
3
+ /**
4
+ * @see https://entreprise.api.gouv.fr/developpeurs#renseigner-les-param%C3%A8tres-dappel-et-de-tra%C3%A7abilit%C3%A9
5
+ */
6
+ export interface ApiEntrepriseTrackingParams {
7
+ recipient: string;
8
+ context: string;
9
+ object: string;
10
+ }
11
+ /**
12
+ * Create an Entreprise openapi-fetch client
13
+ * @see https://openapi-ts.dev/openapi-fetch/api#createclient
14
+ * @param token - the https://entreprise.api.gouv.fr token
15
+ * @param options - the client options
16
+ * @note `options.baseUrl` is "https://entreprise.api.gouv.fr/" by default
17
+ * @returns the client
18
+ */
19
+ export declare function createApiEntrepriseOpenApiClient(token: string, options?: ClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
20
+ export type ApiEntrepriseOpenApiClient = ReturnType<typeof createApiEntrepriseOpenApiClient>;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAIjE;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,gEAU5B;AAED,MAAM,MAAM,0BAA0B,GAAG,UAAU,CACjD,OAAO,gCAAgC,CACxC,CAAC"}
@@ -0,0 +1,21 @@
1
+ //
2
+ import createClient, {} from "openapi-fetch";
3
+ //
4
+ /**
5
+ * Create an Entreprise openapi-fetch client
6
+ * @see https://openapi-ts.dev/openapi-fetch/api#createclient
7
+ * @param token - the https://entreprise.api.gouv.fr token
8
+ * @param options - the client options
9
+ * @note `options.baseUrl` is "https://entreprise.api.gouv.fr/" by default
10
+ * @returns the client
11
+ */
12
+ export function createApiEntrepriseOpenApiClient(token, options = {}) {
13
+ return createClient({
14
+ baseUrl: options.baseUrl ?? "https://entreprise.api.gouv.fr/",
15
+ headers: {
16
+ Authorization: `Bearer ${token}`,
17
+ ...options.headers,
18
+ },
19
+ ...options,
20
+ });
21
+ }
@@ -0,0 +1,3 @@
1
+ import type { InseeAddressEstablishment } from "#src/types";
2
+ export declare function formatAddress(inseeAddress: InseeAddressEstablishment): string;
3
+ //# sourceMappingURL=adresse-establishment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adresse-establishment.d.ts","sourceRoot":"","sources":["../../src/formatters/adresse-establishment.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAe5D,wBAAgB,aAAa,CAAC,YAAY,EAAE,yBAAyB,UAuCpE"}
@@ -0,0 +1,41 @@
1
+ //
2
+ import { capitalize } from "lodash-es";
3
+ //
4
+ const emptyInseeAddressEstablishment = {
5
+ complement_adresse: null,
6
+ distribution_speciale: null,
7
+ indice_repetition_voie: null,
8
+ libelle_voie: null,
9
+ numero_voie: null,
10
+ type_voie: null,
11
+ code_postal: null,
12
+ };
13
+ export function formatAddress(inseeAddress) {
14
+ const isPartiallyNonDiffusible = inseeAddress.status_diffusion === "partiellement_diffusible";
15
+ const { complement_adresse, distribution_speciale, indice_repetition_voie, libelle_voie, numero_voie, type_voie, } = isPartiallyNonDiffusible ? emptyInseeAddressEstablishment : inseeAddress;
16
+ const { libelle_commune, code_cedex, libelle_cedex, libelle_commune_etranger, code_pays_etranger, libelle_pays_etranger, } = inseeAddress;
17
+ const code_postal = isPartiallyNonDiffusible
18
+ ? inseeAddress.code_commune
19
+ : (inseeAddress.code_postal ?? code_cedex);
20
+ return [
21
+ wrapWord(complement_adresse, ", ", true),
22
+ wrapWord(numero_voie),
23
+ wrapWord(indice_repetition_voie),
24
+ wrapWord(type_voie),
25
+ wrapWord(libelle_voie, ", "),
26
+ wrapWord(distribution_speciale, ", "),
27
+ wrapWord(code_postal),
28
+ wrapWord(libelle_commune ?? libelle_cedex ?? libelle_commune_etranger, code_pays_etranger ? ", " : "", true),
29
+ wrapWord(code_pays_etranger, ", "),
30
+ libelle_pays_etranger,
31
+ ].join("");
32
+ }
33
+ const wrapWord = (word, punct = " ", caps = false) => {
34
+ if (!word) {
35
+ return "";
36
+ }
37
+ if (caps) {
38
+ return capitalize(word) + punct;
39
+ }
40
+ return word.toString().toLowerCase() + punct;
41
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./adresse-establishment.js";
2
+ export * from "./libelle-from-code-effectif.js";
3
+ export * from "./main-activity.js";
4
+ export * from "./nom-complet.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatters/index.ts"],"names":[],"mappings":"AAEA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ //
2
+ export * from "./adresse-establishment.js";
3
+ export * from "./libelle-from-code-effectif.js";
4
+ export * from "./main-activity.js";
5
+ export * from "./nom-complet.js";
@@ -0,0 +1,2 @@
1
+ export declare const libelleFromCodeEffectif: (libelle: string | null, anneeEffectif: string | null) => string;
2
+ //# sourceMappingURL=libelle-from-code-effectif.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libelle-from-code-effectif.d.ts","sourceRoot":"","sources":["../../src/formatters/libelle-from-code-effectif.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,GAClC,SAAS,MAAM,GAAG,IAAI,EACtB,eAAe,MAAM,GAAG,IAAI,WAW7B,CAAC"}
@@ -0,0 +1,10 @@
1
+ //
2
+ export const libelleFromCodeEffectif = (libelle, anneeEffectif) => {
3
+ if (libelle && anneeEffectif) {
4
+ return `${libelle}, en ${anneeEffectif}`;
5
+ }
6
+ if (libelle) {
7
+ return libelle;
8
+ }
9
+ return "";
10
+ };
@@ -0,0 +1,3 @@
1
+ import type { InseeMainActivityEstablishment } from "#src/types";
2
+ export declare function formatMainActivity(activity: InseeMainActivityEstablishment): string;
3
+ //# sourceMappingURL=main-activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main-activity.d.ts","sourceRoot":"","sources":["../../src/formatters/main-activity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAIjE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,8BAA8B,UAG1E"}
@@ -0,0 +1,7 @@
1
+ //
2
+ //
3
+ export function formatMainActivity(activity) {
4
+ if (!activity.code)
5
+ return "Activité inconnue";
6
+ return `${activity.code} - ${activity.libelle}`;
7
+ }
@@ -0,0 +1,10 @@
1
+ type FormatNomCompletArgs = {
2
+ denominationUniteLegale: string;
3
+ prenomUsuelUniteLegale: string | null;
4
+ nomUniteLegale: string | null;
5
+ nomUsageUniteLegale: string | null;
6
+ sigleUniteLegale: string | null;
7
+ };
8
+ export declare const formatNomComplet: ({ denominationUniteLegale, prenomUsuelUniteLegale, nomUniteLegale, nomUsageUniteLegale, sigleUniteLegale, }: FormatNomCompletArgs) => string;
9
+ export {};
10
+ //# sourceMappingURL=nom-complet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nom-complet.d.ts","sourceRoot":"","sources":["../../src/formatters/nom-complet.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG;IAC1B,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,6GAM9B,oBAAoB,WAWtB,CAAC"}
@@ -0,0 +1,22 @@
1
+ //
2
+ import { capitalize } from "lodash-es";
3
+ export const formatNomComplet = ({ denominationUniteLegale, prenomUsuelUniteLegale, nomUniteLegale, nomUsageUniteLegale, sigleUniteLegale, }) => {
4
+ const formattedFirstName = formatFirstNames([prenomUsuelUniteLegale ?? ""]);
5
+ const formattedName = formatNameFull(nomUniteLegale ?? "", nomUsageUniteLegale ?? "");
6
+ return `${capitalize(denominationUniteLegale) ||
7
+ [formattedFirstName, formattedName].filter((e) => !!e).join(" ") ||
8
+ "Nom inconnu"}${sigleUniteLegale ? ` (${sigleUniteLegale})` : ""}`;
9
+ };
10
+ const formatFirstNames = (firstNames, nameCount = 0) => {
11
+ const formatted = firstNames.map(capitalize).filter((name) => !!name);
12
+ if (nameCount > 0 && nameCount < firstNames.length) {
13
+ return formatted.slice(0, nameCount).join(", ");
14
+ }
15
+ return formatted.join(", ");
16
+ };
17
+ const formatNameFull = (nomPatronymique = "", nomUsage = "") => {
18
+ if (nomUsage && nomPatronymique) {
19
+ return `${capitalize(nomUsage)} (${capitalize(nomPatronymique)})`;
20
+ }
21
+ return capitalize(nomUsage || nomPatronymique || "");
22
+ };
@@ -0,0 +1,3 @@
1
+ import type { ApiEntrepriseTrackingParams } from "#src/client";
2
+ export declare const coolTrackingParams: ApiEntrepriseTrackingParams;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAI/D,eAAO,MAAM,kBAAkB,EAAE,2BAIhC,CAAC"}
@@ -0,0 +1,7 @@
1
+ //
2
+ //
3
+ export const coolTrackingParams = {
4
+ context: "🎛️",
5
+ recipient: "🏢",
6
+ object: "📦",
7
+ };
@@ -0,0 +1,4 @@
1
+ import type { InseeSireneEstablishmentSiretResponseData } from "#src/types";
2
+ declare const _default: InseeSireneEstablishmentSiretResponseData;
3
+ export default _default;
4
+ //# sourceMappingURL=00557246600026.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"00557246600026.d.ts","sourceRoot":"","sources":["../../../../../src/testing/seed/insee/siret/00557246600026.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,YAAY,CAAC;wBA4FvE,yCAAyC;AA1F9C,wBA0F+C"}