2026-10-04 16:36:09 +00:00
|
|
|
import { createAssetModule } from "@metis/assets/module";
|
2026-10-03 10:36:03 +00:00
|
|
|
import { createCompanyModule } from "@metis/companies/module";
|
2026-10-10 14:40:51 +00:00
|
|
|
import {
|
|
|
|
|
SequelizeSessionStore,
|
|
|
|
|
createIdentityModule,
|
|
|
|
|
migrateIdentity,
|
|
|
|
|
} from "@metis/identity/module";
|
2026-10-05 11:13:51 +00:00
|
|
|
import { createResourceModule } from "@metis/resources/module";
|
2026-10-03 10:36:03 +00:00
|
|
|
import session from "express-session";
|
|
|
|
|
import type { Sequelize } from "sequelize";
|
|
|
|
|
|
|
|
|
|
import type { readDatabaseEnvironment } from "../../config/database";
|
|
|
|
|
|
|
|
|
|
export async function createIdentityRuntime(
|
|
|
|
|
database: Sequelize,
|
2026-10-05 15:01:32 +00:00
|
|
|
environment: ReturnType<typeof readDatabaseEnvironment>,
|
|
|
|
|
options: { legacyResourceFixtures?: boolean } = {}
|
2026-10-03 10:36:03 +00:00
|
|
|
) {
|
|
|
|
|
await database.authenticate();
|
|
|
|
|
await migrateIdentity(database);
|
|
|
|
|
const identity = await createIdentityModule(database, environment.APP_ORIGIN);
|
2026-10-05 15:01:32 +00:00
|
|
|
const companies = await createCompanyModule(
|
|
|
|
|
database,
|
|
|
|
|
identity.authenticate,
|
|
|
|
|
options.legacyResourceFixtures === true && environment.NODE_ENV === "test"
|
|
|
|
|
);
|
2026-10-05 11:13:51 +00:00
|
|
|
const resources = await createResourceModule(database, identity.authenticate);
|
2026-10-10 16:21:06 +00:00
|
|
|
const assets = await createAssetModule(database, identity.authenticate);
|
2026-10-04 21:06:07 +00:00
|
|
|
const mail = await companies.initializeMail(assets.services.inventory);
|
2026-10-06 15:15:42 +00:00
|
|
|
const profiles = await companies.initializeProfiles(
|
|
|
|
|
assets.services.inventory,
|
|
|
|
|
resources.services.inventory
|
|
|
|
|
);
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-05 15:01:32 +00:00
|
|
|
await resources.migrateLegacy();
|
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
|
|
|
const dashboard = companies.initializeDashboard(
|
|
|
|
|
assets.services.dashboard,
|
|
|
|
|
resources.services.dashboard
|
|
|
|
|
);
|
2026-10-10 14:40:51 +00:00
|
|
|
const store = new SequelizeSessionStore(database);
|
2026-10-03 10:36:03 +00:00
|
|
|
const middleware = session({
|
|
|
|
|
name: "metis.sid",
|
|
|
|
|
secret: environment.SESSION_SECRET,
|
|
|
|
|
store,
|
|
|
|
|
resave: false,
|
|
|
|
|
saveUninitialized: false,
|
|
|
|
|
cookie: {
|
|
|
|
|
httpOnly: true,
|
|
|
|
|
sameSite: "strict",
|
|
|
|
|
secure: environment.NODE_ENV === "production",
|
|
|
|
|
maxAge: 8 * 60 * 60 * 1000,
|
|
|
|
|
},
|
|
|
|
|
});
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-03 10:36:03 +00:00
|
|
|
return {
|
|
|
|
|
register: (app: Parameters<typeof identity.register>[0]) => {
|
|
|
|
|
identity.register(app);
|
|
|
|
|
companies.register(app);
|
2026-10-04 16:36:09 +00:00
|
|
|
assets.register(app);
|
2026-10-05 11:13:51 +00:00
|
|
|
resources.register(app);
|
2026-10-04 21:06:07 +00:00
|
|
|
mail.register(app);
|
2026-10-05 07:53:29 +00:00
|
|
|
profiles.register(app);
|
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
|
|
|
dashboard.register(app);
|
2026-10-03 10:36:03 +00:00
|
|
|
},
|
|
|
|
|
middleware,
|
2026-10-10 14:40:51 +00:00
|
|
|
// El almacén relacional no utiliza un temporizador de fondo.
|
|
|
|
|
stop: () => undefined,
|
2026-10-03 10:36:03 +00:00
|
|
|
};
|
|
|
|
|
}
|