README
What is this?
This library is an abstraction for terminal-api usage.
It exposes certain functions to interact with the api
Install:
npm install --save blue-terminal-api-lib
Usage:
Code
const { Terminal } = require('blue-terminal-api-lib');
// or
import Terminal from 'blue-terminal-api-lib';
const terminal = new Terminal('terminal_url', 'api_key');
Options
foldersEndpoint: the url endpoint for accessing the "folders" resource - default:
/folders
uploadEndpoint: the url endpoint for accessing the "upload" resource - default:
/upload
downloadEndpoint: the url endpoint for accessing the "download" resource - default:
/download
tempFolderPath: the location of tempFiles - default:
/tmp
reslutsLimit: the number of results from terminal - default:
1000
sendPollingInterval: the interval time check for transfer file - default:
1000
maxSendTerminalDelay: the time for transfer file - default:
20 * 60 * 1000
downloadTestDelay: the delay in test - default:
1000
Functions:
- createFolder:
/**
* recieve folder metadata and creates new folder in terminal-api
* @param {String} from - file senders user id
* @param {[String]} to - array of user id's to send file to
* @param {String} title - folder title
* @param {String} sourceNetwork - source network
* @param {String} destinationNetwork - destination network
* @returns {IFolder} - folder object
*/
function createFolder(title, sourceNetwork, destinationNetwork, to, from): Promise<IFolder>
- getFolders:
/**
* gets all folders from terminal-api
* @param {GetFolderParams} params - (optional) filter by parameters
* @returns {[IFolder]} - folder objects
*/
function getFolders(params): Promise<IFolder[]>
- getTerminalFiles:
/**
* gets all folders from terminal-api
* @param {GetFolderParams} params - (optional) filter by parameters
* @param {Function} filter - (optional) filter with filter function
* @returns {[IFileExtended]} - folder objects
*/
function getTerminalFiles(params, filter?): Promise<IFileExtended[]>
- getFolderById:
/**
* gets a single folder with given id from terminal-api
* @param {String} folderId - folderId
* @returns {IFolder} - folder object
*/
function getFolderById(folderId): Promise<IFolder>
- getFilesFromFolder:
/**
* gets all files in folder by folderId from terminal-api
* @param {String} folderId - folderId
* @returns {[IFile]} - file objects
*/
function getFilesFromFolder(folderId): Promise<IFile[]>
- getFileFromFolder:
/**
* returns specific file from folder from terminal-api
* @param {String} folderId - folderId
* @param {String} fileId - fileId
* @returns {IFile} - file object
*/
function getFileFromFolder(folderId, fileId): Promise<IFile>
- getTerminalFileStatus:
/**
* returns status specific file from folder from terminal-api
* @param {String} folderId - folderId
* @param {String} fileId - fileId
* @returns {FileStatusObject} - file status object
*/
function getTerminalFileStatus(folderId, fileId): Promise<FileStatusObject>
- getFilesWithExtention:
/**
* returns status specific file from folder from terminal-api
* @param {String} extention - extension to search by
* @param {GetFolderParams} params - (optional) filter by parameters
* @returns {[IFile]} - file objects
*/
function getFilesWithExtention(extention, params}): Promise<IFile[]>
- getFilesWithName:
/**
* returns status specific file from folder from terminal-api
* @param {String} name - filename to search by
* @param {GetFolderParams} params - (optional) filter by parameters
* @returns {[IFile]} - file objects
*/
function getFilesWithName(extention, params}): Promise<IFile[]>
- transferFile:
/**
* transfer file to other side and throw error if something went wrong
* @param {String} from - file senders user id
* @param {[String]} to - array of user id's to send file to
* @param {String} title - folder title
* @param {String} sourceNetwork - source network
* @param {String} destinationNetwork - destination network
* @param {String} fileName - fileName
* @param {FileContentType} fileContent - destination network
*/
function transferFile(from, to, title, sourceNetwork, destinationNetwork, fileName, fileContent): Promise<void>
- sendFolder:
/**
* marks a folder as available for sending to other side
* @param {String} folderId - folderId
* @returns {IFolder} - folder object
*/
function sendFolder(folderId): Promise<IFolder>
- ackFolder:
/**
* marks an "incoming" folder as viewed and handled ( acknowleges it )
* @param {String} folderId - folderId
* @returns {IFolder} - folder object
*/
function ackFolder(folderId): Promise<IFolder>
- nackFolder:
/**
* marks an "incoming" folder as nack
* @param {String} folderId - folderId
* @returns {IFolder} - folder object
*/
function nackFolder(folderId): Promise<IFolder>
- downloadFolder:
/**
* returns a readable stream representing the folder (by id) with all its files in .zip format
* @param {String} folderId - folderId
* @returns {NodeJS.ReadableStream} - folder .zip readableStream
*/
function downloadFolder(folderId): Promise<NodeJS.ReadableStream>
- downloadFileFromFolder:
/**
* returns a base64 string || buffer || readableStream representing the specific file in given file format
* @param {String} folderId - folderId
* @param {String} fileId - fileId
* @param {DownloadFileResponseType} responseType - type of respone
* @returns {DownloadFileResponseType} - file in requested responseType
*/
function downloadFileFromFolder(folderId, fileId, responseType: DownloadFileResponseType)
- uploadFile:
/**
* uploads a file to folder with given metadata
* @param {String} folderId - existing folder if
* @param {String} fileName - name to give to file
* @param {FileContentType} content - content of file
* @returns {IFile} - file object
*/
function uploadFile(folderId, fileName, content): Promise<IFile>