2026-10-05 11:13:51 +00:00
|
|
|
import { UniqueID } from "@repo/rdx-ddd";
|
|
|
|
|
import { Maybe, Result } from "@repo/rdx-utils";
|
|
|
|
|
import type { RequestHandler } from "express";
|
|
|
|
|
import type { Sequelize } from "sequelize";
|
|
|
|
|
|
|
|
|
|
import { ResourceUseCases } from "./application/resource.use-cases";
|
|
|
|
|
import { ResourceCatalogUseCases } from "./application/resource-catalog.use-cases";
|
2026-10-06 15:15:42 +00:00
|
|
|
import { ResourceInventoryService } from "./application/resource-inventory.service";
|
2026-10-05 11:13:51 +00:00
|
|
|
import { seedResourceCatalog } from "./domain/resource-catalog-seed";
|
|
|
|
|
import { registerResourceRoutes } from "./infrastructure/http/resource.routes";
|
|
|
|
|
import { registerResourceCatalogRoutes } from "./infrastructure/http/resource-catalog.routes";
|
2026-10-05 15:01:32 +00:00
|
|
|
import { migrateLegacyResources } from "./infrastructure/persistence/migrate-legacy-resources";
|
2026-10-10 16:21:06 +00:00
|
|
|
import { migrateSupportResources } from "./infrastructure/persistence/migrate-support-resources";
|
2026-10-05 11:13:51 +00:00
|
|
|
import { migrateInventory } from "./infrastructure/persistence/resource.model";
|
|
|
|
|
import {
|
|
|
|
|
ResourceCatalogModel,
|
|
|
|
|
migrateResourceCatalog,
|
|
|
|
|
} from "./infrastructure/persistence/resource-catalog.model";
|
|
|
|
|
import { ResourceCatalogPersistenceMapper } from "./infrastructure/persistence/resource-catalog-persistence.mapper";
|
feat(dashboard): implement dashboard schemas and API integration
- Added Zod schemas for dashboard queries, entries, summaries, and companies.
- Created dashboard API functions for fetching summary, work, attention, activity, and companies data.
- Developed dashboard components including BlockState, DashboardDetailsDialog, and DashboardPage for rendering dashboard information.
- Implemented quick create functionality for companies, tickets, interventions, assets, and resources.
- Introduced a new ResourceDashboardReader for querying resource-related data.
- Added a StatisticCard component for displaying key performance indicators in the dashboard.
2026-10-08 11:27:27 +00:00
|
|
|
import { ResourceDashboardReader } from "./infrastructure/persistence/resource-dashboard-reader";
|
2026-10-10 15:57:05 +00:00
|
|
|
import { enforceResourceConstraints } from "./infrastructure/persistence/resource-relational-schema";
|
2026-10-19 09:45:09 +00:00
|
|
|
import { migrateResourceRevisionSpecifications } from "./infrastructure/persistence/resource-revision-specifications";
|
2026-10-05 11:13:51 +00:00
|
|
|
import { SequelizeResourceRepository } from "./infrastructure/persistence/sequelize-resource.repository";
|
|
|
|
|
import { SequelizeResourceCatalogRepository } from "./infrastructure/persistence/sequelize-resource-catalog.repository";
|
|
|
|
|
|
|
|
|
|
export async function createResourceModule(database: Sequelize, authenticate: RequestHandler) {
|
|
|
|
|
await migrateResourceCatalog(database);
|
|
|
|
|
await ResourceCatalogModel.findOrCreate({
|
|
|
|
|
where: { catalogKey: "global" },
|
|
|
|
|
defaults: { id: UniqueID.generateNewID().toPrimitive(), catalogKey: "global" },
|
|
|
|
|
});
|
|
|
|
|
const repository = new SequelizeResourceCatalogRepository(
|
|
|
|
|
database,
|
|
|
|
|
new ResourceCatalogPersistenceMapper()
|
|
|
|
|
);
|
|
|
|
|
const seeded = await repository.update(Maybe.none(), (catalog) =>
|
|
|
|
|
Result.ok(seedResourceCatalog(catalog))
|
|
|
|
|
);
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-05 11:13:51 +00:00
|
|
|
if (!seeded.isSuccess) {
|
|
|
|
|
throw new Error("No se pudo inicializar el catálogo de recursos.");
|
|
|
|
|
}
|
|
|
|
|
await migrateInventory(database);
|
2026-10-19 09:45:09 +00:00
|
|
|
await migrateResourceRevisionSpecifications(database);
|
2026-10-10 11:32:40 +00:00
|
|
|
await enforceResourceConstraints(database);
|
2026-10-10 16:21:06 +00:00
|
|
|
await migrateSupportResources(database);
|
2026-10-05 11:13:51 +00:00
|
|
|
const catalog = new ResourceCatalogUseCases(repository);
|
2026-10-06 15:15:42 +00:00
|
|
|
const inventoryRepository = new SequelizeResourceRepository(database);
|
|
|
|
|
const inventory = new ResourceUseCases(inventoryRepository);
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-05 11:13:51 +00:00
|
|
|
return {
|
feat(dashboard): implement dashboard schemas and API integration
- Added Zod schemas for dashboard queries, entries, summaries, and companies.
- Created dashboard API functions for fetching summary, work, attention, activity, and companies data.
- Developed dashboard components including BlockState, DashboardDetailsDialog, and DashboardPage for rendering dashboard information.
- Implemented quick create functionality for companies, tickets, interventions, assets, and resources.
- Introduced a new ResourceDashboardReader for querying resource-related data.
- Added a StatisticCard component for displaying key performance indicators in the dashboard.
2026-10-08 11:27:27 +00:00
|
|
|
services: {
|
|
|
|
|
inventory: new ResourceInventoryService(inventoryRepository),
|
|
|
|
|
dashboard: new ResourceDashboardReader(database),
|
|
|
|
|
},
|
2026-10-05 15:01:32 +00:00
|
|
|
migrateLegacy: () => migrateLegacyResources(database),
|
2026-10-05 11:13:51 +00:00
|
|
|
register: (app: Parameters<typeof registerResourceCatalogRoutes>[0]) => {
|
|
|
|
|
registerResourceCatalogRoutes(app, catalog, authenticate);
|
|
|
|
|
registerResourceRoutes(app, inventory, authenticate);
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|