UNPKG

@rubic/catalog-fetcher

Version:
95 lines (94 loc) 2.69 kB
/// <reference path="catalog.d.ts" /> import * as GitHub from "@octokit/rest"; import * as Ajv from "ajv"; export declare const CATALOG_JSON = "catalog.json"; export declare const JSON_ENCODING = "utf8"; export declare const REPOSITORY_JSON = "rubic-repository.json"; export declare const RELEASE_JSON = "release.json"; export declare const ASSET_PATTERN: RegExp; export declare const OFFICIAL_CATALOG: { owner: string; repo: string; branch: string; }; export interface RubicCatalogFetcherOptions { auth?: GitHub.Auth; logger?: ConsoleLogger; userAgent?: string; proxy?: string; rejectUnauthorized?: boolean; } export interface ConsoleLogger { log: Function; info?: Function; warn?: Function; error?: Function; } export interface GitHubRepository { host: "github"; owner: string; repo: string; branch?: string; } /** * Get ajv-based validator for Rubic catalog schema * @param name Name of interface */ export declare function getValidator(name?: string): Ajv.ValidateFunction; /** * Catalog fetcher for Rubic */ export declare class RubicCatalogFetcher { private options; private gh; logger: ConsoleLogger; private limit_used; private limit_remaining; private temp_id_next; /** * Construct Rubic catalog fetcher * @param options Options for fetcher */ constructor(options?: RubicCatalogFetcherOptions); /** * Fetch repository data * @param repo Repository info * @param current Current data to merge * @param ver Version suffix */ fetchRepository(repo: GitHubRepository, current: RubicCatalog.RepositorySummaryV1 | undefined, ver: string): Promise<RubicCatalog.RepositorySummaryV1>; /** * Validate object and report * @param obj Object to validate * @param name Name of interface * @param title Name of object */ private validate; /** * Fetch REPOSITORY_JSON * @param repo Object to store fetched data * @param ver Version suffix */ private fetchRepositoryJSON; /** * Fetch releases * @param repo Object to store fetched data * @param ver Version suffix */ private fetchReleaseList; /** * Fetch ReleaseDetail * @param rel Object to store fetched data * @param ver Version suffix */ private fetchReleaseDetail; /** * RateLimit recording for GitHub API * @param data GitHub API result */ private recordRateLimit; /** * Report RateLimit status for GitHub API */ reportRateLimit(): void; }