@@ -6,7 +6,7 @@ import { Result } from 'ts-results-es';
66import { __Services } from '../_internal' ;
77import { AnyFunction } from '../../types/utility' ;
88import type { Logging } from '../contracts/logging' ;
9-
9+ import type { UnpackFunction } from 'iti' ;
1010//SIDE EFFECT: GLOBAL DI
1111let containerSubject : CoreContainer < Partial < Dependencies > > ;
1212
@@ -34,7 +34,7 @@ export function __add_container(key: string,v : Insertable) {
3434/**
3535 * Returns the underlying data structure holding all dependencies.
3636 * Exposes methods from iti
37- * Use the Service API. The container should be readonly
37+ * Use the Service API. The container should be readonly from the consumer side
3838 */
3939export function useContainerRaw ( ) {
4040 assert . ok (
@@ -49,8 +49,11 @@ export function disposeAll(logger: Logging|undefined) {
4949 ?. disposeAll ( )
5050 . then ( ( ) => logger ?. info ( { message : 'Cleaning container and crashing' } ) ) ;
5151}
52+ type UnpackedDependencies = {
53+ [ K in keyof Dependencies ] : UnpackFunction < Dependencies [ K ] >
54+ }
5255type Insertable =
53- | ( ( container : CoreContainer < Dependencies > ) => unknown )
56+ | ( ( container : UnpackedDependencies ) => unknown )
5457 | object
5558const dependencyBuilder = ( container : any , excluded : string [ ] ) => {
5659 return {
@@ -64,7 +67,7 @@ const dependencyBuilder = (container: any, excluded: string[] ) => {
6467 . expect ( "Failed to add " + key ) ;
6568 } else {
6669 Result . wrap ( ( ) =>
67- container . add ( ( cntr : CoreContainer < Dependencies > ) => ( { [ key ] : v ( cntr ) } ) ) )
70+ container . add ( ( cntr : UnpackedDependencies ) => ( { [ key ] : v ( cntr ) } ) ) )
6871 . expect ( "Failed to add " + key ) ;
6972 }
7073 } ,
@@ -87,7 +90,7 @@ const dependencyBuilder = (container: any, excluded: string[] ) => {
8790 . expect ( "Failed to update " + key ) ;
8891 } else {
8992 Result . wrap ( ( ) =>
90- container . upsert ( ( cntr : CoreContainer < Dependencies > ) => ( { [ key ] : v ( cntr ) } ) ) )
93+ container . upsert ( ( cntr : UnpackedDependencies ) => ( { [ key ] : v ( cntr ) } ) ) )
9194 . expect ( "Failed to update " + key ) ;
9295 }
9396 } ,
@@ -107,10 +110,9 @@ const dependencyBuilder = (container: any, excluded: string[] ) => {
107110 } ;
108111} ;
109112
110- type CallbackBuilder = ( c : ReturnType < typeof dependencyBuilder > ) => any
111113
112114type ValidDependencyConfig =
113- | CallbackBuilder
115+ | ( ( c : ReturnType < typeof dependencyBuilder > ) => any )
114116 | DependencyConfiguration ;
115117
116118
0 commit comments