import { DatabaseSync } from "node:sqlite"; import { type EcosystemsClient, type PackageWithRegistry } from "@ecosyste-ms/ecosystems-ts"; declare const databasePath: string; /** * Every field optional and nullable. * * The OpenAPI spec marks most package fields required and non-null; the API omits them * and sends explicit nulls. Modelling what actually arrives is what keeps the runtime * guards below honest instead of looking redundant. */ type Loose = { [K in keyof T]?: T[K] | null; }; /** * Repository metadata as `GET /packages/critical` serves it -- every field optional. * * The API sends `full_name` ("owner/repo") but never `name`, and nests the host here * rather than on the package. Both were previously read from the wrong place, which left * `repo_metadata.repo_name` and `repo_metadata.host` NULL in every published build. */ export interface ApiRepoMetadata { owner?: string | null; name?: string | null; full_name?: string | null; language?: string | null; stargazers_count?: number | null; forks_count?: number | null; open_issues_count?: number | null; archived?: boolean | null; fork?: boolean | null; host?: ApiHost | null; } /** The registry host, as nested inside `repo_metadata`. */ export interface ApiHost { name?: string | null; } /** * An advisory as the API nests it in a package. * * Derived from the package schema rather than the SDK's top-level `Advisory`: the two * specs describe the same objects differently -- `advisories.ecosyste.ms` types the * optional fields `string | undefined`, while the copy embedded in a package uses * `string | null`, which is what the API actually sends. */ type PackageAdvisory = NonNullable[number]; export type ApiAdvisory = Loose; /** * A package from `GET /packages/critical`, as the SDK types it. * * `repo_metadata` is overridden: the OpenAPI spec types it `Record` -- a * known-opaque object -- while this package reads nine fields out of it. Everything else * is the generated shape. * * The spec is stricter than the API. It declares `normalized_licenses`, `purl` and * `keywords_array` required and non-null; they are not always sent. Every runtime guard * below stays regardless of what these types claim. */ export type ApiPackage = Loose> & Pick & { advisories?: (ApiAdvisory | null)[] | null; repo_metadata?: ApiRepoMetadata | null; }; /** The single `build_info` row, written at the end of every build. */ export interface BuildInfo { built_at: string; package_count: number; version_count: number; advisory_count: number; } export type ProgressReporter = (message: string) => void; export interface BuildOptions { dbPath?: string; fetchVersionsData?: boolean; onProgress?: ProgressReporter; /** * The API client. Defaults to the shared one; a substitute lets the tests drive the * fetch loop's failure accounting without a network. */ client?: Pick; } declare function extractDatabase(source: string, destination: string): Promise; declare function registryFor(pkg: { ecosystem?: string | null; purl?: string | null; }): string | null; declare function fetchAllCriticalPackages(onProgress?: ProgressReporter, api?: Pick): Promise; /** Version numbers for a package, or `[]` when there is no registry to ask. Throws on * transport failure -- the caller decides whether one package's loss is tolerable. */ declare function fetchVersionNumbers(ecosystem: string, name: string): Promise; declare function createDatabase(dbPath: string): DatabaseSync; declare function insertPackage(db: DatabaseSync, pkg: ApiPackage): number; declare function insertRepoMetadata(db: DatabaseSync, packageId: number, repoMetadata: ApiRepoMetadata | null | undefined, host?: ApiHost | null): void; declare function insertAdvisories(db: DatabaseSync, packageId: number, advisories: (ApiAdvisory | null | undefined)[] | null | undefined): void; declare function insertVersions(db: DatabaseSync, packageId: number, versionNumbers: string[] | null | undefined): void; declare function build(options?: BuildOptions): Promise; export { build, createDatabase, databasePath, extractDatabase, fetchAllCriticalPackages, fetchVersionNumbers, insertAdvisories, insertPackage, insertRepoMetadata, insertVersions, registryFor, }; //# sourceMappingURL=index.d.ts.map