From 0b5855d6dd87369913eeb8ea40813077bd9cf117 Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Wed, 13 Sep 2023 00:42:39 +0000 Subject: [PATCH] Fix Packument['versions'] type. --- src/package-managers/npm.ts | 8 +++++--- src/types/Packument.ts | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/package-managers/npm.ts b/src/package-managers/npm.ts index 9eb99a5b..8c8d6bca 100644 --- a/src/package-managers/npm.ts +++ b/src/package-managers/npm.ts @@ -46,7 +46,7 @@ const fetchPackument = async ( opts: { fullMetadata?: boolean }, -): Promise => { +): Promise => { const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' const fullDoc = 'application/json' const headers = { @@ -352,7 +352,7 @@ export const mockViewMany = }, version, // overwritten below - versions: [], + versions: {}, ...(isPackument(partialPackument) ? partialPackument : null), } @@ -369,7 +369,9 @@ export const mockViewMany = } as Index) : ({ ...packument, - versions: [packument], + versions: { + [version]: packument, + }, } as Packument), })), ) diff --git a/src/types/Packument.ts b/src/types/Packument.ts index 99bcea4a..f04d6064 100644 --- a/src/types/Packument.ts +++ b/src/types/Packument.ts @@ -3,6 +3,9 @@ import { Version } from './Version' /** A pacote packument result object. */ export interface Packument { + _npmUser?: { + name: string + } name: string deprecated?: boolean engines: { @@ -12,5 +15,5 @@ export interface Packument { // TODO: store only the time of the latest version? time?: Index version: Version - versions: Packument[] + versions: Index }