MCPcopy
hub / github.com/nestjs/nest / getFactoryProviderDependencies

Method getFactoryProviderDependencies

packages/core/injector/injector.ts:427–465  ·  view source on GitHub ↗
(
    wrapper: InstanceWrapper<T>,
  )

Source from the content-addressed store, hash-verified

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 = [

Callers 2

injector.spec.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected