This commit is contained in:
Marcelo Dares
2026-04-29 01:15:50 +02:00
parent 65aaf9275e
commit ea23136288
172 changed files with 30358 additions and 353 deletions

View File

@@ -1,4 +1,4 @@
import { PrismaClient, ContentPageType, OverallScoreMethod, PriorityLevel } from "@prisma/client";
import { PrismaClient, ContentPageType, LegalJurisdictionLevel, OverallScoreMethod, PriorityLevel } from "@prisma/client";
import { readFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
@@ -389,6 +389,99 @@ const contentPageSeeds = [
},
];
const legalDirectorySeeds = [
{
jurisdictionLevel: LegalJurisdictionLevel.FEDERAL,
name: "Secretaria de la Funcion Publica (SFP)",
scopeTagsJson: ["inconformidades", "sanciones", "organo-interno-control"],
websiteUrl: "https://www.gob.mx/sfp",
phone: null,
email: null,
stateCode: null,
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.FEDERAL,
name: "Tribunal Federal de Justicia Administrativa (TFJA)",
scopeTagsJson: ["juicio-contencioso", "nulidad", "sanciones-administrativas"],
websiteUrl: "https://www.tfja.gob.mx",
phone: null,
email: null,
stateCode: null,
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.FEDERAL,
name: "Auditoria Superior de la Federacion (ASF)",
scopeTagsJson: ["auditoria", "fiscalizacion", "cuenta-publica"],
websiteUrl: "https://www.asf.gob.mx",
phone: null,
email: null,
stateCode: null,
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.FEDERAL,
name: "CompraNet",
scopeTagsJson: ["contrataciones", "licitaciones", "expedientes"],
websiteUrl: "https://compranet.hacienda.gob.mx",
phone: null,
email: null,
stateCode: null,
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.FEDERAL,
name: "Sistema Nacional Anticorrupcion",
scopeTagsJson: ["anticorrupcion", "denuncias", "integridad"],
websiteUrl: "https://www.sna.org.mx",
phone: null,
email: null,
stateCode: null,
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.STATE,
name: "Secretaria de la Contraloria y Transparencia Gubernamental de Nuevo Leon",
scopeTagsJson: ["inconformidades", "contraloria", "responsabilidades"],
websiteUrl: "https://www.nl.gob.mx/dependencias/contraloria",
phone: null,
email: null,
stateCode: "NL",
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.STATE,
name: "Tribunal de Justicia Administrativa de Nuevo Leon",
scopeTagsJson: ["juicio-administrativo", "sanciones", "nulidad"],
websiteUrl: "https://tjanl.gob.mx",
phone: null,
email: null,
stateCode: "NL",
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.STATE,
name: "Auditoria Superior del Estado de Nuevo Leon",
scopeTagsJson: ["auditoria", "fiscalizacion", "cuenta-publica-estatal"],
websiteUrl: "https://www.asenl.gob.mx",
phone: null,
email: null,
stateCode: "NL",
municipalityCode: null,
},
{
jurisdictionLevel: LegalJurisdictionLevel.STATE,
name: "Sistema Estatal Anticorrupcion de Nuevo Leon",
scopeTagsJson: ["anticorrupcion", "politica-estatal", "coordinacion"],
websiteUrl: "https://www.seanl.mx",
phone: null,
email: null,
stateCode: "NL",
municipalityCode: null,
},
];
async function upsertDiagnosticStructure() {
const moduleKeys = moduleSeeds.map((moduleSeed) => moduleSeed.key);
@@ -605,6 +698,48 @@ async function upsertDefaultScoringConfig() {
});
}
async function upsertLegalDirectory() {
for (const item of legalDirectorySeeds) {
const existing = await prisma.legalDirectoryEntity.findFirst({
where: {
jurisdictionLevel: item.jurisdictionLevel,
name: item.name,
stateCode: item.stateCode,
municipalityCode: item.municipalityCode,
},
select: { id: true },
});
if (existing) {
await prisma.legalDirectoryEntity.update({
where: { id: existing.id },
data: {
scopeTagsJson: item.scopeTagsJson,
websiteUrl: item.websiteUrl,
phone: item.phone,
email: item.email,
isActive: true,
},
});
continue;
}
await prisma.legalDirectoryEntity.create({
data: {
jurisdictionLevel: item.jurisdictionLevel,
name: item.name,
scopeTagsJson: item.scopeTagsJson,
websiteUrl: item.websiteUrl,
phone: item.phone,
email: item.email,
stateCode: item.stateCode,
municipalityCode: item.municipalityCode,
isActive: true,
},
});
}
}
async function loadMunicipalitySeeds() {
const filePath = path.join(__dirname, "data", "municipalities.json");
const content = await readFile(filePath, "utf-8");
@@ -697,6 +832,7 @@ async function main() {
await upsertRecommendations();
await upsertContentPages();
await upsertDefaultScoringConfig();
await upsertLegalDirectory();
const municipalitySeedCount = await upsertMunicipalities();
const moduleCount = await prisma.diagnosticModule.count();
@@ -705,6 +841,7 @@ async function main() {
const workshopCount = await prisma.developmentWorkshop.count();
const recommendationCount = await prisma.recommendation.count();
const contentPageCount = await prisma.contentPage.count();
const legalDirectoryCount = await prisma.legalDirectoryEntity.count({ where: { isActive: true } });
const municipalityCount = await prisma.municipality.count({ where: { isActive: true } });
console.log("Seed completed", {
@@ -714,6 +851,7 @@ async function main() {
workshops: workshopCount,
recommendations: recommendationCount,
contentPages: contentPageCount,
legalDirectory: legalDirectoryCount,
municipalities: municipalityCount,
municipalitySeedsProcessed: municipalitySeedCount,
});