import { JSONBuilder } from '@cnpmjs/packument'; import type { RequireAtLeastOne } from 'type-fest'; import { AbstractService } from '../../common/AbstractService.ts'; import type { AbbreviatedPackageManifestType, AuthorType, PackageJSONType, PackageManifestType } from '../../repository/PackageRepository.ts'; import { Package } from '../entity/Package.ts'; import { PackageVersion } from '../entity/PackageVersion.ts'; import { PackageVersionBlock } from '../entity/PackageVersionBlock.ts'; import type { Registry } from '../entity/Registry.ts'; import type { User } from '../entity/User.ts'; export interface PublishPackageCmd { scope: string; name: string; version: string; description?: string; packageJson: PackageJSONType; registryId?: string; readme: string; dist: RequireAtLeastOne<{ content?: Uint8Array; localFile?: string; }, 'content' | 'localFile'>; tags?: string[]; /** * private package or not */ isPrivate: boolean; publishTime?: Date; skipRefreshPackageManifests?: boolean; } export declare class PackageManagerService extends AbstractService { private readonly eventBus; private readonly packageRepository; private readonly packageVersionBlockRepository; private readonly packageVersionDownloadRepository; private readonly bugVersionService; private readonly distRepository; private readonly registryManagerService; private readonly packageVersionService; private static downloadCounters; static resetDownloadCounters(): void; publish(cmd: PublishPackageCmd, publisher: User): Promise; private _shouldIsolateNewVersion; private _isolateNewVersion; private _isDependencyIsolationExcluded; blockPackageByFullname(name: string, reason: string): Promise; blockPackage(pkg: Package, reason: string): Promise; unblockPackageByFullname(name: string): Promise; unblockPackage(pkg: Package): Promise; blockPackageVersion(pkg: Package, version: string, reason: string): Promise; unblockPackageVersion(pkg: Package, version: string): Promise; /** * Idempotently set whether a package version is available (visible) to the outside, for * external decision sources (e.g. a deployment's security scan). * - available=false: permanently block; if the version is currently in the dependency-isolation * buffer, the buffer record is overwritten to a permanent block (type=null, no auto-release). * - available=true: only lifts a PERMANENT block. It deliberately does NOT release a buffer * record — automated "make available" must not let a version escape the isolation window * ahead of its timer. Buffer release is owned by the timer (releaseBufferedVersions); an * admin can still force-release via unblockPackageVersion (the explicit escape channel). */ ensurePackageVersionAvailability(pkg: Package, version: string, available: boolean, reason?: string): Promise<{ changed: boolean; }>; /** * Dependency isolation: release expired buffer versions of a single package in one batch. * Only records still of type='buffer' are released (a record overwritten to a permanent * block is left alone). The package manifest is rebuilt once for the whole batch (the * rebuild is O(versions) regardless of how many are released), then PACKAGE_VERSION_ADDED * is emitted per released version so search / changes stream / file sync pick them up. * Idempotent: already-removed / no-longer-buffer versions are skipped. */ releaseBufferedVersions(packageId: string, versions: string[]): Promise; replacePackageMaintainersAndDist(pkg: Package, maintainers: User[]): Promise; savePackageMaintainers(pkg: Package, maintainers: User[]): Promise; removePackageMaintainer(pkg: Package, maintainer: User): Promise; refreshPackageMaintainersToDists(pkg: Package): Promise; refreshPackageDistTagsToDists(pkg: Package): Promise; listPackageFullManifests(scope: string, name: string, isSync?: boolean): Promise<{ etag: string; data: null; blockReason: string; } | { etag: string; data: PackageManifestType; blockReason: string; }>; listPackageFullManifestsBuffer(scope: string, name: string): Promise<{ etag: string; data: null; blockReason: string; } | { etag: string; data: Buffer; blockReason: string; }>; listPackageAbbreviatedManifests(scope: string, name: string, isSync?: boolean): Promise<{ etag: string; data: null; blockReason: string; } | { etag: string; data: AbbreviatedPackageManifestType | PackageManifestType; blockReason: string; }>; listPackageAbbreviatedManifestsBuffer(scope: string, name: string): Promise<{ etag: string; data: null; blockReason: string; } | { etag: string; data: Buffer; blockReason: string; }>; showPackageVersionByVersionOrTag(scope: string, name: string, spec: string): Promise<{ blockReason?: string; pkg?: Package; packageVersion?: PackageVersion | null; }>; showPackageVersionManifest(scope: string, name: string, spec: string, isSync?: boolean, isFullManifests?: boolean): Promise<{ manifest?: undefined; blockReason?: undefined; pkg?: undefined; } | { blockReason: string; pkg: Package; manifest?: undefined; } | { manifest: PackageJSONType | undefined; blockReason: null; pkg: Package; }>; downloadPackageVersionTar(packageVersion: PackageVersion): Promise; plusPackageVersionCounter(fullname: string, version: string): void; savePackageVersionCounters(): Promise; saveDeprecatedVersions(pkg: Package, deprecatedList: { version: string; deprecated?: string; }[]): Promise; savePackageVersionManifest(pkgVersion: PackageVersion, mergeManifest: object, mergeAbbreviated: object): Promise; savePackageVersionManifestWithBuilder(pkgVersion: PackageVersion, manifestBuilder: JSONBuilder, abbreviatedBuilder?: JSONBuilder): Promise; /** * save package version readme */ savePackageVersionReadme(pkgVersion: PackageVersion, readmeFile: string): Promise; savePackageReadme(pkg: Package, readmeFile: string): Promise; private _removePackageVersionAndDist; unpublishPackage(pkg: Package): Promise; removePackageVersion(pkg: Package, pkgVersion: PackageVersion, skipRefreshPackageManifests?: boolean, skipChangeEvent?: boolean): Promise; savePackageTag(pkg: Package, tag: string, version: string, skipEvent?: boolean): Promise; removePackageTag(pkg: Package, tag: string): Promise; refreshPackageChangeVersionsToDists(pkg: Package, updateVersions?: string[], removeVersions?: string[]): Promise; private _refreshPackageChangeVersionsToDistsWithBuilder; getSourceRegistry(pkg: Package): Promise; distTags(pkg: Package): Promise; private _refreshPackageManifestsToDists; private _refreshPackageManifestRootAttributeOnlyToDists; private _refreshPackageManifestRootAttributeOnlyToDistsWithBuilder; private _mergeLatestManifestFields; private _mergeLatestManifestFieldsWithBuilder; private _setPackageDistTagsAndLatestInfos; private _setPackageDistTagsAndLatestInfosWithBuilder; private _mergeManifestDist; private _updatePackageManifestsToDists; private _updatePackageManifestsToDistsWithBuilder; private _listPackageFullOrAbbreviatedManifests; private _listPackageFullOrAbbreviatedManifestsBuffer; maintainers(pkg: Package): Promise; private _listBlockedVersionMap; private _listPackageFullManifests; private _listPackageAbbreviatedManifests; private _checkPackageDepsVersion; }