MCPcopy
hub / github.com/loopbackio/loopback-next / resolveAsViewFromConfig

Function resolveAsViewFromConfig

packages/context/src/inject-config.ts:198–215  ·  view source on GitHub ↗

* Resolver for `@config.view` * @param ctx - Context object * @param injection - Injection metadata * @param session - Resolution session

(
  ctx: Context,
  injection: Injection,
  session: ResolutionSession,
)

Source from the content-addressed store, hash-verified

196 * @param session - Resolution session
197 */
198function resolveAsViewFromConfig(
199 ctx: Context,
200 injection: Injection,
201 session: ResolutionSession,
202) {
203 assertTargetType(injection, ContextView);
204 const bindingKey = getTargetBindingKey(injection, session);
205 // Return `undefined` if no current binding is present
206 if (!bindingKey) return undefined;
207 const view = new ConfigView(
208 ctx,
209 binding =>
210 binding.key === BindingKey.buildKeyForConfig(bindingKey).toString(),
211 injection.metadata.propertyPath,
212 );
213 view.open();
214 return view;
215}
216
217/**
218 * A subclass of `ContextView` to handle dynamic configuration as its

Callers

nothing calls this directly

Calls 5

assertTargetTypeFunction · 0.90
getTargetBindingKeyFunction · 0.85
buildKeyForConfigMethod · 0.80
openMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected