wip
This commit is contained in:
@@ -24,12 +24,23 @@ export function useEffectiveDriverId(): string {
|
||||
|
||||
try {
|
||||
// Lazy-load to avoid importing DI facade at module evaluation time
|
||||
const { getDriverRepository } = require('./di-container') as typeof import('./di-container');
|
||||
const { getDriverRepository } =
|
||||
require('./di-container') as typeof import('./di-container');
|
||||
const repo = getDriverRepository();
|
||||
// In-memory repository is synchronous for findAll in the demo implementation
|
||||
const allDrivers = repo.findAllSync?.() as Array<{ id: string }> | undefined;
|
||||
if (allDrivers && allDrivers.length > 0) {
|
||||
return allDrivers[0].id;
|
||||
|
||||
interface DriverRepositoryWithSyncFindAll {
|
||||
findAllSync?: () => Array<{ id: string }>;
|
||||
}
|
||||
|
||||
// In alpha/demo mode the in-memory repository exposes a synchronous finder;
|
||||
// access it via a safe dynamic lookup to keep typing compatible with the port.
|
||||
const repoWithSync = repo as DriverRepositoryWithSyncFindAll;
|
||||
const allDrivers = repoWithSync.findAllSync?.();
|
||||
if (Array.isArray(allDrivers) && allDrivers.length > 0) {
|
||||
const firstDriver = allDrivers[0];
|
||||
if (firstDriver) {
|
||||
return firstDriver.id;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore and fall back to legacy default below
|
||||
|
||||
Reference in New Issue
Block a user