UNPKG

canvas-api-ts

Version:

Strongly typed canvas lms api

97 lines (96 loc) 6.89 kB
/// <reference types="node" /> import * as F from '../api/filesAPITypes'; import { Match } from '../request/requestBuidler'; import * as ResponseType from '../api/responseTypes'; interface FileStream { filename: string; meta: ResponseType.File; stream: NodeJS.ReadableStream; } /** * store one FileStream at the given baseDir. * @param baseDir where to download the file to. * @param stream the FileStream object generated by one of the file fetching apis. * @returns a flag that indicate if file is successfully written. */ export declare function store(baseDir: string, stream: FileStream): Promise<void>; /** * @param path the path it store to. * @param stream */ export declare function storeByPath(filepath: string, stream: NodeJS.ReadableStream): Promise<void>; /** * download a single file * @param * @returns a promise FileStream * * Note the filename received in `File` object will be url encoded. */ export declare function fetchFile(file: ResponseType.File): Promise<FileStream>; export declare function fetchFileByUrl(url: string): Promise<{ stream: NodeJS.ReadableStream; }>; /** * download files from a list of File * @param files A list of files that can come from any File[] return apis. * @return a promise of a list of binary file and there corresponding File. * File can be used to determine what to do with the binary buffer. */ export declare function fetchFiles(files: ResponseType.File[]): Promise<Promise<FileStream>[]>; /** * download all files from a folder * @param folder * @return */ export declare function fetchAllFromAFolder(folder: ResponseType.Folder, config: Match<F.List.Folder, "param">): Promise<Promise<FileStream>[]>; export declare function getFile(fileId: Match<F.GetFile.GetFile, "uriParams">["id"], include: Match<F.GetFile.GetFile, "param">["include"]): Promise<ResponseType.File>; export declare function getCourseFileQuota(courseId: Match<F.Quota.GetCourseQuota, "uriParams">["course_id"]): Promise<{ quota: number; quota_used: number; }>; export declare function getGroupFileQuota(groupId: Match<F.Quota.GetGroupQuota, "uriParams">["group_id"]): Promise<{ quota: number; quota_used: number; }>; export declare function getUserFileQuota(userId?: Match<F.Quota.GetUserQuota, "uriParams">["user_id"]): Promise<{ quota: number; quota_used: number; }>; export declare const getQuota: () => Promise<{ quota: number; quota_used: number; }>; export declare function getCourseFiles(courseId: Match<F.List.Course, "uriParams">["course_id"], config: Match<F.List.Course, "param">): Promise<ResponseType.File[]>; export declare function getUserFiles(userId: Match<F.List.User, "uriParams">["user_id"], config: Match<F.List.User, "param">): Promise<ResponseType.File[]>; export declare const getFiles: (config: Match<F.List.User, "param">) => Promise<ResponseType.File[]>; export declare function getGroupFiles(groupId: Match<F.List.Group, "uriParams">["group_id"], config: Match<F.List.Group, "param">): Promise<ResponseType.File[]>; export declare function getFilesOfAFolder(folderId: Match<F.List.Folder, "uriParams">["id"], config: Match<F.List.Folder, "param">): Promise<ResponseType.File[]>; export declare function updateFile(id: Match<F.UpateFile, "uriParams">["id"], config: Match<F.UpateFile, "param">): Promise<ResponseType.File>; export declare function deletFile(id: Match<F.DeleteFile, "uriParams">["id"], config: Match<F.DeleteFile, "param">): Promise<ResponseType.File>; export declare function getCourseFolders(courseId: Match<F.ListAllFolders.ListCourseFolders, "uriParams">["course_id"]): Promise<ResponseType.Folder[]>; export declare function getUserFolders(userId?: Match<F.ListAllFolders.ListUserFolders, "uriParams">["user_id"]): Promise<ResponseType.Folder[]>; export declare function getGroupFolders(groupId: Match<F.ListAllFolders.ListGroupFolders, "uriParams">["group_id"]): Promise<ResponseType.Folder[]>; export declare function getCourseFoldersByPath(courseId: Match<F.ResolvePath.Course, "uriParams">["course_id"], path: string): Promise<ResponseType.Folder[]>; export declare function getGroupFoldersByPath(groupId: Match<F.ResolvePath.Group, "uriParams">["group_id"], path: string): Promise<ResponseType.Folder[]>; export declare function getUserFoldersByPath(userId: Match<F.ResolvePath.User, "uriParams">["user_id"], path: string): Promise<ResponseType.Folder[]>; export declare function getFolderInCourse(courseId: Match<F.GetFolder.Course, "uriParams">["course_id"], folderId: Match<F.GetFolder.Course, "uriParams">["id"]): Promise<ResponseType.Folder>; export declare function getFolderOfUser(userId: Match<F.GetFolder.User, "uriParams">["user_id"], folderId: Match<F.GetFolder.User, "uriParams">["id"]): Promise<ResponseType.Folder>; export declare function getFolderInGroup(groupId: Match<F.GetFolder.Group, "uriParams">["group_id"], folderId: Match<F.GetFolder.Group, "uriParams">["id"]): Promise<ResponseType.Folder>; export declare function getFolder(folderId: Match<F.GetFolder.Folder, "uriParams">["id"]): Promise<ResponseType.Folder>; export declare function getFolders(folderId: Match<F.ListFolders, "uriParams">["id"]): Promise<ResponseType.Folder[]>; export declare function updateFolder(folderId: Match<F.UpdateFoler, "uriParams">["id"], config: Match<F.UpdateFoler, "param">): Promise<ResponseType.Folder>; export declare function createFolderInCourse(courseId: Match<F.CreateFoler.Course, "uriParams">["course_id"], config: Match<F.CreateFoler.Course, "param">): Promise<ResponseType.Folder>; export declare function createFolderOfUser(userId: Match<F.CreateFoler.User, "uriParams">["user_id"], config: Match<F.CreateFoler.User, "param">): Promise<ResponseType.Folder>; export declare function createFolderInGroup(groupId: Match<F.CreateFoler.Group, "uriParams">["group_id"], config: Match<F.CreateFoler.Group, "param">): Promise<ResponseType.Folder>; export declare function createFolder(folderId: Match<F.CreateFoler.Folder, "uriParams">["folder_id"], config: Match<F.CreateFoler.Folder, "param">): Promise<ResponseType.Folder>; export declare function deleteFolder(folderId: Match<F.DeleteFolder, "uriParams">["id"], config: Match<F.DeleteFolder, "param">): Promise<ResponseType.Folder>; export declare function uploadAFileENDPOINT(folderId: Match<F.UploadAFile, "uriParams">["folder_id"], config: Match<F.UploadAFile, "param">): Promise<{ upload_url: string; upload_params: { [unspecified: string]: any; key?: string | undefined; }; }>; export declare function CopyAFile(destFolderId: Match<F.CopyAFile, "uriParams">["dest_folder_id"], config: Match<F.CopyAFile, "param">): Promise<ResponseType.File>; export declare function CopyAFolder(destFolderId: Match<F.CopyAFolder, "uriParams">["dest_folder_id"], config: Match<F.CopyAFolder, "param">): Promise<ResponseType.Folder>; export {};