@tricoteuses/assemblee 3.5.0 → 3.6.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 (42) hide show
  1. package/lib/{amendements-D2X2TneW.js → amendements-BYKlEcWb.js} +1 -1
  2. package/lib/{amendements-DSXfagiR.js → amendements-CvlD2dI4.js} +10 -12
  3. package/lib/cleaners.js +3 -3
  4. package/lib/derouleur.js +1 -1
  5. package/lib/eliasse-socket.d.ts +30 -34
  6. package/lib/eliasse-socket.js +92 -157
  7. package/lib/eliasse-sync.d.ts +65 -0
  8. package/lib/eliasse-sync.js +100 -0
  9. package/lib/eliasse-sync.test.d.ts +1 -0
  10. package/lib/eliasse.js +1 -1
  11. package/lib/git.js +1 -1
  12. package/lib/index.js +3 -6
  13. package/lib/{loaders-DYFDjudN.js → loaders-BNXs79lC.js} +2 -2
  14. package/lib/loaders.js +1 -1
  15. package/lib/parsers/dossier_annexes.d.ts +36 -0
  16. package/lib/parsers/dossier_annexes.test.d.ts +1 -0
  17. package/lib/parsers.js +425 -469
  18. package/lib/registries.d.ts +8 -8
  19. package/lib/schemas/clean/acteurs_et_organes.d.ts +37 -37
  20. package/lib/schemas/clean/amendements.d.ts +12 -12
  21. package/lib/schemas/clean/debats.d.ts +26 -26
  22. package/lib/schemas/clean/dossiers_legislatifs.d.ts +16 -16
  23. package/lib/schemas/clean/questions.d.ts +122 -122
  24. package/lib/schemas/clean/scrutins.d.ts +2 -2
  25. package/lib/schemas/enriched/acteurs_et_organes.d.ts +2 -2
  26. package/lib/schemas/enriched/amendements.d.ts +9 -9
  27. package/lib/schemas/enriched/dossiers_legislatifs.d.ts +12 -12
  28. package/lib/schemas/enriched/questions.d.ts +108 -108
  29. package/lib/schemas/enriched/scrutins.d.ts +2 -2
  30. package/lib/schemas/raw/acteurs_et_organes.d.ts +132 -132
  31. package/lib/schemas/raw/agendas.d.ts +97 -97
  32. package/lib/schemas/raw/amendements.d.ts +83 -83
  33. package/lib/schemas/raw/debats.d.ts +51 -51
  34. package/lib/schemas/raw/dossiers_legislatifs.d.ts +171 -171
  35. package/lib/schemas/raw/questions.d.ts +222 -222
  36. package/lib/schemas/raw/scrutins.d.ts +164 -164
  37. package/lib/scripts/retrieve_dossier_annexes.d.ts +110 -0
  38. package/lib/scripts/shared/utils.d.ts +9 -0
  39. package/lib/{scrutins-CGHd_VPY.js → scrutins-BUVxV-QV.js} +2 -2
  40. package/lib/zod_errors-qS8sQ67W.js +32 -0
  41. package/package.json +8 -1
  42. package/lib/zod_errors-DCnjCNGy.js +0 -34
