UNPKG

terminus-sync-config

Version:

Sync configuration files to GitHub Gist or Gitee Gist

50 lines (49 loc) 1.31 kB
import { AxiosResponse, AxiosRequestConfig } from "axios"; /** * * github: https://docs.github.com/en/rest/reference/gists * * gitee: https://gitee.com/api/v5/swagger#/getV5Gists * * gitlab: https://docs.gitlab.com/ee/api/snippets.html * */ declare class GistFile { /** * gist file name */ readonly name: string; /** * gist file content */ readonly value: string; constructor(name: string, value: string); } declare abstract class Gist { protected readonly token: string; protected customBaseUrl: string; constructor(token: string); /** * get a gist * @param gist gist id * @returns Array<GistFile> */ abstract get(gist: string): Promise<Map<string, GistFile>>; /** * sync * @param gist gist id. if null then add. * @param gists Array<GistFile> * @returns gist id */ abstract sync(gist: string, gists: Array<GistFile>): Promise<string>; /** * del * @param gist gist id * @returns void */ abstract del(gist: string): Promise<boolean>; request(request: AxiosRequestConfig): Promise<AxiosResponse>; toFiles(gists: GistFile[]): object; toMap(result: any): Map<string, GistFile>; } export { Gist, GistFile };