feat(registry): add declarative protocol routing and request-scoped storage hook context across registries
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
function digestToHash(digest: string): string {
|
||||
return digest.split(':')[1];
|
||||
}
|
||||
|
||||
export function getOciBlobPath(digest: string): string {
|
||||
return `oci/blobs/sha256/${digestToHash(digest)}`;
|
||||
}
|
||||
|
||||
export function getOciManifestPath(repository: string, digest: string): string {
|
||||
return `oci/manifests/${repository}/${digestToHash(digest)}`;
|
||||
}
|
||||
|
||||
export function getNpmPackumentPath(packageName: string): string {
|
||||
return `npm/packages/${packageName}/index.json`;
|
||||
}
|
||||
|
||||
export function getNpmTarballPath(packageName: string, version: string): string {
|
||||
const safeName = packageName.replace('@', '').replace('/', '-');
|
||||
return `npm/packages/${packageName}/${safeName}-${version}.tgz`;
|
||||
}
|
||||
|
||||
export function getMavenArtifactPath(
|
||||
groupId: string,
|
||||
artifactId: string,
|
||||
version: string,
|
||||
filename: string
|
||||
): string {
|
||||
const groupPath = groupId.replace(/\./g, '/');
|
||||
return `maven/artifacts/${groupPath}/${artifactId}/${version}/${filename}`;
|
||||
}
|
||||
|
||||
export function getMavenMetadataPath(groupId: string, artifactId: string): string {
|
||||
const groupPath = groupId.replace(/\./g, '/');
|
||||
return `maven/metadata/${groupPath}/${artifactId}/maven-metadata.xml`;
|
||||
}
|
||||
|
||||
export function getCargoConfigPath(): string {
|
||||
return 'cargo/config.json';
|
||||
}
|
||||
|
||||
export function getCargoIndexPath(crateName: string): string {
|
||||
const lower = crateName.toLowerCase();
|
||||
const len = lower.length;
|
||||
|
||||
if (len === 1) {
|
||||
return `cargo/index/1/${lower}`;
|
||||
}
|
||||
|
||||
if (len === 2) {
|
||||
return `cargo/index/2/${lower}`;
|
||||
}
|
||||
|
||||
if (len === 3) {
|
||||
return `cargo/index/3/${lower.charAt(0)}/${lower}`;
|
||||
}
|
||||
|
||||
const prefix1 = lower.substring(0, 2);
|
||||
const prefix2 = lower.substring(2, 4);
|
||||
return `cargo/index/${prefix1}/${prefix2}/${lower}`;
|
||||
}
|
||||
|
||||
export function getCargoCratePath(crateName: string, version: string): string {
|
||||
return `cargo/crates/${crateName}/${crateName}-${version}.crate`;
|
||||
}
|
||||
|
||||
export function getComposerMetadataPath(vendorPackage: string): string {
|
||||
return `composer/packages/${vendorPackage}/metadata.json`;
|
||||
}
|
||||
|
||||
export function getComposerZipPath(vendorPackage: string, reference: string): string {
|
||||
return `composer/packages/${vendorPackage}/${reference}.zip`;
|
||||
}
|
||||
|
||||
export function getPypiMetadataPath(packageName: string): string {
|
||||
return `pypi/metadata/${packageName}/metadata.json`;
|
||||
}
|
||||
|
||||
export function getPypiSimpleIndexPath(packageName: string): string {
|
||||
return `pypi/simple/${packageName}/index.html`;
|
||||
}
|
||||
|
||||
export function getPypiSimpleRootIndexPath(): string {
|
||||
return 'pypi/simple/index.html';
|
||||
}
|
||||
|
||||
export function getPypiPackageFilePath(packageName: string, filename: string): string {
|
||||
return `pypi/packages/${packageName}/${filename}`;
|
||||
}
|
||||
|
||||
export function getRubyGemsVersionsPath(): string {
|
||||
return 'rubygems/versions';
|
||||
}
|
||||
|
||||
export function getRubyGemsInfoPath(gemName: string): string {
|
||||
return `rubygems/info/${gemName}`;
|
||||
}
|
||||
|
||||
export function getRubyGemsNamesPath(): string {
|
||||
return 'rubygems/names';
|
||||
}
|
||||
|
||||
export function getRubyGemsGemPath(gemName: string, version: string, platform?: string): string {
|
||||
const filename = platform ? `${gemName}-${version}-${platform}.gem` : `${gemName}-${version}.gem`;
|
||||
return `rubygems/gems/${filename}`;
|
||||
}
|
||||
|
||||
export function getRubyGemsMetadataPath(gemName: string): string {
|
||||
return `rubygems/metadata/${gemName}/metadata.json`;
|
||||
}
|
||||
Reference in New Issue
Block a user