UNPKG

cnpmcore

Version:
181 lines (180 loc) 6.91 kB
import { Package as PackageEntity } from '../core/entity/Package'; import { PackageVersion as PackageVersionEntity } from '../core/entity/PackageVersion'; import { PackageVersionManifest as PackageVersionManifestEntity } from '../core/entity/PackageVersionManifest'; import type { PackageVersionManifest as PackageVersionManifestModel } from './model/PackageVersionManifest'; import { PackageTag as PackageTagEntity } from '../core/entity/PackageTag'; import { User as UserEntity } from '../core/entity/User'; import { AbstractRepository } from './AbstractRepository'; import { BugVersionPackages } from '../core/entity/BugVersion'; export type PackageManifestType = Pick<PackageJSONType, PackageJSONPickKey> & { _id: string; _rev: string; 'dist-tags': Record<string, string>; versions: Record<string, PackageJSONType | undefined>; maintainers: AuthorType[]; time: { created: Date; modified: Date; [key: string]: Date; }; } & CnpmcorePatchInfo; export type AbbreviatedPackageJSONType = Pick<PackageJSONType, AbbreviatedKey> & CnpmcorePatchInfo; export type AbbreviatedPackageManifestType = Pick<PackageManifestType, 'dist-tags' | 'name'> & { modified: Date; versions: Record<string, AbbreviatedPackageJSONType | undefined>; time?: PackageManifestType['time']; } & CnpmcorePatchInfo; export type PackageJSONType = CnpmcorePatchInfo & { name: string; version: string; readme?: string; description?: string; keywords?: string[]; homepage?: string; bugs?: { url?: string; email?: string; }; license?: LicenseType | string; author?: AuthorType | string; contributors?: ContributorType[] | string[]; maintainers?: ContributorType[] | string[]; files?: string[]; main?: string; bin?: string | { [key: string]: string; }; man?: string | string[]; directories?: DirectoriesType; repository?: RepositoryType; scripts?: Record<string, string>; config?: { 'bug-versions'?: BugVersionPackages; }; dependencies?: DepInfo; acceptDependencies?: DepInfo; devDependencies?: DepInfo; peerDependencies?: DepInfo; peerDependenciesMeta?: { [key: string]: { optional?: boolean; required?: string; version?: string; [key: string]: unknown; }; }; bundleDependencies?: string[]; bundledDependencies?: string[]; optionalDependencies?: DepInfo; engines?: { node?: string; npm?: string; [key: string]: string | undefined; }; os?: string[]; cpu?: string[]; preferGlobal?: boolean; private?: boolean; publishConfig?: { access?: 'public' | 'restricted'; [key: string]: unknown; }; _hasShrinkwrap?: boolean; hasInstallScript?: boolean; dist?: DistType; workspace?: string[]; _npmUser?: { name: string; email: string; }; [key: string]: unknown; }; type PackageJSONPickKey = 'name' | 'author' | 'bugs' | 'description' | 'homepage' | 'keywords' | 'license' | 'readme' | 'readmeFilename' | 'repository' | 'versions' | 'contributors'; export type CnpmcorePatchInfo = { _cnpmcore_publish_time?: Date; publish_time?: number; _source_registry_name?: string; block?: string; }; type AbbreviatedKey = 'name' | 'version' | 'deprecated' | 'dependencies' | 'optionalDependencies' | 'devDependencies' | 'bundleDependencies' | 'peerDependencies' | 'peerDependenciesMeta' | 'bin' | 'os' | 'cpu' | 'libc' | 'workspaces' | 'directories' | 'dist' | 'engines' | 'hasInstallScript' | 'publish_time' | 'block' | '_hasShrinkwrap' | 'acceptDependencies' | 'funding'; type DistType = { tarball: string; size: number; shasum: string; integrity: string; [key: string]: unknown; }; export type AuthorType = { name: string; username?: string; email?: string; url?: string; }; type LicenseType = { type: string; url: string; }; type ContributorType = { name?: string; email?: string; url?: string; [key: string]: unknown; }; type DirectoriesType = { lib?: string; bin?: string; man?: string; test?: string; [key: string]: string | undefined; }; type RepositoryType = { type: string; url: string; [key: string]: unknown; }; type DepInfo = Record<string, string>; export declare class PackageRepository extends AbstractRepository { #private; private readonly Package; private readonly Dist; private readonly PackageVersion; private readonly PackageVersionManifest; private readonly PackageTag; private readonly Maintainer; private readonly User; private readonly config; private readonly orm; findPackage(scope: string, name: string): Promise<PackageEntity | null>; findPackageByPackageId(packageId: string): Promise<PackageEntity | null>; findPackageId(scope: string, name: string): Promise<string | null>; savePackage(pkgEntity: PackageEntity): Promise<void>; savePackageDist(pkgEntity: PackageEntity, isFullManifests: boolean): Promise<void>; removePackageDist(pkgEntity: PackageEntity, isFullManifests: boolean): Promise<void>; savePackageMaintainer(packageId: string, userId: string): Promise<undefined | true>; listPackageMaintainers(packageId: string): Promise<UserEntity[]>; replacePackageMaintainers(packageId: string, userIds: string[]): Promise<void>; removePackageMaintainer(packageId: string, userId: string): Promise<boolean>; listPackagesByUserId(userId: string): Promise<PackageEntity[]>; createPackageVersion(pkgVersionEntity: PackageVersionEntity): Promise<void>; savePackageVersion(pkgVersionEntity: PackageVersionEntity): Promise<void>; findPackageVersion(packageId: string, version: string): Promise<PackageVersionEntity | null>; listPackageVersions(packageId: string): Promise<PackageVersionEntity[]>; listPackageVersionNames(packageId: string): Promise<string[]>; removePackageVersions(packageId: string): Promise<void>; removePackageVersion(pkgVersion: PackageVersionEntity): Promise<void>; savePackageVersionManifest(manifestEntity: PackageVersionManifestEntity): Promise<void>; findPackageVersionManifest(packageVersionId: string): Promise<PackageVersionManifestModel | null>; private getCountSql; queryTotal(): Promise<{ packageCount: number; packageVersionCount: number; lastPackage: string; lastPackageVersion: string; }>; private fillPackageVersionEntityData; findPackageTag(packageId: string, tag: string): Promise<PackageTagEntity | null>; savePackageTag(packageTagEntity: PackageTagEntity): Promise<void>; removePackageTag(packageTagEntity: PackageTagEntity): Promise<void>; listPackageTags(packageId: string): Promise<PackageTagEntity[]>; } export {};