commit 2 refactor

This commit is contained in:
Boki 2026-10-20 14:35:45 -04:00
parent 588f666943
commit 32e43c9243
310 changed files with 33318 additions and 31189 deletions

View file

@ -40,5 +40,18 @@ export interface ServiceTypes {
}
export interface IServiceContainer extends ServiceTypes {
readonly custom?: Record<string, any>;
readonly custom?: Record<string, unknown>;
}
/** Validate required capabilities at the boundary before starting any work. */
export function requireServices<T extends ServiceTypes, K extends keyof ServiceTypes>(
services: T,
...keys: K[]
): T & { [P in K]-?: NonNullable<ServiceTypes[P]> } {
for (const key of keys) {
if (services[key] === null || services[key] === undefined) {
throw new Error(`Required service '${key}' is unavailable`);
}
}
return services as T & { [P in K]-?: NonNullable<ServiceTypes[P]> };
}