import fs , { ReadStream } from "fs" ; import path from "path" ; import to from "await-to-js" ; import { Readable } from "stream" ; import B2 from "backblaze-b2" ; require ( "@gideo-llc/backblaze-b2-upload-any" ) . install ( B2 ) ; import { StorageType , IStorage , ConfigBackblazeB2 , UploadOptions , AdapterConfig , JSON as TypeJSON , } from "./types" ; import { parseUrl } from "./util" ; const init = async ( ) : Promise < boolean > => { return true ; } ; const getConfiguration = ( ) : ConfigBackblazeB2 => { return { type : StorageType . B2 , applicationKeyId : "" , applicationKey : "" , } ; } ; const getType = ( ) : string => "string" ; const test = ( ) : Promise < string > => Promise . resolve ( "ok" ) ; const createBucket = ( name ) : Promise < string > => Promise . resolve ( "ok" ) ; const selectBucket = ( name ? ) : Promise < string > => Promise . resolve ( "ok" ) ; const clearBucket = ( name ? ) : Promise < string > => Promise . resolve ( "ok" ) ; const deleteBucket = ( name ? ) : Promise < string > => Promise . resolve ( "ok" ) ; const listBuckets = ( ) : Promise < string [ ] > => Promise . resolve ( [ "string" , "string" ] ) ; const getSelectedBucket = ( ) : string => "string" ; const addFileFromPath = ( origPath , targetPath ) : Promise < void > => Promise . resolve ( ) ; const addFileFromBuffer = ( buffer , targetPath ) : Promise < void > => Promise . resolve ( ) ; const addFileFromReadable = ( stream , targetPath , options ? ) : Promise < void > => Promise . resolve ( ) ; const getFileAsReadable = ( name , options ? ) : Promise < ReadStream > => Promise . resolve ( fs . createReadStream ( "" ) ) ; const removeFile = ( name ) : Promise < string > => Promise . resolve ( "ok" ) ; const listFiles = ( numFiles ? ) : Promise < [ string , number ] [ ] > => Promise . resolve ( [ [ "s" , 0 ] ] ) ; const sizeOf = ( name ) : Promise < number > => Promise . resolve ( 42 ) ; const fileExists = ( name ) : Promise < boolean > => Promise . resolve ( true ) ; const adapter = { init , getType : ( ) => StorageType . B2 , getConfiguration , test , createBucket , selectBucket , clearBucket , deleteBucket , listBuckets , getSelectedBucket , addFileFromPath , addFileFromBuffer , addFileFromReadable , getFileAsReadable , removeFile , listFiles , sizeOf , fileExists , } ; const createAdapter = ( config ) : IStorage => { console . log ( "create functional adapter" ) ; const state = { applicationKeyId : config . applicationKeyId , applicationKey : config . applicationKey , bucketName : "" , } ; return adapter ; } ; export { createAdapter } ;