File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -193,12 +193,22 @@ class CoCreateLazyLoader {
193193 throw new Error ( `Missing ${ name } key in organization apis object` ) ;
194194
195195 // ToDo: if data.endpoint service not required as endpoint will be used
196- const service = require ( config . path ) ;
197- let instance
198- if ( config . initialize )
199- instance = new service [ config . initialize ] ( key ) ;
200- else
201- instance = new service ( key ) ;
196+ let instance = require ( config . path ) ;
197+
198+ if ( config . initialize ) {
199+ const initialize = config . initialize . split ( '.' ) ;
200+
201+ // Traverse the nested structure to reach the correct constructor
202+ for ( let i = 0 ; i < initialize . length ; i ++ ) {
203+ if ( instance [ initialize [ i ] ] ) {
204+ instance = instance [ initialize [ i ] ] ;
205+ } else {
206+ throw new Error ( `Service path ${ config . initialize } is incorrect at ${ initialize [ i ] } ` ) ;
207+ }
208+ }
209+ }
210+
211+ instance = new instance ( key ) ;
202212
203213 let params = [ ] , mainParam = false
204214 for ( let i = 0 ; true ; i ++ ) {
You can’t perform that action at this time.
0 commit comments