import { Contributor, Header, License } from "@definitelytyped/header-parser"; import { TypeScriptVersion } from "@definitelytyped/typescript-versions"; import { FS } from "@definitelytyped/utils"; import * as semver from "semver"; export declare class AllPackages { private dt; /** Keys are `typesDirectoryName` strings */ private readonly types; private readonly notNeeded; static fromFS(dt: FS): AllPackages; static fromTestData(typingsVersionsRaw: Record, notNeeded: readonly NotNeededPackage[]): AllPackages; /** Use for `--single` tasks only. Do *not* call this in a loop! */ static readSingle(dt: FS, name: string): Promise; /** Keys are `typesDirectoryName` strings */ private readonly errors; private isComplete; private constructor(); getNotNeededPackage(typesDirectoryName: string): NotNeededPackage | undefined; hasTypingFor(dep: PackageId): Promise; getErrorsAsArray(): string[]; /** * Whether a package maintains multiple minor versions of typings simultaneously by * using minor-versioned directories like 'react-native/v14.1' */ hasSeparateMinorVersions(typesDirectoryName: string): Promise; tryResolve(dep: PackageId): Promise; resolve(dep: PackageId): Promise; /** Gets the latest version of a package. E.g. getLatest(node v6) was node v10 (before node v11 came out). */ getLatest(pkg: TypingsData): Promise; private getLatestVersion; tryGetLatestVersion(typesDirectoryName: string): Promise; getTypingsData(id: PackageId): Promise; tryGetTypingsData(pkg: PackageId): Promise; private tryGetTypingsVersions; allPackages(): Promise; /** Note: this includes older version directories (`foo/v0`) */ allTypings(): Promise; allLatestTypings(): Promise; allNotNeeded(): readonly NotNeededPackage[]; /** Returns all of the dependencies *that are typed on DT*, ignoring others, and including test dependencies. */ allDependencyTypings(pkg: TypingsData): AsyncIterable; private readAllTypings; } export declare function getMangledNameForScopedPackage(packageName: string): string; export type AnyPackage = NotNeededPackage | TypingsData; /** Prefer to use `AnyPackage` instead of this. */ export declare abstract class PackageBase { static compare(a: PackageBase, b: PackageBase): number; /** The package.json "name" field */ abstract readonly name: string; /** * For non-npm packages, the human-readable library name recorded in * the package.json "nonNpmDescription" field. Otherwise, the name of * the implementation library, as computed from the package.json "name". */ abstract readonly libraryName: string; abstract readonly major: number; abstract readonly minor: number; abstract readonly isLatest: boolean; /** * The immediate subdirectory name in DefinitelyTyped/types/. * Must be equal to the package.json "name" field without the "@types/" prefix. * Does not include the version directory. */ get typesDirectoryName(): string; /** Short description for debug output. */ get desc(): string; get id(): PackageIdWithDefiniteVersion; isNotNeeded(): this is NotNeededPackage; } interface NotNeededPackageRaw { /** * The npm name of the implementation library that the types package was for. */ readonly libraryName: string; /** * If this is available, @types typings are deprecated as of this version. * This is useful for packages that previously had DefinitelyTyped definitions but which now provide their own. */ readonly asOfVersion: string; } export declare class NotNeededPackage extends PackageBase { readonly name: string; readonly libraryName: string; readonly version: semver.SemVer; get license(): License.MIT; static fromRaw(name: string, raw: NotNeededPackageRaw): NotNeededPackage; constructor(name: string, libraryName: string, asOfVersion: string); get major(): number; get minor(): number; get isLatest(): boolean; get minTypeScriptVersion(): TypeScriptVersion; deprecatedMessage(): string; } export interface TypingsVersionsRaw { [version: `${number}.${number}`]: TypingsDataRaw; } /** Minor may be unknown if parsed from a major-only version directory, like 'types/v15' */ export interface DirectoryParsedTypingVersion { major: number; minor?: number; } /** Version parsed from DT header comment, so both major and minor are known */ export interface HeaderParsedTypingVersion { major: number; minor: number; } export declare function formatTypingVersion(version: DirectoryParsedTypingVersion): string; /** Maps name to version */ export type PackageJsonDependencies = Record; export interface TypingsDataRaw { /** * Header info contained in package.json */ readonly header: Header; /** * Package `imports`, as read in the `package.json` file */ readonly imports?: object; /** * Package `exports`, as read in the `package.json` file */ readonly exports?: object | string; /** * Package `type`, as read in the `package.json` file */ readonly type?: string; /** * Packages that provide definitions that this package depends on. * NOTE: Includes `@types/` packages. */ readonly dependencies: PackageJsonDependencies; /** * Packages that this package's tests or other development depends on. */ readonly devDependencies: PackageJsonDependencies; /** * Packages that this package peer depends on. */ readonly peerDependencies?: PackageJsonDependencies; /** * The [older] version of the library that this definition package refers to, as represented *on-disk*. * * @note The latest version always exists in the root of the package tree and thus does not have a value for this property. */ readonly libraryVersionDirectoryName?: string; /** * List of TS versions that have their own directories, and corresponding "typesVersions" in package.json. * Usually empty. */ readonly typesVersions: readonly TypeScriptVersion[]; /** * The license that this definition package is released under. * * Can be either MIT or Apache v2, defaults to MIT when not explicitly defined in this package’s "package.json". */ readonly license: License; /** * Which subdirectories of this package are older versions, e.g. `v1`, `v0.1`, `v15`. */ readonly olderVersionDirectories: readonly string[]; } export declare class TypingsVersions { private readonly map; /** * Sorted from latest to oldest. */ private readonly versions; constructor(dt: FS, data: TypingsVersionsRaw); getAll(): Iterable; get(version: semver.Range, errorMessage?: string): TypingsData; tryGet(version: semver.Range): TypingsData | undefined; getLatest(): TypingsData; } export declare class TypingsData extends PackageBase { private dt; private readonly data; readonly isLatest: boolean; constructor(dt: FS, data: TypingsDataRaw, isLatest: boolean); get name(): string; get libraryName(): string; get contributors(): readonly Contributor[]; get major(): number; get minor(): number; get minTypeScriptVersion(): TypeScriptVersion; get typesVersions(): readonly TypeScriptVersion[]; private _files; getFiles(): readonly string[]; getDtsFiles(): readonly string[]; get license(): License; get dependencies(): PackageJsonDependencies; get devDependencies(): PackageJsonDependencies; get peerDependencies(): PackageJsonDependencies; allPackageJsonDependencies(): Iterable<[string, string]>; private _contentHash; getContentHash(): string; get projectName(): string | undefined; get type(): string | undefined; get imports(): object | undefined; get exports(): string | object | undefined; get nonNpm(): boolean | "conflict"; get versionDirectoryName(): string | undefined; /** Path to this package, *relative* to the DefinitelyTyped directory. */ get subDirectoryPath(): string; } /** Uniquely identifies a package. */ export type PackageId = { readonly typesDirectoryName: string; readonly version: DirectoryParsedTypingVersion | "*"; } | { readonly name: string; readonly typesDirectoryName?: undefined; readonly version: DirectoryParsedTypingVersion | "*"; }; export interface PackageIdWithDefiniteVersion { readonly typesDirectoryName: string; readonly version: HeaderParsedTypingVersion; } export declare function readNotNeededPackages(dt: FS): readonly NotNeededPackage[]; /** * For "types/a/b/c", returns { name: "a", version: "*" }. * For "types/a/v3/c", returns { name: "a", version: 3 }. * for "types/a/scripts/...", returns "scripts". * For "x", returns undefined. */ export declare function getDependencyFromFile(file: string): { typesDirectoryName: string; version: DirectoryParsedTypingVersion | "*"; } | "scripts" | undefined; export {};