mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
ac96644508
Four files taken apart rather than moved, because they only worked as a knot. The mailer becomes its own leaf module. AuthService sends the password-reset mail while NotificationsModule imports AuthModule for the demo gate in NotificationsMcp - a mailer inside the notifications domain would have closed a hard cycle that only a forwardRef could open again. Webhook and ntfy stay with notifications; auth has no business importing them. The channel registry stays a module singleton and does NOT become a provider. PluginRuntimeService pushes its channel getter in at onModuleInit, and notifications.bridge.ts builds its own NotificationsService for the scheduler crons and the memories senders. A provider would hand the bridge a second, empty registry - every plugin channel would then go quiet with no error anywhere. CHOVR-015 drives that seam end to end: a channel published through the runtime, delivered through the bridge. Nothing pinned it before; the existing cases all set the source themselves. The built-ins no longer self-register by side-effect import. They used to exist only because notificationPreferencesService happened to `import './notifications/builtins'`; removing that line would have silenced email, webhook and ntfy without a failure. They are built from the injected transports and registered from NotificationsService's constructor, so both instances have them. No cached nodemailer transport: MailerService.createTransport re-reads the SMTP config and skipTlsVerify per send, exactly as the three inline call sites did, so an admin changing them does not have to restart. Preferences become a provider over DatabaseService. Eight places built NotificationsService by hand, so a tests/helpers/notifications.ts factory keeps the next constructor parameter a one-file diff instead of an eight-file one.
87 lines
4.7 KiB
TypeScript
87 lines
4.7 KiB
TypeScript
import { DatabaseService } from '../../src/nest/database/database.service';
|
|
import { PluginRuntimeService } from '../../src/nest/plugins/plugin-runtime.service';
|
|
import type { PluginRegistryService } from '../../src/nest/plugins/registry/registry.service';
|
|
import { PluginHostDepsFactory } from '../../src/nest/plugins/host/plugin-host-deps.factory';
|
|
import { PluginOAuthService } from '../../src/nest/plugins/plugin-oauth.service';
|
|
import { BudgetService } from '../../src/nest/budget/budget.service';
|
|
import { ExchangeRatesService } from '../../src/nest/budget/exchange-rates.service';
|
|
import { ReservationsService } from '../../src/nest/reservations/reservations.service';
|
|
import { TagsService } from '../../src/nest/tags/tags.service';
|
|
import { CategoriesService } from '../../src/nest/categories/categories.service';
|
|
import { TodoService } from '../../src/nest/todo/todo.service';
|
|
import { PackingService } from '../../src/nest/packing/packing.service';
|
|
import { DayNotesService } from '../../src/nest/days/day-notes.service';
|
|
import { DaysService } from '../../src/nest/days/days.service';
|
|
import { AssignmentsService } from '../../src/nest/assignments/assignments.service';
|
|
import { LlmConfigResolver } from '../../src/nest/llm-parse/llm-config.resolver';
|
|
import { SettingsService } from '../../src/nest/settings/settings.service';
|
|
import { FilesService } from '../../src/nest/files/files.service';
|
|
import { CollabService } from '../../src/nest/collab/collab.service';
|
|
import { VacayService } from '../../src/nest/vacay/vacay.service';
|
|
import { TripsService } from '../../src/nest/trips/trips.service';
|
|
import { PlacesService } from '../../src/nest/places/places.service';
|
|
import { CollectionsService } from '../../src/nest/collections/collections.service';
|
|
import { AtlasService } from '../../src/nest/atlas/atlas.service';
|
|
import { NotificationsService } from '../../src/nest/notifications/notifications.service';
|
|
import { MapsService } from '../../src/nest/maps/maps.service';
|
|
import { PermissionsService } from '../../src/nest/permissions/permissions.service';
|
|
import { AuditService } from '../../src/nest/audit/audit.service';
|
|
import { AddonsService } from '../../src/nest/addons/addons.service';
|
|
import { RealtimeService } from '../../src/nest/realtime/realtime.service';
|
|
import { QueryHelpersService } from '../../src/nest/query-helpers/query-helpers.service';
|
|
import { makeNotificationsService, makeNotificationPreferencesService } from './notifications';
|
|
|
|
/**
|
|
* Hand-wired counterpart of the PluginsModule DI graph for no-Nest tests
|
|
* (same pattern as mcp-test-controllers.ts): real domain services over the
|
|
* test DB, so runtime tests exercise the same wiring production gets from
|
|
* the container.
|
|
*/
|
|
export function createHostDepsFactory(dbs: DatabaseService): PluginHostDepsFactory {
|
|
const permissions = new PermissionsService(dbs);
|
|
const exchangeRates = new ExchangeRatesService();
|
|
const realtime = new RealtimeService();
|
|
const budget = new BudgetService(dbs, permissions, exchangeRates, realtime);
|
|
const addons = new AddonsService(dbs);
|
|
const queryHelpers = new QueryHelpersService(dbs);
|
|
const todos = new TodoService(dbs, permissions, realtime);
|
|
const packing = new PackingService(dbs, permissions, realtime);
|
|
const files = new FilesService(dbs, permissions, realtime);
|
|
const reservations = new ReservationsService(dbs, permissions, budget, realtime);
|
|
const collab = new CollabService(dbs, permissions, realtime);
|
|
const vacay = new VacayService(dbs, realtime);
|
|
const days = new DaysService(dbs, permissions, realtime, queryHelpers);
|
|
const places = new PlacesService(dbs, permissions, realtime, new MapsService(dbs), queryHelpers);
|
|
return new PluginHostDepsFactory(
|
|
budget,
|
|
reservations,
|
|
new TagsService(dbs),
|
|
new CategoriesService(dbs),
|
|
todos,
|
|
packing,
|
|
new PluginOAuthService(dbs),
|
|
new DayNotesService(dbs, permissions, realtime),
|
|
new AssignmentsService(dbs, permissions, realtime, queryHelpers),
|
|
new LlmConfigResolver(new SettingsService(dbs), dbs, addons),
|
|
dbs,
|
|
files,
|
|
collab,
|
|
vacay,
|
|
days,
|
|
permissions,
|
|
exchangeRates,
|
|
addons,
|
|
realtime,
|
|
new TripsService(dbs, todos, packing, files, reservations, days, permissions, budget, collab, vacay, realtime, places),
|
|
places,
|
|
new CollectionsService(dbs, permissions, realtime),
|
|
new AtlasService(dbs),
|
|
makeNotificationsService(dbs, realtime),
|
|
);
|
|
}
|
|
|
|
/** A PluginRuntimeService constructed the way Nest would: with a real host-deps factory. */
|
|
export function createPluginRuntime(dbs: DatabaseService, registry?: PluginRegistryService): PluginRuntimeService {
|
|
return new PluginRuntimeService(dbs, new AuditService(dbs), new AddonsService(dbs), registry, createHostDepsFactory(dbs));
|
|
}
|