fast-npm-meta 0.1.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -1
- package/dist/index.d.cts +31 -8
- package/dist/index.d.mts +31 -8
- package/dist/index.d.ts +31 -8
- package/dist/index.mjs +6 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,12 @@ async function getVersionsBatch(packages, options = {}) {
|
|
|
28
28
|
apiEndpoint = defaultOptions.apiEndpoint,
|
|
29
29
|
fetch: fetchApi = fetch
|
|
30
30
|
} = options;
|
|
31
|
-
|
|
31
|
+
let query = [
|
|
32
|
+
options.force ? "force=true" : "",
|
|
33
|
+
options.loose ? "loose=true" : ""
|
|
34
|
+
].filter(Boolean).join("&");
|
|
35
|
+
if (query)
|
|
36
|
+
query = `?${query}`;
|
|
32
37
|
const data = await fetchApi(new URL(`/versions/${packages.join("+")}${query}`, apiEndpoint)).then((r) => r.json());
|
|
33
38
|
if (!Array.isArray(data))
|
|
34
39
|
return [data];
|
package/dist/index.d.cts
CHANGED
|
@@ -4,23 +4,46 @@ interface PackageManifest {
|
|
|
4
4
|
latest: string;
|
|
5
5
|
};
|
|
6
6
|
versions: string[];
|
|
7
|
+
time: Record<string, string> & {
|
|
8
|
+
created: string;
|
|
9
|
+
modified: string;
|
|
10
|
+
};
|
|
7
11
|
lastSynced: number;
|
|
8
12
|
}
|
|
13
|
+
interface PackageVersionsInfo extends PackageManifest {
|
|
14
|
+
specifier: string;
|
|
15
|
+
}
|
|
9
16
|
interface ResolvedPackageVersion {
|
|
10
17
|
name: string;
|
|
11
18
|
version: string | null;
|
|
12
19
|
specifier: string;
|
|
13
|
-
|
|
20
|
+
publishedAt: string | null;
|
|
21
|
+
lastSynced: number;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
interface
|
|
17
|
-
force?: boolean;
|
|
24
|
+
interface FetchOptions {
|
|
18
25
|
apiEndpoint?: string;
|
|
19
26
|
/**
|
|
20
27
|
* Fetch function
|
|
21
28
|
*/
|
|
22
29
|
fetch?: typeof fetch;
|
|
23
30
|
}
|
|
31
|
+
interface GetVersionsOptions extends FetchOptions {
|
|
32
|
+
/**
|
|
33
|
+
* By pass cache and get the latest data
|
|
34
|
+
*/
|
|
35
|
+
force?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Include all versions that are newer than the specified version
|
|
38
|
+
*/
|
|
39
|
+
loose?: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface GetLatestVersionOptions extends FetchOptions {
|
|
42
|
+
/**
|
|
43
|
+
* By pass cache and get the latest data
|
|
44
|
+
*/
|
|
45
|
+
force?: boolean;
|
|
46
|
+
}
|
|
24
47
|
declare const defaultOptions: {
|
|
25
48
|
/**
|
|
26
49
|
* API endpoint for fetching package versions
|
|
@@ -29,10 +52,10 @@ declare const defaultOptions: {
|
|
|
29
52
|
*/
|
|
30
53
|
apiEndpoint: string;
|
|
31
54
|
};
|
|
32
|
-
declare function getLatestVersionBatch(packages: string[], options?:
|
|
33
|
-
declare function getLatestVersion(name: string, options?:
|
|
34
|
-
declare function getVersionsBatch(packages: string[], options?:
|
|
35
|
-
declare function getVersions(name: string, options?:
|
|
55
|
+
declare function getLatestVersionBatch(packages: string[], options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion[]>;
|
|
56
|
+
declare function getLatestVersion(name: string, options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion>;
|
|
57
|
+
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions): Promise<PackageVersionsInfo[]>;
|
|
58
|
+
declare function getVersions(name: string, options?: GetVersionsOptions): Promise<PackageVersionsInfo>;
|
|
36
59
|
|
|
37
60
|
declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
38
61
|
/**
|
|
@@ -44,4 +67,4 @@ declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
|
44
67
|
*/
|
|
45
68
|
declare function pickRegistry(scope: string | null | undefined, npmConfigs: Record<string, unknown>, defaultRegistry?: string): string;
|
|
46
69
|
|
|
47
|
-
export { type
|
|
70
|
+
export { type FetchOptions, type GetLatestVersionOptions, type GetVersionsOptions, NPM_REGISTRY, type PackageManifest, type ResolvedPackageVersion, defaultOptions, getLatestVersion, getLatestVersionBatch, getVersions, getVersionsBatch, pickRegistry };
|
package/dist/index.d.mts
CHANGED
|
@@ -4,23 +4,46 @@ interface PackageManifest {
|
|
|
4
4
|
latest: string;
|
|
5
5
|
};
|
|
6
6
|
versions: string[];
|
|
7
|
+
time: Record<string, string> & {
|
|
8
|
+
created: string;
|
|
9
|
+
modified: string;
|
|
10
|
+
};
|
|
7
11
|
lastSynced: number;
|
|
8
12
|
}
|
|
13
|
+
interface PackageVersionsInfo extends PackageManifest {
|
|
14
|
+
specifier: string;
|
|
15
|
+
}
|
|
9
16
|
interface ResolvedPackageVersion {
|
|
10
17
|
name: string;
|
|
11
18
|
version: string | null;
|
|
12
19
|
specifier: string;
|
|
13
|
-
|
|
20
|
+
publishedAt: string | null;
|
|
21
|
+
lastSynced: number;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
interface
|
|
17
|
-
force?: boolean;
|
|
24
|
+
interface FetchOptions {
|
|
18
25
|
apiEndpoint?: string;
|
|
19
26
|
/**
|
|
20
27
|
* Fetch function
|
|
21
28
|
*/
|
|
22
29
|
fetch?: typeof fetch;
|
|
23
30
|
}
|
|
31
|
+
interface GetVersionsOptions extends FetchOptions {
|
|
32
|
+
/**
|
|
33
|
+
* By pass cache and get the latest data
|
|
34
|
+
*/
|
|
35
|
+
force?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Include all versions that are newer than the specified version
|
|
38
|
+
*/
|
|
39
|
+
loose?: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface GetLatestVersionOptions extends FetchOptions {
|
|
42
|
+
/**
|
|
43
|
+
* By pass cache and get the latest data
|
|
44
|
+
*/
|
|
45
|
+
force?: boolean;
|
|
46
|
+
}
|
|
24
47
|
declare const defaultOptions: {
|
|
25
48
|
/**
|
|
26
49
|
* API endpoint for fetching package versions
|
|
@@ -29,10 +52,10 @@ declare const defaultOptions: {
|
|
|
29
52
|
*/
|
|
30
53
|
apiEndpoint: string;
|
|
31
54
|
};
|
|
32
|
-
declare function getLatestVersionBatch(packages: string[], options?:
|
|
33
|
-
declare function getLatestVersion(name: string, options?:
|
|
34
|
-
declare function getVersionsBatch(packages: string[], options?:
|
|
35
|
-
declare function getVersions(name: string, options?:
|
|
55
|
+
declare function getLatestVersionBatch(packages: string[], options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion[]>;
|
|
56
|
+
declare function getLatestVersion(name: string, options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion>;
|
|
57
|
+
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions): Promise<PackageVersionsInfo[]>;
|
|
58
|
+
declare function getVersions(name: string, options?: GetVersionsOptions): Promise<PackageVersionsInfo>;
|
|
36
59
|
|
|
37
60
|
declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
38
61
|
/**
|
|
@@ -44,4 +67,4 @@ declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
|
44
67
|
*/
|
|
45
68
|
declare function pickRegistry(scope: string | null | undefined, npmConfigs: Record<string, unknown>, defaultRegistry?: string): string;
|
|
46
69
|
|
|
47
|
-
export { type
|
|
70
|
+
export { type FetchOptions, type GetLatestVersionOptions, type GetVersionsOptions, NPM_REGISTRY, type PackageManifest, type ResolvedPackageVersion, defaultOptions, getLatestVersion, getLatestVersionBatch, getVersions, getVersionsBatch, pickRegistry };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,23 +4,46 @@ interface PackageManifest {
|
|
|
4
4
|
latest: string;
|
|
5
5
|
};
|
|
6
6
|
versions: string[];
|
|
7
|
+
time: Record<string, string> & {
|
|
8
|
+
created: string;
|
|
9
|
+
modified: string;
|
|
10
|
+
};
|
|
7
11
|
lastSynced: number;
|
|
8
12
|
}
|
|
13
|
+
interface PackageVersionsInfo extends PackageManifest {
|
|
14
|
+
specifier: string;
|
|
15
|
+
}
|
|
9
16
|
interface ResolvedPackageVersion {
|
|
10
17
|
name: string;
|
|
11
18
|
version: string | null;
|
|
12
19
|
specifier: string;
|
|
13
|
-
|
|
20
|
+
publishedAt: string | null;
|
|
21
|
+
lastSynced: number;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
interface
|
|
17
|
-
force?: boolean;
|
|
24
|
+
interface FetchOptions {
|
|
18
25
|
apiEndpoint?: string;
|
|
19
26
|
/**
|
|
20
27
|
* Fetch function
|
|
21
28
|
*/
|
|
22
29
|
fetch?: typeof fetch;
|
|
23
30
|
}
|
|
31
|
+
interface GetVersionsOptions extends FetchOptions {
|
|
32
|
+
/**
|
|
33
|
+
* By pass cache and get the latest data
|
|
34
|
+
*/
|
|
35
|
+
force?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Include all versions that are newer than the specified version
|
|
38
|
+
*/
|
|
39
|
+
loose?: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface GetLatestVersionOptions extends FetchOptions {
|
|
42
|
+
/**
|
|
43
|
+
* By pass cache and get the latest data
|
|
44
|
+
*/
|
|
45
|
+
force?: boolean;
|
|
46
|
+
}
|
|
24
47
|
declare const defaultOptions: {
|
|
25
48
|
/**
|
|
26
49
|
* API endpoint for fetching package versions
|
|
@@ -29,10 +52,10 @@ declare const defaultOptions: {
|
|
|
29
52
|
*/
|
|
30
53
|
apiEndpoint: string;
|
|
31
54
|
};
|
|
32
|
-
declare function getLatestVersionBatch(packages: string[], options?:
|
|
33
|
-
declare function getLatestVersion(name: string, options?:
|
|
34
|
-
declare function getVersionsBatch(packages: string[], options?:
|
|
35
|
-
declare function getVersions(name: string, options?:
|
|
55
|
+
declare function getLatestVersionBatch(packages: string[], options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion[]>;
|
|
56
|
+
declare function getLatestVersion(name: string, options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion>;
|
|
57
|
+
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions): Promise<PackageVersionsInfo[]>;
|
|
58
|
+
declare function getVersions(name: string, options?: GetVersionsOptions): Promise<PackageVersionsInfo>;
|
|
36
59
|
|
|
37
60
|
declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
38
61
|
/**
|
|
@@ -44,4 +67,4 @@ declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
|
44
67
|
*/
|
|
45
68
|
declare function pickRegistry(scope: string | null | undefined, npmConfigs: Record<string, unknown>, defaultRegistry?: string): string;
|
|
46
69
|
|
|
47
|
-
export { type
|
|
70
|
+
export { type FetchOptions, type GetLatestVersionOptions, type GetVersionsOptions, NPM_REGISTRY, type PackageManifest, type ResolvedPackageVersion, defaultOptions, getLatestVersion, getLatestVersionBatch, getVersions, getVersionsBatch, pickRegistry };
|
package/dist/index.mjs
CHANGED
|
@@ -26,7 +26,12 @@ async function getVersionsBatch(packages, options = {}) {
|
|
|
26
26
|
apiEndpoint = defaultOptions.apiEndpoint,
|
|
27
27
|
fetch: fetchApi = fetch
|
|
28
28
|
} = options;
|
|
29
|
-
|
|
29
|
+
let query = [
|
|
30
|
+
options.force ? "force=true" : "",
|
|
31
|
+
options.loose ? "loose=true" : ""
|
|
32
|
+
].filter(Boolean).join("&");
|
|
33
|
+
if (query)
|
|
34
|
+
query = `?${query}`;
|
|
30
35
|
const data = await fetchApi(new URL(`/versions/${packages.join("+")}${query}`, apiEndpoint)).then((r) => r.json());
|
|
31
36
|
if (!Array.isArray(data))
|
|
32
37
|
return [data];
|