@tricoteuses/senat 2.4.2 → 2.5.1

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.
@@ -130,6 +130,7 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
130
130
  date_debut: string;
131
131
  date_fin: string;
132
132
  code_circonscription: string;
133
+ etat: string | null;
133
134
  etat_debut: string | null;
134
135
  etat_fin: string | null;
135
136
  }[];
@@ -140,10 +141,11 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
140
141
  code_organisme: string;
141
142
  type_organisme: string | null;
142
143
  libelle: string | null;
144
+ etat: string | null;
143
145
  fonctions: {
144
146
  date_debut: string;
145
147
  date_fin: string;
146
- libelle: string | null;
148
+ libelle: unknown;
147
149
  }[];
148
150
  }[];
149
151
  delegations: {
@@ -153,28 +155,31 @@ declare const findAllQuery: import("kysely").SelectQueryBuilder<{
153
155
  type_code_organisme: string | null;
154
156
  code_organisme: string;
155
157
  libelle: string | null;
158
+ etat: string | null;
156
159
  fonctions: {
157
160
  date_debut: string;
158
161
  date_fin: string;
159
- libelle: string | null;
162
+ libelle: unknown;
160
163
  }[];
161
164
  }[];
162
165
  groupes: {
163
166
  date_debut: string;
164
167
  date_fin: string;
165
- code: string;
168
+ type_organisme: string | null;
169
+ type_code_organisme: string | null;
170
+ code_organisme: string;
166
171
  libelle: string | null;
167
- fonction: string | null;
172
+ etat: string | null;
168
173
  fonctions: {
169
174
  date_debut: string;
170
175
  date_fin: string;
171
- libelle: string | null;
176
+ libelle: unknown;
172
177
  }[];
173
178
  }[];
174
179
  fonctions_bureau: {
175
180
  date_debut: string;
176
181
  date_fin: string;
177
- libelle: string | null;
182
+ libelle: unknown;
178
183
  }[];
179
184
  }>;
