@proconnect-gouv/proconnect.insee 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @proconnect-gouv/proconnect.insee
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1843](https://github.com/proconnect-gouv/proconnect-identite/pull/1843) [`054f11c`](https://github.com/proconnect-gouv/proconnect-identite/commit/054f11cbb15b5ab9708ee4aefc52695a7eaabb91) Thanks [@douglasduteil](https://github.com/douglasduteil)! - ♻️ Changement de nom des apis
8
+
9
+ ## 1.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1577](https://github.com/proconnect-gouv/proconnect-identite/pull/1577) [`e2cc9d1`](https://github.com/proconnect-gouv/proconnect-identite/commit/e2cc9d1fec67acb4f6bf7bb437bf78da8f816c3f) Thanks [@arnaud-robin](https://github.com/arnaud-robin)! - 🧪 Mise a jour de l'algo de certification
14
+
3
15
  ## 1.0.0
4
16
 
5
17
  ### Major Changes
@@ -0,0 +1,58 @@
1
+ import type { InseeSirenePrivateOpenApiClient } from "#src/client";
2
+ export declare function findUniteLegaleBySirenFactory(client: InseeSirenePrivateOpenApiClient): (siren: string) => Promise<{
3
+ score?: number | undefined;
4
+ siren?: string | undefined;
5
+ statutDiffusionUniteLegale?: string | undefined;
6
+ unitePurgeeUniteLegale?: boolean | undefined;
7
+ dateCreationUniteLegale?: string | undefined;
8
+ dateNaissanceUniteLegale?: string | undefined;
9
+ codeCommuneNaissanceUniteLegale?: string | undefined;
10
+ codePaysNaissanceUniteLegale?: string | undefined;
11
+ libelleNationaliteUniteLegale?: string | undefined;
12
+ identifiantAssociationUniteLegale?: string | undefined;
13
+ trancheEffectifsUniteLegale?: string | undefined;
14
+ anneeEffectifsUniteLegale?: string | undefined;
15
+ dateDernierTraitementUniteLegale?: string | undefined;
16
+ nombrePeriodesUniteLegale?: number | undefined;
17
+ categorieEntreprise?: "PME" | "ETI" | "GE" | null | undefined;
18
+ anneeCategorieEntreprise?: string | undefined;
19
+ sigleUniteLegale?: string | undefined;
20
+ sexeUniteLegale?: "M" | "F" | null | undefined;
21
+ prenom1UniteLegale?: string | undefined;
22
+ prenom2UniteLegale?: string | undefined;
23
+ prenom3UniteLegale?: string | undefined;
24
+ prenom4UniteLegale?: string | undefined;
25
+ prenomUsuelUniteLegale?: string | undefined;
26
+ pseudonymeUniteLegale?: string | undefined;
27
+ periodesUniteLegale?: {
28
+ dateFin?: string | null | undefined;
29
+ dateDebut?: string | undefined;
30
+ etatAdministratifUniteLegale?: "A" | "C" | undefined;
31
+ changementEtatAdministratifUniteLegale?: boolean | undefined;
32
+ nomUniteLegale?: string | undefined;
33
+ changementNomUniteLegale?: boolean | undefined;
34
+ nomUsageUniteLegale?: string | undefined;
35
+ changementNomUsageUniteLegale?: boolean | undefined;
36
+ denominationUniteLegale?: string | undefined;
37
+ changementDenominationUniteLegale?: boolean | undefined;
38
+ denominationUsuelle1UniteLegale?: string | undefined;
39
+ denominationUsuelle2UniteLegale?: string | undefined;
40
+ denominationUsuelle3UniteLegale?: string | undefined;
41
+ categorieJuridiqueUniteLegale?: string | undefined;
42
+ changementCategorieJuridiqueUniteLegale?: boolean | undefined;
43
+ activitePrincipaleUniteLegale?: string | undefined;
44
+ nomenclatureActivitePrincipaleUniteLegale?: "NAP" | "NAFRev1" | "NAFRev2" | "NAF1993" | undefined;
45
+ changementActivitePrincipaleUniteLegale?: boolean | undefined;
46
+ nicSiegeUniteLegale?: string | undefined;
47
+ changementNicSiegeUniteLegale?: boolean | undefined;
48
+ economieSocialeSolidaireUniteLegale?: string | undefined;
49
+ changementEconomieSocialeSolidaireUniteLegale?: boolean | undefined;
50
+ societeMissionUniteLegale?: string | undefined;
51
+ changementSocieteMissionUniteLegale?: boolean | undefined;
52
+ caractereEmployeurUniteLegale?: "O" | "N" | null | undefined;
53
+ changementCaractereEmployeurUniteLegale?: boolean | undefined;
54
+ changementDenominationUsuelleUniteLegale?: boolean | undefined;
55
+ }[] | undefined;
56
+ }>;
57
+ export type FindUniteLegaleBySirenHandler = ReturnType<typeof findUniteLegaleBySirenFactory>;
58
+ //# sourceMappingURL=find-by-siren.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-by-siren.d.ts","sourceRoot":"","sources":["../../src/api/find-by-siren.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAKnE,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,+BAA+B,IAEM,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkC3D;AAED,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,6BAA6B,CACrC,CAAC"}
@@ -0,0 +1,33 @@
1
+ //
2
+ import { InseeApiError } from "#src/types";
3
+ //
4
+ export function findUniteLegaleBySirenFactory(client) {
5
+ return async function findUniteLegaleBySiren(siren) {
6
+ const { data, error } = await client.GET("/siren/{siren}", {
7
+ params: {
8
+ path: {
9
+ siren,
10
+ },
11
+ },
12
+ });
13
+ if (error)
14
+ throw new InseeApiError(error);
15
+ if (!data)
16
+ throw new InseeApiError({
17
+ header: { statut: 404, message: "Not Data" },
18
+ });
19
+ if (!data.uniteLegale)
20
+ throw new InseeApiError({
21
+ header: { statut: 404, message: "Not unite legale" },
22
+ });
23
+ const nomUniteLegale = data.uniteLegale.periodesUniteLegale?.find((periode) => periode.dateFin === null)?.nomUniteLegale;
24
+ if (!nomUniteLegale)
25
+ throw new InseeApiError({
26
+ header: {
27
+ statut: 409,
28
+ message: "Not active periode with nomUniteLegale",
29
+ },
30
+ });
31
+ return data.uniteLegale;
32
+ };
33
+ }
@@ -1,22 +1,40 @@
1
1
  import type { InseeSirenePrivateOpenApiClient } from "#src/client";
2
- import type { FetchOptions } from "openapi-fetch";
3
- export declare function findBySiretFactory(client: InseeSirenePrivateOpenApiClient, optionsFn?: () => FetchOptions<unknown>): (siret: string) => Promise<{
4
- score?: number;
5
- siren?: string;
6
- nic?: string;
7
- siret?: string;
8
- statutDiffusionEtablissement?: string;
9
- dateCreationEtablissement?: string;
10
- trancheEffectifsEtablissement?: string;
11
- anneeEffectifsEtablissement?: string;
12
- activitePrincipaleRegistreMetiersEtablissement?: string;
13
- dateDernierTraitementEtablissement?: string;
14
- etablissementSiege?: boolean;
15
- nombrePeriodesEtablissement?: number;
16
- uniteLegale?: import("../../openapi/index.js").components["schemas"]["UniteLegaleEtablissement"];
17
- adresseEtablissement?: import("../../openapi/index.js").components["schemas"]["Adresse"];
18
- adresse2Etablissement?: import("../../openapi/index.js").components["schemas"]["AdresseComplementaire"];
19
- periodesEtablissement?: import("../../openapi/index.js").components["schemas"]["PeriodeEtablissement"][];
2
+ export declare function findUniteLegaleBySiretFactory(client: InseeSirenePrivateOpenApiClient): (siret: string) => Promise<{
3
+ statutDiffusionUniteLegale?: string | undefined;
4
+ unitePurgeeUniteLegale?: boolean | undefined;
5
+ dateCreationUniteLegale?: string | undefined;
6
+ dateNaissanceUniteLegale?: string | undefined;
7
+ codeCommuneNaissanceUniteLegale?: string | undefined;
8
+ codePaysNaissanceUniteLegale?: string | undefined;
9
+ libelleNationaliteUniteLegale?: string | undefined;
10
+ identifiantAssociationUniteLegale?: string | undefined;
11
+ trancheEffectifsUniteLegale?: string | undefined;
12
+ anneeEffectifsUniteLegale?: string | undefined;
13
+ dateDernierTraitementUniteLegale?: string | undefined;
14
+ categorieEntreprise?: "PME" | "ETI" | "GE" | null | undefined;
15
+ anneeCategorieEntreprise?: string | undefined;
16
+ sigleUniteLegale?: string | undefined;
17
+ sexeUniteLegale?: "M" | "F" | null | undefined;
18
+ prenom1UniteLegale?: string | undefined;
19
+ prenom2UniteLegale?: string | undefined;
20
+ prenom3UniteLegale?: string | undefined;
21
+ prenom4UniteLegale?: string | undefined;
22
+ prenomUsuelUniteLegale?: string | undefined;
23
+ pseudonymeUniteLegale?: string | undefined;
24
+ etatAdministratifUniteLegale?: "A" | "C" | undefined;
25
+ nomUniteLegale?: string | undefined;
26
+ denominationUniteLegale?: string | undefined;
27
+ denominationUsuelle1UniteLegale?: string | undefined;
28
+ denominationUsuelle2UniteLegale?: string | undefined;
29
+ denominationUsuelle3UniteLegale?: string | undefined;
30
+ activitePrincipaleUniteLegale?: string | undefined;
31
+ categorieJuridiqueUniteLegale?: string | undefined;
32
+ nicSiegeUniteLegale?: string | undefined;
33
+ nomenclatureActivitePrincipaleUniteLegale?: "NAP" | "NAFRev1" | "NAFRev2" | "NAF1993" | undefined;
34
+ nomUsageUniteLegale?: string | undefined;
35
+ economieSocialeSolidaireUniteLegale?: string | undefined;
36
+ societeMissionUniteLegale?: string | undefined;
37
+ caractereEmployeurUniteLegale?: "O" | "N" | null | undefined;
20
38
  }>;
21
- export type FindBySiretHandler = ReturnType<typeof findBySiretFactory>;
39
+ export type FindUniteLegaleBySiretHandler = ReturnType<typeof findUniteLegaleBySiretFactory>;
22
40
  //# sourceMappingURL=find-by-siret.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-by-siret.d.ts","sourceRoot":"","sources":["../../src/api/find-by-siret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,+BAA+B,EACvC,SAAS,GAAE,MAAM,YAAY,CAAC,OAAO,CAAc,IAEjB,OAAO,MAAM;;;;;;;;;;;;;kBAwBmhR,sDAAsB;2BAA0D,sDAAsB;4BAA0C,sDAAsB;4BAAwD,sDAAsB;GAHvzR;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"find-by-siret.d.ts","sourceRoot":"","sources":["../../src/api/find-by-siret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAKnE,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,+BAA+B,IAEM,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyB3D;AAED,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,6BAA6B,CACrC,CAAC"}
@@ -1,10 +1,9 @@
1
1
  //
2
2
  import { InseeApiError } from "#src/types";
3
3
  //
4
- export function findBySiretFactory(client, optionsFn = () => ({})) {
5
- return async function findBySiret(siret) {
4
+ export function findUniteLegaleBySiretFactory(client) {
5
+ return async function findUniteLegaleBySiret(siret) {
6
6
  const { data, error } = await client.GET("/siret/{siret}", {
7
- ...optionsFn(),
8
7
  params: {
9
8
  path: {
10
9
  siret,
@@ -19,6 +18,10 @@ export function findBySiretFactory(client, optionsFn = () => ({})) {
19
18
  });
20
19
  if (data.header?.statut !== 200 || !data.etablissement)
21
20
  throw new InseeApiError(data);
22
- return data.etablissement;
21
+ if (!data.etablissement.uniteLegale)
22
+ throw new InseeApiError({
23
+ header: { statut: 404, message: "Not unite legale" },
24
+ });
25
+ return data.etablissement.uniteLegale;
23
26
  };
24
27
  }
@@ -1,9 +1,98 @@
1
- import type { FindBySiretHandler } from "./find-by-siret.js";
2
- import type { GetInseeAccessTokenHandler } from "./get-insee-access-token.js";
3
- export * from "./find-by-siret.js";
1
+ import type { InseeSirenePrivateOpenApiClient } from "#src/client";
4
2
  export * from "./get-insee-access-token.js";
5
- export interface InseeApiRepository {
6
- getInseeAccessToken: GetInseeAccessTokenHandler;
7
- findBySiret: FindBySiretHandler;
8
- }
3
+ export declare function createApiInseeClient(client: InseeSirenePrivateOpenApiClient, getAuthorizationToken: () => Promise<string>): {
4
+ findBySiren: (siren: string) => Promise<{
5
+ score?: number | undefined;
6
+ siren?: string | undefined;
7
+ statutDiffusionUniteLegale?: string | undefined;
8
+ unitePurgeeUniteLegale?: boolean | undefined;
9
+ dateCreationUniteLegale?: string | undefined;
10
+ dateNaissanceUniteLegale?: string | undefined;
11
+ codeCommuneNaissanceUniteLegale?: string | undefined;
12
+ codePaysNaissanceUniteLegale?: string | undefined;
13
+ libelleNationaliteUniteLegale?: string | undefined;
14
+ identifiantAssociationUniteLegale?: string | undefined;
15
+ trancheEffectifsUniteLegale?: string | undefined;
16
+ anneeEffectifsUniteLegale?: string | undefined;
17
+ dateDernierTraitementUniteLegale?: string | undefined;
18
+ nombrePeriodesUniteLegale?: number | undefined;
19
+ categorieEntreprise?: "PME" | "ETI" | "GE" | null | undefined;
20
+ anneeCategorieEntreprise?: string | undefined;
21
+ sigleUniteLegale?: string | undefined;
22
+ sexeUniteLegale?: "M" | "F" | null | undefined;
23
+ prenom1UniteLegale?: string | undefined;
24
+ prenom2UniteLegale?: string | undefined;
25
+ prenom3UniteLegale?: string | undefined;
26
+ prenom4UniteLegale?: string | undefined;
27
+ prenomUsuelUniteLegale?: string | undefined;
28
+ pseudonymeUniteLegale?: string | undefined;
29
+ periodesUniteLegale?: {
30
+ dateFin?: string | null | undefined;
31
+ dateDebut?: string | undefined;
32
+ etatAdministratifUniteLegale?: "A" | "C" | undefined;
33
+ changementEtatAdministratifUniteLegale?: boolean | undefined;
34
+ nomUniteLegale?: string | undefined;
35
+ changementNomUniteLegale?: boolean | undefined;
36
+ nomUsageUniteLegale?: string | undefined;
37
+ changementNomUsageUniteLegale?: boolean | undefined;
38
+ denominationUniteLegale?: string | undefined;
39
+ changementDenominationUniteLegale?: boolean | undefined;
40
+ denominationUsuelle1UniteLegale?: string | undefined;
41
+ denominationUsuelle2UniteLegale?: string | undefined;
42
+ denominationUsuelle3UniteLegale?: string | undefined;
43
+ categorieJuridiqueUniteLegale?: string | undefined;
44
+ changementCategorieJuridiqueUniteLegale?: boolean | undefined;
45
+ activitePrincipaleUniteLegale?: string | undefined;
46
+ nomenclatureActivitePrincipaleUniteLegale?: "NAP" | "NAFRev1" | "NAFRev2" | "NAF1993" | undefined;
47
+ changementActivitePrincipaleUniteLegale?: boolean | undefined;
48
+ nicSiegeUniteLegale?: string | undefined;
49
+ changementNicSiegeUniteLegale?: boolean | undefined;
50
+ economieSocialeSolidaireUniteLegale?: string | undefined;
51
+ changementEconomieSocialeSolidaireUniteLegale?: boolean | undefined;
52
+ societeMissionUniteLegale?: string | undefined;
53
+ changementSocieteMissionUniteLegale?: boolean | undefined;
54
+ caractereEmployeurUniteLegale?: "O" | "N" | null | undefined;
55
+ changementCaractereEmployeurUniteLegale?: boolean | undefined;
56
+ changementDenominationUsuelleUniteLegale?: boolean | undefined;
57
+ }[] | undefined;
58
+ }>;
59
+ findBySiret: (siret: string) => Promise<{
60
+ statutDiffusionUniteLegale?: string | undefined;
61
+ unitePurgeeUniteLegale?: boolean | undefined;
62
+ dateCreationUniteLegale?: string | undefined;
63
+ dateNaissanceUniteLegale?: string | undefined;
64
+ codeCommuneNaissanceUniteLegale?: string | undefined;
65
+ codePaysNaissanceUniteLegale?: string | undefined;
66
+ libelleNationaliteUniteLegale?: string | undefined;
67
+ identifiantAssociationUniteLegale?: string | undefined;
68
+ trancheEffectifsUniteLegale?: string | undefined;
69
+ anneeEffectifsUniteLegale?: string | undefined;
70
+ dateDernierTraitementUniteLegale?: string | undefined;
71
+ categorieEntreprise?: "PME" | "ETI" | "GE" | null | undefined;
72
+ anneeCategorieEntreprise?: string | undefined;
73
+ sigleUniteLegale?: string | undefined;
74
+ sexeUniteLegale?: "M" | "F" | null | undefined;
75
+ prenom1UniteLegale?: string | undefined;
76
+ prenom2UniteLegale?: string | undefined;
77
+ prenom3UniteLegale?: string | undefined;
78
+ prenom4UniteLegale?: string | undefined;
79
+ prenomUsuelUniteLegale?: string | undefined;
80
+ pseudonymeUniteLegale?: string | undefined;
81
+ etatAdministratifUniteLegale?: "A" | "C" | undefined;
82
+ nomUniteLegale?: string | undefined;
83
+ denominationUniteLegale?: string | undefined;
84
+ denominationUsuelle1UniteLegale?: string | undefined;
85
+ denominationUsuelle2UniteLegale?: string | undefined;
86
+ denominationUsuelle3UniteLegale?: string | undefined;
87
+ activitePrincipaleUniteLegale?: string | undefined;
88
+ categorieJuridiqueUniteLegale?: string | undefined;
89
+ nicSiegeUniteLegale?: string | undefined;
90
+ nomenclatureActivitePrincipaleUniteLegale?: "NAP" | "NAFRev1" | "NAFRev2" | "NAF1993" | undefined;
91
+ nomUsageUniteLegale?: string | undefined;
92
+ economieSocialeSolidaireUniteLegale?: string | undefined;
93
+ societeMissionUniteLegale?: string | undefined;
94
+ caractereEmployeurUniteLegale?: "O" | "N" | null | undefined;
95
+ }>;
96
+ };
97
+ export type ApiInseeClient = ReturnType<typeof createApiInseeClient>;
9
98
  //# 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,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAI9E,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAI5C,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,EAAE,0BAA0B,CAAC;IAChD,WAAW,EAAE,kBAAkB,CAAC;CACjC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAInE,cAAc,6BAA6B,CAAC;AAE5C,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,+BAA+B,EACvC,qBAAqB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa7C;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
package/dist/api/index.js CHANGED
@@ -1,4 +1,17 @@
1
1
  //
2
- //
3
- export * from "./find-by-siret.js";
2
+ import { findUniteLegaleBySirenFactory } from "./find-by-siren.js";
3
+ import { findUniteLegaleBySiretFactory } from "./find-by-siret.js";
4
4
  export * from "./get-insee-access-token.js";
5
+ export function createApiInseeClient(client, getAuthorizationToken) {
6
+ client.use({
7
+ async onRequest({ request }) {
8
+ const token = await getAuthorizationToken();
9
+ request.headers.set("Authorization", `Bearer ${token}`);
10
+ return request;
11
+ },
12
+ });
13
+ return {
14
+ findBySiren: findUniteLegaleBySirenFactory(client),
15
+ findBySiret: findUniteLegaleBySiretFactory(client),
16
+ };
17
+ }
@@ -7,6 +7,6 @@ import { type ClientOptions } from "openapi-fetch";
7
7
  * @note `options.baseUrl` is "https://api.insee.fr/api-sirene/prive/3.11" by default
8
8
  * @returns the client
9
9
  */
10
- export declare function createInseeSirenePrivateOpenApiClient(token: string, options?: ClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
10
+ export declare function createInseeSirenePrivateOpenApiClient(options?: ClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
11
11
  export type InseeSirenePrivateOpenApiClient = ReturnType<typeof createInseeSirenePrivateOpenApiClient>;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,gEAS5B;AAED,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,qCAAqC,CAC7C,CAAC"}
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;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACnD,OAAO,GAAE,aAAkB,gEAM5B;AAED,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,qCAAqC,CAC7C,CAAC"}
@@ -8,12 +8,9 @@ import createClient, {} from "openapi-fetch";
8
8
  * @note `options.baseUrl` is "https://api.insee.fr/api-sirene/prive/3.11" by default
9
9
  * @returns the client
10
10
  */
11
- export function createInseeSirenePrivateOpenApiClient(token, options = {}) {
11
+ export function createInseeSirenePrivateOpenApiClient(options = {}) {
12
12
  return createClient({
13
13
  baseUrl: options.baseUrl ?? "https://api.insee.fr/api-sirene/prive/3.11",
14
- headers: {
15
- Authorization: `Bearer ${token}`,
16
- },
17
14
  ...options,
18
15
  });
19
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"birthdate.d.ts","sourceRoot":"","sources":["../../src/formatters/birthdate.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,QAc5C"}
1
+ {"version":3,"file":"birthdate.d.ts","sourceRoot":"","sources":["../../src/formatters/birthdate.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,QAgB5C"}
@@ -11,7 +11,9 @@ export function formatBirthdate(value) {
11
11
  throw new Error(`Invalid date format. Expected YYYYMMDD. Actual: ${value}`);
12
12
  }
13
13
  const { year, month, day } = match.groups;
14
- const date = new Date(`${year}-${month}-${day}`);
14
+ // Use Date.UTC to ensure timezone-independent date creation
15
+ // Month is 0-indexed in Date.UTC
16
+ const date = new Date(Date.UTC(Number(year), Number(month) - 1, Number(day)));
15
17
  if (isNaN(date.getTime())) {
16
18
  throw new Error(`Invalid date format. ${year}-${month}-${day}`);
17
19
  }
@@ -0,0 +1,4 @@
1
+ import type { InseSirenUniteLegale } from "#src/types";
2
+ export declare const LiElJonsonEstablishment: InseSirenUniteLegale;
3
+ export declare const RogalDornEstablishment: InseSirenUniteLegale;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/seed/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,uBAAuB,EAAE,oBAOrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,oBAOpC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export const LiElJonsonEstablishment = {
2
+ codePaysNaissanceUniteLegale: undefined,
3
+ codeCommuneNaissanceUniteLegale: "75056",
4
+ dateNaissanceUniteLegale: "285000205",
5
+ periodesUniteLegale: [{ dateFin: null, nomUniteLegale: "EL'JONSON" }],
6
+ prenom1UniteLegale: "LION",
7
+ sexeUniteLegale: "M",
8
+ };
9
+ export const RogalDornEstablishment = {
10
+ codePaysNaissanceUniteLegale: "99102",
11
+ codeCommuneNaissanceUniteLegale: undefined,
12
+ dateNaissanceUniteLegale: "290000107",
13
+ periodesUniteLegale: [{ dateFin: null, nomUniteLegale: "DORN" }],
14
+ prenom1UniteLegale: "ROGAL",
15
+ sexeUniteLegale: "M",
16
+ };
@@ -1,4 +1,4 @@
1
1
  import type { paths } from "#openapi";
2
- export type InseeSiretResponse = paths["/siret/{siret}"]["get"]["responses"][200]["content"]["application/json"];
3
- export type InseeSiretEstablishment = NonNullable<InseeSiretResponse["etablissement"]>;
2
+ export type InseeSirenResponse = paths["/siren/{siren}"]["get"]["responses"][200]["content"]["application/json"];
3
+ export type InseSirenUniteLegale = NonNullable<InseeSirenResponse["uniteLegale"]>;
4
4
  //# sourceMappingURL=etablissement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"etablissement.d.ts","sourceRoot":"","sources":["../../src/types/etablissement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAItC,MAAM,MAAM,kBAAkB,GAC5B,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAElF,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAC/C,kBAAkB,CAAC,eAAe,CAAC,CACpC,CAAC"}
1
+ {"version":3,"file":"etablissement.d.ts","sourceRoot":"","sources":["../../src/types/etablissement.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAItC,MAAM,MAAM,kBAAkB,GAC5B,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC;AAElF,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAC5C,kBAAkB,CAAC,aAAa,CAAC,CAClC,CAAC"}
@@ -319,7 +319,7 @@ export interface components {
319
319
  * Format: date
320
320
  * @description Date de fin de la période, null pour la dernière période, format AAAA-MM-DD
321
321
  */
322
- dateFin?: string;
322
+ dateFin?: string | null;
323
323
  /**
324
324
  * Format: date
325
325
  * @description Date de début de la période, format AAAA-MM-DD
@@ -337,7 +337,7 @@ export interface components {
337
337
  enseigne3Etablissement?: string;
338
338
  /** @description Indicatrice de changement de l'enseigne de l'établissement par rapport à la période précédente (un seul indicateur pour les trois variables Enseigne1, Enseigne2 et Enseigne3). Un seul indicateur pour les trois variables enseigne */
339
339
  changementEnseigneEtablissement?: boolean;
340
- /** @description Nom sous lequel l’activité de l’établissement est connu du public */
340
+ /** @description Nom sous lequel l’activité de l’établissement est connu du public */
341
341
  denominationUsuelleEtablissement?: string;
342
342
  /** @description Indicatrice de changement de la dénomination usuelle de l’établissement par rapport à la période précédente */
343
343
  changementDenominationUsuelleEtablissement?: boolean;
@@ -347,7 +347,11 @@ export interface components {
347
347
  * @description Nomenclature de l'activité, permet de savoir à partir de quelle nomenclature est codifiée ActivitePrincipaleEtablissement
348
348
  * @enum {string}
349
349
  */
350
- nomenclatureActivitePrincipaleEtablissement?: "NAP,NAFRev1,NAFRev2,NAF1993";
350
+ nomenclatureActivitePrincipaleEtablissement?:
351
+ | "NAP"
352
+ | "NAFRev1"
353
+ | "NAFRev2"
354
+ | "NAF1993";
351
355
  /** @description Indicatrice de changement de l'activité principale de l'établissement par rapport à la période précédente */
352
356
  changementActivitePrincipaleEtablissement?: boolean;
353
357
  /** @description Caractère employeur de l'établissement (O=oui, N=non, null=sans objet) */
@@ -374,6 +378,7 @@ export interface components {
374
378
  * Format: date
375
379
  * @description Date de création de l'unité légale
376
380
  * @example AAAA-MM-JJ
381
+ * @example 1955-01-01
377
382
  */
378
383
  dateCreationUniteLegale?: string;
379
384
  /** @description L’accès à ces données est soumis à une démarche auprès de la Commission nationale de l’informatique et des libertés. Date de naissance pour la personne physique sinon null */
@@ -399,7 +404,7 @@ export interface components {
399
404
  * @description Catégorie à laquelle appartient l'entreprise : Petite ou moyenne entreprise, Entreprise de taille intermédiaire, Grande entreprise
400
405
  * @enum {string}
401
406
  */
402
- categorieEntreprise?: "PME,ETI,GE,null";
407
+ categorieEntreprise?: "PME" | "ETI" | "GE" | null;
403
408
  /** @description Année de validité de la catégorie d'entreprise */
404
409
  anneeCategorieEntreprise?: string;
405
410
  /** @description Sigle de l'unité légale */
@@ -408,7 +413,7 @@ export interface components {
408
413
  * @description Sexe pour les personnes physiques sinon null
409
414
  * @enum {string}
410
415
  */
411
- sexeUniteLegale?: "M,F,null";
416
+ sexeUniteLegale?: "M" | "F" | null;
412
417
  /** @description Premier prénom déclaré pour une personne physique, peut être null dans le cas d'une unité purgée */
413
418
  prenom1UniteLegale?: string;
414
419
  /** @description Deuxième prénom déclaré pour une personne physique */
@@ -425,7 +430,7 @@ export interface components {
425
430
  * @description État de l'entreprise pendant la période (A= entreprise active, C= entreprise cessée)
426
431
  * @enum {string}
427
432
  */
428
- etatAdministratifUniteLegale?: "A,C";
433
+ etatAdministratifUniteLegale?: "A" | "C";
429
434
  /** @description Nom de naissance pour les personnes physiques pour la période (null pour les personnes morales) */
430
435
  nomUniteLegale?: string;
431
436
  /** @description Raison sociale (personnes morales) */
@@ -446,7 +451,11 @@ export interface components {
446
451
  * @description Nomenclature de l'activité, permet de savoir à partir de quelle nomenclature est codifiée ActivitePrincipale
447
452
  * @enum {string}
448
453
  */
449
- nomenclatureActivitePrincipaleUniteLegale?: "NAP,NAFRev1,NAFRev2,NAF1993";
454
+ nomenclatureActivitePrincipaleUniteLegale?:
455
+ | "NAP"
456
+ | "NAFRev1"
457
+ | "NAFRev2"
458
+ | "NAF1993";
450
459
  /** @description Nom d’usage pour les personnes physiques sinon null */
451
460
  nomUsageUniteLegale?: string;
452
461
  /** @description Appartenance de l’unité légale au champ de l’économie sociale et solidaire (ESS) */
@@ -457,7 +466,7 @@ export interface components {
457
466
  * @description Caractère employeur de l'entreprise. Valeur courante=O si au moins l'un des établissements actifs de l'unité légale emploie des salariés
458
467
  * @enum {string}
459
468
  */
460
- caractereEmployeurUniteLegale?: "O,N,null";
469
+ caractereEmployeurUniteLegale?: "O" | "N" | null;
461
470
  };
462
471
  ReponseErreur: {
463
472
  header?: components["schemas"]["Header"];
@@ -514,7 +523,7 @@ export interface components {
514
523
  * Format: date
515
524
  * @description Date de fin de la période, null pour la dernière période, format AAAA-MM-DD
516
525
  */
517
- dateFin?: string;
526
+ dateFin?: string | null;
518
527
  /**
519
528
  * Format: date
520
529
  * @description Date de début de la période, format AAAA-MM-DD
@@ -524,7 +533,7 @@ export interface components {
524
533
  * @description État de l'entreprise pendant la période (A= entreprise active, C= entreprise cessée)
525
534
  * @enum {string}
526
535
  */
527
- etatAdministratifUniteLegale?: "A,C";
536
+ etatAdministratifUniteLegale?: "A" | "C";
528
537
  /** @description Indicatrice de changement d'état par rapport à la période précédente */
529
538
  changementEtatAdministratifUniteLegale?: boolean;
530
539
  /** @description Nom de naissance pour les personnes physiques pour la période (null pour les personnes morales) */
@@ -555,7 +564,11 @@ export interface components {
555
564
  * @description Nomenclature de l'activité, permet de savoir à partir de quelle nomenclature est codifiée ActivitePrincipale
556
565
  * @enum {string}
557
566
  */
558
- nomenclatureActivitePrincipaleUniteLegale?: "NAP,NAFRev1,NAFRev2,NAF1993";
567
+ nomenclatureActivitePrincipaleUniteLegale?:
568
+ | "NAP"
569
+ | "NAFRev1"
570
+ | "NAFRev2"
571
+ | "NAF1993";
559
572
  /** @description Indicatrice de changement de l'activité principale par rapport à la période précédente */
560
573
  changementActivitePrincipaleUniteLegale?: boolean;
561
574
  /** @description Identifiant du siège pour la période (le Siret du siège est obtenu en concaténant le numéro Siren et le Nic) */
@@ -574,7 +587,7 @@ export interface components {
574
587
  * @description Caractère employeur de l'entreprise. Valeur courante=O si au moins l'un des établissements actifs de l'unité légale emploie des salariés
575
588
  * @enum {string}
576
589
  */
577
- caractereEmployeurUniteLegale?: "O,N,null";
590
+ caractereEmployeurUniteLegale?: "O" | "N" | null;
578
591
  /** @description Indicatrice de changement du caractère employeur par rapport à la période précédente */
579
592
  changementCaractereEmployeurUniteLegale?: boolean;
580
593
  /** @description Indicatrice de changement de la dénomination par rapport à la période précédente */
@@ -608,6 +621,7 @@ export interface components {
608
621
  * Format: date
609
622
  * @description Date de création de l'unité légale
610
623
  * @example AAAA-MM-JJ
624
+ * @example 1955-01-01
611
625
  */
612
626
  dateCreationUniteLegale?: string;
613
627
  /** @description L’accès à ces données est soumis à une démarche auprès de la Commission nationale de l’informatique et des libertés. Date de naissance pour la personne physique sinon null */
@@ -638,7 +652,7 @@ export interface components {
638
652
  * @description Catégorie à laquelle appartient l'entreprise : Petite ou moyenne entreprise, Entreprise de taille intermédiaire, Grande entreprise
639
653
  * @enum {string}
640
654
  */
641
- categorieEntreprise?: "PME,ETI,GE,null";
655
+ categorieEntreprise?: "PME" | "ETI" | "GE" | null;
642
656
  /** @description Année de validité de la catégorie d'entreprise */
643
657
  anneeCategorieEntreprise?: string;
644
658
  /** @description Sigle de l'unité légale */
@@ -647,7 +661,7 @@ export interface components {
647
661
  * @description Sexe pour les personnes physiques sinon null
648
662
  * @enum {string}
649
663
  */
650
- sexeUniteLegale?: "M,F,null";
664
+ sexeUniteLegale?: "M" | "F" | null;
651
665
  /** @description Premier prénom déclaré pour une personne physique, peut être null dans le cas d'une unité purgée */
652
666
  prenom1UniteLegale?: string;
653
667
  /** @description Deuxième prénom déclaré pour une personne physique */
@@ -751,7 +765,7 @@ export interface components {
751
765
  * @description Nom de la collection
752
766
  * @enum {string}
753
767
  */
754
- collection?: "Unités Légales, Établissements";
768
+ collection?: "Unités Légales" | "Établissements";
755
769
  /**
756
770
  * Format: date-time
757
771
  * @description Date et heure (yyyy-MM-ddTHH:mm:ss.SSS) de la dernière mise à disposition des données de la collection
@@ -778,7 +792,7 @@ export interface components {
778
792
  * @description Etat du service
779
793
  * @enum {string}
780
794
  */
781
- etatCollection?: "UP,DOWN";
795
+ etatCollection?: "UP" | "DOWN";
782
796
  };
783
797
  /** @description Objet renvoyé en cas de requête demandant les informations sur le service */
784
798
  ReponseInformations: {
@@ -787,7 +801,7 @@ export interface components {
787
801
  * @description État actuel du service
788
802
  * @enum {string}
789
803
  */
790
- etatService?: "UP,DOWN";
804
+ etatService?: "UP" | "DOWN";
791
805
  /** @description Etats des services */
792
806
  etatsDesServices?: components["schemas"]["EtatCollection"][];
793
807
  /** @description Numéro de la version */