diff --git a/index.html b/index.html
index 0eb31685..111e4da5 100644
--- a/index.html
+++ b/index.html
@@ -10,18 +10,18 @@
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
-
+
diff --git a/migrations/20240522130558_ajout-localisation-dossier.js b/migrations/20240522130558_ajout-localisation-dossier.js
new file mode 100644
index 00000000..dc163669
--- /dev/null
+++ b/migrations/20240522130558_ajout-localisation-dossier.js
@@ -0,0 +1,20 @@
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export function up(knex) {
+ return knex.schema.alterTable('dossier', (table) => {
+ table.json('départements');
+ table.json('communes');
+ });
+};
+
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export function down(knex) {
+ return knex.schema.alterTable('dossier', (table) => {
+ table.dropColumns('départements', 'communes');
+ });
+};
diff --git "a/migrations/20240527151149_ajout-d\303\251posant.js" "b/migrations/20240527151149_ajout-d\303\251posant.js"
new file mode 100644
index 00000000..45e05d16
--- /dev/null
+++ "b/migrations/20240527151149_ajout-d\303\251posant.js"
@@ -0,0 +1,20 @@
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export function up(knex) {
+ return knex.schema.alterTable('dossier', (table) => {
+ table.integer('déposant').unsigned().index()
+ table.foreign('déposant').references('id').inTable('personne')
+ });
+};
+
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export function down(knex) {
+ return knex.schema.alterTable('dossier', (table) => {
+ table.dropColumn('déposant');
+ });
+};
diff --git a/migrations/20240529134326_ajout-demandeur-dossier.js b/migrations/20240529134326_ajout-demandeur-dossier.js
new file mode 100644
index 00000000..aa3f2472
--- /dev/null
+++ b/migrations/20240529134326_ajout-demandeur-dossier.js
@@ -0,0 +1,37 @@
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export async function up(knex) {
+ await knex.schema.createTable('entreprise', (table) => {
+ table.string('siret', 14).primary();
+ table.string('raison_sociale');
+ table.string('adresse');
+ });
+
+ return knex.schema.alterTable('dossier', (table) => {
+ table.integer('demandeur_personne_physique').unsigned().index()
+ table.foreign('demandeur_personne_physique').references('id').inTable('personne')
+ table.string('demandeur_personne_morale', 14).index()
+ table.foreign('demandeur_personne_morale').references('siret').inTable('entreprise')
+
+ table.dropColumn('identité_petitionnaire')
+ });
+};
+
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export async function down(knex) {
+ await knex.schema.dropTable('entreprise');
+
+ return knex.schema.alterTable('dossier', (table) => {
+ table.dropColumn('demandeur_personne_physique');
+ table.dropColumn('demandeur_personne_morale');
+
+ // Ça recréé la colonne, mais les données sont perdues
+ // et ce n'est pas grave, cette colonne était pensée comme temporaire depuis le début
+ table.string('identité_petitionnaire');
+ });
+};
diff --git "a/migrations/20240529184142_ajout-r\303\251gions.js" "b/migrations/20240529184142_ajout-r\303\251gions.js"
new file mode 100644
index 00000000..aeabd4ff
--- /dev/null
+++ "b/migrations/20240529184142_ajout-r\303\251gions.js"
@@ -0,0 +1,19 @@
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export function up(knex) {
+ return knex.schema.alterTable('dossier', (table) => {
+ table.json('régions');
+ });
+};
+
+/**
+ * @param { import("knex").Knex } knex
+ * @returns { Promise }
+ */
+export function down(knex) {
+ return knex.schema.alterTable('dossier', (table) => {
+ table.dropColumn('régions');
+ });
+};
diff --git "a/outils/sync-d\303\251marches-simplifi\303\251es.js" "b/outils/sync-d\303\251marches-simplifi\303\251es.js"
index 2a825bf6..7c1f70de 100644
--- "a/outils/sync-d\303\251marches-simplifi\303\251es.js"
+++ "b/outils/sync-d\303\251marches-simplifi\303\251es.js"
@@ -1,11 +1,14 @@
//@ts-check
-import '../scripts/types/database/public/Dossier.js'
import { formatISO } from 'date-fns';
-import knex from 'knex';
+import {listAllPersonnes, listAllEntreprises, dumpDossiers, dumpEntreprises, créerPersonnes} from '../scripts/server/database.js'
import {recupérerDossiersRécemmentModifiés} from '../scripts/server/recupérerDossiersRécemmentModifiés.js'
+/** @typedef {import('../scripts/types/database/public/Dossier.js').default} Dossier */
+/** @typedef {import('../scripts/types/database/public/Personne.js').default} Personne */
+/** @typedef {import('../scripts/types/database/public/Entreprise.js').default} Entreprise */
+
// récups les données de DS
const API_TOKEN = process.env.API_TOKEN
@@ -23,10 +26,7 @@ if(!DATABASE_URL){
throw new TypeError(`Variable d'environnement DATABASE_URL manquante`)
}
-const database = knex({
- client: 'pg',
- connection: DATABASE_URL,
-});
+
const démarche = await recupérerDossiersRécemmentModifiés({
token: API_TOKEN,
@@ -34,74 +34,261 @@ const démarche = await recupérerDossiersRécemmentModifiés({
updatedSince: formatISO(new Date(2020, 1, 22))
})
-console.log('démarche', démarche)
-console.log('dossiers', démarche.dossiers.nodes)
-
-/*
-
-id: { type: 'int', primaryKey: true },
-id_demarches_simplifiées: { type: 'string' },
-statut: { type: 'string' },
-date_dépôt: { type: 'datetime' },
-identité_petitionnaire: { type: 'string'},
-espèces_protégées_concernées: { type: 'string' },
-enjeu_écologiques: { type: 'string' }
+//console.log('démarche', démarche)
+//console.log('dossiers', démarche.dossiers.nodes.length)
+//console.log('3 dossiers', démarche.dossiers.nodes.slice(0, 3))
+//console.log('champs', démarche.dossiers.nodes[0].champs)
+console.log('un dossier', JSON.stringify(démarche.dossiers.nodes[21], null, 2))
-*/
// stocker les dossiers en BDD
-const pitchouKeyToChampDS = Object.assign(Object.create(null), {
+const pitchouKeyToChampDS = {
"SIRET": "Q2hhbXAtMzg5NzM5NA==",
"Nom-Prénom": "Q2hhbXAtMzg5NzM1NA==",
- "espèces_protégées_concernées": 'Q2hhbXAtMzg5NzQwNQ=='
-})
+ "espèces_protégées_concernées": 'Q2hhbXAtMzg5NzQwNQ==',
+ "communes": 'Q2hhbXAtNDA0MTQ0MQ==',
+ "départements" : 'Q2hhbXAtNDA0MTQ0NQ==',
+ "régions" : 'Q2hhbXAtNDA0MTQ0OA==',
+ "Le projet se situe au niveau…": 'Q2hhbXAtMzg5NzQwOA=='
+}
-const pitchouKeyToAnnotationDS = Object.assign(Object.create(null), {
+const pitchouKeyToAnnotationDS = {
"enjeu_écologiques": "Q2hhbXAtNDAwMTQ3MQ=="
-})
+}
+
+const allPersonnesCurrentlyInDatabaseP = listAllPersonnes();
+const allEntreprisesCurrentlyInDatabase = listAllEntreprises();
/** @type {Dossier[]} */
const dossiers = démarche.dossiers.nodes.map(({
id: id_demarches_simplifiées,
dateDepot: date_dépôt,
state: statut,
+ demandeur,
champs,
annotations
}) => {
- const SIRETChamp = champs.find(({id}) => id === pitchouKeyToChampDS["SIRET"])
- const NomPrenomChamp = champs.find(({id}) => id === pitchouKeyToChampDS["Nom-Prénom"])
+ const espèces_protégées_concernées = champs.find(({id}) => id === pitchouKeyToChampDS["espèces_protégées_concernées"]).stringValue
- if(!SIRETChamp && !NomPrenomChamp) throw new TypeError(`Champ id ${pitchouKeyToChampDS["SIRET"]} et ${pitchouKeyToChampDS["Nom-Prénom"]} manquants (devrait être le Siret ou le prénom-nom de la personne)`)
+ /* localisation */
+ const projetSitué = champs.find(({id}) => id === pitchouKeyToChampDS["Le projet se situe au niveau…"]).stringValue
+ const champCommunes = champs.find(({id}) => id === pitchouKeyToChampDS["communes"])
+ const champDépartements = champs.find(({id}) => id === pitchouKeyToChampDS["départements"])
+ const champRégions = champs.find(({id}) => id === pitchouKeyToChampDS["régions"])
- const identité_petitionnaire = SIRETChamp ?
- SIRETChamp.etablissement && `${SIRETChamp.etablissement.entreprise.raisonSociale} - (${SIRETChamp.etablissement.siret})` || `entreprise inconnue (SIRET: ${SIRETChamp.stringValue})` :
- NomPrenomChamp.stringValue
+ let communes;
+ let départements;
+ let régions;
- const espèces_protégées_concernées = champs.find(({id}) => id === pitchouKeyToChampDS["espèces_protégées_concernées"]).stringValue
+ if(champCommunes){
+ communes = champCommunes.rows.map(c => c.champs[0].commune)
+ départements = [... new Set(champCommunes.rows.map(c => c.champs[0].departement.code))]
+ }
+ else{
+ if(champDépartements){
+ départements = [... new Set(champDépartements.rows.map(c => c.champs[0].departement.code))]
+ }
+ else{
+ if(champRégions){
+ régions = [... new Set(champRégions.rows.map(c => c.champs[0].stringValue))]
+ }
+ else{
+ if(projetSitué){
+ console.log('localisation manquante', projetSitué, champs)
+ process.exit(1)
+ }
+ }
+ }
+ }
const enjeu_écologiques = annotations.find(({id}) => id === pitchouKeyToAnnotationDS["enjeu_écologiques"]).stringValue
+ /*
+ déposant
+
+ Le déposant est la personne qui dépose le dossier sur DS
+ Dans certaines situations, cette personne est différente du demandeur (personne morale ou physique
+ qui demande la dérogation), par exemple, si un bureau d'étude mandaté par une personne morale dépose le dossier,
+ Le déposant n'est pas forcément représentant interne (point de contact principale) du demandeur
+
+ Dans la nomenclature DS, ce que nous appelons "déposant" se trouve dans la propriété "demandeur"
+ (qui est différent de notre "demandeur")
+
+ */
+
+ /** @type {import('../scripts/types/database/public/Personne.js').PersonneInitializer} */
+ let déposant;
+ {
+ const {prenom: prénoms, nom, email} = demandeur
+ déposant = {
+ prénoms,
+ nom,
+ email: email === '' ? undefined : email
+ }
+ }
+
+ /*
+ demandeur
+
+ Personne physique ou morale qui formule la demande de dérogation espèces protégées
+
+ */
+
+ /** @type {import('../scripts/types/database/public/Personne.js').PersonneInitializer | undefined} */
+ let demandeur_personne_physique = undefined;
+ /** @type {Entreprise | undefined} */
+ let demandeur_personne_morale = undefined
+
+ const SIRETChamp = champs.find(({id}) => id === pitchouKeyToChampDS["SIRET"])
+ if(!SIRETChamp){
+ demandeur_personne_physique = déposant;
+ }
+ else{
+ const etablissement = SIRETChamp.etablissement
+ if(etablissement){
+ const { siret, address = {}, entreprise = {}} = etablissement
+ const {streetAddress, postalCode, cityName} = address
+ const {raisonSociale} = entreprise
+
+
+ demandeur_personne_morale = {
+ siret,
+ raison_sociale: raisonSociale,
+ adresse: `${streetAddress} ${postalCode} ${cityName}`
+ }
+ }
+ }
+
+
return {
id_demarches_simplifiées,
statut,
date_dépôt,
- identité_petitionnaire,
+ demandeur_personne_physique,
+ demandeur_personne_morale,
+ déposant,
+ //représentant,
espèces_protégées_concernées,
- enjeu_écologiques
+ enjeu_écologiques,
+ // https://knexjs.org/guide/schema-builder.html#json
+ communes: JSON.stringify(communes),
+ départements: JSON.stringify(départements),
+ régions: JSON.stringify(régions)
}
+
})
-console.log('dossiers', dossiers)
+/*
+ Créer toutes les personnes manquantes en BDD pour qu'elles aient toutes un id
+*/
+
+/** @type {Map} */
+const personneByEmail = new Map()
+const allPersonnesCurrentlyInDatabase = await allPersonnesCurrentlyInDatabaseP
+
+for(const personne of allPersonnesCurrentlyInDatabase){
+ if(personne.email){
+ personneByEmail.set(personne.email, personne)
+ }
+}
+
+/** @type {Personne[]} */
+const personnesInDossiers = [...new Set(dossiers.map(({déposant, demandeur_personne_physique}) => [déposant, demandeur_personne_physique].filter(p => !!p)).flat())]
+
+/**
+ *
+ * @param {Personne | undefined} descriptionPersonne
+ * @returns {Personne['id'] | undefined}
+ */
+function getPersonneId(descriptionPersonne){
+ if(!descriptionPersonne){
+ return undefined
+ }
+
+ if(descriptionPersonne.id){
+ return descriptionPersonne.id
+ }
+
+ if(descriptionPersonne.email){
+ const personne = personneByEmail.get(descriptionPersonne.email)
+ return personne && personne.id
+ }
+
+ const personneParNomPrénom = allPersonnesCurrentlyInDatabase.find(
+ ({email, nom, prénoms}) => !email && descriptionPersonne.nom === nom && descriptionPersonne.prénoms === prénoms
+ )
+
+ return personneParNomPrénom && personneParNomPrénom.id
+}
+
+const personnesInDossiersWithoutId = personnesInDossiers.filter(p => !getPersonneId(p))
+
+//console.log('personnesInDossiersWithoutId', personnesInDossiersWithoutId)
+
+if(personnesInDossiersWithoutId.length >= 1){
+ await créerPersonnes(personnesInDossiersWithoutId)
+ .then((personneIds) => {
+ personnesInDossiersWithoutId.forEach((p, i) => {
+ p.id = personneIds[i].id
+ })
+ })
+}
+
+//console.log('personnesInDossiersWithoutId après', personnesInDossiersWithoutId)
+
+/*
+ Après avoir créé les personnes, remplacer les objets Personne par leur id
+*/
+dossiers.forEach(d => {
+ d.déposant = getPersonneId(d.déposant)
+ d.demandeur_personne_physique = getPersonneId(d.demandeur_personne_physique)
+})
+
+
+/*
+ Rajouter les entreprises demandeuses qui ne sont pas déjà en BDD
+*/
+
+/** @type {Map {
+ d.demandeur_personne_morale = d.demandeur_personne_morale && d.demandeur_personne_morale.siret
+})
+
+
+/*throw `PPP
+ - le demandeur est une personne physique ou morale (foreign key)
+ - le représentant est une personne physique (foreign key)
+ - les instructeurs sont des personnes (foreign key)
+ - besoin de recup les groupes d'instructeurs de la démarche
+`*/
+
-database('dossier')
-.insert(dossiers)
-.onConflict('id_demarches_simplifiées')
-.merge()
+dumpDossiers(dossiers)
.catch(err => {
console.error('sync démarche simplifiée database error', err)
process.exit(1)
})
-.then(() => process.exit())
\ No newline at end of file
+.then(() => process.exit())
diff --git a/package.json b/package.json
index 554df305..9ecd876f 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,7 @@
"start:server": "node --env-file=.env --watch scripts/server/main.js",
"prestart:prod-server": "knex migrate:latest",
"start:prod-server": "node scripts/server/main.js",
- "build-db-types": "kanel -d postgresql://dev:dev_password@localhost:5432/principale -o ./scripts/types/database && ts-to-jsdoc ./scripts/types/database/public/*.ts"
+ "build-db-types": "kanel -d postgresql://dev:dev_password@localhost:5432/principale -o ./scripts/types/database && ts-to-jsdoc --force ./scripts/types/database/public/*.ts"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
diff --git a/scripts/front-end/actions/main.js b/scripts/front-end/actions/main.js
index ab46338e..a3754f4c 100644
--- a/scripts/front-end/actions/main.js
+++ b/scripts/front-end/actions/main.js
@@ -1,19 +1,39 @@
//@ts-check
+import {json} from 'd3-fetch'
+import remember, {forget} from 'remember'
+
import store from '../store.js';
-import remember from 'remember'
+
+/** @typedef {import('../../types/database/public/Dossier.js').default} Dossier */
const PITCHOU_SECRET_STORAGE_KEY = 'secret-pitchou'
+export function chargerDossiers(){
+ console.log('store.state.secret', store.state.secret)
+ if(store.state.secret){
+ return json(`/dossiers?secret=${store.state.secret}`)
+ .then(/** @type {Dossier[]} */ dossiers => {
+ console.log('dossiers', dossiers)
+ store.mutations.setDossiers(dossiers)
+ return dossiers
+ })
+ }
+ else{
+ return Promise.reject('Impossible de charger les dossiers, secret manquant')
+ }
+}
+
export function init(){
return remember(PITCHOU_SECRET_STORAGE_KEY)
- .then(secret => {
- if(secret){
- // @ts-ignore
- store.mutations.setSecret(secret)
- }
- })
+ .then(secret => {
+ if(secret){
+ // @ts-ignore
+ store.mutations.setSecret(secret)
+ return chargerDossiers()
+ }
+ })
}
export async function secretFromURL(){
@@ -28,4 +48,9 @@ export async function secretFromURL(){
return remember(PITCHOU_SECRET_STORAGE_KEY, secret)
}
+}
+
+export async function logout(){
+ store.mutations.setSecret(undefined)
+ return forget(PITCHOU_SECRET_STORAGE_KEY)
}
\ No newline at end of file
diff --git a/scripts/front-end/affichageDossier.js b/scripts/front-end/affichageDossier.js
new file mode 100644
index 00000000..1b7b08aa
--- /dev/null
+++ b/scripts/front-end/affichageDossier.js
@@ -0,0 +1,69 @@
+//@ts-check
+
+import { differenceInDays, format, formatRelative } from 'date-fns'
+import { fr } from 'date-fns/locale'
+
+export function formatLocalisation({communes, départements, régions}){
+ if(!communes && !départements && régions){
+ return `Régions: ${régions.join(', ')}`
+ }
+
+ if(!communes && départements){
+ return départements.join(', ')
+ }
+
+ if((!communes && !départements) || (communes.length === 0 && départements.length === 0)){
+ return '(inconnue)'
+ }
+
+ return communes.map(({name}) => name).join(', ') + ' ' + `(${départements.join(', ')})`
+}
+
+export function formatDéposant({déposant_nom, déposant_prénoms}){
+ if(!déposant_nom){
+ déposant_nom = ''
+ }
+ if(!déposant_prénoms){
+ déposant_prénoms = ''
+ }
+
+ return déposant_nom ? déposant_nom + ' ' + déposant_prénoms : déposant_prénoms
+}
+
+export function formatDemandeur({demandeur_personne_physique_nom, demandeur_personne_physique_prénoms, demandeur_personne_morale_raison_sociale, demandeur_personne_morale_siret}){
+ if(demandeur_personne_physique_nom){
+ return demandeur_personne_physique_nom + ' ' + demandeur_personne_physique_prénoms
+ }
+ else{
+ if(demandeur_personne_morale_siret){
+ return `${demandeur_personne_morale_raison_sociale} (${demandeur_personne_morale_siret})`
+ }
+ else
+ return '(inconnu)'
+ }
+}
+
+/**
+ *
+ * @param {Date} date
+ * @returns {string}
+ */
+export function formatDateAbsolue(date) {
+ return format(date, 'd MMMM yyyy', { locale: fr })
+}
+
+ /**
+ *
+ * @param {Date} date
+ * @returns {string}
+ */
+export function formatDateRelative(date) {
+ if (differenceInDays(date, new Date()) === 0) {
+ return `Aujourd'hui`
+ }
+ if (Math.abs(differenceInDays(date, new Date())) <= 7) {
+ return formatRelative(date, new Date(), {locale: fr })
+ }
+
+ return formatDateAbsolue(date)
+}
\ No newline at end of file
diff --git a/scripts/front-end/components/Dossier.svelte b/scripts/front-end/components/Dossier.svelte
new file mode 100644
index 00000000..88d2b39c
--- /dev/null
+++ b/scripts/front-end/components/Dossier.svelte
@@ -0,0 +1,76 @@
+
+
+
+ Dossier {dossier.id} - {statut}
+
+
+ Demandeur
+ {formatDemandeur(dossier)}
+
+ Localisation
+ {formatLocalisation(dossier)}
+
+
+
+ Chronologie
+
+ -
+ Dépôt sur Démarche Simplifiée
+ {formatDateRelative(date_dépôt)}
+
+
+
+
+
+ Interlocueurs
+
+ {#if déposant_nom}
+ Déposant
+ {formatDéposant(dossier)}
+ {/if}
+
+ Représentant du demandeur
+ (à faire)
+
+
+
+
+
diff --git "a/scripts/front-end/components/SaisieEsp\303\250ces.svelte" "b/scripts/front-end/components/SaisieEsp\303\250ces.svelte"
index af301d45..e6836c2a 100644
--- "a/scripts/front-end/components/SaisieEsp\303\250ces.svelte"
+++ "b/scripts/front-end/components/SaisieEsp\303\250ces.svelte"
@@ -157,19 +157,39 @@
})
}
+ let copyButton;
let lienPartage;
- function créerLienPartage(){
+ function créerEtCopierLienPartage(){
const jsonable = descriptionMenacesEspècesToJSON(descriptionMenacesEspèces)
console.log('jsonable', jsonable, UTF8ToB64(JSON.stringify(jsonable)).length)
lienPartage = `${location.origin}${location.pathname}?data=${UTF8ToB64(JSON.stringify(jsonable))}`
+
+ copyButton.classList.add("animate");
+ copyButton.addEventListener("animationend", () =>
+ copyButton.classList.remove("animate"),
+ );
+
+ navigator.clipboard
+ .writeText(lienPartage)
+ .then(() => {
+ copyButton.textContent = "Copié dans le presse-papier !";
+ })
+ .catch((error) => {
+ console.error("Une erreur s'est produite lors de la copie : ", error);
+ });
+
}
- Saisie des espèces protégées
- et des activités et méthodes, etc.
+ Saisie des espèces protégées impactées
+
+
+ Une fois la liste des espèces saisie, créer un lien ci-dessous et le copier dans votre dossier Démarches Simplifiées.
+
+
\ No newline at end of file
diff --git a/scripts/front-end/main.js b/scripts/front-end/main.js
index 64805f99..2f874981 100644
--- a/scripts/front-end/main.js
+++ b/scripts/front-end/main.js
@@ -2,15 +2,17 @@
import page from 'page'
-import {json, dsv} from 'd3-fetch'
+import {dsv} from 'd3-fetch'
import LoginViaEmail from './components/LoginViaEmail.svelte';
import SuiviInstructeur from './components/SuiviInstructeur.svelte';
import SaisieEspèces from './components/SaisieEspèces.svelte';
+import Dossier from './components/Dossier.svelte';
+
import { replaceComponent } from './routeComponentLifeCycle.js'
import store from './store.js'
-import {init, secretFromURL} from './actions/main.js'
+import {init, secretFromURL, logout, chargerDossiers} from './actions/main.js'
import {envoiEmailConnexion} from './serveur.js'
import { authorizedEmailDomains } from '../commun/constantes.js';
@@ -19,42 +21,76 @@ import '../types.js'
const svelteTarget = document.querySelector('.svelte-main')
+function showLoginByEmail(){
+ function mapStateToProps(){
+ return {
+ authorizedEmailDomains,
+ envoiEmailConnexion: envoiEmailConnexion
+ }
+ }
+
+ const loginViaEmail = new LoginViaEmail({
+ target: svelteTarget,
+ props: mapStateToProps()
+ });
+
+ replaceComponent(loginViaEmail, mapStateToProps)
+}
+
page('/', async () => {
console.info('route', '/')
- const secret = await secretFromURL().then(() => store.state.secret)
-
- if(secret){
- json(`/dossiers?secret=${secret}`).then(dossiers => {
- function mapStateToProps(){
- return {dossiers}
- }
-
- console.log('dossiers', dossiers)
-
- const suiviInstructeur = new SuiviInstructeur({
- target: svelteTarget,
- props: mapStateToProps()
- });
-
- replaceComponent(suiviInstructeur, mapStateToProps)
- })
+ await secretFromURL()
+ if(!store.state.dossiers){
+ await chargerDossiers()
+ .catch(err => {
+ if(err.message.includes('403')){
+ console.info('Invalid token. Logout.')
+ }
+ else{
+ console.error('Erreur de chargement des dossiers', err)
+ }
+ logout().then(showLoginByEmail)
+ })
}
- else{
- function mapStateToProps(){
- return {
- authorizedEmailDomains,
- envoiEmailConnexion: envoiEmailConnexion
- }
- }
- const loginViaEmail = new LoginViaEmail({
+ if(store.state.dossiers){
+ function mapStateToProps({dossiers}){
+ return {dossiers}
+ }
+
+ const suiviInstructeur = new SuiviInstructeur({
target: svelteTarget,
- props: mapStateToProps()
+ props: mapStateToProps(store.state)
});
- replaceComponent(loginViaEmail, mapStateToProps)
+ replaceComponent(suiviInstructeur, mapStateToProps)
+
}
+ else{
+ showLoginByEmail()
+ }
+
+})
+
+page('/dossier/:dossierId', ({params: {dossierId}}) => {
+ /**
+ *
+ * @param {import('./store.js').PitchouState} _
+ * @returns
+ */
+ function mapStateToProps({dossiers}){
+ const dossierIdNb = Number(dossierId)
+
+ return {dossier: dossiers.find(({id}) => id === dossierIdNb)}
+ }
+
+ const dossier = new Dossier({
+ target: svelteTarget,
+ props: mapStateToProps(store.state)
+ });
+
+ replaceComponent(dossier, mapStateToProps)
})
diff --git a/scripts/front-end/store.js b/scripts/front-end/store.js
index a383a59e..6a81fa60 100644
--- a/scripts/front-end/store.js
+++ b/scripts/front-end/store.js
@@ -16,15 +16,20 @@ import Store from 'baredux'
import '../types.js'
+/** @typedef {import('../types/database/public/Personne.js').default} Personne */
+/** @typedef {import('../types/database/public/Dossier.js').default} Dossier */
+
/**
* @typedef {Object} PitchouState
- * @property {string} [secret]
+ * @property {Personne['code_accès']} [secret]
+ * @property {Dossier[]} [dossiers] // pas vraiment des Dossier vu que venant d'un join
*/
/** @type {PitchouState} */
const state = {
- secret: undefined
+ secret: undefined,
+ dossiers: undefined
}
const mutations = {
@@ -34,6 +39,13 @@ const mutations = {
*/
setSecret(state, secret) {
state.secret = secret
+ },
+ /**
+ * @param {PitchouState} state
+ * @param {PitchouState['dossiers']} dossiers
+ */
+ setDossiers(state, dossiers) {
+ state.dossiers = dossiers
}
}
diff --git a/scripts/server/database.js b/scripts/server/database.js
index a26e8338..6340adcb 100644
--- a/scripts/server/database.js
+++ b/scripts/server/database.js
@@ -4,6 +4,7 @@ import knex from 'knex';
/** @typedef {import('../types/database/public/Personne.js').default} Personne */
/** @typedef {import('../types/database/public/Dossier.js').default} Dossier */
+/** @typedef {import('../types/database/public/Entreprise.js').default} Entreprise */
const DATABASE_URL = process.env.DATABASE_URL
if(!DATABASE_URL){
@@ -24,6 +25,16 @@ export function créerPersonne(personne){
.insert(personne)
}
+/**
+ * @param {import('../types/database/public/Personne.js').PersonneInitializer[]} personnes
+ * @returns { Promise<{id: Personne['id']}[]> }
+ */
+export function créerPersonnes(personnes){
+ return database('personne')
+ .insert(personnes, ['id'])
+}
+
+
/**
*
* @param {Personne['code_accès']} code_accès
@@ -48,15 +59,6 @@ export function getPersonneByEmail(email) {
.first()
}
-/**
- *
- * @returns {Promise}
- */
-export function getAllDossier() {
- return database('dossier')
- .select()
-}
-
/**
*
* @param {Personne['email']} email
@@ -88,4 +90,97 @@ export function créerPersonneOuMettreÀJourCodeAccès(email){
return updateCodeAccès(email, codeAccès)
})
.then(() => codeAccès)
+}
+
+/**
+ *
+ * @returns {Promise}
+ */
+export function listAllPersonnes(){
+ return database('personne').select()
+}
+
+
+
+
+
+/**
+ *
+ * @returns {Promise}
+ */
+export function listAllDossier() {
+ return database('dossier').select()
+}
+
+/**
+ * @typedef {Dossier} DossierComplet
+ * @property {string} déposant_nom
+ * @property {string} déposant_prénoms
+ *
+ */
+
+
+/**
+ *
+ * @returns {Promise}
+ */
+export function listAllDossiersComplets() {
+ return database('dossier')
+ .select([
+ "dossier.id as id",
+ "id_demarches_simplifiées",
+ "statut",
+ "date_dépôt",
+ "espèces_protégées_concernées",
+ "enjeu_écologiques",
+ // localisation
+ "départements",
+ "communes",
+ "régions",
+ // déposant
+ "déposant.nom as déposant_nom",
+ "déposant.prénoms as déposant_prénoms",
+ // demandeur_personne_physique
+ "demandeur_personne_physique.nom as demandeur_personne_physique_nom",
+ "demandeur_personne_physique.prénoms as demandeur_personne_physique_prénoms",
+ // demandeur_personne_morale
+ "demandeur_personne_morale.siret as demandeur_personne_morale_siret",
+ "demandeur_personne_morale.raison_sociale as demandeur_personne_morale_raison_sociale",
+ ])
+ .leftJoin('personne as déposant', {'déposant.id': 'dossier.déposant'})
+ .leftJoin('personne as demandeur_personne_physique', {'demandeur_personne_physique.id': 'dossier.demandeur_personne_physique'})
+ .leftJoin('entreprise as demandeur_personne_morale', {'demandeur_personne_morale.siret': 'dossier.demandeur_personne_morale'})
+}
+
+/**
+ *
+ * @param {Dossier[]} dossiers
+ * @returns {Promise}
+ */
+export function dumpDossiers(dossiers){
+ return database('dossier')
+ .insert(dossiers)
+ .onConflict('id_demarches_simplifiées')
+ .merge()
+}
+
+
+/**
+ *
+ * @returns {Promise}
+ */
+export function listAllEntreprises(){
+ return database('entreprise').select()
+}
+
+/**
+ *
+ * @param {Entreprise[]} entreprises
+ * @returns {Promise}
+ */
+export function dumpEntreprises(entreprises){
+ return database('entreprise')
+ .insert(entreprises)
+ .onConflict('siret')
+ .merge()
}
\ No newline at end of file
diff --git a/scripts/server/main.js b/scripts/server/main.js
index efbb853e..dbbfb4ef 100644
--- a/scripts/server/main.js
+++ b/scripts/server/main.js
@@ -5,7 +5,7 @@ import path from 'node:path'
import Fastify from 'fastify'
import fastatic from '@fastify/static'
-import { getPersonneByCode, getAllDossier, créerPersonneOuMettreÀJourCodeAccès } from './database.js'
+import { getPersonneByCode, listAllDossiersComplets, créerPersonneOuMettreÀJourCodeAccès } from './database.js'
import { authorizedEmailDomains } from '../commun/constantes.js'
import { envoyerEmailConnexion } from './emails.js'
@@ -37,6 +37,9 @@ fastify.register(fastatic, {
fastify.get('/saisie-especes', (request, reply) => {
reply.sendFile('index.html')
})
+fastify.get('/dossier/:dossierId', (request, reply) => {
+ reply.sendFile('index.html')
+})
// Privileged routes
@@ -46,7 +49,7 @@ fastify.get('/dossiers', async function (request, reply) {
if (code_accès) {
const personne = await getPersonneByCode(code_accès)
if (personne) {
- return getAllDossier()
+ return listAllDossiersComplets()
} else {
reply.code(403).send("Code d'accès non valide.")
}
@@ -55,6 +58,7 @@ fastify.get('/dossiers', async function (request, reply) {
}
})
+
fastify.post('/envoi-email-connexion', async function (request, reply) {
// @ts-ignore
const email = decodeURIComponent(request.query.email)
diff --git "a/scripts/server/recup\303\251rerDossiersR\303\251cemmentModifi\303\251s.js" "b/scripts/server/recup\303\251rerDossiersR\303\251cemmentModifi\303\251s.js"
index 502ae147..9984663f 100644
--- "a/scripts/server/recup\303\251rerDossiersR\303\251cemmentModifi\303\251s.js"
+++ "b/scripts/server/recup\303\251rerDossiersR\303\251cemmentModifi\303\251s.js"
@@ -28,20 +28,16 @@ query getDemarche(
$deletedBefore: String
$deletedAfter: String
$deletedSince: ISO8601DateTime
- $includeGroupeInstructeurs: Boolean = false
$includeDossiers: Boolean = true
$includePendingDeletedDossiers: Boolean = false
$includeDeletedDossiers: Boolean = false
- $includeRevision: Boolean = false
- $includeService: Boolean = false
$includeChamps: Boolean = true
$includeAnotations: Boolean = true
$includeTraitements: Boolean = true
$includeInstructeurs: Boolean = true
- $includeAvis: Boolean = false
- $includeMessages: Boolean = false
- $includeCorrections: Boolean = false
- $includeGeometry: Boolean = false
+ $includeAvis: Boolean = true
+ $includeMessages: Boolean = true
+ $includeCorrections: Boolean = true
) {
demarche(number: $demarcheNumber) {
id
@@ -50,15 +46,9 @@ query getDemarche(
state
dateCreation
dateFermeture
- activeRevision @include(if: $includeRevision) {
- ...RevisionFragment
- }
- groupeInstructeurs @include(if: $includeGroupeInstructeurs) {
+ groupeInstructeurs {
...GroupeInstructeurFragment
}
- service @include(if: $includeService) {
- ...ServiceFragment
- }
dossiers(
state: $state
first: $first
@@ -108,13 +98,6 @@ query getDemarche(
}
}
-fragment ServiceFragment on Service {
- nom
- siret
- organisme
- typeOrganisme
-}
-
fragment GroupeInstructeurFragment on GroupeInstructeur {
id
number
@@ -156,7 +139,6 @@ fragment DossierFragment on Dossier {
prenomMandataire
nomMandataire
deposeParUnTiers
- connectionUsager
groupeInstructeur {
...GroupeInstructeurFragment
}
@@ -206,54 +188,6 @@ fragment DeletedDossierFragment on DeletedDossier {
reason
}
-fragment RevisionFragment on Revision {
- id
- datePublication
- champDescriptors {
- ...ChampDescriptorFragment
- ... on RepetitionChampDescriptor {
- champDescriptors {
- ...ChampDescriptorFragment
- }
- }
- }
- annotationDescriptors {
- ...ChampDescriptorFragment
- ... on RepetitionChampDescriptor {
- champDescriptors {
- ...ChampDescriptorFragment
- }
- }
- }
-}
-
-fragment ChampDescriptorFragment on ChampDescriptor {
- __typename
- id
- label
- description
- required
- ... on DropDownListChampDescriptor {
- options
- otherOption
- }
- ... on MultipleDropDownListChampDescriptor {
- options
- }
- ... on LinkedDropDownListChampDescriptor {
- options
- }
- ... on PieceJustificativeChampDescriptor {
- fileTemplate {
- ...FileFragment
- }
- }
- ... on ExplicationChampDescriptor {
- collapsibleExplanationEnabled
- collapsibleExplanationText
- }
-}
-
fragment AvisFragment on Avis {
id
question
@@ -285,23 +219,6 @@ fragment MessageFragment on Message {
}
}
-fragment GeoAreaFragment on GeoArea {
- id
- source
- description
- geometry @include(if: $includeGeometry) {
- type
- coordinates
- }
- ... on ParcelleCadastrale {
- commune
- numero
- section
- prefixe
- surface
- }
-}
-
fragment RootChampFragment on Champ {
... on RepetitionChamp {
rows {
@@ -310,11 +227,6 @@ fragment RootChampFragment on Champ {
}
}
}
- ... on CarteChamp {
- geoAreas {
- ...GeoAreaFragment
- }
- }
... on DossierLinkChamp {
dossier {
id
@@ -326,12 +238,9 @@ fragment RootChampFragment on Champ {
fragment ChampFragment on Champ {
id
- champDescriptorId
- __typename
label
stringValue
updatedAt
- prefilled
... on DateChamp {
date
}
@@ -399,11 +308,6 @@ fragment ChampFragment on Champ {
...RegionFragment
}
}
- ... on PaysChamp {
- pays {
- ...PaysFragment
- }
- }
... on SiretChamp {
etablissement {
...PersonneMoraleFragment
@@ -420,40 +324,18 @@ fragment ChampFragment on Champ {
...DepartementFragment
}
}
- ... on EngagementJuridiqueChamp {
- engagementJuridique {
- ...EngagementJuridiqueFragment
- }
- }
}
fragment PersonneMoraleFragment on PersonneMorale {
siret
- siegeSocial
- naf
- libelleNaf
address {
...AddressFragment
}
entreprise {
siren
- capitalSocial
- numeroTvaIntracommunautaire
- formeJuridique
- formeJuridiqueCode
nomCommercial
raisonSociale
siretSiegeSocial
- codeEffectifEntreprise
- dateCreation
- nom
- prenom
- attestationFiscaleAttachment {
- ...FileFragment
- }
- attestationSocialeAttachment {
- ...FileFragment
- }
}
association {
rna
@@ -489,22 +371,11 @@ fragment FileFragment on File {
fragment AddressFragment on Address {
label
- type
streetAddress
- streetNumber
- streetName
postalCode
cityName
cityCode
- departmentName
departmentCode
- regionName
- regionCode
-}
-
-fragment PaysFragment on Pays {
- name
- code
}
fragment RegionFragment on Region {
@@ -536,11 +407,6 @@ fragment RNFFragment on RNF {
}
}
-fragment EngagementJuridiqueFragment on EngagementJuridique {
- montantEngage
- montantPaye
-}
-
fragment PageInfoFragment on PageInfo {
hasPreviousPage
hasNextPage
@@ -548,7 +414,6 @@ fragment PageInfoFragment on PageInfo {
endCursor
}
-
`;
export async function recupérerDossiersRécemmentModifiés({token, démarcheId, updatedSince}) {
@@ -567,8 +432,9 @@ export async function recupérerDossiersRécemmentModifiés({token, démarcheId,
}
}).json();
- if(response.error){
- console.error('request page error', response.error)
+
+ if(response.errors){
+ console.error('request page error', response.errors)
}
return response.data.demarche;
diff --git a/scripts/types/database/public/Dossier.js b/scripts/types/database/public/Dossier.js
index cd0a722f..bd0abfc3 100644
--- a/scripts/types/database/public/Dossier.js
+++ b/scripts/types/database/public/Dossier.js
@@ -1,5 +1,5 @@
-// @generated
-// This file is automatically generated by Kanel. Do not modify manually.
+/** @typedef {import('./Personne').PersonneId} PersonneId */
+/** @typedef {import('./Entreprise').EntrepriseSiret} EntrepriseSiret */
/**
* Identifier type for public.dossier
@@ -12,20 +12,30 @@
* @property {string | null} id_demarches_simplifiées
* @property {string | null} statut
* @property {Date | null} date_dépôt
- * @property {string | null} identité_petitionnaire
* @property {string | null} espèces_protégées_concernées
* @property {string | null} enjeu_écologiques
+ * @property {unknown | null} départements
+ * @property {unknown | null} communes
+ * @property {PersonneId | null} déposant
+ * @property {PersonneId | null} demandeur_personne_physique
+ * @property {EntrepriseSiret | null} demandeur_personne_morale
+ * @property {unknown | null} régions
*/
/**
* Represents the initializer for the table public.dossier
* @typedef {Object} DossierInitializer
- * @property {DossierId} [id] Default value: nextval('dossiers_id_seq'::regclass)
+ * @property {DossierId} [id] Default value: nextval('dossier_id_seq'::regclass)
* @property {string | null} [id_demarches_simplifiées]
* @property {string | null} [statut]
* @property {Date | null} [date_dépôt]
- * @property {string | null} [identité_petitionnaire]
* @property {string | null} [espèces_protégées_concernées]
* @property {string | null} [enjeu_écologiques]
+ * @property {unknown | null} [départements]
+ * @property {unknown | null} [communes]
+ * @property {PersonneId | null} [déposant]
+ * @property {PersonneId | null} [demandeur_personne_physique]
+ * @property {EntrepriseSiret | null} [demandeur_personne_morale]
+ * @property {unknown | null} [régions]
*/
/**
* Represents the mutator for the table public.dossier
@@ -34,7 +44,12 @@
* @property {string | null} [id_demarches_simplifiées]
* @property {string | null} [statut]
* @property {Date | null} [date_dépôt]
- * @property {string | null} [identité_petitionnaire]
* @property {string | null} [espèces_protégées_concernées]
* @property {string | null} [enjeu_écologiques]
+ * @property {unknown | null} [départements]
+ * @property {unknown | null} [communes]
+ * @property {PersonneId | null} [déposant]
+ * @property {PersonneId | null} [demandeur_personne_physique]
+ * @property {EntrepriseSiret | null} [demandeur_personne_morale]
+ * @property {unknown | null} [régions]
*/
diff --git a/scripts/types/database/public/Dossier.ts b/scripts/types/database/public/Dossier.ts
index 7a7358cc..28738ff9 100644
--- a/scripts/types/database/public/Dossier.ts
+++ b/scripts/types/database/public/Dossier.ts
@@ -1,6 +1,9 @@
// @generated
// This file is automatically generated by Kanel. Do not modify manually.
+import { type PersonneId } from './Personne';
+import { type EntrepriseSiret } from './Entreprise';
+
/** Identifier type for public.dossier */
export type DossierId = number & { __brand: 'DossierId' };
@@ -14,16 +17,26 @@ export default interface Dossier {
date_dépôt: Date | null;
- identité_petitionnaire: string | null;
-
espèces_protégées_concernées: string | null;
enjeu_écologiques: string | null;
+
+ départements: unknown | null;
+
+ communes: unknown | null;
+
+ déposant: PersonneId | null;
+
+ demandeur_personne_physique: PersonneId | null;
+
+ demandeur_personne_morale: EntrepriseSiret | null;
+
+ régions: unknown | null;
}
/** Represents the initializer for the table public.dossier */
export interface DossierInitializer {
- /** Default value: nextval('dossiers_id_seq'::regclass) */
+ /** Default value: nextval('dossier_id_seq'::regclass) */
id?: DossierId;
id_demarches_simplifiées?: string | null;
@@ -32,11 +45,21 @@ export interface DossierInitializer {
date_dépôt?: Date | null;
- identité_petitionnaire?: string | null;
-
espèces_protégées_concernées?: string | null;
enjeu_écologiques?: string | null;
+
+ départements?: unknown | null;
+
+ communes?: unknown | null;
+
+ déposant?: PersonneId | null;
+
+ demandeur_personne_physique?: PersonneId | null;
+
+ demandeur_personne_morale?: EntrepriseSiret | null;
+
+ régions?: unknown | null;
}
/** Represents the mutator for the table public.dossier */
@@ -49,9 +72,19 @@ export interface DossierMutator {
date_dépôt?: Date | null;
- identité_petitionnaire?: string | null;
-
espèces_protégées_concernées?: string | null;
enjeu_écologiques?: string | null;
+
+ départements?: unknown | null;
+
+ communes?: unknown | null;
+
+ déposant?: PersonneId | null;
+
+ demandeur_personne_physique?: PersonneId | null;
+
+ demandeur_personne_morale?: EntrepriseSiret | null;
+
+ régions?: unknown | null;
}
diff --git a/scripts/types/database/public/Entreprise.js b/scripts/types/database/public/Entreprise.js
new file mode 100644
index 00000000..18543673
--- /dev/null
+++ b/scripts/types/database/public/Entreprise.js
@@ -0,0 +1,28 @@
+// @generated
+// This file is automatically generated by Kanel. Do not modify manually.
+
+/**
+ * Identifier type for public.entreprise
+ * @typedef {string & { __brand: 'EntrepriseSiret' }} EntrepriseSiret
+ */
+/**
+ * Represents the table public.entreprise
+ * @typedef {Object} Entreprise
+ * @property {EntrepriseSiret} siret
+ * @property {string | null} raison_sociale
+ * @property {string | null} adresse
+ */
+/**
+ * Represents the initializer for the table public.entreprise
+ * @typedef {Object} EntrepriseInitializer
+ * @property {EntrepriseSiret} siret
+ * @property {string | null} [raison_sociale]
+ * @property {string | null} [adresse]
+ */
+/**
+ * Represents the mutator for the table public.entreprise
+ * @typedef {Object} EntrepriseMutator
+ * @property {EntrepriseSiret} [siret]
+ * @property {string | null} [raison_sociale]
+ * @property {string | null} [adresse]
+ */
diff --git a/scripts/types/database/public/Entreprise.ts b/scripts/types/database/public/Entreprise.ts
new file mode 100644
index 00000000..fe17377f
--- /dev/null
+++ b/scripts/types/database/public/Entreprise.ts
@@ -0,0 +1,32 @@
+// @generated
+// This file is automatically generated by Kanel. Do not modify manually.
+
+/** Identifier type for public.entreprise */
+export type EntrepriseSiret = string & { __brand: 'EntrepriseSiret' };
+
+/** Represents the table public.entreprise */
+export default interface Entreprise {
+ siret: EntrepriseSiret;
+
+ raison_sociale: string | null;
+
+ adresse: string | null;
+}
+
+/** Represents the initializer for the table public.entreprise */
+export interface EntrepriseInitializer {
+ siret: EntrepriseSiret;
+
+ raison_sociale?: string | null;
+
+ adresse?: string | null;
+}
+
+/** Represents the mutator for the table public.entreprise */
+export interface EntrepriseMutator {
+ siret?: EntrepriseSiret;
+
+ raison_sociale?: string | null;
+
+ adresse?: string | null;
+}
diff --git a/scripts/types/database/public/KnexMigrations.js b/scripts/types/database/public/KnexMigrations.js
new file mode 100644
index 00000000..313d69ad
--- /dev/null
+++ b/scripts/types/database/public/KnexMigrations.js
@@ -0,0 +1,31 @@
+// @generated
+// This file is automatically generated by Kanel. Do not modify manually.
+export {};
+/**
+ * Identifier type for public.knex_migrations
+ * @typedef {number & { __brand: 'KnexMigrationsId' }} KnexMigrationsId
+ */
+/**
+ * Represents the table public.knex_migrations
+ * @typedef {Object} KnexMigrations
+ * @property {KnexMigrationsId} id
+ * @property {string | null} name
+ * @property {number | null} batch
+ * @property {Date | null} migration_time
+ */
+/**
+ * Represents the initializer for the table public.knex_migrations
+ * @typedef {Object} KnexMigrationsInitializer
+ * @property {KnexMigrationsId} [id] Default value: nextval('knex_migrations_id_seq'::regclass)
+ * @property {string | null} [name]
+ * @property {number | null} [batch]
+ * @property {Date | null} [migration_time]
+ */
+/**
+ * Represents the mutator for the table public.knex_migrations
+ * @typedef {Object} KnexMigrationsMutator
+ * @property {KnexMigrationsId} [id]
+ * @property {string | null} [name]
+ * @property {number | null} [batch]
+ * @property {Date | null} [migration_time]
+ */
diff --git a/scripts/types/database/public/KnexMigrations.ts b/scripts/types/database/public/KnexMigrations.ts
new file mode 100644
index 00000000..3a05fd55
--- /dev/null
+++ b/scripts/types/database/public/KnexMigrations.ts
@@ -0,0 +1,39 @@
+// @generated
+// This file is automatically generated by Kanel. Do not modify manually.
+
+/** Identifier type for public.knex_migrations */
+export type KnexMigrationsId = number & { __brand: 'KnexMigrationsId' };
+
+/** Represents the table public.knex_migrations */
+export default interface KnexMigrations {
+ id: KnexMigrationsId;
+
+ name: string | null;
+
+ batch: number | null;
+
+ migration_time: Date | null;
+}
+
+/** Represents the initializer for the table public.knex_migrations */
+export interface KnexMigrationsInitializer {
+ /** Default value: nextval('knex_migrations_id_seq'::regclass) */
+ id?: KnexMigrationsId;
+
+ name?: string | null;
+
+ batch?: number | null;
+
+ migration_time?: Date | null;
+}
+
+/** Represents the mutator for the table public.knex_migrations */
+export interface KnexMigrationsMutator {
+ id?: KnexMigrationsId;
+
+ name?: string | null;
+
+ batch?: number | null;
+
+ migration_time?: Date | null;
+}
diff --git a/scripts/types/database/public/KnexMigrationsLock.js b/scripts/types/database/public/KnexMigrationsLock.js
new file mode 100644
index 00000000..1a383045
--- /dev/null
+++ b/scripts/types/database/public/KnexMigrationsLock.js
@@ -0,0 +1,25 @@
+// @generated
+// This file is automatically generated by Kanel. Do not modify manually.
+export {};
+/**
+ * Identifier type for public.knex_migrations_lock
+ * @typedef {number & { __brand: 'KnexMigrationsLockIndex' }} KnexMigrationsLockIndex
+ */
+/**
+ * Represents the table public.knex_migrations_lock
+ * @typedef {Object} KnexMigrationsLock
+ * @property {KnexMigrationsLockIndex} index
+ * @property {number | null} is_locked
+ */
+/**
+ * Represents the initializer for the table public.knex_migrations_lock
+ * @typedef {Object} KnexMigrationsLockInitializer
+ * @property {KnexMigrationsLockIndex} [index] Default value: nextval('knex_migrations_lock_index_seq'::regclass)
+ * @property {number | null} [is_locked]
+ */
+/**
+ * Represents the mutator for the table public.knex_migrations_lock
+ * @typedef {Object} KnexMigrationsLockMutator
+ * @property {KnexMigrationsLockIndex} [index]
+ * @property {number | null} [is_locked]
+ */
diff --git a/scripts/types/database/public/KnexMigrationsLock.ts b/scripts/types/database/public/KnexMigrationsLock.ts
new file mode 100644
index 00000000..4b45161a
--- /dev/null
+++ b/scripts/types/database/public/KnexMigrationsLock.ts
@@ -0,0 +1,27 @@
+// @generated
+// This file is automatically generated by Kanel. Do not modify manually.
+
+/** Identifier type for public.knex_migrations_lock */
+export type KnexMigrationsLockIndex = number & { __brand: 'KnexMigrationsLockIndex' };
+
+/** Represents the table public.knex_migrations_lock */
+export default interface KnexMigrationsLock {
+ index: KnexMigrationsLockIndex;
+
+ is_locked: number | null;
+}
+
+/** Represents the initializer for the table public.knex_migrations_lock */
+export interface KnexMigrationsLockInitializer {
+ /** Default value: nextval('knex_migrations_lock_index_seq'::regclass) */
+ index?: KnexMigrationsLockIndex;
+
+ is_locked?: number | null;
+}
+
+/** Represents the mutator for the table public.knex_migrations_lock */
+export interface KnexMigrationsLockMutator {
+ index?: KnexMigrationsLockIndex;
+
+ is_locked?: number | null;
+}
diff --git a/scripts/types/database/public/Migrations.js b/scripts/types/database/public/Migrations.js
deleted file mode 100644
index fad2190a..00000000
--- a/scripts/types/database/public/Migrations.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// @generated
-// This file is automatically generated by Kanel. Do not modify manually.
-export {};
-/**
- * Identifier type for public.migrations
- * @typedef {number & { __brand: 'MigrationsId' }} MigrationsId
- */
-/**
- * Represents the table public.migrations
- * @typedef {Object} Migrations
- * @property {MigrationsId} id
- * @property {string} name
- * @property {Date} run_on
- */
-/**
- * Represents the initializer for the table public.migrations
- * @typedef {Object} MigrationsInitializer
- * @property {MigrationsId} [id] Default value: nextval('migrations_id_seq'::regclass)
- * @property {string} name
- * @property {Date} run_on
- */
-/**
- * Represents the mutator for the table public.migrations
- * @typedef {Object} MigrationsMutator
- * @property {MigrationsId} [id]
- * @property {string} [name]
- * @property {Date} [run_on]
- */
diff --git a/scripts/types/database/public/Migrations.ts b/scripts/types/database/public/Migrations.ts
deleted file mode 100644
index 8c551c1e..00000000
--- a/scripts/types/database/public/Migrations.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-// @generated
-// This file is automatically generated by Kanel. Do not modify manually.
-
-/** Identifier type for public.migrations */
-export type MigrationsId = number & { __brand: 'MigrationsId' };
-
-/** Represents the table public.migrations */
-export default interface Migrations {
- id: MigrationsId;
-
- name: string;
-
- run_on: Date;
-}
-
-/** Represents the initializer for the table public.migrations */
-export interface MigrationsInitializer {
- /** Default value: nextval('migrations_id_seq'::regclass) */
- id?: MigrationsId;
-
- name: string;
-
- run_on: Date;
-}
-
-/** Represents the mutator for the table public.migrations */
-export interface MigrationsMutator {
- id?: MigrationsId;
-
- name?: string;
-
- run_on?: Date;
-}