180
185
  declare const findAllCirconscriptionsQuery: import("kysely").SelectQueryBuilder<{
@@ -445,6 +450,7 @@ export declare function findAll(): AsyncIterableIterator<{
445
450
  date_debut: string;
446
451
  date_fin: string;
447
452
  code_circonscription: string;
453
+ etat: string | null;
448
454
  etat_debut: string | null;
449
455
  etat_fin: string | null;
450
456
  }[];
@@ -455,10 +461,11 @@ export declare function findAll(): AsyncIterableIterator<{
455
461
  code_organisme: string;
456
462
  type_organisme: string | null;
457
463
  libelle: string | null;
464
+ etat: string | null;
458
465
  fonctions: {
459
466
  date_debut: string;
460
467
  date_fin: string;
461
- libelle: string | null;
468
+ libelle: unknown;
462
469
  }[];
463
470
  }[];
464
471
  delegations: {
@@ -468,28 +475,31 @@ export declare function findAll(): AsyncIterableIterator<{
468
475
  type_code_organisme: string | null;
469
476
  code_organisme: string;
470
477
  libelle: string | null;
478
+ etat: string | null;
471
479
  fonctions: {
472
480
  date_debut: string;
473
481
  date_fin: string;
474
- libelle: string | null;
482
+ libelle: unknown;
475
483
  }[];
476
484
  }[];
477
485
  groupes: {
478
486
  date_debut: string;
479
487
  date_fin: string;
480
- code: string;
488
+ type_organisme: string | null;
489
+ type_code_organisme: string | null;
490
+ code_organisme: string;
481
491
  libelle: string | null;
482
- fonction: string | null;
492
+ etat: string | null;
483
493
  fonctions: {
484
494
  date_debut: string;
485
495
  date_fin: string;
486
- libelle: string | null;
496
+ libelle: unknown;
487
497
  }[];
488
498
  }[];
489
499
  fonctions_bureau: {
490
500
  date_debut: string;
491
501
  date_fin: string;
492
- libelle: string | null;
502
+ libelle: unknown;
493
503
  }[];
494
504
  }>;
495
505
  export declare function findAllCirconscriptions(): AsyncIterableIterator<{
package/lib/model/sens.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsonArrayFrom, jsonObjectFrom } from "kysely/helpers/postgres";
2
2
  import { dbSens } from "../databases";
3
- import { concat, rtrim, toDateString } from "./util";
3
+ import { concat, nullIf, rtrim, toDateString } from "./util";
4
4
  function circonscription(dptNum) {
5
5
  return jsonObjectFrom(dbSens
6
6
  .selectFrom("dpt")
@@ -49,10 +49,10 @@ function fonctionsBureau(senMat) {
49
49
  .selectFrom("senbur")
50
50
  .leftJoin("bur", "senbur.burcod", "bur.burcod")
51
51
  .where("senbur.senmat", "=", senMat)
52
- .select(({ ref }) => [
52
+ .select(({ eb, ref }) => [
53
53
  toDateString(ref("senbur.senburdatdeb")).as("date_debut"),
54
54
  toDateString(ref("senbur.senburdatfin")).as("date_fin"),
55
- "bur.burlib as libelle",
55
+ eb.fn.coalesce(nullIf(ref("bur.burlib")), nullIf(ref("bur.burlil")), nullIf(ref("bur.burlic"))).as("libelle"),
56
56
  ])
57
57
  .orderBy("senbur.senburdatdeb desc"));
58
58
  }
@@ -110,6 +110,7 @@ function mandatsEluSenateur(senMat) {
110
110
  "elusen.dptnum as code_circonscription",
111
111
  toDateString(ref("elusen.eludatdeb")).as("date_debut"),
112
112
  toDateString(ref("elusen.eludatfin")).as("date_fin"),
113
+ "elusen.temvalcod as etat",
113
114
  "etadebman.etadebmanlib as etat_debut",
114
115
  "etafinman.etafinman as etat_fin",
115
116
  ])
@@ -135,10 +136,10 @@ function fonctionsMembreCommission(memComId) {
135
136
  .selectFrom("fonmemcom")
136
137
  .leftJoin("foncom", "fonmemcom.foncomcod", "foncom.foncomcod")
137
138
  .where("fonmemcom.memcomid", "=", memComId)
138
- .select(({ ref }) => [
139
+ .select(({ eb, ref }) => [
139
140
  toDateString(ref("fonmemcom.fonmemcomdatdeb")).as("date_debut"),
140
141
  toDateString(ref("fonmemcom.fonmemcomdatfin")).as("date_fin"),
141
- "foncom.foncomlib as libelle",
142
+ eb.fn.coalesce(nullIf(ref("foncom.foncomlib")), nullIf(ref("foncom.foncomlil")), nullIf(ref("foncom.foncomlic"))).as("libelle"),
142
143
  ])
143
144
  .orderBy("fonmemcom.fonmemcomdatdeb desc"));
144
145
  }
@@ -155,6 +156,7 @@ function mandatsMembreCommission(senMat) {
155
156
  "com.comlilmin as libelle",
156
157
  toDateString(ref("memcom.memcomdatdeb")).as("date_debut"),
157
158
  toDateString(ref("memcom.memcomdatfin")).as("date_fin"),
159
+ "memcom.temvalcod as etat",
158
160
  ])
159
161
  .select(({ ref }) => [
160
162
  fonctionsMembreCommission(ref("memcom.memcomid")).as("fonctions"),
@@ -166,10 +168,10 @@ function fonctionsMembreDelegation(memDelegaId) {
166
168
  .selectFrom("fonmemdelega")
167
169
  .leftJoin("fondelega", "fonmemdelega.fondelcod", "fondelega.fondelcod")
168
170
  .where("fonmemdelega.memdelegaid", "=", memDelegaId)
169
- .select(({ ref }) => [
171
+ .select(({ eb, ref }) => [
170
172
  toDateString(ref("fonmemdelega.fonmemdeldatdeb")).as("date_debut"),
171
173
  toDateString(ref("fonmemdelega.fonmemdeldatfin")).as("date_fin"),
172
- "fondelega.fondellib as libelle",
174
+ eb.fn.coalesce(nullIf(ref("fondelega.fondellib")), nullIf(ref("fondelega.fondellil")), nullIf(ref("fondelega.fondellic"))).as("libelle"),
173
175
  ])
174
176
  .orderBy("fonmemdelega.fonmemdeldatdeb desc"));
175
177
  }
@@ -187,6 +189,7 @@ function mandatsMembreDelegation(senMat) {
187
189
  "delega.evelib as libelle",
188
190
  toDateString(ref("memdelega.memdelegadatdeb")).as("date_debut"),
189
191
  toDateString(ref("memdelega.memdelegadatfin")).as("date_fin"),
192
+ "memdelega.temvalcod as etat",
190
193
  ])
191
194
  .select(({ ref }) => [
192
195
  fonctionsMembreDelegation(ref("memdelega.memdelegaid")).as("fonctions"),
@@ -206,10 +209,10 @@ function fonctionsMembreGroupePolitique(memGrpPolId) {
206
209
  .selectFrom("fonmemgrppol")
207
210
  .leftJoin("fongrppol", "fonmemgrppol.fongrppolcod", "fongrppol.fongrppolcod")
208
211
  .where("fonmemgrppol.memgrppolid", "=", memGrpPolId)
209
- .select(({ ref }) => [
212
+ .select(({ eb, ref }) => [
210
213
  toDateString(ref("fonmemgrppol.fonmemgrppoldatdeb")).as("date_debut"),
211
214
  toDateString(ref("fonmemgrppol.fonmemgrppoldatfin")).as("date_fin"),
212
- "fongrppol.fongrppollib as libelle",
215
+ eb.fn.coalesce(nullIf(ref("fongrppol.fongrppollib")), nullIf(ref("fongrppol.fongrppollil")), nullIf(ref("fongrppol.fongrppollic"))).as("libelle"),
213
216
  ])
214
217
  .orderBy("fonmemgrppol.fonmemgrppoldatdeb desc"));
215
218
  }
@@ -218,13 +221,16 @@ function mandatsMembreGroupePolitique(senMat) {
218
221
  .selectFrom("memgrppol")
219
222
  .leftJoin("grppol", "memgrppol.grppolcod", "grppol.grppolcod")
220
223
  .leftJoin("typapppol", "memgrppol.typapppolcod", "typapppol.typapppolcod")
224
+ .leftJoin("typorg", "grppol.typorgcod", "typorg.typorgcod")
221
225
  .where("memgrppol.senmat", "=", senMat)
222
226
  .select(({ ref }) => [
223
- "memgrppol.grppolcod as code",
227
+ "grppol.typorgcod as type_code_organisme",
228
+ "memgrppol.grppolcod as code_organisme",
229
+ "typorg.typorglib as type_organisme",
224
230
  "grppol.grppollibcou as libelle",
225
231
  toDateString(ref("memgrppol.memgrppoldatdeb")).as("date_debut"),
226
232
  toDateString(ref("memgrppol.memgrppoldatfin")).as("date_fin"),
227
- "typapppol.typapppollib as fonction",
233
+ "memgrppol.temvalcod as etat",
228
234
  ])
229
235
  .select(({ ref }) => [
230
236
  fonctionsMembreGroupePolitique(ref("memgrppol.memgrppolid")).as("fonctions"),
@@ -1,6 +1,7 @@
1
1
  import { Expression } from "kysely";
2
2
  export declare function concat(...exprs: Expression<number | string | null | undefined>[]): import("kysely").RawBuilder<string>;
3
3
  export declare function expandToRows(expr: Expression<string | null | undefined>, regexp: Expression<string>): import("kysely").RawBuilder<unknown>;
4
+ export declare function nullIf(expr: Expression<number | string | null | undefined>): import("kysely").RawBuilder<unknown>;
4
5
  export declare function removeSubstring(expr: Expression<string | null | undefined>, pattern: Expression<string>): import("kysely").RawBuilder<string>;
5
6
  export declare function replace(expr: Expression<string | null | undefined>, pattern: Expression<string>, replacement: Expression<string>): import("kysely").RawBuilder<string>;
6
7
  export declare function rtrim(expr: Expression<string | null | undefined>): import("kysely").RawBuilder<string>;
package/lib/model/util.js CHANGED
@@ -5,6 +5,9 @@ export function concat(...exprs) {
5
5
  export function expandToRows(expr, regexp) {
6
6
  return sql `unnest(regexp_matches(${expr}, ${regexp}, 'g'))`;
7
7
  }
8
+ export function nullIf(expr) {
9
+ return sql `nullif(trim(${expr}), '')`;
10
+ }
8
11
  export function removeSubstring(expr, pattern) {
9
12
  return replace(expr, pattern, sql.val(""));
10
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "2.4.2",
3
+ "version": "2.5.1",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",