UNPKG

@accordproject/concerto-util

Version:

Utilities for Concerto Modeling Language

39 lines (38 loc) 1.57 kB
import type { FileLoader } from './loaders/fileloader'; type ExternalImportMap = Record<string, string>; type DownloadJob<TFile> = { downloadedUris: Set<string>; url: string; options: RequestInit; }; /** * Downloads the transitive closure of a set of model files. * @memberof module:concerto-core */ declare class FileDownloader<TFile = unknown> { fileLoader: FileLoader<TFile>; getExternalImports: (file: TFile) => ExternalImportMap; concurrency: number; /** * Create a FileDownloader and bind to a FileLoader. * @param fileLoader - the loader to use to download model files * @param getExternalImports - a function taking a file and returning new files * @param concurrency - the number of model files to download concurrently */ constructor(fileLoader: FileLoader<TFile>, getExternalImports: (file: TFile) => ExternalImportMap, concurrency?: number); /** * Download all external dependencies for an array of model files * @param files - the model files * @param options - Options object passed to FileLoaders * @return a promise that resolves to Files[] for the external model files */ downloadExternalDependencies(files: TFile[], options?: RequestInit): Promise<TFile[]>; /** * Execute a Job * @param job - the job to execute * @param fileLoader - the loader to use to download model files. * @return a promise to the job results */ runJob(job: DownloadJob<TFile>, fileLoader: FileLoader<TFile>): Promise<TFile[]>; } export = FileDownloader;