Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected getSource(context: ActionContext, operation: Algebra.Pattern): Promise {
const contextSource = this.getContextSource(context);
const url = this.getContextSourceUrl(contextSource);
let source: MediatedQuadSource;
// Try to read from cache
if (this.cacheSize && this.cache.has(url)) {
source = this.cache.get(url);
} else {
// If not in cache, create a new source
source = new MediatedQuadSource(this.cacheSize, context, url, getDataSourceType(contextSource), {
mediatorMetadata: this.mediatorMetadata,
mediatorMetadataExtract: this.mediatorMetadataExtract,
mediatorRdfDereference: this.mediatorRdfDereference,
mediatorRdfResolveHypermedia: this.mediatorRdfResolveHypermedia,
mediatorRdfResolveHypermediaLinks: this.mediatorRdfResolveHypermediaLinks,
});
// Set in cache
if (this.cacheSize) {
this.cache.set(url, source);
}
}
return Promise.resolve(source);
}
public static async getSingleSourceType(context: ActionContext): Promise {
const source = await this.getSingleSource(context);
return source ? getDataSourceType(source) : null;
}