@@ -0,0 +1,110 @@
1
+ import { z } from 'zod';
2
+ import { DossierAnnexe } from '../parsers/dossier_annexes.js';
3
+ declare const retrieveDossierAnnexesParser: import('zod-opts').Parser<{
4
+ "not-found": {
5
+ alias: string;
6
+ description: string;
7
+ type: z.ZodDefault<z.ZodBoolean>;
8
+ };
9
+ uid: {
10
+ alias: string;
11
+ description: string;
12
+ type: z.ZodOptional<z.ZodString>;
13
+ };
14
+ categories: {
15
+ alias: string;
16
+ description: string;
17
+ type: z.ZodDefault<z.ZodArray<z.ZodString>>;
18
+ };
19
+ legislature: {
20
+ alias: string;
21
+ description: string;
22
+ type: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
23
+ };
24
+ silent: {
25
+ alias: string;
26
+ description: string;
27
+ type: z.ZodDefault<z.ZodBoolean>;
28
+ };
29
+ verbose: {
30
+ alias: string;
31
+ description: string;
32
+ type: z.ZodDefault<z.ZodBoolean>;
33
+ };
34
+ "only-recent": {
35
+ description: string;
36
+ type: z.ZodOptional<z.ZodNumber>;
37
+ };
38
+ skipReindent: {
39
+ description: string;
40
+ type: z.ZodDefault<z.ZodBoolean>;
41
+ };
42
+ keepDir: {
43
+ description: string;
44
+ type: z.ZodDefault<z.ZodBoolean>;
45
+ };
46
+ clone: {
47
+ alias: string;
48
+ description: string;
49
+ type: z.ZodOptional<z.ZodString>;
50
+ };
51
+ commit: {
52
+ alias: string;
53
+ description: string;
54
+ type: z.ZodDefault<z.ZodBoolean>;
55
+ };
56
+ remote: {
57
+ alias: string;
58
+ description: string;
59
+ type: z.ZodDefault<z.ZodArray<z.ZodString>>;
60
+ };
61
+ pull: {
62
+ alias: string;
63
+ description: string;
64
+ type: z.ZodDefault<z.ZodBoolean>;
65
+ };
66
+ fetchDocuments: {
67
+ description: string;
68
+ type: z.ZodDefault<z.ZodBoolean>;
69
+ };
70
+ parseDocuments: {
71
+ description: string;
72
+ type: z.ZodDefault<z.ZodBoolean>;
73
+ };
74
+ format: {
75
+ alias: string;
76
+ description: string;
77
+ type: z.ZodDefault<z.ZodArray<z.ZodString>>;
78
+ };
79
+ fetchVideos: {
80
+ description: string;
81
+ type: z.ZodDefault<z.ZodBoolean>;
82
+ };
83
+ fetchCrCommissions: {
84
+ description: string;
85
+ type: z.ZodDefault<z.ZodBoolean>;
86
+ };
87
+ }, [{
88
+ description: string;
89
+ type: z.ZodString;
90
+ name: "dataDir";
91
+ }]>;
92
+ export type Options = ReturnType<typeof retrieveDossierAnnexesParser.parse>;
93
+ /**
94
+ * Annexes of a dossier published only on the Assemblée nationale website
95
+ * (not in open data), indexed per dossier in the Documents repository.
96
+ */
97
+ export type DossierAnnexeFileInfos = DossierAnnexe & {
98
+ filename: string;
99
+ sha256?: string;
100
+ status?: number;
101
+ };
102
+ export type DossierAnnexesIndex = {
103
+ pageUrl: string;
104
+ dateRetrieval: string;
105
+ annexes: DossierAnnexeFileInfos[];
106
+ };
107
+ export declare function annexesIndexPath(dataDir: string, dossierUid: string): string;
108
+ export declare function annexFileName(url: string, existingNames: Set<string>): string;
109
+ export declare function retrieveDossierAnnexesForDossier(dossierUid: string, pageUrl: string, options: Options): Promise<void>;
110
+ export {};
@@ -1,5 +1,14 @@
1
1
  export declare const writeIfChanged: (p: string, content: string) => Promise<void>;
2
2
  export declare function fetchWithRetry(url: string, retries?: number, backoff?: number): Promise<Response>;
