chore: move budget backend to proper DI

This commit is contained in:
jubnl
2026-07-27 23:48:05 +02:00
parent b0041f34ba
commit 7f34dadf70
39 changed files with 1780 additions and 1490 deletions
+7 -2
View File
@@ -116,7 +116,9 @@ Wave-2 pair — its `checkPermission` import became the injected
`PermissionsService` (the auditLog half never touched the factory: the plugin
host's audit trail is the separate `plugin-audit.ts`); exchangeRateService
swapped in 2026-07 with the budget-domain fold — its `getRates` import became
the injected `ExchangeRatesService`; the remaining factory
the injected `ExchangeRatesService`; budgetService swapped in 2026-07 with the
budget migration — its `listBudgetItems` import became the already-injected
`BudgetService`, so no constructor change at all; the remaining factory
imports are all Wave-4+ domains: trips, places, journeys, atlas, collections).
### Test impact (as landed)
@@ -126,7 +128,10 @@ imports are all Wave-4+ domains: trips, places, journeys, atlas, collections).
- `tests/unit/plugins/plugin-host-deps.factory.test.ts` (was
`create-rpc-host.test.ts`) — the six DI-domain path mocks became constructor
stubs (sixteen stubs as of the 2026-07 exchange-rates fold); the ~22
legacy-service path mocks remain; a file-local shim keeps the
legacy-service path mocks shrank by one with the 2026-07 budget migration
(the budgetService satisfy-the-import mock died with the legacy file — the
`budgetStub` gained `listBudgetItems` for the two swapped closures); a
file-local shim keeps the
historical `createRealRpcHost(id, granted)` call sites and supplies a default
no-op router.
- Bridge delegation tests (TAG-SVC-016..020, CAT-SVC-016) — deleted with the
@@ -1,7 +1,6 @@
import { Injectable } from '@nestjs/common';
import { readEnv } from '../../../app-config';
import { broadcast, broadcastToUser } from '../../../websocket';
import { listBudgetItems } from '../../../services/budgetService';
import { isUpdateConflict } from '../../../services/conflictResult';
import { getWeather } from '../../../services/weatherService';
import { BLOCKED_EXTENSIONS, filesDir } from '../../files/files.constants';
@@ -426,12 +425,12 @@ export class PluginHostDepsFactory {
const r = this.db.prepare('DELETE FROM plugin_scheduled_tasks WHERE plugin_id = ? AND name = ?').run(id, name);
return { cancelled: r.changes > 0 };
},
listCostsForTrip: (tripId) => listBudgetItems(tripId),
listCostsForTrip: (tripId) => this.budget.listBudgetItems(tripId),
// Cross-trip: every accessible trip's budget items (membership predicate is
// baked into listTrips). Reuses the hydrated list so members/payers come too.
listCostsForUser: (userId) => {
const trips = listTrips(userId, null) as Array<{ id: number }>;
return trips.flatMap((t) => listBudgetItems(t.id));
return trips.flatMap((t) => this.budget.listBudgetItems(t.id));
},
// Reuses BudgetService.create (frozen FX + members/payers), then broadcasts
// the same 'budget:created' event the controller emits so the web app updates