From 06af780423bdce8b62c471d3c26bb4c75364a959 Mon Sep 17 00:00:00 2001 From: Edoardo Scibona <12040076+velut@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:02:56 +0200 Subject: [PATCH] chore: delete v2 code --- .../endpoints/get-abbreviated-packument.ts | 54 - .../endpoints/get-daily-package-downloads.ts | 75 - .../endpoints/get-daily-registry-downloads.ts | 63 - old/src/endpoints/get-package-downloads.ts | 75 - old/src/endpoints/get-package-manifest.ts | 86 - old/src/endpoints/get-packument.ts | 51 - .../get-raw-abbreviated-packument.ts | 50 - old/src/endpoints/get-raw-package-manifest.ts | 73 - old/src/endpoints/get-raw-packument.ts | 49 - old/src/endpoints/get-registry-downloads.ts | 63 - old/src/endpoints/get-registry-metadata.ts | 47 - old/src/endpoints/search-packages.ts | 47 - old/src/index.ts | 127 -- old/src/types/abbreviated-packument.ts | 28 - old/src/types/bug-tracker.ts | 7 - old/src/types/dist-info.ts | 24 - old/src/types/dist-tags.ts | 10 - old/src/types/download-period.ts | 46 - old/src/types/downloads.ts | 69 - old/src/types/git-repository.ts | 19 - old/src/types/npm-operational-internal.ts | 4 - old/src/types/package-json.ts | 159 -- old/src/types/package-manifest.ts | 40 - old/src/types/packument.ts | 44 - old/src/types/person.ts | 9 - old/src/types/raw-abbreviated-packument.ts | 51 - old/src/types/raw-package-manifest.ts | 62 - old/src/types/raw-packument.ts | 79 - old/src/types/registry-metadata.ts | 36 - old/src/types/repository.ts | 19 - old/src/types/search-criteria.ts | 51 - old/src/types/search-results.ts | 168 -- old/src/types/versions-to-timestamps.ts | 13 - old/src/utils/assert-valid-package-name.ts | 12 - old/src/utils/errors.ts | 35 - old/src/utils/extract-package-manifest.ts | 25 - .../utils/fetch-downloads-from-registry.ts | 19 - old/src/utils/fetch-from-registry.ts | 46 - old/src/utils/fetch.ts | 48 - old/src/utils/get-definitely-typed-name.ts | 43 - old/src/utils/get-untyped-name.ts | 14 - old/src/utils/log.ts | 9 - old/src/utils/normalize-download-period.ts | 22 - .../normalize-raw-abbreviated-packument.ts | 16 - old/src/utils/normalize-raw-license.ts | 11 - .../utils/normalize-raw-package-manifest.ts | 52 - old/src/utils/normalize-raw-packument.ts | 30 - old/src/utils/normalize-raw-repository.ts | 80 - .../utils/normalize-raw-search-criteria.ts | 13 - .../get-abbreviated-packument.test.ts.snap | 1732 ----------------- .../get-abbreviated-packument.test.ts | 99 - .../get-daily-package-downloads.test.ts | 128 -- .../get-daily-registry-downloads.test.ts | 94 - .../endpoints/get-package-downloads.test.ts | 122 -- .../endpoints/get-package-manifest.test.ts | 354 ---- old/test/endpoints/get-packument.test.ts | 64 - .../get-raw-abbreviated-packument.test.ts | 80 - .../get-raw-package-manifest.test.ts | 99 - old/test/endpoints/get-raw-packument.test.ts | 78 - .../endpoints/get-registry-downloads.test.ts | 90 - .../get-registry-metadata.disable-test.ts | 73 - old/test/endpoints/search-packages.test.ts | 47 - old/test/utils/fetch-from-registry.test.ts | 78 - .../utils/normalize-raw-repository.test.ts | 85 - 64 files changed, 5496 deletions(-) delete mode 100644 old/src/endpoints/get-abbreviated-packument.ts delete mode 100644 old/src/endpoints/get-daily-package-downloads.ts delete mode 100644 old/src/endpoints/get-daily-registry-downloads.ts delete mode 100644 old/src/endpoints/get-package-downloads.ts delete mode 100644 old/src/endpoints/get-package-manifest.ts delete mode 100644 old/src/endpoints/get-packument.ts delete mode 100644 old/src/endpoints/get-raw-abbreviated-packument.ts delete mode 100644 old/src/endpoints/get-raw-package-manifest.ts delete mode 100644 old/src/endpoints/get-raw-packument.ts delete mode 100644 old/src/endpoints/get-registry-downloads.ts delete mode 100644 old/src/endpoints/get-registry-metadata.ts delete mode 100644 old/src/endpoints/search-packages.ts delete mode 100644 old/src/index.ts delete mode 100644 old/src/types/abbreviated-packument.ts delete mode 100644 old/src/types/bug-tracker.ts delete mode 100644 old/src/types/dist-info.ts delete mode 100644 old/src/types/dist-tags.ts delete mode 100644 old/src/types/download-period.ts delete mode 100644 old/src/types/downloads.ts delete mode 100644 old/src/types/git-repository.ts delete mode 100644 old/src/types/npm-operational-internal.ts delete mode 100644 old/src/types/package-json.ts delete mode 100644 old/src/types/package-manifest.ts delete mode 100644 old/src/types/packument.ts delete mode 100644 old/src/types/person.ts delete mode 100644 old/src/types/raw-abbreviated-packument.ts delete mode 100644 old/src/types/raw-package-manifest.ts delete mode 100644 old/src/types/raw-packument.ts delete mode 100644 old/src/types/registry-metadata.ts delete mode 100644 old/src/types/repository.ts delete mode 100644 old/src/types/search-criteria.ts delete mode 100644 old/src/types/search-results.ts delete mode 100644 old/src/types/versions-to-timestamps.ts delete mode 100644 old/src/utils/assert-valid-package-name.ts delete mode 100644 old/src/utils/errors.ts delete mode 100644 old/src/utils/extract-package-manifest.ts delete mode 100644 old/src/utils/fetch-downloads-from-registry.ts delete mode 100644 old/src/utils/fetch-from-registry.ts delete mode 100644 old/src/utils/fetch.ts delete mode 100644 old/src/utils/get-definitely-typed-name.ts delete mode 100644 old/src/utils/get-untyped-name.ts delete mode 100644 old/src/utils/log.ts delete mode 100644 old/src/utils/normalize-download-period.ts delete mode 100644 old/src/utils/normalize-raw-abbreviated-packument.ts delete mode 100644 old/src/utils/normalize-raw-license.ts delete mode 100644 old/src/utils/normalize-raw-package-manifest.ts delete mode 100644 old/src/utils/normalize-raw-packument.ts delete mode 100644 old/src/utils/normalize-raw-repository.ts delete mode 100644 old/src/utils/normalize-raw-search-criteria.ts delete mode 100644 old/test/endpoints/__snapshots__/get-abbreviated-packument.test.ts.snap delete mode 100644 old/test/endpoints/get-abbreviated-packument.test.ts delete mode 100644 old/test/endpoints/get-daily-package-downloads.test.ts delete mode 100644 old/test/endpoints/get-daily-registry-downloads.test.ts delete mode 100644 old/test/endpoints/get-package-downloads.test.ts delete mode 100644 old/test/endpoints/get-package-manifest.test.ts delete mode 100644 old/test/endpoints/get-packument.test.ts delete mode 100644 old/test/endpoints/get-raw-abbreviated-packument.test.ts delete mode 100644 old/test/endpoints/get-raw-package-manifest.test.ts delete mode 100644 old/test/endpoints/get-raw-packument.test.ts delete mode 100644 old/test/endpoints/get-registry-downloads.test.ts delete mode 100644 old/test/endpoints/get-registry-metadata.disable-test.ts delete mode 100644 old/test/endpoints/search-packages.test.ts delete mode 100644 old/test/utils/fetch-from-registry.test.ts delete mode 100644 old/test/utils/normalize-raw-repository.test.ts diff --git a/old/src/endpoints/get-abbreviated-packument.ts b/old/src/endpoints/get-abbreviated-packument.ts deleted file mode 100644 index e0262c0..0000000 --- a/old/src/endpoints/get-abbreviated-packument.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { AbbreviatedPackument } from "../types/abbreviated-packument"; -import { normalizeRawAbbreviatedPackument } from "../utils/normalize-raw-abbreviated-packument"; -import { getRawAbbreviatedPackument } from "./get-raw-abbreviated-packument"; - -/** - * `getAbbreviatedPackument` returns the abbreviated packument (package document) - * containing only the metadata necessary to install a package present on the registry. - * - * @remarks - * To get all the metadata (full packument) about a package see {@link getPackument}. - * - * @param name - package name - * @param registry - URL of the registry (default: npm registry) - * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the abbreviated packument for package `query-registry` from the npm registry: - * - * ```typescript - * import { getAbbreviatedPackument } from 'query-registry'; - * - * (async () => { - * const packument = await getAbbreviatedPackument({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(packument.name); - * })(); - * ``` - * - * @see {@link AbbreviatedPackument} - * @see {@link RawAbbreviatedPackument} - * @see {@link npmRegistry} - * @see {@link npmRegistryMirrors} - */ -export async function getAbbreviatedPackument({ - name, - registry, - mirrors, - cached, -}: { - name: string; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const rawAbbreviatedPackument = await getRawAbbreviatedPackument({ - name, - registry, - mirrors, - cached, - }); - return normalizeRawAbbreviatedPackument({ rawAbbreviatedPackument }); -} diff --git a/old/src/endpoints/get-daily-package-downloads.ts b/old/src/endpoints/get-daily-package-downloads.ts deleted file mode 100644 index bc17cb0..0000000 --- a/old/src/endpoints/get-daily-package-downloads.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { DownloadPeriod } from "../types/download-period"; -import { DailyPackageDownloads } from "../types/downloads"; -import { assertValidPackageName } from "../utils/assert-valid-package-name"; -import { fetchDownloadsFromRegistry } from "../utils/fetch-downloads-from-registry"; -import { normalizeRawDownloadPeriod } from "../utils/normalize-download-period"; - -/** - * `getDailyPackageDownloads` returns the number of downloads for a package - * for each day in a given time period. - * - * @param name - package name - * @param period - time period in which downloads happened (default: `last-week`) - * @param registryDownloadsAPI - URL of the registry's downloads API (default: npm registry) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the day by day weekly downloads for package `query-registry` from the npm registry: - * - * ```typescript - * import { getDailyPackageDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getDailyPackageDownloads({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(downloads.package); - * - * // Output: 'number' - * console.log(typeof downloads.downloads[0].downloads); - * })(); - * ``` - * - * @example - * Get the day by day monthly downloads for package `query-registry` from the npm registry: - * - * ```typescript - * import { getDailyPackageDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getDailyPackageDownloads({ name: 'query-registry', period: 'last-month' }); - * - * // Output: 'query-registry' - * console.log(downloads.package); - * - * // Output: 'number' - * console.log(typeof downloads.downloads[0].downloads); - * })(); - * ``` - * - * @see {@link DailyPackageDownloads} - * @see {@link DownloadPeriod} - * @see {@link npmRegistryDownloadsAPI} - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#ranges} - */ -export async function getDailyPackageDownloads({ - name, - period: rawDownloadPeriod, - registryDownloadsAPI, - cached, -}: { - name: string; - period?: DownloadPeriod; - registryDownloadsAPI?: string; - cached?: boolean; -}): Promise { - assertValidPackageName({ name }); - - const period = normalizeRawDownloadPeriod({ rawDownloadPeriod }); - const endpoint = `/downloads/range/${period}/${name}`; - return fetchDownloadsFromRegistry({ - endpoint, - registryDownloadsAPI, - cached, - }); -} diff --git a/old/src/endpoints/get-daily-registry-downloads.ts b/old/src/endpoints/get-daily-registry-downloads.ts deleted file mode 100644 index 52345d1..0000000 --- a/old/src/endpoints/get-daily-registry-downloads.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { DownloadPeriod } from "../types/download-period"; -import { DailyRegistryDownloads } from "../types/downloads"; -import { fetchDownloadsFromRegistry } from "../utils/fetch-downloads-from-registry"; -import { normalizeRawDownloadPeriod } from "../utils/normalize-download-period"; - -/** - * `getDailyRegistryDownloads` returns the number of downloads for all registry packages - * for each day in a given time period. - * - * @param period - time period in which downloads happened (default: `last-week`) - * @param registryDownloadsAPI - URL of the registry's downloads API (default: npm registry) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the day by day weekly downloads for the npm registry: - * - * ```typescript - * import { getDailyRegistryDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getDailyRegistryDownloads(); - * - * // Output: 'number' - * console.log(typeof downloads.downloads[0].downloads); - * })(); - * ``` - * - * @example - * Get the day by day monthly downloads for the npm registry: - * - * ```typescript - * import { getDailyRegistryDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getDailyRegistryDownloads({ period: 'last-month' }); - * - * // Output: 'number' - * console.log(typeof downloads.downloads[0].downloads); - * })(); - * ``` - * - * @see {@link DailyRegistryDownloads} - * @see {@link DownloadPeriod} - * @see {@link npmRegistryDownloadsAPI} - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#ranges} - */ -export async function getDailyRegistryDownloads({ - period: rawDownloadPeriod, - registryDownloadsAPI, - cached, -}: { - period?: DownloadPeriod; - registryDownloadsAPI?: string; - cached?: boolean; -} = {}): Promise { - const period = normalizeRawDownloadPeriod({ rawDownloadPeriod }); - const endpoint = `/downloads/range/${period}`; - return fetchDownloadsFromRegistry({ - endpoint, - registryDownloadsAPI, - cached, - }); -} diff --git a/old/src/endpoints/get-package-downloads.ts b/old/src/endpoints/get-package-downloads.ts deleted file mode 100644 index e9c66d4..0000000 --- a/old/src/endpoints/get-package-downloads.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { DownloadPeriod } from "../types/download-period"; -import { PackageDownloads } from "../types/downloads"; -import { assertValidPackageName } from "../utils/assert-valid-package-name"; -import { fetchDownloadsFromRegistry } from "../utils/fetch-downloads-from-registry"; -import { normalizeRawDownloadPeriod } from "../utils/normalize-download-period"; - -/** - * `getPackageDownloads` returns the number of downloads for a package - * in a given time period. - * - * @param name - package name - * @param period - time period in which downloads happened (default: `last-week`) - * @param registryDownloadsAPI - URL of the registry's downloads API (default: npm registry) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the weekly downloads for package `query-registry` from the npm registry: - * - * ```typescript - * import { getPackageDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getPackageDownloads({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(downloads.package); - * - * // Output: 'number' - * console.log(typeof downloads.downloads); - * })(); - * ``` - * - * @example - * Get the monthly downloads for package `query-registry` from the npm registry: - * - * ```typescript - * import { getPackageDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getPackageDownloads({ name: 'query-registry', period: 'last-month' }); - * - * // Output: 'query-registry' - * console.log(downloads.package); - * - * // Output: 'number' - * console.log(typeof downloads.downloads); - * })(); - * ``` - * - * @see {@link PackageDownloads} - * @see {@link DownloadPeriod} - * @see {@link npmRegistryDownloadsAPI} - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#point-values} - */ -export async function getPackageDownloads({ - name, - period: rawDownloadPeriod, - registryDownloadsAPI, - cached, -}: { - name: string; - period?: DownloadPeriod; - registryDownloadsAPI?: string; - cached?: boolean; -}): Promise { - assertValidPackageName({ name }); - - const period = normalizeRawDownloadPeriod({ rawDownloadPeriod }); - const endpoint = `/downloads/point/${period}/${name}`; - return fetchDownloadsFromRegistry({ - endpoint, - registryDownloadsAPI, - cached, - }); -} diff --git a/old/src/endpoints/get-package-manifest.ts b/old/src/endpoints/get-package-manifest.ts deleted file mode 100644 index 4cf4345..0000000 --- a/old/src/endpoints/get-package-manifest.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { PackageManifest } from "../types/package-manifest"; -import { extractRawPackageManifest } from "../utils/extract-package-manifest"; -import { normalizeRawPackageManifest } from "../utils/normalize-raw-package-manifest"; -import { getRawPackument } from "./get-raw-packument"; - -/** - * `getPackageManifest` returns the manifest describing - * a specific version of a package. - * - * @param name - package name - * @param version - package version (default: `latest`) - * @param registry - URL of the registry (default: npm registry) - * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the latest manifest for package `query-registry` from the npm registry: - * - * ```typescript - * import { getPackageManifest } from 'query-registry'; - * - * (async () => { - * const manifest = await getPackageManifest({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(manifest.name); - * })(); - * ``` - * - * @example - * Get the manifest for package `query-registry@1.0.0` from the npm registry: - * - * ```typescript - * import { getPackageManifest } from 'query-registry'; - * - * (async () => { - * const manifest = await getPackageManifest({ name: 'query-registry', version: '1.0.0' }); - * - * // Output: 'query-registry' - * console.log(manifest.name); - * - * // Output: '1.0.0' - * console.log(manifest.version); - * })(); - * ``` - * - * @see {@link PackageManifest} - * @see {@link RawPackageManifest} - * @see {@link npmRegistry} - * @see {@link npmRegistryMirrors} - */ -export async function getPackageManifest({ - name, - version, - registry, - mirrors, - cached, -}: { - name: string; - version?: string; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const rawPackument = await getRawPackument({ - name, - registry, - mirrors, - cached, - }); - - const rawPackageManifest = extractRawPackageManifest({ - rawPackument, - version, - }); - - const packageManifest = await normalizeRawPackageManifest({ - rawPackageManifest, - rawPackument, - registry, - mirrors, - cached, - }); - - return packageManifest; -} diff --git a/old/src/endpoints/get-packument.ts b/old/src/endpoints/get-packument.ts deleted file mode 100644 index e9104a9..0000000 --- a/old/src/endpoints/get-packument.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Packument } from "../types/packument"; -import { normalizeRawPackument } from "../utils/normalize-raw-packument"; -import { getRawPackument } from "./get-raw-packument"; - -/** - * `getPackument` returns the packument (package document) containing - * all the metadata about a package present on the registry. - * - * @param name - package name - * @param registry - URL of the registry (default: npm registry) - * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the packument for package `query-registry` from the npm registry: - * - * ```typescript - * import { getPackument } from 'query-registry'; - * - * (async () => { - * const packument = await getPackument({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(packument.name); - * })(); - * ``` - * - * @see {@link Packument} - * @see {@link RawPackument} - * @see {@link npmRegistry} - * @see {@link npmRegistryMirrors} - */ -export async function getPackument({ - name, - registry, - mirrors, - cached, -}: { - name: string; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const rawPackument = await getRawPackument({ - name, - registry, - mirrors, - cached, - }); - return normalizeRawPackument({ rawPackument }); -} diff --git a/old/src/endpoints/get-raw-abbreviated-packument.ts b/old/src/endpoints/get-raw-abbreviated-packument.ts deleted file mode 100644 index f660a24..0000000 --- a/old/src/endpoints/get-raw-abbreviated-packument.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { RawAbbreviatedPackument } from "../types/raw-abbreviated-packument"; -import { assertValidPackageName } from "../utils/assert-valid-package-name"; -import { fetchFromRegistry } from "../utils/fetch-from-registry"; - -/** - * `getRawAbbreviatedPackument` returns the abbreviated packument (package document) - * containing only the metadata necessary to install a package present on the registry. - * - * Note: the abbreviated packument is returned as retrieved from the registry. - * - * @param name - package name - * @param registry - URL of the registry (default: npm registry) - * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the abbreviated packument for package `query-registry` from the npm registry: - * - * ```typescript - * import { getRawAbbreviatedPackument } from 'query-registry'; - * - * (async () => { - * const packument = await getRawAbbreviatedPackument({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(packument.name); - * })(); - * ``` - * - * @see {@link RawAbbreviatedPackument} - * @see {@link npmRegistry} - * @see {@link npmRegistryMirrors} - */ -export async function getRawAbbreviatedPackument({ - name, - registry, - mirrors, - cached, -}: { - name: string; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - assertValidPackageName({ name }); - - const endpoint = `/${name}`; - const headers = { Accept: "application/vnd.npm.install-v1+json" }; - return fetchFromRegistry({ endpoint, headers, registry, mirrors, cached }); -} diff --git a/old/src/endpoints/get-raw-package-manifest.ts b/old/src/endpoints/get-raw-package-manifest.ts deleted file mode 100644 index a4cd592..0000000 --- a/old/src/endpoints/get-raw-package-manifest.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { RawPackageManifest } from "../types/raw-package-manifest"; -import { extractRawPackageManifest } from "../utils/extract-package-manifest"; -import { getRawPackument } from "./get-raw-packument"; - -/** - * `getRawPackageManifest` returns the manifest describing - * a specific version of a package. - * - * Note: the manifest is returned as retrieved from the registry. - * - * @param name - package name - * @param version - package version (default: `latest`) - * @param registry - URL of the registry (default: npm registry) - * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the latest manifest for package `query-registry` from the npm registry: - * - * ```typescript - * import { getRawPackageManifest } from 'query-registry'; - * - * (async () => { - * const manifest = await getRawPackageManifest({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(manifest.name); - * })(); - * ``` - * - * @example - * Get the manifest for package `query-registry@1.0.0` from the npm registry: - * - * ```typescript - * import { getRawPackageManifest } from 'query-registry'; - * - * (async () => { - * const manifest = await getRawPackageManifest({ name: 'query-registry', version: '1.0.0' }); - * - * // Output: 'query-registry' - * console.log(manifest.name); - * - * // Output: '1.0.0' - * console.log(manifest.version); - * })(); - * ``` - * - * @see {@link RawPackageManifest} - * @see {@link npmRegistry} - * @see {@link npmRegistryMirrors} - */ -export async function getRawPackageManifest({ - name, - version, - registry, - mirrors, - cached, -}: { - name: string; - version?: string; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const rawPackument = await getRawPackument({ - name, - registry, - mirrors, - cached, - }); - - return extractRawPackageManifest({ rawPackument, version }); -} diff --git a/old/src/endpoints/get-raw-packument.ts b/old/src/endpoints/get-raw-packument.ts deleted file mode 100644 index d37b653..0000000 --- a/old/src/endpoints/get-raw-packument.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { RawPackument } from "../types/raw-packument"; -import { assertValidPackageName } from "../utils/assert-valid-package-name"; -import { fetchFromRegistry } from "../utils/fetch-from-registry"; - -/** - * `getRawPackument` returns the packument (package document) containing - * all the metadata about a package present on the registry. - * - * Note: the packument is returned as retrieved from the registry. - * - * @param name - package name - * @param registry - URL of the registry (default: npm registry) - * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the packument for package `query-registry` from the npm registry: - * - * ```typescript - * import { getRawPackument } from 'query-registry'; - * - * (async () => { - * const packument = await getRawPackument({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(packument.name); - * })(); - * ``` - * - * @see {@link RawPackument} - * @see {@link npmRegistry} - * @see {@link npmRegistryMirrors} - */ -export async function getRawPackument({ - name, - registry, - mirrors, - cached, -}: { - name: string; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - assertValidPackageName({ name }); - - const endpoint = `/${name}`; - return fetchFromRegistry({ endpoint, registry, mirrors, cached }); -} diff --git a/old/src/endpoints/get-registry-downloads.ts b/old/src/endpoints/get-registry-downloads.ts deleted file mode 100644 index b06ba90..0000000 --- a/old/src/endpoints/get-registry-downloads.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { DownloadPeriod } from "../types/download-period"; -import { RegistryDownloads } from "../types/downloads"; -import { fetchDownloadsFromRegistry } from "../utils/fetch-downloads-from-registry"; -import { normalizeRawDownloadPeriod } from "../utils/normalize-download-period"; - -/** - * `getRegistryDownloads` returns the number of downloads for all registry packages - * in a given time period. - * - * @param period - time period in which downloads happened (default: `last-week`) - * @param registryDownloadsAPI - URL of the registry's downloads API (default: npm registry) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the weekly downloads for the npm registry: - * - * ```typescript - * import { getRegistryDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getRegistryDownloads(); - * - * // Output: 'number' - * console.log(typeof downloads.downloads); - * })(); - * ``` - * - * @example - * Get the monthly downloads for the npm registry: - * - * ```typescript - * import { getRegistryDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getRegistryDownloads({ period: 'last-month' }); - * - * // Output: 'number' - * console.log(typeof downloads.downloads); - * })(); - * ``` - * - * @see {@link RegistryDownloads} - * @see {@link DownloadPeriod} - * @see {@link npmRegistryDownloadsAPI} - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#point-values} - */ -export async function getRegistryDownloads({ - period: rawDownloadPeriod, - registryDownloadsAPI, - cached, -}: { - period?: DownloadPeriod; - registryDownloadsAPI?: string; - cached?: boolean; -} = {}): Promise { - const period = normalizeRawDownloadPeriod({ rawDownloadPeriod }); - const endpoint = `/downloads/point/${period}`; - return fetchDownloadsFromRegistry({ - endpoint, - registryDownloadsAPI, - cached, - }); -} diff --git a/old/src/endpoints/get-registry-metadata.ts b/old/src/endpoints/get-registry-metadata.ts deleted file mode 100644 index 56f498a..0000000 --- a/old/src/endpoints/get-registry-metadata.ts +++ /dev/null @@ -1,47 +0,0 @@ -import type { RegistryMetadata } from "../types/registry-metadata"; -import { fetchFromRegistry } from "../utils/fetch-from-registry"; - -/** - * `getRegistryMetadata` returns the metadata describing the registry itself. - * - * @param registry - URL of the registry (default: npm registry) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the metadata for the npm registry: - * - * ```typescript - * import { getRegistryMetadata } from 'query-registry'; - * - * (async () => { - * const metadata = await getRegistryMetadata(); - * - * // Output: 'registry' - * console.log(metadata.db_name); - * })(); - * ``` - * - * @example - * Get the metadata for a custom registry: - * - * ```typescript - * import { getRegistryMetadata } from 'query-registry'; - * - * (async () => { - * const metadata = await getRegistryMetadata({ registry: 'https://example.com' }); - * })(); - * ``` - * - * @see {@link RegistryMetadata} - * @see {@link npmRegistry} - */ -export async function getRegistryMetadata({ - registry, - cached, -}: { - registry?: string; - cached?: boolean; -} = {}): Promise { - const endpoint = "/"; - return fetchFromRegistry({ registry, mirrors: [], endpoint, cached }); -} diff --git a/old/src/endpoints/search-packages.ts b/old/src/endpoints/search-packages.ts deleted file mode 100644 index 5533027..0000000 --- a/old/src/endpoints/search-packages.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { SearchCriteria } from "../types/search-criteria"; -import { SearchResults } from "../types/search-results"; -import { fetchFromRegistry } from "../utils/fetch-from-registry"; -import { normalizeRawSearchCriteria } from "../utils/normalize-raw-search-criteria"; - -/** - * `searchPackages` returns the packages corresponding to a given query. - * - * @param query - one or more search criteria - * @param registry - URL of the registry (default: npm registry) - * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors) - * @param cached - accept cached responses (default: `true`) - * - * @example - * Get the search results for text query `query-registry` from the npm registry: - * - * ```typescript - * import { searchPackages } from 'query-registry'; - * - * (async () => { - * const results = await searchPackages({ query: { text: 'query-registry' } }); - * - * // Output: 'query-registry' - * console.log(results.objects[0].package.name); - * })(); - * ``` - * - * @see {@link SearchResults} - * @see {@link SearchCriteria} - * @see {@link npmRegistry} - * @see {@link npmRegistryMirrors} - */ -export async function searchPackages({ - query: rawSearchCriteria, - registry, - mirrors, - cached, -}: { - query: SearchCriteria; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const endpoint = "/-/v1/search"; - const query = normalizeRawSearchCriteria({ rawSearchCriteria }); - return fetchFromRegistry({ endpoint, query, registry, mirrors, cached }); -} diff --git a/old/src/index.ts b/old/src/index.ts deleted file mode 100644 index 4d8c2fa..0000000 --- a/old/src/index.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * This package exports several functions to query - * the {@link https://www.npmjs.com | npm registry} - * (or one of its mirrors) through one of its - * {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md | endpoints}. - * - * @example - * Get the metadata for the npm registry: - * - * ```typescript - * import { getRegistryMetadata } from 'query-registry'; - * - * (async () => { - * const metadata = await getRegistryMetadata(); - * - * // Output: 'registry' - * console.log(metadata.db_name); - * })(); - * ``` - * - * @example - * Get the latest manifest for package `query-registry` from the npm registry: - * - * ```typescript - * import { getPackageManifest } from 'query-registry'; - * - * (async () => { - * const manifest = await getPackageManifest({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(manifest.name); - * })(); - * ``` - * - * @example - * Get the abbreviated packument for package `query-registry` from the npm registry: - * - * ```typescript - * import { getAbbreviatedPackument } from 'query-registry'; - * - * (async () => { - * const packument = await getAbbreviatedPackument({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(manifest.name); - * })(); - * ``` - * - * @example - * Get the weekly downloads for package `query-registry` from the npm registry: - * - * ```typescript - * import { getPackageDownloads } from 'query-registry'; - * - * (async () => { - * const downloads = await getPackageDownloads({ name: 'query-registry' }); - * - * // Output: 'query-registry' - * console.log(downloads.package); - * - * // Output: 'number' - * console.log(typeof downloads.downloads); - * })(); - * ``` - * - * @example - * Get the search results for text query `query-registry` from the npm registry: - * - * ```typescript - * import { searchPackages } from 'query-registry'; - * - * (async () => { - * const results = await searchPackages({ query: { text: 'query-registry' } }); - * - * // Output: 'query-registry' - * console.log(results.objects[0].package.name); - * })(); - * ``` - * - * @example - * Enable {@link https://www.npmjs.com/package/debug | debug messages} - * by setting the `DEBUG` environment variable to `query-registry` - * (available only in non production environments): - * - * ```bash - * $ DEBUG="query-registry" - * ``` - * - * @packageDocumentation - */ - -// export * from "./data/registries"; -// export * from "./endpoints/get-abbreviated-packument"; -// export * from "./endpoints/get-daily-package-downloads"; -// export * from "./endpoints/get-daily-registry-downloads"; -// export * from "./endpoints/get-package-downloads"; -// export * from "./endpoints/get-package-manifest"; -// export * from "./endpoints/get-packument"; -// export * from "./endpoints/get-raw-abbreviated-packument"; -// export * from "./endpoints/get-raw-package-manifest"; -// export * from "./endpoints/get-raw-packument"; -// export * from "./endpoints/get-registry-downloads"; -// export * from "./endpoints/get-registry-metadata"; -// export * from "./endpoints/search-packages"; -// export * from "./types/abbreviated-packument"; -// export * from "./types/bug-tracker"; -// export * from "./types/dist-info"; -// export * from "./types/dist-tags"; -// export * from "./types/download-period"; -// export * from "./types/downloads"; -// export * from "./types/git-repository"; -// export * from "./types/npm-operational-internal"; -// export * from "./types/package-json"; -// export * from "./types/package-manifest"; -// export * from "./types/packument"; -// export * from "./types/person"; -// export * from "./types/raw-abbreviated-packument"; -// export * from "./types/raw-package-manifest"; -// export * from "./types/raw-packument"; -// export * from "./types/registry-metadata"; -// export * from "./types/repository"; -// export * from "./types/search-criteria"; -// export * from "./types/search-results"; -// export * from "./types/versions-to-timestamps"; -// export * from "./utils/errors"; - -export {}; diff --git a/old/src/types/abbreviated-packument.ts b/old/src/types/abbreviated-packument.ts deleted file mode 100644 index 585c2a9..0000000 --- a/old/src/types/abbreviated-packument.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { DistTags } from "./dist-tags"; -import { RawAbbreviatedPackument } from "./raw-abbreviated-packument"; - -/** - * `AbbreviatedPackument` represents a packument (package document) - * containing only the metadata necessary to install a package. - * - * @see {@link RawAbbreviatedPackument} - */ -export interface AbbreviatedPackument extends RawAbbreviatedPackument { - /** Unique package name (for example, `foo` or `@bar/baz`) */ - readonly id: string; - - /** - * Timestamp of when the package was last modified - * in ISO 8601 format (for example, `2021-11-23T19:12:24.006Z`); - * (alias to `modified`) - */ - readonly modifiedAt: string; - - /** - * Mapping of distribution tags to version numbers - * (alias to `dist-tags`) - * - * @see {@link DistTags} - */ - readonly distTags: DistTags; -} diff --git a/old/src/types/bug-tracker.ts b/old/src/types/bug-tracker.ts deleted file mode 100644 index 349e5f4..0000000 --- a/old/src/types/bug-tracker.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * `BugTracker` represents the bug tracking methods. - */ -export interface BugTracker { - readonly url?: string; - readonly email?: string; -} diff --git a/old/src/types/dist-info.ts b/old/src/types/dist-info.ts deleted file mode 100644 index 5020fe4..0000000 --- a/old/src/types/dist-info.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * `DistInfo` contains data describing the distributed package. - * - * @see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#dist} - */ -export interface DistInfo { - /** Tarball URL */ - readonly tarball: string; - - /** SHA1 sum of the tarball */ - readonly shasum: string; - - /** Usually, SHA512 sum of the tarball preceded by `sha512-` */ - readonly integrity?: string; - - /** Number of files in the tarball */ - readonly fileCount?: number; - - /** Total size in bytes of the unpacked files in the tarball */ - readonly unpackedSize?: number; - - /** npm PGP signature */ - readonly "npm-signature"?: string; -} diff --git a/old/src/types/dist-tags.ts b/old/src/types/dist-tags.ts deleted file mode 100644 index aa80b8c..0000000 --- a/old/src/types/dist-tags.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * `DistTags` maps distribution tags to version numbers. - */ -export interface DistTags { - /** Latest version number */ - readonly latest: string; - - /** Mapping of distribution tags to version numbers */ - readonly [key: string]: string; -} diff --git a/old/src/types/download-period.ts b/old/src/types/download-period.ts deleted file mode 100644 index 7a83861..0000000 --- a/old/src/types/download-period.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * `DownloadPeriod` represents a time period - * for which downloads should be counted. - * - * @remarks - * The following time periods are supported: - * - * - a {@link DefaultDownloadPeriod} (for example, `last-week`) - * - * - a date for a single day (for example, `new Date('2020-01-01')`) - * - * - a {@link DateRange} - * - * @see {@link DefaultDownloadPeriod} - * @see {@link DateRange} - * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date} - */ -export type DownloadPeriod = DefaultDownloadPeriod | Date | DateRange; - -/** - * `DefaultDownloadPeriod` represents the default time periods - * supported by the npm registry. - */ -export type DefaultDownloadPeriod = "last-day" | "last-week" | "last-month" | "last-year"; - -/** - * `DateRange` represents a time period between two days - * where the `start` and `end` dates are inclusive. - * - * @example - * ```typescript - * const dateRange = { - * start: new Date('2019-01-01'), - * end: new Date('2020-01-01'), - * }; - * ``` - * - * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date} - */ -export interface DateRange { - /** Date of the first day (inclusive) */ - readonly start: Date; - - /** Date of the last day (inclusive) */ - readonly end: Date; -} diff --git a/old/src/types/downloads.ts b/old/src/types/downloads.ts deleted file mode 100644 index 7c2c091..0000000 --- a/old/src/types/downloads.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * `PackageDownloads` lists the number of downloads for a package - * in a given time period. - * - * @see {@link RegistryDownloads} - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#point-values} - */ -export interface PackageDownloads extends RegistryDownloads { - /** Package name */ - readonly package: string; -} - -/** - * `RegistryDownloads` lists the number of downloads for the registry - * in a given time period. - * - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#point-values} - */ -export interface RegistryDownloads { - /** Total number of downloads */ - readonly downloads: number; - - /** Date of the first day (inclusive) */ - readonly start: string; - - /** Date of the last day (inclusive) */ - readonly end: string; -} - -/** - * `DailyPackageDownloads` lists the number of downloads for a package - * for each day in a given time period. - * - * @see {@link DailyRegistryDownloads} - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#ranges} - */ -export interface DailyPackageDownloads extends DailyRegistryDownloads { - /** Package name */ - readonly package: string; -} - -/** - * `DailyRegistryDownloads` lists the number of downloads for the registry - * for each day in a given time period. - * - * @see {@link DownloadsPerDay} - * @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#ranges} - */ -export interface DailyRegistryDownloads { - /** Download counts per day */ - readonly downloads: DownloadsPerDay[]; - - /** Date of the first day (inclusive) */ - readonly start: string; - - /** Date of the last day (inclusive) */ - readonly end: string; -} - -/** - * `DownloadsPerDay` lists the number of downloads in a given day. - */ -export interface DownloadsPerDay { - /** Total number of downloads in the day */ - readonly downloads: number; - - /** Day date */ - readonly day: string; -} diff --git a/old/src/types/git-repository.ts b/old/src/types/git-repository.ts deleted file mode 100644 index fcdec49..0000000 --- a/old/src/types/git-repository.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * `GitRepository` represents a git repository hosting - * the source code of a package. - * - * @see {@link Repository} - */ -export interface GitRepository { - /** Repository type, always `git` */ - readonly type: "git"; - - /** Repository URL */ - readonly url: string; - - /** - * Specific directory in the repository - * (for example, a directory in a monorepo) - */ - readonly directory?: string; -} diff --git a/old/src/types/npm-operational-internal.ts b/old/src/types/npm-operational-internal.ts deleted file mode 100644 index ccf50f1..0000000 --- a/old/src/types/npm-operational-internal.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface NpmOperationalInternal { - readonly host: string; - readonly tmp: string; -} diff --git a/old/src/types/package-json.ts b/old/src/types/package-json.ts deleted file mode 100644 index 1ba40e8..0000000 --- a/old/src/types/package-json.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { BugTracker } from "./bug-tracker"; -import { Person } from "./person"; -import { Repository } from "./repository"; - -/** - * `PackageJSON` contains the package metadata - * usually found in `package.json` files. - * - * @remarks - * For some packages, especially legacy ones, - * the properties may be mistyped due to incorrect data present on the registry. - * - * @see {@link https://docs.npmjs.com/cli/v6/configuring-npm/package-json} - */ -export interface PackageJSON { - /** Package name */ - readonly name: string; - - /** Package version number */ - readonly version: string; - - /** Package description */ - readonly description?: string; - - /** Homepage URL */ - readonly homepage?: string; - - /** SPDX license identifier */ - readonly license?: string; - - /** Text of the license */ - readonly licenseText?: string; - - /** Keywords describing the package */ - readonly keywords?: string[]; - - /** - * Author of the package - * - * @see {@link Person} - */ - readonly author?: Person; - - /** - * Maintainers of the package - * - * @see {@link Person} - */ - readonly maintainers?: Person[]; - - /** - * Contributors to the package - * - * @see {@link Person} - */ - readonly contributors?: Person[]; - - /** - * Repository containing the package's source - * - * @see {@link Repository} - */ - readonly repository?: string | Repository; - - /** - * Bug tracker - * - * @see {@link BugTracker} - */ - readonly bugs?: BugTracker; - - /** Runtime dependencies */ - readonly dependencies?: Record; - - /** Development dependencies */ - readonly devDependencies?: Record; - - /** Peer dependencies */ - readonly peerDependencies?: Record; - - /** Optional dependencies */ - readonly optionalDependencies?: Record; - - /** Bundled dependencies */ - readonly bundleDependencies?: string[]; - - /** Bundled dependencies (alias) */ - readonly bundledDependencies?: string[]; - - /** Main source file */ - readonly source?: string; - - /** Main file (Node) */ - readonly main?: string; - - /** Main file (Browser) */ - readonly browser?: string; - - /** Main file (Modules) */ - readonly module?: string; - - /** Type declarations file */ - readonly types?: string; - - /** Type declarations file (alias) */ - readonly typings?: string; - - /** - * Export map - * - * @see {@link https://nodejs.org/api/packages.html#packages_subpath_exports} - */ - readonly exports?: string | Record; - - /** File patterns included in the package */ - readonly files?: string[]; - - /** Executable files */ - readonly bin?: string | Record; - - /** Man pages */ - readonly man?: string | string[]; - - /** Directories describing the package's structure */ - readonly directories?: Record; - - /** npm scripts */ - readonly scripts?: Record; - - /** npm config */ - readonly config?: Record; - - /** Node compatibility */ - readonly engines?: Record; - - /** OS compatibility */ - readonly os?: string[]; - - /** CPU compatibility */ - readonly cpu?: string[]; - - /** Prevent publishing */ - readonly private?: boolean; - - /** Publishing configuration */ - readonly publishConfig?: Record; - - /** Deprecation message */ - readonly deprecated?: string; - - /** README contents */ - readonly readme?: string; - - /** Name of the README file */ - readonly readmeFilename?: string; - - /** Other fields */ - readonly [key: string]: unknown; -} diff --git a/old/src/types/package-manifest.ts b/old/src/types/package-manifest.ts deleted file mode 100644 index b1733d5..0000000 --- a/old/src/types/package-manifest.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { GitRepository } from "./git-repository"; -import { Person } from "./person"; -import { RawPackageManifest } from "./raw-package-manifest"; - -/** - * `PackageManifest` represents the manifest describing a specific version - * of a package. - * - * @remarks - * For some packages, especially legacy ones, - * the properties may be mistyped due to incorrect data present on the registry. - * - * @see {@link RawPackageManifest} - */ -export interface PackageManifest extends RawPackageManifest { - /** Package version ID (for example, `foo@1.0.0` or `@bar/baz@1.0.0`) */ - readonly id: string; - - /** Publishing timestamp */ - readonly createdAt: string; - - /** - * User who published this version of the package - * - * @see {@link Person} - */ - readonly publisher: Person; - - /** Normalized license */ - readonly license?: string; - - /** Normalized git repository */ - readonly gitRepository?: GitRepository; - - /** Name of the corresponding DefinitelyTyped package, if any */ - readonly definitelyTypedName?: string; - - /** Name of the corresponding untyped package (w.r.t. DefinitelyTyped) */ - readonly untypedName?: string; -} diff --git a/old/src/types/packument.ts b/old/src/types/packument.ts deleted file mode 100644 index 90ed940..0000000 --- a/old/src/types/packument.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { DistTags } from "./dist-tags"; -import { GitRepository } from "./git-repository"; -import { RawPackument } from "./raw-packument"; - -/** - * `Packument` represents a packument (package document) - * containing all the data about a package. - * - * @remarks - * For some packages, especially legacy ones, - * the properties may be mistyped due to incorrect data present on the registry. - * - * @see {@link RawPackument} - */ -export interface Packument extends RawPackument { - /** - * Unique package name (for example, `foo` or `@bar/baz`; - * alias to `_id`) - */ - readonly id: string; - - /** - * Mapping of distribution tags to version numbers - * (alias to `dist-tags`) - * - * @see {@link DistTags} - */ - readonly distTags: DistTags; - - /** - * Mapping of version numbers to publishing timestamps - * without the `created` or `modified` properties - * present in the `time` property - * - * @see {@link VersionsToTimestamps} - */ - readonly versionsToTimestamps: Record; - - /** Normalized license */ - readonly license?: string; - - /** Normalized git repository */ - readonly gitRepository?: GitRepository; -} diff --git a/old/src/types/person.ts b/old/src/types/person.ts deleted file mode 100644 index 423e686..0000000 --- a/old/src/types/person.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * `Person` represents a person associated to a package. - */ -export interface Person { - readonly name?: string; - readonly username?: string; - readonly email?: string; - readonly url?: string; -} diff --git a/old/src/types/raw-abbreviated-packument.ts b/old/src/types/raw-abbreviated-packument.ts deleted file mode 100644 index eb2eecc..0000000 --- a/old/src/types/raw-abbreviated-packument.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { DistTags } from "./dist-tags"; -import { RawPackageManifest } from "./raw-package-manifest"; - -/** - * `RawAbbreviatedPackument` represents an abbreviated packument (package document), - * as returned from the registry, containing only the metadata necessary to install a package. - * - * @see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-metadata-format} - */ -export interface RawAbbreviatedPackument { - /** Package name */ - readonly name: string; - - /** - * Timestamp of when the package was last modified - * in ISO 8601 format (for example, `2021-11-23T19:12:24.006Z`) - */ - readonly modified: string; - - /** - * Mapping of distribution tags to version numbers - * - * @see {@link DistTags} - */ - readonly "dist-tags": DistTags; - - /** - * Mapping of version numbers to package manifests - * - * @see {@link RawPackageManifest} - */ - readonly versions: Record< - string, - Pick< - RawPackageManifest, - | "name" - | "version" - | "dist" - | "deprecated" - | "dependencies" - | "optionalDependencies" - | "devDependencies" - | "bundleDependencies" - | "peerDependencies" - | "bin" - | "directories" - | "engines" - | "_hasShrinkwrap" - > - >; -} diff --git a/old/src/types/raw-package-manifest.ts b/old/src/types/raw-package-manifest.ts deleted file mode 100644 index 7008784..0000000 --- a/old/src/types/raw-package-manifest.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { DistInfo } from "./dist-info"; -import { NpmOperationalInternal } from "./npm-operational-internal"; -import { PackageJSON } from "./package-json"; -import { Person } from "./person"; - -/** - * `RawPackageManifest` represents the manifest, as returned by the registry, - * describing a specific version of a package. - * - * @remarks - * For some packages, especially legacy ones, - * the properties may be mistyped due to incorrect data present on the registry. - * - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#getpackageversion} - * @see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object} - * @see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#full-metadata-format} - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#version} - * @see {@link PackageJSON} - */ -export interface RawPackageManifest extends PackageJSON { - /** Package version ID (for example, `foo@1.0.0` or `@bar/baz@1.0.0`) */ - readonly _id: string; - - /** Package name */ - readonly name: string; - - /** Package version number */ - readonly version: string; - - /** - * Distribution data from the registry - * - * @see {@link DistInfo} - */ - readonly dist: DistInfo; - - /** Commit hash corresponding to the published version */ - readonly gitHead?: string; - - /** - * User who published this package version - * - * @see {@link Person} - */ - readonly _npmUser: Person; - - /** Node version used when publishing */ - readonly _nodeVersion?: string; - - /** npm version used when publishing */ - readonly _npmVersion?: string; - - /** - * Internal npm data - * - * @see {@link NpmOperationalInternal} - */ - readonly _npmOperationalInternal?: NpmOperationalInternal; - - /** True if the package has a shrinkwrap file */ - readonly _hasShrinkwrap?: boolean; -} diff --git a/old/src/types/raw-packument.ts b/old/src/types/raw-packument.ts deleted file mode 100644 index a2ae003..0000000 --- a/old/src/types/raw-packument.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { DistTags } from "./dist-tags"; -import { PackageJSON } from "./package-json"; -import { RawPackageManifest } from "./raw-package-manifest"; -import { VersionsToTimestamps } from "./versions-to-timestamps"; - -/** - * `RawPackument` represents a packument (package document), as returned - * from the registry, containing all the data about a package . - * - * @remarks - * For some packages, especially legacy ones, - * the properties may be mistyped due to incorrect data present on the registry. - * - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#getpackage} - * @see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#full-metadata-format} - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#package} - * @see {@link HoistedPackageJSON} - */ -export interface RawPackument extends HoistedPackageJSON { - /** Unique package name (for example, `foo` or `@bar/baz`) */ - readonly _id: string; - - /** Latest revision ID in CouchDB */ - readonly _rev: string; - - /** Package name */ - readonly name: string; - - /** - * Mapping of distribution tags to version numbers - * - * @see {@link DistTags} - */ - readonly "dist-tags": DistTags; - - /** - * Mapping of version numbers to publishing timestamps - * - * @see {@link VersionsToTimestamps} - */ - readonly time: VersionsToTimestamps; - - /** - * Mapping of version numbers to package manifests - * - * @see {@link RawPackageManifest} - */ - readonly versions: Record; - - /** Names of the npm users who starred the package */ - readonly users?: Record; -} - -/** - * `HoistedPackageJSON` contains the data hoisted - * from the latest package version into the packument. - * - * @remarks - * For some packages, especially legacy ones, - * the properties may be mistyped due to incorrect data present on the registry. - * - * @see {@link PackageJSON} - * @see {@link RawPackument} - * @see {@link https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#full-metadata-format} - */ -export type HoistedPackageJSON = Pick< - PackageJSON, - | "author" - | "bugs" - | "contributors" - | "description" - | "homepage" - | "keywords" - | "license" - | "maintainers" - | "readme" - | "readmeFilename" - | "repository" ->; diff --git a/old/src/types/registry-metadata.ts b/old/src/types/registry-metadata.ts deleted file mode 100644 index 916dabc..0000000 --- a/old/src/types/registry-metadata.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * `RegistryMetadata` contains information about the registry itself. - * - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#registry} - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get} - * @see {@link RegistryMetadataOther} - * @see {@link RegistryMetadataSizes} - */ -export interface RegistryMetadata { - /** Database name, usually `registry` */ - readonly db_name: string; - readonly doc_count: number; - readonly doc_del_count: number; - readonly update_seq: number; - readonly purge_seq: number; - readonly compact_running: boolean; - readonly disk_size: number; - readonly data_size: number; - readonly instance_start_time: string; - readonly disk_format_version: number; - readonly committed_update_seq: number; - readonly compacted_seq: number; - readonly uuid: string; - readonly other: RegistryMetadataOther; - readonly sizes: RegistryMetadataSizes; -} - -export interface RegistryMetadataOther { - readonly data_size: number; -} - -export interface RegistryMetadataSizes { - readonly file: number; - readonly active: number; - readonly external: number; -} diff --git a/old/src/types/repository.ts b/old/src/types/repository.ts deleted file mode 100644 index 2e60e0e..0000000 --- a/old/src/types/repository.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * `Repository` represents a remote repository hosting - * the source code of a package. - * - * @see {@link https://docs.npmjs.com/cli/v6/configuring-npm/package-json#repository}. - */ -export interface Repository { - /** Repository type (for example, `git`) */ - readonly type?: string; - - /** Repository's URL */ - readonly url: string; - - /** - * Specific directory in the repository containing the package - * (for example, a directory in a monorepo) - */ - readonly directory?: string; -} diff --git a/old/src/types/search-criteria.ts b/old/src/types/search-criteria.ts deleted file mode 100644 index 39357f0..0000000 --- a/old/src/types/search-criteria.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * `SearchCriteria` represents the available search criteria. - * - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search} - */ -export interface SearchCriteria { - /** - * Query text - * - * @remarks - * The following special text attributes can be used to refine results: - * - * - `author:`: show packages from the given author - * (for example, `author:someone`) - * - * - `maintainer:`: show packages with the given maintainer - * (for example, `maintainer:someone`) - * - * - `keywords:`: show packages matching the given keyword(s); - * separators `,`, `+` and `,-` mean respectively `OR`, `AND` and `NOT` - * (for example, use `keywords:foo,bar+baz,-quux` to include keywords `foo` - * or `bar` and `baz` but not `quux`) - * - * - `not:unstable`: exclude unstable packages (version `<1.0.0`) - * - * - `not:insecure`: exclude insecure packages - * - * - `is:unstable`: include only unstable packages (version `<1.0.0`) - * - * - `is:insecure`: include only insecure packages - * - * - `boost-exact:`: boost packages with exact name match - * (default: `true`) - */ - readonly text?: string; - - /** Number of results to return (from `0` to `250`; default: `20` on the npm registry) */ - readonly size?: number; - - /** Return results from this offset */ - readonly from?: number; - - /** Package quality influence on results (from `0.0` to `1.0`) */ - readonly quality?: number; - - /** Package popularity influence on results (from `0.0` to `1.0`) */ - readonly popularity?: number; - - /** Package maintenance influence on results (from `0.0` to `1.0`) */ - readonly maintenance?: number; -} diff --git a/old/src/types/search-results.ts b/old/src/types/search-results.ts deleted file mode 100644 index a007c04..0000000 --- a/old/src/types/search-results.ts +++ /dev/null @@ -1,168 +0,0 @@ -import { Person } from "./person"; - -/** - * `SearchResults` contains the results returned by the registry for a query. - * - * @see {@link SearchResult} - * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search} - */ -export interface SearchResults { - /** - * List of search results - * - * @see {@link SearchResult} - */ - readonly objects: SearchResult[]; - - /** - * Total number of search results corresponding to a query; - * may be higher than the number of `objects` - */ - readonly total: number; - - /** Date at which the search happened */ - readonly time: string; -} - -/** - * `SearchResult` contains the search result for a single package - * and its search score. - * - * @see {@link PackageSearchResult} - * @see {@link SearchScore} - * @see {@link PackageFlags} - */ -export interface SearchResult { - /** - * Abbreviated package metadata - * - * @see {@link PackageSearchResult} - */ - readonly package: PackageSearchResult; - - /** - * Final and detailed search score values - * - * @see {@link SearchScore} - */ - readonly score: SearchScore; - - /** Search score value; may be different from `score.final` */ - readonly searchScore: number; - - /** - * Flag attributes for the package - * - * @see {@link PackageFlags} - */ - readonly flags?: PackageFlags; -} - -/** - * `PackageSearchResult` contains abbreviated package metadata returned - * by searching the registry for packages. - * - * @see {@link Person} - * @see {@link PackageLinks} - */ -export interface PackageSearchResult { - /** Package name */ - readonly name: string; - - /** Latest package version number */ - readonly version: string; - - /** Package scope; either `unscoped` or the package's scope */ - readonly scope: string; - - /** Publishing timestamp for the latest version */ - readonly date: string; - - /** - * Package publisher - * - * @see {@link Person} - */ - readonly publisher: Person; - - /** - * Links for pages associated to the package - * - * @see {@link PackageLinks} - */ - readonly links: PackageLinks; - - /** Package description */ - readonly description?: string; - - /** Keywords describing the package */ - readonly keywords?: string[]; - - /** - * Package author - * - * @see {@link Person} - */ - readonly author?: Person; - - /** - * Package maintainers - * - * @see {@link Person} - */ - readonly maintainers?: Person[]; -} - -/** - * `PackageLinks` contains a collection of links of pages associated to the package. - */ -export interface PackageLinks { - readonly npm?: string; - readonly homepage?: string; - readonly repository?: string; - readonly bugs?: string; - readonly [key: string]: string | undefined; -} - -/** - * `SearchScore` contains the final and detailed search score values. - * - * @see {@link SearchScoreDetail} - */ -export interface SearchScore { - /** Final search score value, computed from the detailed scores */ - readonly final: number; - - /** - * Detailed search score values - * - * @see {@link SearchScoreDetail} - */ - readonly detail: SearchScoreDetail; -} - -/** - * `SearchScoreDetail` contains the search score values for the - * quality, popularity and maintenance categories. - */ -export interface SearchScoreDetail { - /** Package quality score value */ - readonly quality: number; - - /** Package popularity score value */ - readonly popularity: number; - - /** Package maintenance score value */ - readonly maintenance: number; -} - -/** - * `PackageFlags` contains flag attributes categorizing the package. - */ -export interface PackageFlags { - /** If true, package version is `<1.0.0` */ - readonly unstable?: boolean; - - /** If true, package is insecure or has vulnerable dependencies */ - readonly insecure?: boolean; -} diff --git a/old/src/types/versions-to-timestamps.ts b/old/src/types/versions-to-timestamps.ts deleted file mode 100644 index cbabfe6..0000000 --- a/old/src/types/versions-to-timestamps.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * `VersionsToTimestamps` maps version numbers to their publishing timestamps. - */ -export interface VersionsToTimestamps { - /** Package creation time */ - readonly created: string; - - /** Last package update time */ - readonly modified: string; - - /** Mapping of version numbers to publishing timestamps */ - readonly [key: string]: string; -} diff --git a/old/src/utils/assert-valid-package-name.ts b/old/src/utils/assert-valid-package-name.ts deleted file mode 100644 index 19b1d86..0000000 --- a/old/src/utils/assert-valid-package-name.ts +++ /dev/null @@ -1,12 +0,0 @@ -import validatePackageName from "validate-npm-package-name"; -import { InvalidPackageNameError } from "./errors"; -import { log } from "./log"; - -export function assertValidPackageName({ name }: { name: string }): void { - const { validForOldPackages, validForNewPackages } = validatePackageName(name); - const valid = validForOldPackages || validForNewPackages; - if (!valid) { - log("assertValidPackageName: invalid package name: %O", { name }); - throw new InvalidPackageNameError(`invalid package name: '${name}'`); - } -} diff --git a/old/src/utils/errors.ts b/old/src/utils/errors.ts deleted file mode 100644 index 17b7a56..0000000 --- a/old/src/utils/errors.ts +++ /dev/null @@ -1,35 +0,0 @@ -import makeError, { BaseError } from "make-error"; - -/** - * `FetchError` represents an error that happened when fetching a URL. - * - * The `instanceof` operator can be used to check for this error. - */ -export class FetchError extends BaseError { - constructor( - /** URL originally fetched */ - readonly url: string, - - /** Response received */ - readonly response: Response, - ) { - super(`fetch: request to ${url} failed with status ${response.statusText}`); - } -} - -/** - * `InvalidPackageNameError` is thrown when the name of a package - * is not valid according to the npm registry naming rules. - * - * The `instanceof` operator can be used to check for this error. - * - * @see {@link https://www.npmjs.com/package/validate-npm-package-name} - */ -export const InvalidPackageNameError = makeError("InvalidPackageNameError"); - -/** - * `InvalidPackageVersionError` is thrown when a package's version does not exist. - * - * The `instanceof` operator can be used to check for this error. - */ -export const InvalidPackageVersionError = makeError("InvalidPackageVersionError"); diff --git a/old/src/utils/extract-package-manifest.ts b/old/src/utils/extract-package-manifest.ts deleted file mode 100644 index 6af16d5..0000000 --- a/old/src/utils/extract-package-manifest.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { RawPackageManifest } from "../types/raw-package-manifest"; -import { RawPackument } from "../types/raw-packument"; -import { InvalidPackageVersionError } from "./errors"; -import { log } from "./log"; - -export function extractRawPackageManifest({ - rawPackument, - version = "latest", -}: { - rawPackument: RawPackument; - version?: string; -}): RawPackageManifest { - const { name, "dist-tags": distTags, versions } = rawPackument; - const versionNumber = distTags[version] ?? version; - const manifest = versions[versionNumber]; - if (!manifest) { - log("getPackageManifest: invalid package version: %O", { - name, - version, - }); - throw new InvalidPackageVersionError(`invalid package version: '${name}@${version}'`); - } - - return manifest; -} diff --git a/old/src/utils/fetch-downloads-from-registry.ts b/old/src/utils/fetch-downloads-from-registry.ts deleted file mode 100644 index e89a104..0000000 --- a/old/src/utils/fetch-downloads-from-registry.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { npmRegistryDownloadsAPI } from "../data/registries"; -import { fetchFromRegistry } from "./fetch-from-registry"; - -export async function fetchDownloadsFromRegistry({ - endpoint, - registryDownloadsAPI = npmRegistryDownloadsAPI, - cached, -}: { - endpoint: string; - registryDownloadsAPI?: string; - cached?: boolean; -}): Promise { - return fetchFromRegistry({ - endpoint, - registry: registryDownloadsAPI, - mirrors: [], - cached, - }); -} diff --git a/old/src/utils/fetch-from-registry.ts b/old/src/utils/fetch-from-registry.ts deleted file mode 100644 index 3d0a4c8..0000000 --- a/old/src/utils/fetch-from-registry.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { npmRegistry, npmRegistryMirrors } from "../data/registries"; -import { FetchError } from "./errors"; -import { fetch } from "./fetch"; -import { log } from "./log"; -import urlJoin from "url-join"; - -export async function fetchFromRegistry({ - endpoint, - headers, - query, - registry = npmRegistry, - mirrors = npmRegistryMirrors, - cached, -}: { - endpoint: string; - headers?: Record; - query?: string; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const urls = [registry, ...mirrors].map((base) => - urlJoin(base, endpoint, query ? `?${query}` : ""), - ); - - let lastError: FetchError | undefined; - for (const url of urls) { - try { - const json = await fetch({ url, headers, cached }); - return json as T; - } catch (err) { - // Keep last fetch error - lastError = err as any; - } - } - - log("fetchFromRegistry: cannot retrieve data from registry or mirrors: %O", { - endpoint, - headers, - query, - registry, - mirrors, - lastError, - }); - throw lastError; -} diff --git a/old/src/utils/fetch.ts b/old/src/utils/fetch.ts deleted file mode 100644 index d181ce9..0000000 --- a/old/src/utils/fetch.ts +++ /dev/null @@ -1,48 +0,0 @@ -import unfetch from "isomorphic-unfetch"; -import { lru } from "tiny-lru"; -import { FetchError } from "./errors"; -import { log } from "./log"; - -const maxItems = 250; -const fiveMinutesTTL = 5 * 60 * 1000; -const cache = lru(maxItems, fiveMinutesTTL); - -export async function fetch({ - url, - headers, - cached = true, -}: { - url: string; - headers?: Record; - cached?: boolean; -}): Promise { - const cacheKey = `headers=${JSON.stringify(headers)};url=${url}`; - const cachedJSON = cache.get(cacheKey); - if (cached && cachedJSON) { - log("fetch: returning cached response: %O", { - cacheKey, - url, - cachedJSON, - }); - return cachedJSON; - } - - const response = await unfetch(url, { headers }); - if (!response.ok) { - log("fetch: request failed: %O", { - url, - headers, - status: response.statusText, - response, - }); - throw new FetchError(url, response); - } - - const json = await response.json(); - if (cached) { - cache.set(cacheKey, json); - } - - log("fetch: returning fresh response: %O", { url, json }); - return json; -} diff --git a/old/src/utils/get-definitely-typed-name.ts b/old/src/utils/get-definitely-typed-name.ts deleted file mode 100644 index 8f0b145..0000000 --- a/old/src/utils/get-definitely-typed-name.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { getRawPackageManifest } from "../endpoints/get-raw-package-manifest"; -import { RawPackageManifest } from "../types/raw-package-manifest"; - -export async function getDefinitelyTypedName({ - rawPackageManifest, - registry, - mirrors, - cached, -}: { - rawPackageManifest: RawPackageManifest; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const { name, types, typings } = rawPackageManifest; - const definitelyTypedName = toDefinitelyTypedName({ name }); - const alreadyTyped = name === definitelyTypedName || !!types || !!typings; - if (alreadyTyped) { - return undefined; - } - - let ok = false; - try { - const { deprecated } = await getRawPackageManifest({ - name: definitelyTypedName, - registry, - mirrors, - cached, - }); - ok = deprecated === undefined; - } catch {} - return ok ? definitelyTypedName : undefined; -} - -/** - * `toDefinitelyTypedName` returns the name of the corresponding - * DefinitelyTyped package (for example, - * `foo` => `@types/foo`, - * `@bar/baz` => `@types/bar__baz`). - */ -function toDefinitelyTypedName({ name }: { name: string }): string { - return name.startsWith("@types/") ? name : `@types/${name.replace("@", "").replace("/", "__")}`; -} diff --git a/old/src/utils/get-untyped-name.ts b/old/src/utils/get-untyped-name.ts deleted file mode 100644 index a2485a4..0000000 --- a/old/src/utils/get-untyped-name.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * `getUntypedName` returns the name of the normal package - * corresponding to a DefinitelyTyped package. - */ -export function getUntypedName({ name }: { name: string }): string | undefined { - if (!name.startsWith("@types/")) { - return undefined; - } - - // ['foo', undefined] or ['@bar', 'baz'] - const [scopeOrName, scopedName] = name.replace("@types/", "").split("__"); - - return scopedName ? `@${scopeOrName}/${scopedName}` : scopeOrName; -} diff --git a/old/src/utils/log.ts b/old/src/utils/log.ts deleted file mode 100644 index bc94358..0000000 --- a/old/src/utils/log.ts +++ /dev/null @@ -1,9 +0,0 @@ -export async function log(formatter: any, ...args: any[]): Promise { - if (process.env.NODE_ENV !== "production") { - try { - const { debug } = await import("debug"); - const logger = debug("query-registry"); - logger(formatter, args); - } catch {} - } -} diff --git a/old/src/utils/normalize-download-period.ts b/old/src/utils/normalize-download-period.ts deleted file mode 100644 index 80a4f92..0000000 --- a/old/src/utils/normalize-download-period.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { DownloadPeriod } from "../types/download-period"; - -export function normalizeRawDownloadPeriod({ - rawDownloadPeriod = "last-week", -}: { - rawDownloadPeriod?: DownloadPeriod; -}): string { - if (typeof rawDownloadPeriod === "string") { - return rawDownloadPeriod; - } - - if (rawDownloadPeriod instanceof Date) { - return getDay(rawDownloadPeriod); - } - - const { start, end } = rawDownloadPeriod; - return `${getDay(start)}:${getDay(end)}`; -} - -function getDay(date: Date): string { - return date.toISOString().split("T")[0]!; -} diff --git a/old/src/utils/normalize-raw-abbreviated-packument.ts b/old/src/utils/normalize-raw-abbreviated-packument.ts deleted file mode 100644 index 02b4e19..0000000 --- a/old/src/utils/normalize-raw-abbreviated-packument.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { AbbreviatedPackument } from "../types/abbreviated-packument"; -import { RawAbbreviatedPackument } from "../types/raw-abbreviated-packument"; - -export function normalizeRawAbbreviatedPackument({ - rawAbbreviatedPackument, -}: { - rawAbbreviatedPackument: RawAbbreviatedPackument; -}): AbbreviatedPackument { - const { "dist-tags": distTags, name: id, modified: modifiedAt } = rawAbbreviatedPackument; - return { - ...rawAbbreviatedPackument, - id, - distTags, - modifiedAt, - }; -} diff --git a/old/src/utils/normalize-raw-license.ts b/old/src/utils/normalize-raw-license.ts deleted file mode 100644 index 5c81158..0000000 --- a/old/src/utils/normalize-raw-license.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function normalizeRawLicense({ rawLicense }: { rawLicense?: any }): string | undefined { - if (!rawLicense) { - return undefined; - } - - if (typeof rawLicense !== "string") { - return undefined; - } - - return rawLicense; -} diff --git a/old/src/utils/normalize-raw-package-manifest.ts b/old/src/utils/normalize-raw-package-manifest.ts deleted file mode 100644 index 6160638..0000000 --- a/old/src/utils/normalize-raw-package-manifest.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { PackageManifest } from "../types/package-manifest"; -import { RawPackageManifest } from "../types/raw-package-manifest"; -import { RawPackument } from "../types/raw-packument"; -import { getDefinitelyTypedName } from "./get-definitely-typed-name"; -import { getUntypedName } from "./get-untyped-name"; -import { normalizeRawLicense } from "./normalize-raw-license"; -import { normalizeRawRepository } from "./normalize-raw-repository"; - -export async function normalizeRawPackageManifest({ - rawPackageManifest, - rawPackument, - registry, - mirrors, - cached, -}: { - rawPackageManifest: RawPackageManifest; - rawPackument: RawPackument; - registry?: string; - mirrors?: string[]; - cached?: boolean; -}): Promise { - const { - _id: id, - name, - version, - license: rawLicense, - repository: rawRepository, - _npmUser: publisher, - } = rawPackageManifest; - - const createdAt = rawPackument.time[version]!; - const license = normalizeRawLicense({ rawLicense }); - const gitRepository = normalizeRawRepository({ rawRepository }); - const definitelyTypedName = await getDefinitelyTypedName({ - rawPackageManifest, - registry, - mirrors, - cached, - }); - const untypedName = getUntypedName({ name }); - - return { - ...rawPackageManifest, - id, - createdAt, - publisher, - license, - gitRepository, - definitelyTypedName, - untypedName, - }; -} diff --git a/old/src/utils/normalize-raw-packument.ts b/old/src/utils/normalize-raw-packument.ts deleted file mode 100644 index 4a176a8..0000000 --- a/old/src/utils/normalize-raw-packument.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Packument } from "../types/packument"; -import { RawPackument } from "../types/raw-packument"; -import { normalizeRawLicense } from "./normalize-raw-license"; -import { normalizeRawRepository } from "./normalize-raw-repository"; - -export function normalizeRawPackument({ rawPackument }: { rawPackument: RawPackument }): Packument { - const { - _id: id, - "dist-tags": distTags, - time, - license: rawLicense, - repository: rawRepository, - } = rawPackument; - const license = normalizeRawLicense({ rawLicense }); - const gitRepository = normalizeRawRepository({ rawRepository }); - const versionsToTimestamps = Object.fromEntries( - Object.entries(time).filter(([key]) => { - return !["created", "modified"].includes(key); - }), - ); - - return { - ...rawPackument, - id, - distTags, - versionsToTimestamps, - license, - gitRepository, - }; -} diff --git a/old/src/utils/normalize-raw-repository.ts b/old/src/utils/normalize-raw-repository.ts deleted file mode 100644 index 3be0c51..0000000 --- a/old/src/utils/normalize-raw-repository.ts +++ /dev/null @@ -1,80 +0,0 @@ -import urlJoin from "url-join"; -import { GitRepository } from "../types/git-repository"; -import { Repository } from "../types/repository"; - -export function normalizeRawRepository({ - rawRepository, -}: { - rawRepository?: any; -}): GitRepository | undefined { - if (isRepository(rawRepository)) { - return normalizeRepository({ rawRepository }); - } - - if (typeof rawRepository === "string") { - return normalizeRepository({ - rawRepository: { url: rawRepository }, - }); - } - - return undefined; -} - -function isRepository(rawRepository: any): rawRepository is Repository { - return ( - rawRepository && - typeof rawRepository === "object" && - typeof rawRepository["url"] === "string" && - ["string", "undefined"].includes(typeof rawRepository["type"]) && - ["string", "undefined"].includes(typeof rawRepository["directory"]) - ); -} - -function normalizeRepository({ - rawRepository, -}: { - rawRepository: Repository; -}): GitRepository | undefined { - const { url, directory } = rawRepository; - - const parsedUrl = parseGitURL({ url }); - if (!parsedUrl) { - return undefined; - } - - return { - type: "git", - url: parsedUrl, - directory, - }; -} - -function parseGitURL({ url }: { url: string }): string | undefined { - const urlWithProtocol = - url.includes(":") ? - // A normal URL or a shortcut like `github:user/repository` - url - // The short form github shortcut `user/repository` - : url.includes("/") ? `github:${url}` - // Not a URL - : ""; - try { - const { protocol, hostname, pathname } = new URL(urlWithProtocol); - const cleanPathname = pathname.replace(/\.git$/, ""); - if (protocol === "github:" || hostname === "github.com") { - return urlJoin("https://github.com", cleanPathname); - } - if (protocol === "gist:" || hostname === "gist.github.com") { - return urlJoin("https://gist.github.com", cleanPathname); - } - if (protocol === "bitbucket:" || hostname === "bitbucket.org") { - return urlJoin("https://bitbucket.org", cleanPathname); - } - if (protocol === "gitlab:" || hostname === "gitlab.com") { - return urlJoin("https://gitlab.com", cleanPathname); - } - return urlWithProtocol; - } catch { - return undefined; - } -} diff --git a/old/src/utils/normalize-raw-search-criteria.ts b/old/src/utils/normalize-raw-search-criteria.ts deleted file mode 100644 index 4fee20f..0000000 --- a/old/src/utils/normalize-raw-search-criteria.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { SearchCriteria } from "../types/search-criteria"; - -export function normalizeRawSearchCriteria({ - rawSearchCriteria, -}: { - rawSearchCriteria: SearchCriteria; -}): string { - // Convert SearchCriteria to a URL query string - return Object.entries(rawSearchCriteria) - .filter(([, value]) => ["string", "number"].includes(typeof value)) - .map(([key, value]) => `${key}=${value}`) - .join("&"); -} diff --git a/old/test/endpoints/__snapshots__/get-abbreviated-packument.test.ts.snap b/old/test/endpoints/__snapshots__/get-abbreviated-packument.test.ts.snap deleted file mode 100644 index e2207d6..0000000 --- a/old/test/endpoints/__snapshots__/get-abbreviated-packument.test.ts.snap +++ /dev/null @@ -1,1732 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`getAbbreviatedPackument does not conflict with getPackument on cached responses 1`] = ` -{ - "_id": "short-time-ago", - "_rev": "8-146add6d8ac21b435c570b9193de7828", - "author": { - "name": "velut", - }, - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (for example, '1 minute ago')", - "dist-tags": { - "latest": "2.0.0", - }, - "distTags": { - "latest": "2.0.0", - }, - "gitRepository": { - "directory": undefined, - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "id": "short-time-ago", - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "name": "short-time-ago", - "readme": "# short-time-ago - -[![Build status](https://img.shields.io/github/workflow/status/velut/node-short-time-ago/CI)](https://github.com/velut/node-short-time-ago/actions?query=workflow%3ACI) -[![Coverage](https://img.shields.io/codecov/c/gh/velut/node-short-time-ago)](https://codecov.io/gh/velut/node-short-time-ago) -[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/short-time-ago) -![Language](https://img.shields.io/github/languages/top/velut/node-short-time-ago) -[![Dependencies](https://img.shields.io/david/velut/node-short-time-ago)](https://david-dm.org/velut/node-short-time-ago) -[![npm bundle size](https://img.shields.io/bundlephobia/min/short-time-ago)](https://bundlephobia.com/result?p=short-time-ago) -[![npm](https://img.shields.io/npm/v/short-time-ago)](https://www.npmjs.com/package/short-time-ago) -[![License](https://img.shields.io/github/license/velut/node-short-time-ago)](https://github.com/velut/node-short-time-ago/blob/master/LICENSE) - -This package exports a single function, \`timeAgo\`, -which describes the time elapsed between a given date and the current date -in a human readable format (for example, _"10 minutes ago"_, _"in 3 seconds"_). - -## Pros - -- Simple API and usage -- Small size (< 1KB) -- No dependencies -- Works in the browser -- Written in Typescript -- Well tested and documented -- Accepts a custom date for the \`now\` anchor time - -## Cons - -- Only \`en_US\` locale support. - -## Contents - -View on [unpkg](https://unpkg.com/short-time-ago/). - -## Install - -Using \`npm\`: - -\`\`\` -npm i short-time-ago -\`\`\` - -Using \`yarn\`: - -\`\`\` -yarn add short-time-ago -\`\`\` - -## CDN - -UMD build: - -\`\`\`html - - - - - -\`\`\` - -Module build: - -\`\`\`html - -\`\`\` - -## Usage - -Basic usage: - -\`\`\`typescript -import { timeAgo } from 'short-time-ago'; - -const myDate = new Date(); -const description = timeAgo(myDate); - -// Output: \`just now\`. -console.log(description); -\`\`\` - -Specifying a custom current date with the \`now\` parameter: - -\`\`\`typescript -import { timeAgo } from 'short-time-ago'; - -const myDate = new Date('2019-01-01T00:00:00.000Z'); -const now = new Date('2019-01-01T00:01:00.000Z'); -const description = timeAgo(myDate, now); - -// Output: \`1 minute ago\`. -console.log(description); -\`\`\` - -\`\`\`typescript -import { timeAgo } from 'short-time-ago'; - -const myDate = new Date('2019-01-02T00:00:00.000Z'); -const now = new Date('2019-01-01T00:00:00.000Z'); -const description = timeAgo(myDate, now); - -// Output: \`in 1 day\`. -console.log(description); -\`\`\` - -## API - -\`\`\`typescript -timeAgo: (date: Date, now?: Date) => string; -\`\`\` - -Explore the API on [jsDocs.io](https://www.jsdocs.io/package/short-time-ago). - -## Output - -The following table describes \`timeAgo\`'s output. - -| Time elapsed | Past output | Future output | -| --------------------- | ----------------- | ---------------- | -| < 1 second | \`just now\` | \`just now\` | -| < 1 minute | \`N second(s) ago\` | \`in N second(s)\` | -| < 1 hour | \`N minute(s) ago\` | \`in N minute(s)\` | -| < 1 day | \`N hour(s) ago\` | \`in N hour(s)\` | -| < 1 month (30.5 days) | \`N day(s) ago\` | \`in N day(s)\` | -| < 1 year (365 days) | \`N month(s) ago\` | \`in N month(s)\` | -| > 1 year | \`N year(s) ago\` | \`in N year(s)\` | - -## License - -MIT License - -Copyright (c) 2020 Edoardo Scibona - -See LICENSE file. -", - "readmeFilename": "README.md", - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "time": { - "0.1.0": "2020-06-24T20:56:30.762Z", - "0.1.1": "2020-06-24T21:24:02.188Z", - "0.2.0": "2020-06-25T17:52:13.129Z", - "1.0.0": "2020-06-25T18:31:41.554Z", - "1.0.1": "2020-06-27T22:35:44.286Z", - "1.1.0": "2020-06-29T17:20:18.834Z", - "1.1.1": "2020-07-12T17:03:27.911Z", - "2.0.0": "2020-12-30T22:00:15.470Z", - "created": "2020-06-24T20:56:30.552Z", - "modified": "2022-05-17T18:18:09.563Z", - }, - "versions": { - "0.1.0": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@0.1.0", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_0.1.0_1593032190553_0.6531229156028178", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "author": { - "name": "velut", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (e.g., '1 minute ago')", - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "directories": {}, - "dist": { - "fileCount": 16, - "integrity": "sha512-MIWljj3xMYo/x0RdoLBX/2NbX+p2mMT/cO0Mde1RrYRMDKeTOaygTRUZ7T1NVF1pllBh97rDX55I9HGX48UDvQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe873/CRA9TVsSAnZWagAA+YMP/ArNQE1IQST5AnEjMBk/ -8r/g0CRtuXuFK7ixZXtk9zle8LxiwIHbjWCkw+UsJdGiFeqWfgkuXmNcXOR5 -1gl06sbAeTZUJgRipkJNpoev+12yJFO6sktWLx+s5rkngzErtcZ+REVxDLUj -mMKOpzYJXpKorOvz9eZ3oFhi2S6SR4NmTc2pb8MKppmHi1e9nJrEa81R0JK6 -udMWVHqZCFcgqOYrEwfpuD5jtRgcib5+zcfCkn0TUDJc8gbw6v14VqdBcIx/ -Eyd5n+Fiw/P1kqILI+DHbVwgVyxy+eyuYtRD1KfSBEnNi+G0iLKcFYh3UNnK -dhPK3qpCNAYiMBbDX8jwSDlWM/yfH0+tCm7J0gdomkuneu1UCGm6xhxXO0rq -hXibVr/RRrhjHJJZf1JDSP5ODdziGDGEeSJdQFhkiLgWx7sHDlr7/nO4c8cQ -AcuYq97v6QfuTeqd/20iLCGsa9SgFVMddgR6zEz/cx16BorIW7AOIk8c4i7+ -jvGIVgNXVA4681piS3Wpqhjk6Nk09igYEE6KYc/OJvaJVNgMWjP5dLXMUado -ewqxgB3yyfQwMk3HWk9e8g6OGDeXtm3ij39P6nFuaSUMgbBhupZ5oKQEoI7D -3EA3ZgTyQFA3avdH1HbkDA0SLqoq5OaNFKI22Yut/EFWUgTp96NSGRF6mDUd -4uqe -=W/31 ------END PGP SIGNATURE----- -", - "shasum": "101f912c5f9de58e1076791e8f6ec37c05fde2f7", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEQCICk2ZBGKOa3ngtPMa1uMVfCvCYYmVPqkfI6jS5KE98bTAiBROrM/FtTXmqDqyw2jO45ayrIVibOvqxwaGlc2LTWGpg==", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-0.1.0.tgz", - "unpackedSize": 29625, - }, - "engines": { - "node": ">=10", - }, - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "dist/short-time-ago.esm.js", - "name": "short-time-ago", - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "scripts": { - "build": "tsdx build", - "lint": "tsdx lint src test", - "pre-push": "yarn lint && yarn build && yarn test:cov", - "prepare": "tsdx build && sed -i 's/src/..\\/src/g' dist/index.d.ts.map", - "start": "tsdx watch", - "test": "tsdx test", - "test:cov": "tsdx test --coverage", - "test:watch": "tsdx test --watchAll --coverage", - }, - "typings": "dist/index.d.ts", - "version": "0.1.0", - }, - "0.1.1": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@0.1.1", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_0.1.1_1593033842081_0.6662526070570363", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "author": { - "name": "velut", - }, - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (e.g., '1 minute ago')", - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "directories": {}, - "dist": { - "fileCount": 16, - "integrity": "sha512-+0A0gW488pjJLO/PP6CuYPdwR0tIYumhIPIdzEjPjHz7prc7XIQTRj8PWQgO4XgZE6fJXiLOR0m4SjnkV7KwGQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe88RyCRA9TVsSAnZWagAAyJ8P/ApU/orrNlpW/UJFiPGM -/G70gHJSdPJRB6Gl0UyP0/fHX02IFD+BtwGvn+91c3aA7V8LvxdHiK07yECM -6/yKefXxPl1pQXtZ3+hVEj+lTe+qvprX0/yGDCGH0FWoTP61ueT7ovPExJQ0 -npaMYtIL/sElbvtsiY2JNofEMt7ELMp5Rq29Atb2SVEQ6ohcKbZ5vTYkFvAC -kdiHvj/9t3vUi0iqnvZTQoPSLD3Thq1RNdN8KZ6YFZCRt5QNN63C04FlMW3L -MdVPuxojAu9ZF4OmdSWysPGC6+DsKL+OjRdY7NToC3peY4aLOVMiAL/r5a4S -B4P+2+DWo5HpNnEsqwwlf+68MPfhoaPUdHVC39V4vgw6rFg6XykVJzXp0Opl -umjn9D49jWuCt89Vz55DGXADEIjSYOMqpWiD1oZDc8Yz+2GpbOIS709EA8ik -wDr8/SpG/0J9xl1J5h5beMVJY/xA3ub9lPNMnqGA05m8iP7b8up+wUtU+poz -TR7uBnpzAET8Tn2qKdo4oe/6A0xc4F33mAGlCTU0oqaR/F5be1fRddYsQc+8 -JLtzQ697jTN830bUHT60rOEEhkly1+4iH7cUDGj8bMIgVPmaP+y4k8ofKbha -oyLwVooesd0arAxpIwExgAug7IbQFywzbwMymllDLQEUkRxglf2V30uZ95GO -uXJZ -=sbmB ------END PGP SIGNATURE----- -", - "shasum": "a71de26c06b0078c9308a341c06d0649fadcbde5", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIQDypJeFCIlsdbdOL6kUNQwKBgPHqLejSjFhwJnF4Q+H4gIgQShiZTiqJCyO5gGY9BRk9SLW7j+zExqDypPFJATemPA=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-0.1.1.tgz", - "unpackedSize": 29827, - }, - "engines": { - "node": ">=10", - }, - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "dist/short-time-ago.esm.js", - "name": "short-time-ago", - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "scripts": { - "build": "tsdx build", - "lint": "tsdx lint src test", - "pre-push": "yarn lint && yarn build && yarn test:cov", - "prepare": "tsdx build && sed -i 's/src/..\\/src/g' dist/index.d.ts.map", - "start": "tsdx watch", - "test": "tsdx test", - "test:cov": "tsdx test --coverage", - "test:watch": "tsdx test --watchAll --coverage", - }, - "typings": "dist/index.d.ts", - "version": "0.1.1", - }, - "0.2.0": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@0.2.0", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_0.2.0_1593107532990_0.9941335857684626", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "author": { - "name": "velut", - }, - "browser": "dist/short-time-ago.umd.production.min.js", - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (e.g., '1 minute ago')", - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "directories": {}, - "dist": { - "fileCount": 18, - "integrity": "sha512-ex7/YRbrvQJJkDDq41jLq2EsVmRjNTepih04UQh4KeYZ3t+gi7GfP57yH3ixbvLsjtdOeHK4kDzIh8Rg7jtKbg==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe9ORNCRA9TVsSAnZWagAA06sP/1Tf2GUy50JxL4KF09BZ -kYSnMziYw9TuLPP+nZ+kF3+ySgjjnm3mWgA1PC8yqQNI+mMo6kfda2pmwJ49 -RwYCLJCn0VPDvKQXRDqszNczBrCmFg9F5AX6DHz9oxoenmH0E1W7KVDDcrHL -xwOon33mnZzw3XqmIuh3Lyc8otMwM9A4sw1g07pyF0wOYqFuRhG60UWKduyA -9QsD5XY6B5+CY5E9Ss9TalhIXQRORN4vRv7pf2hqzdXbNcT0j07ti640G0Kd -dAJj0SpxaWXxHNLAVJPYLGnVYM5Y0vrYiEEw0RPHG1AtKgh8lTXDgtzxwQC7 -rwc2NpDOHPpF5ibJeM4KekbhWgr0s3tXkeCeZTC80aKRHBX6MKx0ZypsQpJh -oZB7qk5uGoUDqULDvBXAC2gABs+L9mPGfGP3Nigav3rOD1aeh3TtLxH2YWp0 -c6J03XJB4ePOIuhq/8ujRWCCDkitGOL9SWroVxYAKZEGuLw2e6BM3sZM95g+ -raUHjeiYqJUgh7WzxwVNIgvyUQHPYUk1ii+UdEGXUluNUZbCiOzKXyMbZbtF -75woVPzIZCzroQaL4/u9fqkYiV8QY4gs2LmKxJbO0zI3sbTpfMnzo0L4JqlF -3sWSY5jViMZRYB9uZOO0jNroxy2tkM29Wn7iM58bnYLSqrxSej+5iHXg9MtN -E9U0 -=QvWK ------END PGP SIGNATURE----- -", - "shasum": "363b36e8b690c497db6f57222e7ab3275023c57f", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEYCIQCyTi2jNWhIZ1z1gb5h6bDwwIvzDqiD7AsaUYzCoj2ynAIhAM4kS66n4RvEfVabo6Vskc/UQvF0+1Ose3I2QaCCfMY3", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-0.2.0.tgz", - "unpackedSize": 35090, - }, - "engines": { - "node": ">=10", - }, - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "dist/short-time-ago.esm.js", - "name": "short-time-ago", - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "scripts": { - "build": "tsdx build --format cjs,ejs,umd", - "fixDeclarationMap": "sed -i 's/src/..\\/src/g' dist/index.d.ts.map", - "lint": "tsdx lint src test", - "pre-push": "yarn lint && yarn build && yarn test:cov", - "prepare": "yarn build && yarn fixDeclarationMap", - "start": "tsdx watch", - "test": "tsdx test", - "test:cov": "tsdx test --coverage", - "test:watch": "tsdx test --watchAll --coverage", - }, - "typings": "dist/index.d.ts", - "unpkg": "dist/short-time-ago.umd.production.min.js", - "version": "0.2.0", - }, - "1.0.0": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@1.0.0", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_1.0.0_1593109901440_0.2943562424251429", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "author": { - "name": "velut", - }, - "browser": "dist/short-time-ago.umd.production.min.js", - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (e.g., '1 minute ago')", - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "directories": {}, - "dist": { - "fileCount": 18, - "integrity": "sha512-CzPlGX0r0zY7nJGMwb0rmcV4e8fRsw4vMQDaKzE5NxtXbUxT6Ie4oE1RptWLftYJ9/uBrgpW76oSCySH8QPRkA==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe9O2NCRA9TVsSAnZWagAArfIP/3PFmOkWEoPTsPd4sP9x -bno/QcKzusjXSFE8XEz+gEoQV5AWHKnVs8ho8ElTVJLIkbs3SESJYuFtuKnC -6oneIO9ZePu5ZCA68BCWo8YxCmjogayszs81t/V25kdrjCGw7Ap4wjmbY73R -ik3fu0W6h0izkMfF7/Bfwk2Pkpr4ibWO3YMhlY4j7Tg+okukPunaij/HUWxD -Ez2xF2WOoDcm71KjEuWM1QhYLVJoplNIm73GpbhTWtlRjTZNmJlxveINVUEh -g5P8rLl/C8+MYYJLZgX5XphnbQs0OyvKk4NHfvKfTTW3PtO2DWUJWY95LbKw -4GYJhp//gceYKt5masMJVpONZ8yuFxfTxC96cvnivsoRQL6v4MfJOodghNzu -Z1H0IMrnC0UnVjau7OGz+BlAESGg7CruUpxuWvLEVYct2a0cG4byjlOGvWFJ -PjJNyj1KUyA8Vep2uj2oU7fiwOEN04lbQr6QtRLptwOxxLi3j8ec//rckHx8 -2E2w78UicScrrcuRDCy41KQac+ZU7+gHIbHCFykvj9vaYerpHFQPEsh2bANT -Tbpz9RQ38WlYeZAtaRhrSPynqX3MG2vC3shTqw06Mo4WSbL+eEtbrAsyhmSZ -wTb07ZwsL5DitFIhbYvp4FkF0or0WKbemFkhSVb6rXHX/tcC9C64CZVU7f89 -HxeZ -=jKYu ------END PGP SIGNATURE----- -", - "shasum": "8f019fc3acaa9c1bcc0278b315a37f5baff9bea6", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIGJtV6q2MKHT0rQj4UsqHCOxPpHPK7sXZ6hLNPqDqJCCAiEAixMJD128N/2QXSWw5UsEWpGwFA+/Jp0PuSwWgskq8To=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.0.0.tgz", - "unpackedSize": 35463, - }, - "engines": { - "node": ">=10", - }, - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "dist/short-time-ago.esm.js", - "name": "short-time-ago", - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "scripts": { - "build": "tsdx build --format cjs,ejs,umd", - "fixDeclarationMap": "sed -i 's/src/..\\/src/g' dist/index.d.ts.map", - "lint": "tsdx lint src test", - "pre-push": "yarn lint && yarn build && yarn test:cov", - "prepare": "yarn build && yarn fixDeclarationMap", - "start": "tsdx watch", - "test": "tsdx test", - "test:cov": "tsdx test --coverage", - "test:watch": "tsdx test --watchAll --coverage", - }, - "typings": "dist/index.d.ts", - "unpkg": "dist/short-time-ago.umd.production.min.js", - "version": "1.0.0", - }, - "1.0.1": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@1.0.1", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_1.0.1_1593297344197_0.37129412936967077", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "author": { - "name": "velut", - }, - "browser": "dist/short-time-ago.umd.production.min.js", - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (e.g., '1 minute ago')", - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "directories": {}, - "dist": { - "fileCount": 20, - "integrity": "sha512-0Ao0R46EIZ78w8I8BD/VHb2UK12Knp8Pn/zgg4Z42pI6/a618VoMv+nYWRUvJoANKb6n0jTUShkBeZK4/oflFQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe98nACRA9TVsSAnZWagAAf9IP/2k5K91weuysPam6hL5+ -kti56jaGaBisoYWwB+Mc/wMgE/RyTmudVzkz5cLjewmJmRr/IyLAPeJzMczW -ZBAzUr9ZdriLm0LHjz8Mr3FaYVqZxgvRIELwWLlzOzk0fcfFgJC0ZsGQYsfv -5qQTN3Hg5ER+XvKKcr7QkD2Z87wxv122RPFlKow6rZKeiuLYPD7uZiI9EIRI -Zj1uNXI/l7rQlzUZ46gbzvK6iwy3PS9hekUDLJXQvAkqaDNavq2u4tYFYqHN -68GiAeZhyxoDINnxt3uZ5gtoqCikuQ5dpnrujlM2lYXbKq7+GwlMSdBVEmxM -6Pn2M2Iwanq0Masa4z5qy82tdUSS8YJVZsIAV5qXDqCCCwjDdkgyn/+wGReY -dhdebvpxPHqXMmEtt1nwqtY2gHQJSyKgSAHThafLEm13jB3s+c+iptXYB6tF -kUGmkHaeedwXcsO/TZwkY/8Db4iox02JA5QVrxX+a5uHJ6KZeTY8F1EPOXm+ -+J6AHIDuZlXh6/Icxc7mVZb3rZZUK7zGdB7SKDlcMBTQaUbfeW8e3X2UirKh -pejLENMOXg7O3cor2m3TT/ltUpNP5rE+OfxgqM+pBD3yrS+aAvKUzTMrYIoB -gV3nyp7FpLTyHHIVoxuI01cBTD8K4/uSaxWZ5z6wgqihRtSjXo+vq9XqMjta -sqb2 -=Ia0H ------END PGP SIGNATURE----- -", - "shasum": "8c0d5f9b8b5cd8341b00cee1023658c24825698d", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIQC7FUcpqgR8Lpk3isKB//Z9xSsT+haD4Rito3mjKz+UwwIgaWalxGe749Va9Vf6mnwR1edt3vBxmrgiD524aNhFUNY=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.0.1.tgz", - "unpackedSize": 42911, - }, - "engines": { - "node": ">=10", - }, - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "dist/short-time-ago.esm.js", - "name": "short-time-ago", - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "scripts": { - "build": "tsdx build --format cjs,esm,umd", - "fixDeclarationMap": "sed -i 's/src/..\\/src/g' dist/index.d.ts.map", - "lint": "tsdx lint src test", - "pre-push": "yarn lint && yarn build && yarn test:cov", - "prepare": "yarn build && yarn fixDeclarationMap", - "start": "tsdx watch", - "test": "tsdx test", - "test:cov": "tsdx test --coverage", - "test:watch": "tsdx test --watchAll --coverage", - }, - "source": "src/index.ts", - "typings": "dist/index.d.ts", - "unpkg": "dist/short-time-ago.umd.production.min.js", - "version": "1.0.1", - }, - "1.1.0": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@1.1.0", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_1.1.0_1593451218635_0.9404354029485447", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "amdName": "short-time-ago", - "author": { - "name": "velut", - }, - "browser": "dist/index.umd.js", - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (e.g., '1 minute ago')", - "devDependencies": { - "husky": "^4.2.5", - "microbundle": "^0.12.2", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "directories": {}, - "dist": { - "fileCount": 17, - "integrity": "sha512-9kzJsEPgPlXKfekrNsOTAL+rsF6H//TE85wXOh5CR6DnhpGdUkd1wKXO4eZPq/PWlhZZPG+LOGxo1b/BPfFVig==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe+iLTCRA9TVsSAnZWagAAvuAP/jDQ4egaWuZ78N3TOHVy -8748TE94AY97cL4Vo5u+/f/fYd13RQqy38TgWARWDKVbS/bWmUObMp0v9NQ4 -APOlakmTz4WOJpdRyEXhHxASJF9qMIC3Sb6K4jSlw9kYYE3YeNilUyFoFk3u -PZkhQsK8L7gC3nGIjSj3H8+l0otqNmAx2+U14cRE+kDmmAH4bdjucMmBU/Jp -4jGGvWr941eQg7EuqeyDlDeUiJoI3KReXZZmb/wcor1lSfdczn6Apbi8FYM2 -tUznqwYw/lfoGwtRVKM9+3J3xyoGWhUtLaAzvIhWPAhA4dDtfWQgolC5Zkbt -bF5Jsnt0pAsgy+cJekuwTOjxu1j0HRWkMbzEnG9eomUOnlhtLZ0I1ZYLr+nF -bmMQTOtlYyQbPIJ4xqpqL26g2tR9OLBlUkjn1nnMKnhPG9x/5ui7CIjXDWld -g+MIk4dRdnraHL5kqAO2SGhA7BWI/5wVCG6Fd2CoVmhChucznEYNsmMoOUhm -d8v+HsdYnFBlpzoFn2oheB0tTu8F4hQzPaQ/7vFeUGoadVjt43kB6T5xtBLQ -bDO38xWwbOJjZbya6xi5IqbtoU4YSiQxhrIagc67glfPcaetewnmIICAt3Ym -N/OJMVdZR9rDXd0TdJuTScz5aDjh9h8RcQGHPgS5ToHS/NX8fXIEBzZknpAf -ClLU -=0eP/ ------END PGP SIGNATURE----- -", - "shasum": "328990c99d25a9883927b3c8ee55d466706f71fd", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEYCIQD3Kki6COtAxOHBMi8ootEBs+Ut+9scL9dlsVnEpnuTAQIhANwhaPZq3AAHVBt3nIToLvIBVjuTxbU5d+vyBWXoImbi", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.1.0.tgz", - "unpackedSize": 27886, - }, - "engines": { - "node": ">=10", - }, - "esmodule": "dist/index.modern.js", - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "dist/index.module.js", - "name": "short-time-ago", - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "scripts": { - "build": "microbundle --strict", - "build:tsdx": "tsdx build --format cjs,esm,umd", - "fixDeclarationMap": "sed -i 's/src/..\\/src/g' dist/index.d.ts.map", - "lint": "tsdx lint src test", - "pre-push": "yarn lint && yarn build && yarn test:cov", - "prepare": "yarn build", - "start": "tsdx watch", - "test": "tsdx test", - "test:cov": "tsdx test --coverage", - "test:watch": "tsdx test --watchAll --coverage", - }, - "source": "src/index.ts", - "typings": "dist/index.d.ts", - "unpkg": "dist/index.umd.js", - "version": "1.1.0", - }, - "1.1.1": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@1.1.1", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_1.1.1_1594573407735_0.2048708175516325", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "amdName": "short-time-ago", - "author": { - "name": "velut", - }, - "browser": "dist/index.umd.js", - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (e.g., '1 minute ago')", - "devDependencies": { - "husky": "^4.2.5", - "microbundle": "^0.12.2", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "directories": {}, - "dist": { - "fileCount": 17, - "integrity": "sha512-vM5LgYu2ywFwAQvjGpDIMcJeiXTQhXorO+zZ4ODV0YcI8I2yhhBuOznqq62NKaVuLhrm5jTXFstx0NeouEi0gQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJfC0JgCRA9TVsSAnZWagAAE6IP/AgIq7O1+31t9mYkVbO+ -zXdmf0q2OX3HBMzH5+zQwIKzYYh1l4VU0KGvyGeGYTLX+kCPVdSbHYx5zfXM -4qKR7HydSvOkrKWDamqb+na9A5iZBkFVPWFyNYe8jU+0mBfEEGYGxZJHrvE3 -wXLSZaXnSqF+a5vbQINvr2Ae8qWrO3DxyyFS6oNQt3NWbyXWBrFd6wybldww -d5g/oQweuVYr2wRe2rxr9WrklIYqlQXnKkrVpcERi9raPsOHFVJp4AQWZXxo -TPSZgmW1MkDOV1TWs/mQJ7XSxA3CzrZ4S41TywVjdzHwU9sDcjH8AU2OkC35 -IzDOAYgnk3jAM/eY5/ygzg8ceUJE2Y84BTyu3YoPJAGfKHclk5WEZyL2bx9Z -fW6hB8BZXrpGafga1ynB4NH6wqhsQzUBucvKJpKQ4u+LxZZ36lg0OZ13h849 -Wg2byUbwjLdIJ4ryeJdUYkUxZGYAr5vcFqCyVORKevDGDBlutJ0QrMOjUZh6 -3773PtZMLlEkCkG5xdVnHvQrlSfrVIn8kdUTp2VnBk06htyDqoMIN3NJpJe9 -ON6jjxXnlVtTGBi0v7V4NZVmlY7wAbRiaK0nL2uo1Yka6puO7nYmr50uOS7r -lF3HL4U86p0s4CsaCcAZNxfsloNL6MQVavjOL8JuvbFQFt0mJaNLyivsA7Mr -4jQP -=JDss ------END PGP SIGNATURE----- -", - "shasum": "23d4305c9721fd9078b58227f356828c311e0f27", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEYCIQDeF9FduUrWBi608c7IyA64h5lKp+v/r2BXd/n6Z4qrzwIhAI6qgWtPfRqGWqxNfivnqj7gNF8VEc11pwTrfVIKQczb", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.1.1.tgz", - "unpackedSize": 28882, - }, - "engines": { - "node": ">=10", - }, - "esmodule": "dist/index.modern.js", - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "dist/index.module.js", - "name": "short-time-ago", - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "scripts": { - "build": "microbundle --strict", - "build:tsdx": "tsdx build --format cjs,esm,umd", - "fixDeclarationMap": "sed -i 's/src/..\\/src/g' dist/index.d.ts.map", - "lint": "tsdx lint src test", - "pre-push": "yarn lint && yarn build && yarn test:cov", - "prepare": "yarn build", - "start": "tsdx watch", - "test": "tsdx test --runInBand", - "test:ci": "tsdx test --runInBand --ci --coverage", - "test:cov": "tsdx test --runInBand --coverage", - "test:watch": "tsdx test --runInBand --watchAll --coverage", - }, - "sideEffects": false, - "source": "src/index.ts", - "typings": "dist/index.d.ts", - "unpkg": "dist/index.umd.js", - "version": "1.1.1", - }, - "2.0.0": { - "_hasShrinkwrap": false, - "_id": "short-time-ago@2.0.0", - "_npmOperationalInternal": { - "host": "s3://npm-registry-packages", - "tmp": "tmp/short-time-ago_2.0.0_1609365615301_0.03713104019779956", - }, - "_npmUser": { - "email": "velut@jsref.org", - "name": "velut", - }, - "amdName": "short-time-ago", - "author": { - "name": "velut", - }, - "browser": "./dist/index.umd.js", - "bugs": { - "url": "https://github.com/velut/node-short-time-ago/issues", - }, - "description": "A small, no dependencies, Typescript utility to describe time differences in a human readable format (for example, '1 minute ago')", - "devDependencies": { - "eslint-plugin-prettier": "3.3.0", - "husky": "4.3.6", - "microbundle": "0.13.0", - "np": "7.1.0", - "prettier": "2.2.1", - "semantic-release": "17.3.1", - "tsdx": "0.14.1", - "tslib": "2.0.3", - "typescript": "4.1.3", - }, - "directories": {}, - "dist": { - "fileCount": 17, - "integrity": "sha512-klqvTBTPpU2xI/+qeTl3zMX6EVfcF7ddTfoaOg+aOpJY4IOhwwgxTQ2eu3sLDrSAQL0PwjFAoWqJUDUcJSEXXA==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.13 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJf7PhvCRA9TVsSAnZWagAAUaIP+wYrEzP9UnByN7HgvTNQ -E+akBOTBkuxo8nXI8t9htsjVZ49rhAuuhdSp24KWpE/dXHekQDXirmAav3Yf -GwUQM5HaghRaVQZXM4W0E3vw8I3MZqPnkr3C5HogDLCdDWDG8ahvEpw2N7ue -yWA52C2nCEZnM/jsfDcF+6XAdGZmuczNK2mfiX+hXDEATUE5eUTgeHPG20la -V4e/Iy+5F8r1mhxbgg+vn+V1lGTTqSO0fj0mEp480IBBaU0aX+s3yVFX7icq -XsCTXHk12r1Z//FSWlL9m2wrzedj7cmpXDbtYE1XCXrP1e3jc9wbWYGEHzVY -ogHj08LK5kdMjAY9bv29gIb4esLp7CTSyij4GTNPNH6uqFAVQ3+R1jTELchD -t4rDEoebiLZqt6n1rYxUOHYctIksB0HY/1duTQtvg13/JBxasYPlPNzsdlb8 -LUaFMWeuTKmQ4iJHyg9FQ114T+sfQwnyssx8L4wZeAcKms5ie6yzfEfYzlZK -8Z6CRw76fcXje7hBRAmL7S6+rQthosImN7jjQgqw4mNVc1G3dvvLfvwhNJ/l -8h2umtdhVYVuh5OZGNqQgMBcT1ATYzEmoHdJhBsA6ePKIP52jkk3Wt0LJvZq -GWQFNErosV8tvZBTLXohdbREtZl07v31PJKQZ50kSQSOiO6IjTheE/erR93d -ZGJV -=+NyU ------END PGP SIGNATURE----- -", - "shasum": "3fde172e626999510c5ca6784aba568c964d50dc", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIFy5+OLxSy0dQBrhaYfUDtqP0MTeNE6OsgrgL/5BhSkCAiEAwbDFSmL73uopAcb0OgxBblPBziWiqwn/wqejFBcCTYM=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-2.0.0.tgz", - "unpackedSize": 29378, - }, - "engines": { - "node": ">=10", - }, - "esmodule": "./dist/index.modern.js", - "exports": { - "browser": "./dist/index.umd.js", - "default": "./dist/index.js", - "import": "./dist/index.modern.js", - "require": "./dist/index.js", - }, - "husky": { - "hooks": { - "pre-commit": "yarn lint", - "pre-push": "yarn pre-push", - }, - }, - "keywords": [ - "time", - "ago", - "date", - "format", - "relative", - "human", - "readable", - "typescript", - ], - "license": "MIT", - "licenseText": "MIT License - -Copyright (c) 2020 Edoardo Scibona - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.", - "main": "./dist/index.js", - "maintainers": [ - { - "email": "velut@jsref.org", - "name": "velut", - }, - ], - "module": "./dist/index.module.js", - "name": "short-time-ago", - "np": { - "branch": "main", - }, - "peerDependencies": {}, - "prettier": { - "arrowParens": "always", - "printWidth": 80, - "semi": true, - "singleQuote": true, - "tabWidth": 4, - "trailingComma": "es5", - }, - "repository": { - "type": "git", - "url": "https://github.com/velut/node-short-time-ago", - }, - "scripts": { - "build": "microbundle --strict", - "build:tsdx": "tsdx build --format cjs,esm,umd", - "lint": "tsdx lint src test", - "pre-push": "yarn && yarn lint && yarn build && yarn test:cov", - "prepare": "yarn build", - "release": "np", - "semantic-release": "semantic-release", - "start": "tsdx watch", - "test": "tsdx test --runInBand", - "test:ci": "tsdx test --runInBand --ci --coverage", - "test:cov": "tsdx test --runInBand --coverage", - "test:watch": "tsdx test --runInBand --watchAll --coverage", - }, - "sideEffects": false, - "source": "./src/index.ts", - "types": "./dist/index.d.ts", - "unpkg": "./dist/index.umd.js", - "version": "2.0.0", - }, - }, - "versionsToTimestamps": { - "0.1.0": "2020-06-24T20:56:30.762Z", - "0.1.1": "2020-06-24T21:24:02.188Z", - "0.2.0": "2020-06-25T17:52:13.129Z", - "1.0.0": "2020-06-25T18:31:41.554Z", - "1.0.1": "2020-06-27T22:35:44.286Z", - "1.1.0": "2020-06-29T17:20:18.834Z", - "1.1.1": "2020-07-12T17:03:27.911Z", - "2.0.0": "2020-12-30T22:00:15.470Z", - }, -} -`; - -exports[`getAbbreviatedPackument does not conflict with getPackument on cached responses 2`] = ` -{ - "dist-tags": { - "latest": "2.0.0", - }, - "distTags": { - "latest": "2.0.0", - }, - "id": "short-time-ago", - "modified": "2022-05-17T18:18:09.563Z", - "modifiedAt": "2022-05-17T18:18:09.563Z", - "name": "short-time-ago", - "versions": { - "0.1.0": { - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "dist": { - "fileCount": 16, - "integrity": "sha512-MIWljj3xMYo/x0RdoLBX/2NbX+p2mMT/cO0Mde1RrYRMDKeTOaygTRUZ7T1NVF1pllBh97rDX55I9HGX48UDvQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe873/CRA9TVsSAnZWagAA+YMP/ArNQE1IQST5AnEjMBk/ -8r/g0CRtuXuFK7ixZXtk9zle8LxiwIHbjWCkw+UsJdGiFeqWfgkuXmNcXOR5 -1gl06sbAeTZUJgRipkJNpoev+12yJFO6sktWLx+s5rkngzErtcZ+REVxDLUj -mMKOpzYJXpKorOvz9eZ3oFhi2S6SR4NmTc2pb8MKppmHi1e9nJrEa81R0JK6 -udMWVHqZCFcgqOYrEwfpuD5jtRgcib5+zcfCkn0TUDJc8gbw6v14VqdBcIx/ -Eyd5n+Fiw/P1kqILI+DHbVwgVyxy+eyuYtRD1KfSBEnNi+G0iLKcFYh3UNnK -dhPK3qpCNAYiMBbDX8jwSDlWM/yfH0+tCm7J0gdomkuneu1UCGm6xhxXO0rq -hXibVr/RRrhjHJJZf1JDSP5ODdziGDGEeSJdQFhkiLgWx7sHDlr7/nO4c8cQ -AcuYq97v6QfuTeqd/20iLCGsa9SgFVMddgR6zEz/cx16BorIW7AOIk8c4i7+ -jvGIVgNXVA4681piS3Wpqhjk6Nk09igYEE6KYc/OJvaJVNgMWjP5dLXMUado -ewqxgB3yyfQwMk3HWk9e8g6OGDeXtm3ij39P6nFuaSUMgbBhupZ5oKQEoI7D -3EA3ZgTyQFA3avdH1HbkDA0SLqoq5OaNFKI22Yut/EFWUgTp96NSGRF6mDUd -4uqe -=W/31 ------END PGP SIGNATURE----- -", - "shasum": "101f912c5f9de58e1076791e8f6ec37c05fde2f7", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEQCICk2ZBGKOa3ngtPMa1uMVfCvCYYmVPqkfI6jS5KE98bTAiBROrM/FtTXmqDqyw2jO45ayrIVibOvqxwaGlc2LTWGpg==", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-0.1.0.tgz", - "unpackedSize": 29625, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "0.1.0", - }, - "0.1.1": { - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "dist": { - "fileCount": 16, - "integrity": "sha512-+0A0gW488pjJLO/PP6CuYPdwR0tIYumhIPIdzEjPjHz7prc7XIQTRj8PWQgO4XgZE6fJXiLOR0m4SjnkV7KwGQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe88RyCRA9TVsSAnZWagAAyJ8P/ApU/orrNlpW/UJFiPGM -/G70gHJSdPJRB6Gl0UyP0/fHX02IFD+BtwGvn+91c3aA7V8LvxdHiK07yECM -6/yKefXxPl1pQXtZ3+hVEj+lTe+qvprX0/yGDCGH0FWoTP61ueT7ovPExJQ0 -npaMYtIL/sElbvtsiY2JNofEMt7ELMp5Rq29Atb2SVEQ6ohcKbZ5vTYkFvAC -kdiHvj/9t3vUi0iqnvZTQoPSLD3Thq1RNdN8KZ6YFZCRt5QNN63C04FlMW3L -MdVPuxojAu9ZF4OmdSWysPGC6+DsKL+OjRdY7NToC3peY4aLOVMiAL/r5a4S -B4P+2+DWo5HpNnEsqwwlf+68MPfhoaPUdHVC39V4vgw6rFg6XykVJzXp0Opl -umjn9D49jWuCt89Vz55DGXADEIjSYOMqpWiD1oZDc8Yz+2GpbOIS709EA8ik -wDr8/SpG/0J9xl1J5h5beMVJY/xA3ub9lPNMnqGA05m8iP7b8up+wUtU+poz -TR7uBnpzAET8Tn2qKdo4oe/6A0xc4F33mAGlCTU0oqaR/F5be1fRddYsQc+8 -JLtzQ697jTN830bUHT60rOEEhkly1+4iH7cUDGj8bMIgVPmaP+y4k8ofKbha -oyLwVooesd0arAxpIwExgAug7IbQFywzbwMymllDLQEUkRxglf2V30uZ95GO -uXJZ -=sbmB ------END PGP SIGNATURE----- -", - "shasum": "a71de26c06b0078c9308a341c06d0649fadcbde5", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIQDypJeFCIlsdbdOL6kUNQwKBgPHqLejSjFhwJnF4Q+H4gIgQShiZTiqJCyO5gGY9BRk9SLW7j+zExqDypPFJATemPA=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-0.1.1.tgz", - "unpackedSize": 29827, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "0.1.1", - }, - "0.2.0": { - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "dist": { - "fileCount": 18, - "integrity": "sha512-ex7/YRbrvQJJkDDq41jLq2EsVmRjNTepih04UQh4KeYZ3t+gi7GfP57yH3ixbvLsjtdOeHK4kDzIh8Rg7jtKbg==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe9ORNCRA9TVsSAnZWagAA06sP/1Tf2GUy50JxL4KF09BZ -kYSnMziYw9TuLPP+nZ+kF3+ySgjjnm3mWgA1PC8yqQNI+mMo6kfda2pmwJ49 -RwYCLJCn0VPDvKQXRDqszNczBrCmFg9F5AX6DHz9oxoenmH0E1W7KVDDcrHL -xwOon33mnZzw3XqmIuh3Lyc8otMwM9A4sw1g07pyF0wOYqFuRhG60UWKduyA -9QsD5XY6B5+CY5E9Ss9TalhIXQRORN4vRv7pf2hqzdXbNcT0j07ti640G0Kd -dAJj0SpxaWXxHNLAVJPYLGnVYM5Y0vrYiEEw0RPHG1AtKgh8lTXDgtzxwQC7 -rwc2NpDOHPpF5ibJeM4KekbhWgr0s3tXkeCeZTC80aKRHBX6MKx0ZypsQpJh -oZB7qk5uGoUDqULDvBXAC2gABs+L9mPGfGP3Nigav3rOD1aeh3TtLxH2YWp0 -c6J03XJB4ePOIuhq/8ujRWCCDkitGOL9SWroVxYAKZEGuLw2e6BM3sZM95g+ -raUHjeiYqJUgh7WzxwVNIgvyUQHPYUk1ii+UdEGXUluNUZbCiOzKXyMbZbtF -75woVPzIZCzroQaL4/u9fqkYiV8QY4gs2LmKxJbO0zI3sbTpfMnzo0L4JqlF -3sWSY5jViMZRYB9uZOO0jNroxy2tkM29Wn7iM58bnYLSqrxSej+5iHXg9MtN -E9U0 -=QvWK ------END PGP SIGNATURE----- -", - "shasum": "363b36e8b690c497db6f57222e7ab3275023c57f", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEYCIQCyTi2jNWhIZ1z1gb5h6bDwwIvzDqiD7AsaUYzCoj2ynAIhAM4kS66n4RvEfVabo6Vskc/UQvF0+1Ose3I2QaCCfMY3", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-0.2.0.tgz", - "unpackedSize": 35090, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "0.2.0", - }, - "1.0.0": { - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "dist": { - "fileCount": 18, - "integrity": "sha512-CzPlGX0r0zY7nJGMwb0rmcV4e8fRsw4vMQDaKzE5NxtXbUxT6Ie4oE1RptWLftYJ9/uBrgpW76oSCySH8QPRkA==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe9O2NCRA9TVsSAnZWagAArfIP/3PFmOkWEoPTsPd4sP9x -bno/QcKzusjXSFE8XEz+gEoQV5AWHKnVs8ho8ElTVJLIkbs3SESJYuFtuKnC -6oneIO9ZePu5ZCA68BCWo8YxCmjogayszs81t/V25kdrjCGw7Ap4wjmbY73R -ik3fu0W6h0izkMfF7/Bfwk2Pkpr4ibWO3YMhlY4j7Tg+okukPunaij/HUWxD -Ez2xF2WOoDcm71KjEuWM1QhYLVJoplNIm73GpbhTWtlRjTZNmJlxveINVUEh -g5P8rLl/C8+MYYJLZgX5XphnbQs0OyvKk4NHfvKfTTW3PtO2DWUJWY95LbKw -4GYJhp//gceYKt5masMJVpONZ8yuFxfTxC96cvnivsoRQL6v4MfJOodghNzu -Z1H0IMrnC0UnVjau7OGz+BlAESGg7CruUpxuWvLEVYct2a0cG4byjlOGvWFJ -PjJNyj1KUyA8Vep2uj2oU7fiwOEN04lbQr6QtRLptwOxxLi3j8ec//rckHx8 -2E2w78UicScrrcuRDCy41KQac+ZU7+gHIbHCFykvj9vaYerpHFQPEsh2bANT -Tbpz9RQ38WlYeZAtaRhrSPynqX3MG2vC3shTqw06Mo4WSbL+eEtbrAsyhmSZ -wTb07ZwsL5DitFIhbYvp4FkF0or0WKbemFkhSVb6rXHX/tcC9C64CZVU7f89 -HxeZ -=jKYu ------END PGP SIGNATURE----- -", - "shasum": "8f019fc3acaa9c1bcc0278b315a37f5baff9bea6", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIGJtV6q2MKHT0rQj4UsqHCOxPpHPK7sXZ6hLNPqDqJCCAiEAixMJD128N/2QXSWw5UsEWpGwFA+/Jp0PuSwWgskq8To=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.0.0.tgz", - "unpackedSize": 35463, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "1.0.0", - }, - "1.0.1": { - "devDependencies": { - "husky": "^4.2.5", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "dist": { - "fileCount": 20, - "integrity": "sha512-0Ao0R46EIZ78w8I8BD/VHb2UK12Knp8Pn/zgg4Z42pI6/a618VoMv+nYWRUvJoANKb6n0jTUShkBeZK4/oflFQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe98nACRA9TVsSAnZWagAAf9IP/2k5K91weuysPam6hL5+ -kti56jaGaBisoYWwB+Mc/wMgE/RyTmudVzkz5cLjewmJmRr/IyLAPeJzMczW -ZBAzUr9ZdriLm0LHjz8Mr3FaYVqZxgvRIELwWLlzOzk0fcfFgJC0ZsGQYsfv -5qQTN3Hg5ER+XvKKcr7QkD2Z87wxv122RPFlKow6rZKeiuLYPD7uZiI9EIRI -Zj1uNXI/l7rQlzUZ46gbzvK6iwy3PS9hekUDLJXQvAkqaDNavq2u4tYFYqHN -68GiAeZhyxoDINnxt3uZ5gtoqCikuQ5dpnrujlM2lYXbKq7+GwlMSdBVEmxM -6Pn2M2Iwanq0Masa4z5qy82tdUSS8YJVZsIAV5qXDqCCCwjDdkgyn/+wGReY -dhdebvpxPHqXMmEtt1nwqtY2gHQJSyKgSAHThafLEm13jB3s+c+iptXYB6tF -kUGmkHaeedwXcsO/TZwkY/8Db4iox02JA5QVrxX+a5uHJ6KZeTY8F1EPOXm+ -+J6AHIDuZlXh6/Icxc7mVZb3rZZUK7zGdB7SKDlcMBTQaUbfeW8e3X2UirKh -pejLENMOXg7O3cor2m3TT/ltUpNP5rE+OfxgqM+pBD3yrS+aAvKUzTMrYIoB -gV3nyp7FpLTyHHIVoxuI01cBTD8K4/uSaxWZ5z6wgqihRtSjXo+vq9XqMjta -sqb2 -=Ia0H ------END PGP SIGNATURE----- -", - "shasum": "8c0d5f9b8b5cd8341b00cee1023658c24825698d", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIQC7FUcpqgR8Lpk3isKB//Z9xSsT+haD4Rito3mjKz+UwwIgaWalxGe749Va9Vf6mnwR1edt3vBxmrgiD524aNhFUNY=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.0.1.tgz", - "unpackedSize": 42911, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "1.0.1", - }, - "1.1.0": { - "devDependencies": { - "husky": "^4.2.5", - "microbundle": "^0.12.2", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "dist": { - "fileCount": 17, - "integrity": "sha512-9kzJsEPgPlXKfekrNsOTAL+rsF6H//TE85wXOh5CR6DnhpGdUkd1wKXO4eZPq/PWlhZZPG+LOGxo1b/BPfFVig==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJe+iLTCRA9TVsSAnZWagAAvuAP/jDQ4egaWuZ78N3TOHVy -8748TE94AY97cL4Vo5u+/f/fYd13RQqy38TgWARWDKVbS/bWmUObMp0v9NQ4 -APOlakmTz4WOJpdRyEXhHxASJF9qMIC3Sb6K4jSlw9kYYE3YeNilUyFoFk3u -PZkhQsK8L7gC3nGIjSj3H8+l0otqNmAx2+U14cRE+kDmmAH4bdjucMmBU/Jp -4jGGvWr941eQg7EuqeyDlDeUiJoI3KReXZZmb/wcor1lSfdczn6Apbi8FYM2 -tUznqwYw/lfoGwtRVKM9+3J3xyoGWhUtLaAzvIhWPAhA4dDtfWQgolC5Zkbt -bF5Jsnt0pAsgy+cJekuwTOjxu1j0HRWkMbzEnG9eomUOnlhtLZ0I1ZYLr+nF -bmMQTOtlYyQbPIJ4xqpqL26g2tR9OLBlUkjn1nnMKnhPG9x/5ui7CIjXDWld -g+MIk4dRdnraHL5kqAO2SGhA7BWI/5wVCG6Fd2CoVmhChucznEYNsmMoOUhm -d8v+HsdYnFBlpzoFn2oheB0tTu8F4hQzPaQ/7vFeUGoadVjt43kB6T5xtBLQ -bDO38xWwbOJjZbya6xi5IqbtoU4YSiQxhrIagc67glfPcaetewnmIICAt3Ym -N/OJMVdZR9rDXd0TdJuTScz5aDjh9h8RcQGHPgS5ToHS/NX8fXIEBzZknpAf -ClLU -=0eP/ ------END PGP SIGNATURE----- -", - "shasum": "328990c99d25a9883927b3c8ee55d466706f71fd", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEYCIQD3Kki6COtAxOHBMi8ootEBs+Ut+9scL9dlsVnEpnuTAQIhANwhaPZq3AAHVBt3nIToLvIBVjuTxbU5d+vyBWXoImbi", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.1.0.tgz", - "unpackedSize": 27886, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "1.1.0", - }, - "1.1.1": { - "devDependencies": { - "husky": "^4.2.5", - "microbundle": "^0.12.2", - "tsdx": "^0.13.2", - "tslib": "^2.0.0", - "typescript": "^3.9.5", - }, - "dist": { - "fileCount": 17, - "integrity": "sha512-vM5LgYu2ywFwAQvjGpDIMcJeiXTQhXorO+zZ4ODV0YcI8I2yhhBuOznqq62NKaVuLhrm5jTXFstx0NeouEi0gQ==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.4 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJfC0JgCRA9TVsSAnZWagAAE6IP/AgIq7O1+31t9mYkVbO+ -zXdmf0q2OX3HBMzH5+zQwIKzYYh1l4VU0KGvyGeGYTLX+kCPVdSbHYx5zfXM -4qKR7HydSvOkrKWDamqb+na9A5iZBkFVPWFyNYe8jU+0mBfEEGYGxZJHrvE3 -wXLSZaXnSqF+a5vbQINvr2Ae8qWrO3DxyyFS6oNQt3NWbyXWBrFd6wybldww -d5g/oQweuVYr2wRe2rxr9WrklIYqlQXnKkrVpcERi9raPsOHFVJp4AQWZXxo -TPSZgmW1MkDOV1TWs/mQJ7XSxA3CzrZ4S41TywVjdzHwU9sDcjH8AU2OkC35 -IzDOAYgnk3jAM/eY5/ygzg8ceUJE2Y84BTyu3YoPJAGfKHclk5WEZyL2bx9Z -fW6hB8BZXrpGafga1ynB4NH6wqhsQzUBucvKJpKQ4u+LxZZ36lg0OZ13h849 -Wg2byUbwjLdIJ4ryeJdUYkUxZGYAr5vcFqCyVORKevDGDBlutJ0QrMOjUZh6 -3773PtZMLlEkCkG5xdVnHvQrlSfrVIn8kdUTp2VnBk06htyDqoMIN3NJpJe9 -ON6jjxXnlVtTGBi0v7V4NZVmlY7wAbRiaK0nL2uo1Yka6puO7nYmr50uOS7r -lF3HL4U86p0s4CsaCcAZNxfsloNL6MQVavjOL8JuvbFQFt0mJaNLyivsA7Mr -4jQP -=JDss ------END PGP SIGNATURE----- -", - "shasum": "23d4305c9721fd9078b58227f356828c311e0f27", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEYCIQDeF9FduUrWBi608c7IyA64h5lKp+v/r2BXd/n6Z4qrzwIhAI6qgWtPfRqGWqxNfivnqj7gNF8VEc11pwTrfVIKQczb", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-1.1.1.tgz", - "unpackedSize": 28882, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "1.1.1", - }, - "2.0.0": { - "devDependencies": { - "eslint-plugin-prettier": "3.3.0", - "husky": "4.3.6", - "microbundle": "0.13.0", - "np": "7.1.0", - "prettier": "2.2.1", - "semantic-release": "17.3.1", - "tsdx": "0.14.1", - "tslib": "2.0.3", - "typescript": "4.1.3", - }, - "dist": { - "fileCount": 17, - "integrity": "sha512-klqvTBTPpU2xI/+qeTl3zMX6EVfcF7ddTfoaOg+aOpJY4IOhwwgxTQ2eu3sLDrSAQL0PwjFAoWqJUDUcJSEXXA==", - "npm-signature": "-----BEGIN PGP SIGNATURE----- -Version: OpenPGP.js v3.0.13 -Comment: https://openpgpjs.org - -wsFcBAEBCAAQBQJf7PhvCRA9TVsSAnZWagAAUaIP+wYrEzP9UnByN7HgvTNQ -E+akBOTBkuxo8nXI8t9htsjVZ49rhAuuhdSp24KWpE/dXHekQDXirmAav3Yf -GwUQM5HaghRaVQZXM4W0E3vw8I3MZqPnkr3C5HogDLCdDWDG8ahvEpw2N7ue -yWA52C2nCEZnM/jsfDcF+6XAdGZmuczNK2mfiX+hXDEATUE5eUTgeHPG20la -V4e/Iy+5F8r1mhxbgg+vn+V1lGTTqSO0fj0mEp480IBBaU0aX+s3yVFX7icq -XsCTXHk12r1Z//FSWlL9m2wrzedj7cmpXDbtYE1XCXrP1e3jc9wbWYGEHzVY -ogHj08LK5kdMjAY9bv29gIb4esLp7CTSyij4GTNPNH6uqFAVQ3+R1jTELchD -t4rDEoebiLZqt6n1rYxUOHYctIksB0HY/1duTQtvg13/JBxasYPlPNzsdlb8 -LUaFMWeuTKmQ4iJHyg9FQ114T+sfQwnyssx8L4wZeAcKms5ie6yzfEfYzlZK -8Z6CRw76fcXje7hBRAmL7S6+rQthosImN7jjQgqw4mNVc1G3dvvLfvwhNJ/l -8h2umtdhVYVuh5OZGNqQgMBcT1ATYzEmoHdJhBsA6ePKIP52jkk3Wt0LJvZq -GWQFNErosV8tvZBTLXohdbREtZl07v31PJKQZ50kSQSOiO6IjTheE/erR93d -ZGJV -=+NyU ------END PGP SIGNATURE----- -", - "shasum": "3fde172e626999510c5ca6784aba568c964d50dc", - "signatures": [ - { - "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA", - "sig": "MEUCIFy5+OLxSy0dQBrhaYfUDtqP0MTeNE6OsgrgL/5BhSkCAiEAwbDFSmL73uopAcb0OgxBblPBziWiqwn/wqejFBcCTYM=", - }, - ], - "tarball": "https://registry.npmjs.org/short-time-ago/-/short-time-ago-2.0.0.tgz", - "unpackedSize": 29378, - }, - "engines": { - "node": ">=10", - }, - "name": "short-time-ago", - "version": "2.0.0", - }, - }, -} -`; diff --git a/old/test/endpoints/get-abbreviated-packument.test.ts b/old/test/endpoints/get-abbreviated-packument.test.ts deleted file mode 100644 index e1024a5..0000000 --- a/old/test/endpoints/get-abbreviated-packument.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { - FetchError, - getAbbreviatedPackument, - getPackument, - InvalidPackageNameError, -} from "../../src/index.old"; - -describe("getAbbreviatedPackument", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the packument for `short-time-ago`", async () => { - expect.assertions(8); - - const packument = await getAbbreviatedPackument({ - name: "short-time-ago", - }); - expect(packument).toMatchObject({ - id: "short-time-ago", - name: "short-time-ago", - }); - expect(packument).toHaveProperty("dist-tags"); - expect(packument).toHaveProperty("dist-tags.latest"); - expect(packument).toHaveProperty("distTags"); - expect(packument).toHaveProperty("distTags.latest"); - expect(packument).toHaveProperty("modified"); - expect(packument).toHaveProperty("modifiedAt"); - expect(packument).toHaveProperty("versions"); - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getAbbreviatedPackument({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getAbbreviatedPackument({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); - - it("does not conflict with getPackument on cached responses", async () => { - expect.assertions(12); - - // Retrieve fresh packuments - await getPackument({ name: "short-time-ago" }); - await getAbbreviatedPackument({ name: "short-time-ago" }); - - // Retrieve cached packuments - const cachedPackument = await getPackument({ - name: "short-time-ago", - }); - const cachedAbbreviatedPackument = await getAbbreviatedPackument({ - name: "short-time-ago", - }); - - expect(cachedPackument).toMatchSnapshot(); - expect(cachedPackument).toHaveProperty("_id"); - expect(cachedPackument).toHaveProperty("_rev"); - expect(cachedPackument).toHaveProperty("time"); - expect(cachedPackument).not.toHaveProperty("modified"); - expect(cachedPackument).not.toHaveProperty("modifiedAt"); - - expect(cachedAbbreviatedPackument).toMatchSnapshot(); - expect(cachedAbbreviatedPackument).not.toHaveProperty("_id"); - expect(cachedAbbreviatedPackument).not.toHaveProperty("_rev"); - expect(cachedAbbreviatedPackument).not.toHaveProperty("time"); - expect(cachedAbbreviatedPackument).toHaveProperty("modified"); - expect(cachedAbbreviatedPackument).toHaveProperty("modifiedAt"); - }); -}); diff --git a/old/test/endpoints/get-daily-package-downloads.test.ts b/old/test/endpoints/get-daily-package-downloads.test.ts deleted file mode 100644 index b865ae0..0000000 --- a/old/test/endpoints/get-daily-package-downloads.test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { FetchError, getDailyPackageDownloads, InvalidPackageNameError } from "../../src/index.old"; - -describe("getDailyPackageDownloads", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the weekly downloads for `short-time-ago`", async () => { - expect.assertions(8); - - const downloads = await getDailyPackageDownloads({ - name: "short-time-ago", - }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the monthly downloads for `short-time-ago`", async () => { - expect.assertions(8); - - const downloads = await getDailyPackageDownloads({ - name: "short-time-ago", - period: "last-month", - }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads on a given day for `short-time-ago`", async () => { - expect.assertions(8); - - const downloads = await getDailyPackageDownloads({ - name: "short-time-ago", - period: new Date("2021-01-01"), - }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads for a given time period for `short-time-ago`", async () => { - expect.assertions(8); - - const downloads = await getDailyPackageDownloads({ - name: "short-time-ago", - period: { - start: new Date("2021-01-01"), - end: new Date("2021-01-02"), - }, - }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("supports a custom registry downloads API", async () => { - expect.assertions(1); - - try { - await getDailyPackageDownloads({ - name: "short-time-ago", - registryDownloadsAPI: "https://example.com", - }); - } catch (err) { - expect(err).toBeDefined(); - } - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getDailyPackageDownloads({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getDailyPackageDownloads({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); -}); diff --git a/old/test/endpoints/get-daily-registry-downloads.test.ts b/old/test/endpoints/get-daily-registry-downloads.test.ts deleted file mode 100644 index 345dc64..0000000 --- a/old/test/endpoints/get-daily-registry-downloads.test.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { getDailyRegistryDownloads } from "../../src/index.old"; - -describe("getDailyRegistryDownloads", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the weekly downloads for the npm registry", async () => { - expect.assertions(7); - - const downloads = await getDailyRegistryDownloads(); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the monthly downloads for the npm registry", async () => { - expect.assertions(7); - - const downloads = await getDailyRegistryDownloads({ - period: "last-month", - }); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads on a given day for the npm registry", async () => { - expect.assertions(7); - - const downloads = await getDailyRegistryDownloads({ - period: new Date("2021-01-01"), - }); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads for a given time period for the npm registry", async () => { - expect.assertions(7); - - const downloads = await getDailyRegistryDownloads({ - period: { - start: new Date("2021-01-01"), - end: new Date("2021-01-02"), - }, - }); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads[0]!.downloads).toEqual("number"); - expect(typeof downloads.downloads[0]!.day).toEqual("string"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("supports a custom registry downloads API", async () => { - expect.assertions(1); - - try { - await getDailyRegistryDownloads({ - registryDownloadsAPI: "https://example.com", - }); - } catch (err) { - expect(err).toBeDefined(); - } - }); -}); diff --git a/old/test/endpoints/get-package-downloads.test.ts b/old/test/endpoints/get-package-downloads.test.ts deleted file mode 100644 index 1a9e114..0000000 --- a/old/test/endpoints/get-package-downloads.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { FetchError, getPackageDownloads, InvalidPackageNameError } from "../../src/index.old"; - -describe("getPackageDownloads", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the weekly downloads for `short-time-ago`", async () => { - expect.assertions(7); - - const downloads = await getPackageDownloads({ name: "short-time-ago" }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the monthly downloads for `short-time-ago`", async () => { - expect.assertions(7); - - const downloads = await getPackageDownloads({ - name: "short-time-ago", - period: "last-month", - }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads on a given day for `short-time-ago`", async () => { - expect.assertions(7); - - const downloads = await getPackageDownloads({ - name: "short-time-ago", - period: new Date("2021-01-01"), - }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads for a given time period for `short-time-ago`", async () => { - expect.assertions(7); - - const downloads = await getPackageDownloads({ - name: "short-time-ago", - period: { - start: new Date("2021-01-01"), - end: new Date("2021-01-02"), - }, - }); - expect(downloads).toHaveProperty("package", "short-time-ago"); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("supports a custom registry downloads API", async () => { - expect.assertions(1); - - try { - await getPackageDownloads({ - name: "short-time-ago", - registryDownloadsAPI: "https://example.com", - }); - } catch (err) { - expect(err).toBeDefined(); - } - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getPackageDownloads({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getPackageDownloads({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); -}); diff --git a/old/test/endpoints/get-package-manifest.test.ts b/old/test/endpoints/get-package-manifest.test.ts deleted file mode 100644 index 35c2b3c..0000000 --- a/old/test/endpoints/get-package-manifest.test.ts +++ /dev/null @@ -1,354 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { - FetchError, - getPackageManifest, - InvalidPackageNameError, - InvalidPackageVersionError, -} from "../../src/index.old"; - -describe("getPackageManifest", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the manifest for `short-time-ago@latest`", async () => { - expect.assertions(8); - - const manifest = await getPackageManifest({ - name: "short-time-ago", - }); - expect(manifest).toMatchObject({ - name: "short-time-ago", - }); - expect(manifest).toHaveProperty("_id"); - expect(manifest).toHaveProperty("version"); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `short-time-ago@1.0.0`", async () => { - expect.assertions(8); - - const manifest = await getPackageManifest({ - name: "short-time-ago", - version: "1.0.0", - }); - expect(manifest).toMatchObject({ - _id: "short-time-ago@1.0.0", - id: "short-time-ago@1.0.0", - name: "short-time-ago", - version: "1.0.0", - createdAt: "2020-06-25T18:31:41.554Z", - license: "MIT", - gitRepository: { - type: "git", - url: "https://github.com/velut/node-short-time-ago", - directory: undefined, - }, - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("_npmUser.name", "velut"); - expect(manifest).toHaveProperty("publisher"); - expect(manifest).toHaveProperty("publisher.name", "velut"); - }); - - it("returns the manifest for `chalk@4.1.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "chalk", - version: "4.1.0", - }); - expect(manifest).toMatchObject({ - _id: "chalk@4.1.0", - id: "chalk@4.1.0", - name: "chalk", - version: "4.1.0", - gitRepository: { - type: "git", - url: "https://github.com/chalk/chalk", - directory: undefined, - }, - definitelyTypedName: undefined, - untypedName: undefined, - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `xmldoc@1.1.2`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "xmldoc", - version: "1.1.2", - }); - expect(manifest).toMatchObject({ - _id: "xmldoc@1.1.2", - id: "xmldoc@1.1.2", - name: "xmldoc", - version: "1.1.2", - gitRepository: { - type: "git", - url: "https://github.com/nfarina/xmldoc", - directory: undefined, - }, - definitelyTypedName: "@types/xmldoc", - untypedName: undefined, - license: undefined, - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `ui-devtools@0.0.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "ui-devtools", - version: "0.0.0", - }); - expect(manifest).toMatchObject({ - _id: "ui-devtools@0.0.0", - id: "ui-devtools@0.0.0", - name: "ui-devtools", - version: "0.0.0", - gitRepository: undefined, - definitelyTypedName: undefined, - untypedName: undefined, - license: undefined, - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `pug@3.0.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "pug", - version: "3.0.0", - }); - expect(manifest).toMatchObject({ - _id: "pug@3.0.0", - id: "pug@3.0.0", - name: "pug", - version: "3.0.0", - gitRepository: { - type: "git", - url: "https://github.com/pugjs/pug/tree/master/packages/pug", - directory: undefined, - }, - definitelyTypedName: "@types/pug", - untypedName: undefined, - license: "MIT", - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `Base64@1.1.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "Base64", - version: "1.1.0", - }); - expect(manifest).toMatchObject({ - _id: "Base64@1.1.0", - id: "Base64@1.1.0", - name: "Base64", - version: "1.1.0", - gitRepository: { - type: "git", - url: "https://github.com/davidchambers/Base64.js", - directory: undefined, - }, - definitelyTypedName: undefined, - untypedName: undefined, - license: "(Apache-2.0 OR WTFPL)", - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `react@17.0.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "react", - version: "17.0.0", - }); - expect(manifest).toMatchObject({ - _id: "react@17.0.0", - id: "react@17.0.0", - name: "react", - version: "17.0.0", - gitRepository: { - type: "git", - url: "https://github.com/facebook/react", - directory: "packages/react", - }, - definitelyTypedName: "@types/react", - untypedName: undefined, - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `@types/react@17.0.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "@types/react", - version: "17.0.0", - }); - expect(manifest).toMatchObject({ - _id: "@types/react@17.0.0", - id: "@types/react@17.0.0", - name: "@types/react", - version: "17.0.0", - gitRepository: { - type: "git", - url: "https://github.com/DefinitelyTyped/DefinitelyTyped", - directory: "types/react", - }, - definitelyTypedName: undefined, - untypedName: "react", - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `@types/pollyjs__core@4.3.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "@types/pollyjs__core", - version: "4.3.0", - }); - expect(manifest).toMatchObject({ - _id: "@types/pollyjs__core@4.3.0", - id: "@types/pollyjs__core@4.3.0", - name: "@types/pollyjs__core", - version: "4.3.0", - gitRepository: { - type: "git", - url: "https://github.com/DefinitelyTyped/DefinitelyTyped", - directory: "types/pollyjs__core", - }, - definitelyTypedName: undefined, - untypedName: "@pollyjs/core", - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("returns the manifest for `@types/jest-diff@24.3.0`", async () => { - expect.assertions(6); - - const manifest = await getPackageManifest({ - name: "@types/jest-diff", - version: "24.3.0", - }); - expect(manifest).toMatchObject({ - _id: "@types/jest-diff@24.3.0", - id: "@types/jest-diff@24.3.0", - name: "@types/jest-diff", - version: "24.3.0", - gitRepository: { - type: "git", - url: "https://github.com/facebook/jest/tree/master/packages/jest-diff", - directory: undefined, - }, - definitelyTypedName: undefined, - untypedName: "jest-diff", - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - expect(manifest).toHaveProperty("publisher"); - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getPackageManifest({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getPackageManifest({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); - - it("throws on non-existing package versions", async () => { - expect.assertions(2); - - try { - await getPackageManifest({ - name: "short-time-ago", - version: "0.0.0-invalid", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageVersionError).toBeTruthy(); - } - }); -}); diff --git a/old/test/endpoints/get-packument.test.ts b/old/test/endpoints/get-packument.test.ts deleted file mode 100644 index b21193c..0000000 --- a/old/test/endpoints/get-packument.test.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { FetchError, getPackument, InvalidPackageNameError } from "../../src/index.old"; - -describe("getPackument", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the packument for `short-time-ago`", async () => { - expect.assertions(9); - - const packument = await getPackument({ name: "short-time-ago" }); - expect(packument).toMatchObject({ - _id: "short-time-ago", - id: "short-time-ago", - name: "short-time-ago", - }); - expect(packument).toHaveProperty("_rev"); - expect(packument).toHaveProperty("dist-tags"); - expect(packument).toHaveProperty("dist-tags.latest"); - expect(packument).toHaveProperty("distTags"); - expect(packument).toHaveProperty("distTags.latest"); - expect(packument).toHaveProperty("time"); - expect(packument).toHaveProperty("versions"); - expect(packument).toHaveProperty("versionsToTimestamps"); - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getPackument({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getPackument({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); -}); diff --git a/old/test/endpoints/get-raw-abbreviated-packument.test.ts b/old/test/endpoints/get-raw-abbreviated-packument.test.ts deleted file mode 100644 index 7843a0e..0000000 --- a/old/test/endpoints/get-raw-abbreviated-packument.test.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { - FetchError, - getRawAbbreviatedPackument, - InvalidPackageNameError, -} from "../../src/index.old"; - -describe("getRawAbbreviatedPackument", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the packument for `short-time-ago`", async () => { - expect.assertions(5); - - const packument = await getRawAbbreviatedPackument({ - name: "short-time-ago", - }); - expect(packument).toMatchObject({ - name: "short-time-ago", - }); - expect(packument).toHaveProperty("dist-tags"); - expect(packument).toHaveProperty("dist-tags.latest"); - expect(packument).toHaveProperty("modified"); - expect(packument).toHaveProperty("versions"); - }); - - it("returns the uncached packument for `short-time-ago`", async () => { - expect.assertions(5); - - const packument = await getRawAbbreviatedPackument({ - name: "short-time-ago", - cached: false, - }); - expect(packument).toMatchObject({ - name: "short-time-ago", - }); - expect(packument).toHaveProperty("dist-tags"); - expect(packument).toHaveProperty("dist-tags.latest"); - expect(packument).toHaveProperty("modified"); - expect(packument).toHaveProperty("versions"); - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getRawAbbreviatedPackument({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getRawAbbreviatedPackument({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); -}); diff --git a/old/test/endpoints/get-raw-package-manifest.test.ts b/old/test/endpoints/get-raw-package-manifest.test.ts deleted file mode 100644 index e2f46f3..0000000 --- a/old/test/endpoints/get-raw-package-manifest.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { - FetchError, - getRawPackageManifest, - InvalidPackageNameError, - InvalidPackageVersionError, -} from "../../src/index.old"; - -describe("getRawPackageManifest", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the manifest for `short-time-ago@latest`", async () => { - expect.assertions(7); - - const manifest = await getRawPackageManifest({ - name: "short-time-ago", - }); - expect(manifest).toMatchObject({ - name: "short-time-ago", - }); - expect(manifest).toHaveProperty("_id"); - expect(manifest).toHaveProperty("version"); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - }); - - it("returns the manifest for `short-time-ago@1.0.0`", async () => { - expect.assertions(5); - - const manifest = await getRawPackageManifest({ - name: "short-time-ago", - version: "1.0.0", - }); - expect(manifest).toMatchObject({ - _id: "short-time-ago@1.0.0", - name: "short-time-ago", - version: "1.0.0", - }); - expect(manifest).toHaveProperty("dist"); - expect(manifest).toHaveProperty("dist.tarball"); - expect(manifest).toHaveProperty("dist.shasum"); - expect(manifest).toHaveProperty("_npmUser"); - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getRawPackageManifest({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getRawPackageManifest({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); - - it("throws on non-existing package versions", async () => { - expect.assertions(2); - - try { - await getRawPackageManifest({ - name: "short-time-ago", - version: "0.0.0-invalid", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageVersionError).toBeTruthy(); - } - }); -}); diff --git a/old/test/endpoints/get-raw-packument.test.ts b/old/test/endpoints/get-raw-packument.test.ts deleted file mode 100644 index d6e90e5..0000000 --- a/old/test/endpoints/get-raw-packument.test.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { FetchError, getRawPackument, InvalidPackageNameError } from "../../src/index.old"; - -describe("getRawPackument", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the packument for `short-time-ago`", async () => { - expect.assertions(6); - - const packument = await getRawPackument({ name: "short-time-ago" }); - expect(packument).toMatchObject({ - _id: "short-time-ago", - name: "short-time-ago", - }); - expect(packument).toHaveProperty("_rev"); - expect(packument).toHaveProperty("dist-tags"); - expect(packument).toHaveProperty("dist-tags.latest"); - expect(packument).toHaveProperty("time"); - expect(packument).toHaveProperty("versions"); - }); - - it("returns the uncached packument for `short-time-ago`", async () => { - expect.assertions(6); - - const packument = await getRawPackument({ - name: "short-time-ago", - cached: false, - }); - expect(packument).toMatchObject({ - _id: "short-time-ago", - name: "short-time-ago", - }); - expect(packument).toHaveProperty("_rev"); - expect(packument).toHaveProperty("dist-tags"); - expect(packument).toHaveProperty("dist-tags.latest"); - expect(packument).toHaveProperty("time"); - expect(packument).toHaveProperty("versions"); - }); - - it("throws on invalid package names", async () => { - expect.assertions(2); - - try { - await getRawPackument({ name: "" }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof InvalidPackageNameError).toBeTruthy(); - } - }); - - it("throws on non-existing packages", async () => { - expect.assertions(2); - - try { - await getRawPackument({ - name: "@velut/this-package-does-not-exist", - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); -}); diff --git a/old/test/endpoints/get-registry-downloads.test.ts b/old/test/endpoints/get-registry-downloads.test.ts deleted file mode 100644 index 99da9cb..0000000 --- a/old/test/endpoints/get-registry-downloads.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { getRegistryDownloads } from "../../src/index.old"; - -describe("getRegistryDownloads", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the weekly downloads for the npm registry", async () => { - expect.assertions(6); - - const downloads = await getRegistryDownloads(); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the monthly downloads for the npm registry", async () => { - expect.assertions(6); - - const downloads = await getRegistryDownloads({ - period: "last-month", - }); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads on a given day for the npm registry", async () => { - expect.assertions(6); - - const downloads = await getRegistryDownloads({ - period: new Date("2021-01-01"), - }); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("returns the downloads for a given time period for the npm registry", async () => { - expect.assertions(6); - - const downloads = await getRegistryDownloads({ - period: { - start: new Date("2021-01-01"), - end: new Date("2021-01-02"), - }, - }); - expect(downloads).toHaveProperty("downloads"); - expect(typeof downloads.downloads).toEqual("number"); - expect(downloads).toHaveProperty("start"); - expect(downloads).toHaveProperty("end"); - expect(typeof downloads.start).toEqual("string"); - expect(typeof downloads.end).toEqual("string"); - }); - - it("supports a custom registry downloads API", async () => { - expect.assertions(1); - - try { - await getRegistryDownloads({ - registryDownloadsAPI: "https://example.com", - }); - } catch (err) { - expect(err).toBeDefined(); - } - }); -}); diff --git a/old/test/endpoints/get-registry-metadata.disable-test.ts b/old/test/endpoints/get-registry-metadata.disable-test.ts deleted file mode 100644 index 1a610ca..0000000 --- a/old/test/endpoints/get-registry-metadata.disable-test.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { getRegistryMetadata, yarnRegistry } from "../../src/index.old"; - -describe("getRegistryMetadata", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns metadata for the npm registry", async () => { - expect.assertions(19); - - const metadata = await getRegistryMetadata(); - expect(metadata).toHaveProperty("db_name", "registry"); - expect(metadata).toHaveProperty("doc_count"); - expect(metadata).toHaveProperty("doc_del_count"); - expect(metadata).toHaveProperty("update_seq"); - expect(metadata).toHaveProperty("purge_seq"); - expect(metadata).toHaveProperty("compact_running"); - expect(metadata).toHaveProperty("disk_size"); - expect(metadata).toHaveProperty("data_size"); - expect(metadata).toHaveProperty("instance_start_time"); - expect(metadata).toHaveProperty("disk_format_version"); - expect(metadata).toHaveProperty("committed_update_seq"); - expect(metadata).toHaveProperty("compacted_seq"); - expect(metadata).toHaveProperty("uuid"); - expect(metadata).toHaveProperty("other"); - expect(metadata).toHaveProperty("other.data_size"); - expect(metadata).toHaveProperty("sizes"); - expect(metadata).toHaveProperty("sizes.file"); - expect(metadata).toHaveProperty("sizes.active"); - expect(metadata).toHaveProperty("sizes.external"); - }); - - it("returns metadata for the Yarn registry", async () => { - expect.assertions(19); - - const metadata = await getRegistryMetadata({ - registry: yarnRegistry, - }); - expect(metadata).toHaveProperty("db_name", "registry"); - expect(metadata).toHaveProperty("doc_count"); - expect(metadata).toHaveProperty("doc_del_count"); - expect(metadata).toHaveProperty("update_seq"); - expect(metadata).toHaveProperty("purge_seq"); - expect(metadata).toHaveProperty("compact_running"); - expect(metadata).toHaveProperty("disk_size"); - expect(metadata).toHaveProperty("data_size"); - expect(metadata).toHaveProperty("instance_start_time"); - expect(metadata).toHaveProperty("disk_format_version"); - expect(metadata).toHaveProperty("committed_update_seq"); - expect(metadata).toHaveProperty("compacted_seq"); - expect(metadata).toHaveProperty("uuid"); - expect(metadata).toHaveProperty("other"); - expect(metadata).toHaveProperty("other.data_size"); - expect(metadata).toHaveProperty("sizes"); - expect(metadata).toHaveProperty("sizes.file"); - expect(metadata).toHaveProperty("sizes.active"); - expect(metadata).toHaveProperty("sizes.external"); - }); -}); diff --git a/old/test/endpoints/search-packages.test.ts b/old/test/endpoints/search-packages.test.ts deleted file mode 100644 index 79a6141..0000000 --- a/old/test/endpoints/search-packages.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { searchPackages } from "../../src/index.old"; - -describe("searchPackages", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("returns the results for an empty query", async () => { - expect.assertions(3); - - const results = await searchPackages({ query: {} }); - expect(results).toMatchObject({ - objects: [], - total: 0, - }); - expect(results).toHaveProperty("time"); - expect(typeof results.time).toEqual("string"); - }); - - it("returns the results for text query `short-time-ago`", async () => { - expect.assertions(6); - - const results = await searchPackages({ - query: { text: "short-time-ago" }, - }); - expect(results).toHaveProperty("objects"); - expect(results.objects[0]!.package.name).toEqual("short-time-ago"); - expect(results).toHaveProperty("total"); - expect(typeof results.total).toEqual("number"); - expect(results).toHaveProperty("time"); - expect(typeof results.time).toEqual("string"); - }); -}); diff --git a/old/test/utils/fetch-from-registry.test.ts b/old/test/utils/fetch-from-registry.test.ts deleted file mode 100644 index a9aff63..0000000 --- a/old/test/utils/fetch-from-registry.test.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** @jest-environment setup-polly-jest/jest-environment-node */ -// See https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine?id=supported-test-runners - -import NodeHttpAdapter from "@pollyjs/adapter-node-http"; -import FSPersister from "@pollyjs/persister-fs"; -import * as path from "path"; -import { setupPolly } from "setup-polly-jest"; -import { yarnRegistry } from "../../src/data/registries"; -import { FetchError } from "../../src/utils/errors"; -import { fetchFromRegistry } from "../../src/utils/fetch-from-registry"; - -describe("fetchFromRegistry", () => { - setupPolly({ - adapters: [NodeHttpAdapter], - persister: FSPersister, - persisterOptions: { - fs: { - recordingsDir: path.resolve(__dirname, "../../__recordings__"), - }, - }, - recordFailedRequests: true, - }); - - it("fetches from mirrors if the main registry is not available", async () => { - expect.assertions(1); - - const json = await fetchFromRegistry({ - endpoint: "/short-time-ago", - registry: "https://example.com", - mirrors: [yarnRegistry], - }); - expect(json).toHaveProperty("_id", "short-time-ago"); - }); - - it("throws if data cannot be retrieved", async () => { - expect.assertions(2); - - try { - await fetchFromRegistry({ - endpoint: "/short-time-ago", - registry: "https://example.com", - mirrors: [], - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); - - it("supports registries with an included pathname", async () => { - expect.assertions(2); - - try { - await fetchFromRegistry({ - endpoint: "/short-time-ago", - registry: "https://example.com/some/path/name", - mirrors: [], - }); - } catch (err) { - expect(err).toBeDefined(); - expect(err instanceof FetchError).toBeTruthy(); - } - }); - - it("throws if registry URLs are invalid", async () => { - expect.assertions(1); - - try { - await fetchFromRegistry({ - endpoint: "/", - registry: "", - mirrors: [""], - }); - } catch (err) { - expect(err).toBeDefined(); - } - }); -}); diff --git a/old/test/utils/normalize-raw-repository.test.ts b/old/test/utils/normalize-raw-repository.test.ts deleted file mode 100644 index f1b1705..0000000 --- a/old/test/utils/normalize-raw-repository.test.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { GitRepository } from "../../src"; -import { normalizeRawRepository } from "../../src/utils/normalize-raw-repository"; - -describe("normalizeRawRepository", () => { - it("returns undefined for invalid repositories", () => { - expect(normalizeRawRepository({ rawRepository: "" })).toBeUndefined(); - expect(normalizeRawRepository({ rawRepository: "!" })).toBeUndefined(); - }); - - it("prefers the specified directory to the one in the URL", () => { - const gitRepository = normalizeRawRepository({ - rawRepository: { - type: "git", - url: "https://github.com/user/repo/tree/main/second-dir", - directory: "first-dir", - }, - }); - expect((gitRepository as GitRepository).directory).toEqual("first-dir"); - }); - - it("supports npm-style shortcuts", () => { - expect( - normalizeRawRepository({ - rawRepository: "user/repo", - }), - ).toStrictEqual({ - type: "git", - url: "https://github.com/user/repo", - directory: undefined, - }); - - expect( - normalizeRawRepository({ - rawRepository: "github:user/repo", - }), - ).toStrictEqual({ - type: "git", - url: "https://github.com/user/repo", - directory: undefined, - }); - - expect( - normalizeRawRepository({ - rawRepository: "gist:11081aaa281", - }), - ).toStrictEqual({ - type: "git", - url: "https://gist.github.com/11081aaa281", - directory: undefined, - }); - - expect( - normalizeRawRepository({ - rawRepository: "gitlab:user/repo", - }), - ).toStrictEqual({ - type: "git", - url: "https://gitlab.com/user/repo", - directory: undefined, - }); - - expect( - normalizeRawRepository({ - rawRepository: "bitbucket:user/repo", - }), - ).toStrictEqual({ - type: "git", - url: "https://bitbucket.org/user/repo", - directory: undefined, - }); - }); - - it("keeps the repository subdomain", () => { - const gitRepository = normalizeRawRepository({ - rawRepository: { - type: "git", - url: "https://git.example.com/user/repo", - }, - }); - expect(gitRepository).toMatchObject({ - type: "git", - url: "https://git.example.com/user/repo", - }); - }); -});