UNPKG

doggo.js

Version:

Typed client for Doggo.Ninja's public API

80 lines (79 loc) 3.08 kB
export interface File { url: string; shortName: string; originalName: string; mimeType: string; uncachedHits: number; size: number; parentId: string | null; isPrivate: boolean; privatesAt: number | null; hasPassword: boolean; updatedAt: number; createdAt: number; } export interface Folder { id: string; name: string; parentId: string | null; createdAt: number; } export declare type User = { id: string; name: string; email: string | null; isAdmin: boolean; usage: number; preferredDomain: string; createdAt: number; }; export declare type UsageInfo = { username: string; usage: number; email: string; }; export declare class PatClient { private baseUrl; token?: string; constructor(baseUrl?: string); files(parentId: string | null): Promise<File[]>; recentFiles(count: number): Promise<File[]>; upload(file: globalThis.File, parentId: string | null, onProgress?: (loaded: number, total: number) => void): Promise<File>; replace(shortName: string, file: globalThis.File, onProgress?: (loaded: number, total: number) => void): Promise<File>; getDownloadToken(shortName: string, password?: string): Promise<string | null>; updateFileSharing(shortName: string, isPrivate: boolean, details: { privatesAt: number | null; password: string | boolean; }): Promise<File>; moveFile(shortName: string, details: { originalName?: string; parentId?: string | null; }, copy?: boolean): Promise<File>; getFile(shortName: string): Promise<File>; deleteFile(shortName: string): Promise<File>; deleteFolder(id: string): Promise<File>; folders(parentId: string | null): Promise<Folder[]>; createFolder(name: string, parentId: string | null): Promise<Folder>; moveFolder(id: string, details: { name?: string; parentId?: string | null; }): Promise<File>; getFolder(id: string): Promise<Folder[]>; checkAuth(): Promise<boolean>; login(username: string, password: string): Promise<{ sessionToken: string; expiration: Date; }>; resetPassword(nameOrEmail?: string): Promise<{ censoredEmail: string; }>; completeResetPassword(resetToken: string, newPassword: string, regenerateAccessToken: boolean): Promise<void>; invalidateSession(): Promise<void>; regenerateAccessToken(): Promise<string>; me(): Promise<User>; setDomain(domain: 'doggo.ninja' | 'ninja.dog'): Promise<User>; adminUsage(): Promise<UsageInfo[]>; makeUser(username: string, email: string): Promise<void>; makeUploadRequest<Type = {}>(method: 'post' | 'put' | 'delete', url: string, file: globalThis.File, onProgress?: (loaded: number, total: number) => void): Promise<Type>; makeRequest<Type = {}>(method: 'get' | 'post' | 'put' | 'delete', path: string, query?: Record<string, string | null>, body?: Record<string, unknown>): Promise<Type>; }