diff --git a/src/download.ts b/src/download.ts index 82022da..9355cd3 100644 --- a/src/download.ts +++ b/src/download.ts @@ -1,22 +1,11 @@ import path from 'path'; import fsp from 'fs/promises'; -import { HttpClient } from 'isomorphic-git/http/node'; import { bodyToBuffer, isWriteable } from './util'; import { Pointer } from './pointers'; +import { HTTPRequest } from './types'; -interface DownloadBlobRequest { - http: HttpClient; - headers?: Record; - - /** Repository URL. */ - url: string; - - /** Auth data for basic HTTP auth. */ - auth?: { username: string, password: string } -} - interface LFSInfoResponse { objects: { actions: { @@ -37,7 +26,7 @@ function isValidLFSInfoResponseData(val: Record): val is LFSInfoRes * Downloads, caches and returns a blob corresponding to given LFS pointer. */ export default async function downloadBlobFromPointer( - { http: { request }, headers = {}, url, auth }: DownloadBlobRequest, + { http: { request }, headers = {}, url, auth }: HTTPRequest, { info, objectPath }: Pointer, ): Promise { diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..5093c06 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,23 @@ +import { HttpClient, ProgressCallback } from 'isomorphic-git/http/node'; + + +export interface BasicAuth { + username: string + password: string +} + + +// TODO: Restructure HTTPRequest to reuse Isomorphic Git’s GitHttpRequest? + +export interface HTTPRequest { + http: HttpClient; + headers?: Record; + + /** Repository URL. */ + url: string; + + /** Auth data for basic HTTP auth. */ + auth?: BasicAuth + + onProgress?: ProgressCallback +}