cnpmcore
Version:
Private NPM Registry for Enterprise
179 lines (178 loc) • 7.05 kB
TypeScript
import type { BugVersionPackages } from '../core/entity/BugVersion.ts';
import { Package as PackageEntity } from '../core/entity/Package.ts';
import { PackageTag as PackageTagEntity } from '../core/entity/PackageTag.ts';
import { PackageVersion as PackageVersionEntity } from '../core/entity/PackageVersion.ts';
import type { PackageVersionManifest as PackageVersionManifestEntity } from '../core/entity/PackageVersionManifest.ts';
import { User as UserEntity } from '../core/entity/User.ts';
import { AbstractRepository } from './AbstractRepository.ts';
import type { PackageVersionManifest as PackageVersionManifestModel } from './model/PackageVersionManifest.ts';
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 | string;
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;
};
export type PackageJSONPickKey = 'name' | 'author' | 'bugs' | 'description' | 'homepage' | 'keywords' | 'license' | 'readme' | 'readmeFilename' | 'repository' | 'versions' | 'contributors';
export interface CnpmcorePatchInfo {
_cnpmcore_publish_time?: Date;
publish_time?: number;
_source_registry_name?: string;
block?: string;
}
export 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';
export interface DistType {
tarball: string;
size: number;
shasum: string;
integrity: string;
[key: string]: unknown;
}
export interface AuthorType {
name: string;
username?: string;
email?: string;
url?: string;
}
export interface LicenseType {
type: string;
url: string;
}
export interface ContributorType {
name?: string;
email?: string;
url?: string;
[key: string]: unknown;
}
export interface DirectoriesType {
lib?: string;
bin?: string;
man?: string;
test?: string;
[key: string]: string | undefined;
}
export interface RepositoryType {
type: string;
url: string;
[key: string]: unknown;
}
export 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 totalRepository;
findPackage(scope: string, name: string): Promise<PackageEntity | null>;
findPackageByPackageId(packageId: string): Promise<PackageEntity | null>;
findPackagesByPackageIds(packageIds: string[]): Promise<PackageEntity[]>;
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>;
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[]>;
}