MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / getResolutionContext

Method getResolutionContext

packages/context/src/binding.ts:594–624  ·  view source on GitHub ↗

* Locate and validate the resolution context * @param ctx - Current context * @param options - Resolution options

(ctx: Context, options: ResolutionOptions)

Source from the content-addressed store, hash-verified

592 * @param options - Resolution options
593 */
594 private getResolutionContext(ctx: Context, options: ResolutionOptions) {
595 const resolutionCtx = ctx.getResolutionContext(this);
596 switch (this.scope) {
597 case BindingScope.APPLICATION:
598 case BindingScope.SERVER:
599 case BindingScope.REQUEST:
600 if (resolutionCtx == null) {
601 const msg =
602 `Binding "${this.key}" in context "${ctx.name}" cannot` +
603 ` be resolved in scope "${this.scope}"`;
604 if (options.optional) {
605 debug(msg);
606 return undefined;
607 }
608 throw new Error(msg);
609 }
610 }
611
612 const ownerCtx = ctx.getOwnerContext(this.key);
613 if (ownerCtx != null && !ownerCtx.isVisibleTo(resolutionCtx!)) {
614 const msg =
615 `Resolution context "${resolutionCtx?.name}" does not have ` +
616 `visibility to binding "${this.key} (scope:${this.scope})" in context "${ownerCtx.name}"`;
617 if (options.optional) {
618 debug(msg);
619 return undefined;
620 }
621 throw new Error(msg);
622 }
623 return resolutionCtx;
624 }
625
626 /**
627 * Lock the binding so that it cannot be rebound

Callers 4

getValueMethod · 0.95
resolveContextFunction · 0.45
refreshMethod · 0.45
context.unit.tsFile · 0.45

Calls 2

getOwnerContextMethod · 0.80
isVisibleToMethod · 0.80

Tested by

no test coverage detected