Antes de la última revisión de etapa 4. Sprint 1. Previo al ajuste de look n feel de app, reportes, nombre y colores.

This commit is contained in:
2026-05-15 22:14:53 -03:00
parent b6f31f4371
commit 8b71c6ee13
54 changed files with 6497 additions and 261 deletions

View File

@@ -18,6 +18,29 @@ export class ProcessCostDb extends Dexie {
resources: 'id, processId, name',
simulations: 'id, processId, executedAt',
})
// Sprint 1: agrega campos de automatización a Activity y volumetría a Process.
// El upgrade popula datos existentes con defaults para garantizar invariante de tipo.
this.version(2)
.stores({
processes: 'id, name, updatedAt',
activities: 'id, processId, bpmnElementId',
gateways: 'id, processId, bpmnElementId',
resources: 'id, processId, name',
simulations: 'id, processId, executedAt',
})
.upgrade(async (tx) => {
await tx.table('activities').toCollection().modify((act) => {
if (act.automatable === undefined) act.automatable = false
if (act.automatedCostFixed === undefined) act.automatedCostFixed = 0
if (act.automatedTimeMinutes === undefined) act.automatedTimeMinutes = 0
})
await tx.table('processes').toCollection().modify((proc) => {
if (proc.annualFrequency === undefined) proc.annualFrequency = 1000
if (proc.analysisHorizonYears === undefined) proc.analysisHorizonYears = 3
if (proc.automationInvestment === undefined) proc.automationInvestment = 0
})
})
}
}

View File

@@ -1,8 +1,27 @@
/**
* @internal
*
* Repositorios de acceso a IndexedDB (Dexie).
*
* REGLA ARQUITECTÓNICA: este módulo solo debe importarse desde `src/store/**`.
* Las features y hooks deben mutar datos a través de los stores (useProcessStore,
* useSimulationStore), que garantizan la invalidación del resultado de simulación
* cuando los datos cambian.
*
* Excepciones permitidas (ver eslint.config.js):
* - src/features/import/** → operación de importación inicial (no hay simulación previa)
* - src/features/report/useReportData.ts → solo lectura, sin mutaciones
* - tests/** → acceso directo controlado en contexto de testing
*
* Cualquier import desde fuera de estos paths falla `npm run lint`.
*/
import { db } from './db'
import type { Process, Activity, GatewayConfig, Resource, Simulation } from '@/domain/types'
// ─── Process ─────────────────────────────────────────────────────────────────
/** @internal Solo llamar desde src/store/process-store.ts */
export const processRepo = {
async save(process: Process): Promise<void> {
await db.processes.put(process)
@@ -29,6 +48,7 @@ export const processRepo = {
// ─── Activity ─────────────────────────────────────────────────────────────────
/** @internal Solo llamar desde src/store/process-store.ts */
export const activityRepo = {
async save(activity: Activity): Promise<void> {
await db.activities.put(activity)
@@ -56,6 +76,7 @@ export const activityRepo = {
// ─── GatewayConfig ────────────────────────────────────────────────────────────
/** @internal Solo llamar desde src/store/process-store.ts */
export const gatewayRepo = {
async save(gateway: GatewayConfig): Promise<void> {
await db.gateways.put(gateway)
@@ -76,6 +97,7 @@ export const gatewayRepo = {
// ─── Resource ─────────────────────────────────────────────────────────────────
/** @internal Solo llamar desde src/store/process-store.ts */
export const resourceRepo = {
async save(resource: Resource): Promise<void> {
await db.resources.put(resource)
@@ -96,6 +118,7 @@ export const resourceRepo = {
// ─── Simulation ───────────────────────────────────────────────────────────────
/** @internal Solo llamar desde src/store/simulation-store.ts */
export const simulationRepo = {
async save(simulation: Simulation): Promise<void> {
await db.simulations.put(simulation)