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

Method resolveProperties

packages/core/injector/injector.ts:726–823  ·  view source on GitHub ↗
(
    wrapper: InstanceWrapper<T>,
    moduleRef: Module,
    inject?: InjectorDependency[],
    resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },
    parentInquirer?: InstanceWrapper,
  )

Source from the content-addressed store, hash-verified

724 }
725
726 public async resolveProperties<T>(
727 wrapper: InstanceWrapper<T>,
728 moduleRef: Module,
729 inject?: InjectorDependency[],
730 resolutionContext: ResolutionContext = { contextId: STATIC_CONTEXT },
731 parentInquirer?: InstanceWrapper,
732 ): Promise<PropertyDependency[]> {
733 if (!isNil(inject)) {
734 return [];
735 }
736 const metadata = wrapper.getPropertiesMetadata();
737 if (metadata && resolutionContext.contextId !== STATIC_CONTEXT) {
738 return this.loadPropertiesMetadata(
739 metadata,
740 resolutionContext.contextId,
741 resolutionContext.inquirer,
742 );
743 }
744 const properties = this.reflectProperties(wrapper.metatype as Type<any>);
745 const propertyBarrier = new Barrier(properties.length);
746 const instances = await Promise.all(
747 properties.map(async (item: PropertyDependency) => {
748 try {
749 const dependencyContext = {
750 key: item.key,
751 name: item.name as Function | string | symbol,
752 };
753 if (this.isInquirer(item.name, parentInquirer)) {
754 /*
755 * Signal the barrier to make sure other dependencies do not get stuck waiting forever.
756 */
757 propertyBarrier.signal();
758
759 return parentInquirer && parentInquirer.instance;
760 }
761 const nestedResolutionContext =
762 this.getStaticTransientResolutionContext(
763 resolutionContext,
764 parentInquirer,
765 );
766 const paramWrapper = await this.resolveSingleParam<T>(
767 wrapper,
768 item.name as string,
769 dependencyContext,
770 moduleRef,
771 nestedResolutionContext,
772 item.key,
773 );
774
775 /*
776 * Ensure that all instance wrappers are resolved at this point before we continue.
777 * Otherwise the staticity of `wrapper`'s dependency tree may be evaluated incorrectly
778 * and result in undefined / null injection.
779 */
780 await propertyBarrier.signalAndWait();
781
782 const effectivePropertyResolutionContext =
783 this.getEffectiveResolutionContext(

Callers 3

callbackMethod · 0.95
callbackFunction · 0.80
injector.spec.tsFile · 0.80

Calls 13

reflectPropertiesMethod · 0.95
isInquirerMethod · 0.95
signalMethod · 0.95
signalAndWaitMethod · 0.95
resolveComponentHostMethod · 0.95
getContextIdMethod · 0.95
isNilFunction · 0.90
getPropertiesMetadataMethod · 0.80
allMethod · 0.80

Tested by

no test coverage detected