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

Method resolve

packages/context/src/context-view.ts:196–227  ·  view source on GitHub ↗

* Resolve values for the matching bindings * @param session - Resolution session

(session?: ResolutionOptionsOrSession)

Source from the content-addressed store, hash-verified

194 * @param session - Resolution session
195 */
196 resolve(session?: ResolutionOptionsOrSession): ValueOrPromise<T[]> {
197 debug('Resolving values');
198 if (this._cachedValues != null) {
199 return this.getCachedValues();
200 }
201 const bindings = this.bindings;
202 let result = resolveList(bindings, b => {
203 const options = {
204 ...this.resolutionOptions,
205 ...asResolutionOptions(session),
206 };
207 // https://github.com/loopbackio/loopback-next/issues/9041
208 // We should start with a new session for `view` resolution to avoid
209 // possible circular dependencies
210 options.session = undefined;
211 return b.getValue(this.context, options);
212 });
213 if (isPromiseLike(result)) {
214 result = result.then(values => {
215 const list = values.filter(v => v != null) as T[];
216 this.updateCachedValues(list);
217 this.emit('resolve', list);
218 return list;
219 });
220 } else {
221 // Clone the array so that the cached values won't be mutated
222 const list = (result = result.filter(v => v != null) as T[]);
223 this.updateCachedValues(list);
224 this.emit('resolve', list);
225 }
226 return result as ValueOrPromise<T[]>;
227 }
228
229 /**
230 * Get the list of resolved values. If they are not cached, it tries to find

Callers 15

listFunction · 0.95
serviceFunction · 0.95
valuesMethod · 0.95
resolveValuesByFilterFunction · 0.95
givenHttpsServerFunction · 0.80
initFunction · 0.80
startFunction · 0.80
stopFunction · 0.80
initFunction · 0.80
startFunction · 0.80
stopFunction · 0.80

Calls 6

getCachedValuesMethod · 0.95
updateCachedValuesMethod · 0.95
resolveListFunction · 0.90
asResolutionOptionsFunction · 0.90
isPromiseLikeFunction · 0.90
getValueMethod · 0.45

Tested by 15

givenHttpsServerFunction · 0.64
initFunction · 0.64
startFunction · 0.64
stopFunction · 0.64
initFunction · 0.64
startFunction · 0.64
stopFunction · 0.64
connectMethod · 0.64
disconnectMethod · 0.64
pingMethod · 0.64
createMethod · 0.64
findMethod · 0.64