3
+ /**
4
+ * Download a binary file as a Buffer, retrying on network failures.
5
+ * The Assemblée nationale server sometimes terminates connections on large
6
+ * PDFs, hence the retries with exponential backoff.
7
+ */
8
+ export declare function downloadBufferWithRetry(url: string, retries?: number, backoff?: number): Promise<{
9
+ response: Response;
10
+ buffer: Buffer;
11
+ }>;
3
12
  export declare function newestRequestedLegislature({ onlyRecent, legislature, }: {
4
13
  onlyRecent?: number;
5
14
  legislature: number[];
@@ -1,5 +1,5 @@
1
- import { $ as e, Q as t, X as n, Y as r, Z as i, et as a, nt as o, tt as s } from "./amendements-DSXfagiR.js";
2
- import { t as c } from "./zod_errors-DCnjCNGy.js";
1
+ import { $ as e, Q as t, X as n, Y as r, Z as i, et as a, nt as o, tt as s } from "./amendements-CvlD2dI4.js";
2
+ import { t as c } from "./zod_errors-qS8sQ67W.js";
3
3
  import { z as l } from "zod";
4
4
  //#region src/legislatures.ts
5
5
  var ee = /* @__PURE__ */ function(e) {
@@ -0,0 +1,32 @@
1
+ function e(e) {
2
+ if (typeof e == "string") {
3
+ let t = e.length > 160 ? `${e.slice(0, 157)}...` : e;
4
+ return JSON.stringify(t);
5
+ }
6
+ if (typeof e == "bigint") return `${e}n`;
7
+ if (typeof e == "symbol") return String(e);
8
+ if (typeof e == "function") return `[Function ${e.name || "anonymous"}]`;
9
+ try {
10
+ let t = JSON.stringify(e);
11
+ return t === void 0 ? String(e) : t.length > 160 ? `${t.slice(0, 157)}...` : t;
12
+ } catch {
13
+ return String(e);
14
+ }
15
+ }
16
+ function t(e, t) {
17
+ let n = e;
18
+ for (let e of t) {
19
+ if (n === null || typeof n != "object" && !Array.isArray(n)) return;
20
+ n = n[e];
21
+ }
22
+ return n;
23
+ }
24
+ function n(n, r) {
25
+ let i = n.path.length > 0 ? n.path.join(".") : "(root)", a = "input" in n && n.input !== void 0 ? n.input : r === void 0 ? void 0 : t(r, n.path), o = a === void 0 ? "" : ` (received: ${e(a)})`;
26
+ return ` - ${i}: ${n.message}${o}`;
27
+ }
28
+ function r(e, t, r) {
29
+ return `Invalid ${e}:\n${t.issues.map((e) => n(e, r)).join("\n")}`;
30
+ }
31
+ //#endregion
32
+ export { r as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/assemblee",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "Retrieve, clean up & handle French Assemblée nationale's open data",
5
5
  "keywords": [
6
6
  "Assemblée nationale",
@@ -63,6 +63,11 @@
63
63
  "import": "./lib/eliasse-socket.js",
64
64
  "types": "./lib/eliasse-socket.d.ts"
65
65
  },
66
+ "./eliasse-sync": {
67
+ "typedoc": "./src/eliasse-sync.ts",
68
+ "import": "./lib/eliasse-sync.js",
69
+ "types": "./lib/eliasse-sync.d.ts"
70
+ },
66
71
  "./git": {
67
72
  "typedoc": "./src/git.ts",
68
73
  "import": "./lib/git.js",
@@ -93,6 +98,7 @@
93
98
  "data:retrieve_deputes_photos": "tsx src/scripts/retrieve_deputes_photos.ts --fetch",
94
99
  "data:retrieve_documents": "tsx src/scripts/retrieve_documents.ts",
95
100
  "data:retrieve_open_data": "tsx src/scripts/retrieve_open_data.ts --fetch",
101
+ "data:retrieve_dossier_annexes": "tsx src/scripts/retrieve_dossier_annexes.ts",
96
102
  "data:retrieve_pending_amendements": "tsx src/scripts/retrieve_pending_amendments.ts --incremental",
97
103
  "data:retrieve_senateurs_photos": "tsx src/scripts/retrieve_senateurs_photos.ts --fetch",
98
104
  "data:validate_raw_data": "tsx src/scripts/reorganize_data.ts --validate-only",
@@ -105,6 +111,7 @@
105
111
  "type-check:watch": "npm run type-check -- --watch"
106
112
  },
107
113
  "dependencies": {
114
+ "@stomp/stompjs": "^7.3.0",
108
115
  "cheerio": "^1.2.0",
109
116
  "date-fns": "^4.4.0",
110
117
  "deep-equal": "^2.2.3",
@@ -1,34 +0,0 @@
1
- //#region src/schemas/zod_errors.ts
2
- var e = 160;
3
- function t(t) {
4
- if (typeof t == "string") {
5
- let n = t.length > e ? `${t.slice(0, e - 3)}...` : t;
6
- return JSON.stringify(n);
7
- }
8
- if (typeof t == "bigint") return `${t}n`;
9
- if (typeof t == "symbol") return String(t);
10
- if (typeof t == "function") return `[Function ${t.name || "anonymous"}]`;
11
- try {
12
- let n = JSON.stringify(t);
13
- return n === void 0 ? String(t) : n.length > e ? `${n.slice(0, e - 3)}...` : n;
14
- } catch {
15
- return String(t);
16
- }
17
- }
18
- function n(e, t) {
19
- let n = e;
20
- for (let e of t) {
21
- if (n === null || typeof n != "object" && !Array.isArray(n)) return;
22
- n = n[e];
23
- }
24
- return n;
25
- }
26
- function r(e, r) {
27
- let i = e.path.length > 0 ? e.path.join(".") : "(root)", a = "input" in e && e.input !== void 0 ? e.input : r === void 0 ? void 0 : n(r, e.path), o = a === void 0 ? "" : ` (received: ${t(a)})`;
28
- return ` - ${i}: ${e.message}${o}`;
29
- }
30
- function i(e, t, n) {
31
- return `Invalid ${e}:\n${t.issues.map((e) => r(e, n)).join("\n")}`;
32
- }
33
- //#endregion
34
- export { i as t };