(
wrapper: InstanceWrapper<T>,
)
| 425 | } |
| 426 | |
| 427 | public getFactoryProviderDependencies<T>( |
| 428 | wrapper: InstanceWrapper<T>, |
| 429 | ): [InjectorDependency[], number[]] { |
| 430 | const optionalDependenciesIds: number[] = []; |
| 431 | |
| 432 | /** |
| 433 | * Same as the internal utility function `isOptionalFactoryDependency` from `@nestjs/common`. |
| 434 | * We are duplicating it here because that one is not supposed to be exported. |
| 435 | */ |
| 436 | function isOptionalFactoryDependency( |
| 437 | value: InjectionToken | OptionalFactoryDependency, |
| 438 | ): value is OptionalFactoryDependency { |
| 439 | return ( |
| 440 | !isUndefined((value as OptionalFactoryDependency).token) && |
| 441 | !isUndefined((value as OptionalFactoryDependency).optional) && |
| 442 | !(value as any).prototype |
| 443 | ); |
| 444 | } |
| 445 | |
| 446 | const mapFactoryProviderInjectArray = ( |
| 447 | item: InjectionToken | OptionalFactoryDependency, |
| 448 | index: number, |
| 449 | ): InjectionToken => { |
| 450 | if (typeof item !== 'object') { |
| 451 | return item; |
| 452 | } |
| 453 | if (isOptionalFactoryDependency(item)) { |
| 454 | if (item.optional) { |
| 455 | optionalDependenciesIds.push(index); |
| 456 | } |
| 457 | return item?.token; |
| 458 | } |
| 459 | return item; |
| 460 | }; |
| 461 | return [ |
| 462 | wrapper.inject?.map?.(mapFactoryProviderInjectArray) as any[], |
| 463 | optionalDependenciesIds, |
| 464 | ]; |
| 465 | } |
| 466 | |
| 467 | public reflectConstructorParams(type: Type<unknown> | Function): any[] { |
| 468 | const paramtypes = [ |
no outgoing calls
no test coverage detected