fast-npm-meta 0.2.2 → 0.3.1
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 +8 -2
- package/dist/index.d.cts +30 -8
- package/dist/index.d.mts +30 -8
- package/dist/index.d.ts +30 -8
- package/dist/index.mjs +8 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13,7 +13,12 @@ async function getLatestVersionBatch(packages, options = {}) {
|
|
|
13
13
|
apiEndpoint = defaultOptions.apiEndpoint,
|
|
14
14
|
fetch: fetchApi = fetch
|
|
15
15
|
} = options;
|
|
16
|
-
|
|
16
|
+
let query = [
|
|
17
|
+
options.force ? "force=true" : "",
|
|
18
|
+
options.metadata ? "metadata=true" : ""
|
|
19
|
+
].filter(Boolean).join("&");
|
|
20
|
+
if (query)
|
|
21
|
+
query = `?${query}`;
|
|
17
22
|
const data = await fetchApi(new URL(packages.join("+") + query, apiEndpoint)).then((r) => r.json());
|
|
18
23
|
if (!Array.isArray(data))
|
|
19
24
|
return [data];
|
|
@@ -30,7 +35,8 @@ async function getVersionsBatch(packages, options = {}) {
|
|
|
30
35
|
} = options;
|
|
31
36
|
let query = [
|
|
32
37
|
options.force ? "force=true" : "",
|
|
33
|
-
options.loose ? "loose=true" : ""
|
|
38
|
+
options.loose ? "loose=true" : "",
|
|
39
|
+
options.metadata ? "metadata=true" : ""
|
|
34
40
|
].filter(Boolean).join("&");
|
|
35
41
|
if (query)
|
|
36
42
|
query = `?${query}`;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,17 +3,29 @@ interface PackageManifest {
|
|
|
3
3
|
distTags: Record<string, string> & {
|
|
4
4
|
latest: string;
|
|
5
5
|
};
|
|
6
|
+
versionsMeta: Record<string, PackageVersionMeta>;
|
|
7
|
+
timeCreated: string;
|
|
8
|
+
timeModified: string;
|
|
9
|
+
lastSynced: number;
|
|
10
|
+
}
|
|
11
|
+
type Engines = Partial<Record<string, string>>;
|
|
12
|
+
interface PackageVersionMeta {
|
|
13
|
+
time?: string;
|
|
14
|
+
engines?: Engines;
|
|
15
|
+
deprecated?: string;
|
|
16
|
+
}
|
|
17
|
+
interface PackageVersionsInfo extends Pick<PackageManifest, 'name' | 'distTags' | 'lastSynced'> {
|
|
6
18
|
versions: string[];
|
|
7
|
-
|
|
19
|
+
specifier: string;
|
|
20
|
+
time: {
|
|
8
21
|
created: string;
|
|
9
22
|
modified: string;
|
|
10
|
-
}
|
|
11
|
-
lastSynced: number;
|
|
23
|
+
} & Record<string, string>;
|
|
12
24
|
}
|
|
13
|
-
interface
|
|
25
|
+
interface PackageVersionsInfoWithMetadata extends PackageManifest {
|
|
14
26
|
specifier: string;
|
|
15
27
|
}
|
|
16
|
-
interface ResolvedPackageVersion {
|
|
28
|
+
interface ResolvedPackageVersion extends Partial<PackageVersionMeta> {
|
|
17
29
|
name: string;
|
|
18
30
|
version: string | null;
|
|
19
31
|
specifier: string;
|
|
@@ -28,7 +40,7 @@ interface FetchOptions {
|
|
|
28
40
|
*/
|
|
29
41
|
fetch?: typeof fetch;
|
|
30
42
|
}
|
|
31
|
-
interface GetVersionsOptions extends FetchOptions {
|
|
43
|
+
interface GetVersionsOptions<WithMetadata extends boolean> extends FetchOptions {
|
|
32
44
|
/**
|
|
33
45
|
* By pass cache and get the latest data
|
|
34
46
|
*/
|
|
@@ -37,12 +49,20 @@ interface GetVersionsOptions extends FetchOptions {
|
|
|
37
49
|
* Include all versions that are newer than the specified version
|
|
38
50
|
*/
|
|
39
51
|
loose?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Includes metadata, this will change the return type
|
|
54
|
+
*/
|
|
55
|
+
metadata?: WithMetadata;
|
|
40
56
|
}
|
|
41
57
|
interface GetLatestVersionOptions extends FetchOptions {
|
|
42
58
|
/**
|
|
43
59
|
* By pass cache and get the latest data
|
|
44
60
|
*/
|
|
45
61
|
force?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Includes metadata
|
|
64
|
+
*/
|
|
65
|
+
metadata?: boolean;
|
|
46
66
|
}
|
|
47
67
|
declare const defaultOptions: {
|
|
48
68
|
/**
|
|
@@ -54,8 +74,10 @@ declare const defaultOptions: {
|
|
|
54
74
|
};
|
|
55
75
|
declare function getLatestVersionBatch(packages: string[], options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion[]>;
|
|
56
76
|
declare function getLatestVersion(name: string, options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion>;
|
|
57
|
-
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions): Promise<PackageVersionsInfo[]>;
|
|
58
|
-
declare function
|
|
77
|
+
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions<false>): Promise<PackageVersionsInfo[]>;
|
|
78
|
+
declare function getVersionsBatch(packages: string[], options: GetVersionsOptions<true>): Promise<PackageVersionsInfoWithMetadata[]>;
|
|
79
|
+
declare function getVersions(name: string, options?: GetVersionsOptions<false>): Promise<PackageVersionsInfo>;
|
|
80
|
+
declare function getVersions(name: string, options: GetVersionsOptions<true>): Promise<PackageVersionsInfoWithMetadata>;
|
|
59
81
|
|
|
60
82
|
declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
61
83
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -3,17 +3,29 @@ interface PackageManifest {
|
|
|
3
3
|
distTags: Record<string, string> & {
|
|
4
4
|
latest: string;
|
|
5
5
|
};
|
|
6
|
+
versionsMeta: Record<string, PackageVersionMeta>;
|
|
7
|
+
timeCreated: string;
|
|
8
|
+
timeModified: string;
|
|
9
|
+
lastSynced: number;
|
|
10
|
+
}
|
|
11
|
+
type Engines = Partial<Record<string, string>>;
|
|
12
|
+
interface PackageVersionMeta {
|
|
13
|
+
time?: string;
|
|
14
|
+
engines?: Engines;
|
|
15
|
+
deprecated?: string;
|
|
16
|
+
}
|
|
17
|
+
interface PackageVersionsInfo extends Pick<PackageManifest, 'name' | 'distTags' | 'lastSynced'> {
|
|
6
18
|
versions: string[];
|
|
7
|
-
|
|
19
|
+
specifier: string;
|
|
20
|
+
time: {
|
|
8
21
|
created: string;
|
|
9
22
|
modified: string;
|
|
10
|
-
}
|
|
11
|
-
lastSynced: number;
|
|
23
|
+
} & Record<string, string>;
|
|
12
24
|
}
|
|
13
|
-
interface
|
|
25
|
+
interface PackageVersionsInfoWithMetadata extends PackageManifest {
|
|
14
26
|
specifier: string;
|
|
15
27
|
}
|
|
16
|
-
interface ResolvedPackageVersion {
|
|
28
|
+
interface ResolvedPackageVersion extends Partial<PackageVersionMeta> {
|
|
17
29
|
name: string;
|
|
18
30
|
version: string | null;
|
|
19
31
|
specifier: string;
|
|
@@ -28,7 +40,7 @@ interface FetchOptions {
|
|
|
28
40
|
*/
|
|
29
41
|
fetch?: typeof fetch;
|
|
30
42
|
}
|
|
31
|
-
interface GetVersionsOptions extends FetchOptions {
|
|
43
|
+
interface GetVersionsOptions<WithMetadata extends boolean> extends FetchOptions {
|
|
32
44
|
/**
|
|
33
45
|
* By pass cache and get the latest data
|
|
34
46
|
*/
|
|
@@ -37,12 +49,20 @@ interface GetVersionsOptions extends FetchOptions {
|
|
|
37
49
|
* Include all versions that are newer than the specified version
|
|
38
50
|
*/
|
|
39
51
|
loose?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Includes metadata, this will change the return type
|
|
54
|
+
*/
|
|
55
|
+
metadata?: WithMetadata;
|
|
40
56
|
}
|
|
41
57
|
interface GetLatestVersionOptions extends FetchOptions {
|
|
42
58
|
/**
|
|
43
59
|
* By pass cache and get the latest data
|
|
44
60
|
*/
|
|
45
61
|
force?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Includes metadata
|
|
64
|
+
*/
|
|
65
|
+
metadata?: boolean;
|
|
46
66
|
}
|
|
47
67
|
declare const defaultOptions: {
|
|
48
68
|
/**
|
|
@@ -54,8 +74,10 @@ declare const defaultOptions: {
|
|
|
54
74
|
};
|
|
55
75
|
declare function getLatestVersionBatch(packages: string[], options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion[]>;
|
|
56
76
|
declare function getLatestVersion(name: string, options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion>;
|
|
57
|
-
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions): Promise<PackageVersionsInfo[]>;
|
|
58
|
-
declare function
|
|
77
|
+
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions<false>): Promise<PackageVersionsInfo[]>;
|
|
78
|
+
declare function getVersionsBatch(packages: string[], options: GetVersionsOptions<true>): Promise<PackageVersionsInfoWithMetadata[]>;
|
|
79
|
+
declare function getVersions(name: string, options?: GetVersionsOptions<false>): Promise<PackageVersionsInfo>;
|
|
80
|
+
declare function getVersions(name: string, options: GetVersionsOptions<true>): Promise<PackageVersionsInfoWithMetadata>;
|
|
59
81
|
|
|
60
82
|
declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
61
83
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3,17 +3,29 @@ interface PackageManifest {
|
|
|
3
3
|
distTags: Record<string, string> & {
|
|
4
4
|
latest: string;
|
|
5
5
|
};
|
|
6
|
+
versionsMeta: Record<string, PackageVersionMeta>;
|
|
7
|
+
timeCreated: string;
|
|
8
|
+
timeModified: string;
|
|
9
|
+
lastSynced: number;
|
|
10
|
+
}
|
|
11
|
+
type Engines = Partial<Record<string, string>>;
|
|
12
|
+
interface PackageVersionMeta {
|
|
13
|
+
time?: string;
|
|
14
|
+
engines?: Engines;
|
|
15
|
+
deprecated?: string;
|
|
16
|
+
}
|
|
17
|
+
interface PackageVersionsInfo extends Pick<PackageManifest, 'name' | 'distTags' | 'lastSynced'> {
|
|
6
18
|
versions: string[];
|
|
7
|
-
|
|
19
|
+
specifier: string;
|
|
20
|
+
time: {
|
|
8
21
|
created: string;
|
|
9
22
|
modified: string;
|
|
10
|
-
}
|
|
11
|
-
lastSynced: number;
|
|
23
|
+
} & Record<string, string>;
|
|
12
24
|
}
|
|
13
|
-
interface
|
|
25
|
+
interface PackageVersionsInfoWithMetadata extends PackageManifest {
|
|
14
26
|
specifier: string;
|
|
15
27
|
}
|
|
16
|
-
interface ResolvedPackageVersion {
|
|
28
|
+
interface ResolvedPackageVersion extends Partial<PackageVersionMeta> {
|
|
17
29
|
name: string;
|
|
18
30
|
version: string | null;
|
|
19
31
|
specifier: string;
|
|
@@ -28,7 +40,7 @@ interface FetchOptions {
|
|
|
28
40
|
*/
|
|
29
41
|
fetch?: typeof fetch;
|
|
30
42
|
}
|
|
31
|
-
interface GetVersionsOptions extends FetchOptions {
|
|
43
|
+
interface GetVersionsOptions<WithMetadata extends boolean> extends FetchOptions {
|
|
32
44
|
/**
|
|
33
45
|
* By pass cache and get the latest data
|
|
34
46
|
*/
|
|
@@ -37,12 +49,20 @@ interface GetVersionsOptions extends FetchOptions {
|
|
|
37
49
|
* Include all versions that are newer than the specified version
|
|
38
50
|
*/
|
|
39
51
|
loose?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Includes metadata, this will change the return type
|
|
54
|
+
*/
|
|
55
|
+
metadata?: WithMetadata;
|
|
40
56
|
}
|
|
41
57
|
interface GetLatestVersionOptions extends FetchOptions {
|
|
42
58
|
/**
|
|
43
59
|
* By pass cache and get the latest data
|
|
44
60
|
*/
|
|
45
61
|
force?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Includes metadata
|
|
64
|
+
*/
|
|
65
|
+
metadata?: boolean;
|
|
46
66
|
}
|
|
47
67
|
declare const defaultOptions: {
|
|
48
68
|
/**
|
|
@@ -54,8 +74,10 @@ declare const defaultOptions: {
|
|
|
54
74
|
};
|
|
55
75
|
declare function getLatestVersionBatch(packages: string[], options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion[]>;
|
|
56
76
|
declare function getLatestVersion(name: string, options?: GetLatestVersionOptions): Promise<ResolvedPackageVersion>;
|
|
57
|
-
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions): Promise<PackageVersionsInfo[]>;
|
|
58
|
-
declare function
|
|
77
|
+
declare function getVersionsBatch(packages: string[], options?: GetVersionsOptions<false>): Promise<PackageVersionsInfo[]>;
|
|
78
|
+
declare function getVersionsBatch(packages: string[], options: GetVersionsOptions<true>): Promise<PackageVersionsInfoWithMetadata[]>;
|
|
79
|
+
declare function getVersions(name: string, options?: GetVersionsOptions<false>): Promise<PackageVersionsInfo>;
|
|
80
|
+
declare function getVersions(name: string, options: GetVersionsOptions<true>): Promise<PackageVersionsInfoWithMetadata>;
|
|
59
81
|
|
|
60
82
|
declare const NPM_REGISTRY = "https://registry.npmjs.org/";
|
|
61
83
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,12 @@ async function getLatestVersionBatch(packages, options = {}) {
|
|
|
11
11
|
apiEndpoint = defaultOptions.apiEndpoint,
|
|
12
12
|
fetch: fetchApi = fetch
|
|
13
13
|
} = options;
|
|
14
|
-
|
|
14
|
+
let query = [
|
|
15
|
+
options.force ? "force=true" : "",
|
|
16
|
+
options.metadata ? "metadata=true" : ""
|
|
17
|
+
].filter(Boolean).join("&");
|
|
18
|
+
if (query)
|
|
19
|
+
query = `?${query}`;
|
|
15
20
|
const data = await fetchApi(new URL(packages.join("+") + query, apiEndpoint)).then((r) => r.json());
|
|
16
21
|
if (!Array.isArray(data))
|
|
17
22
|
return [data];
|
|
@@ -28,7 +33,8 @@ async function getVersionsBatch(packages, options = {}) {
|
|
|
28
33
|
} = options;
|
|
29
34
|
let query = [
|
|
30
35
|
options.force ? "force=true" : "",
|
|
31
|
-
options.loose ? "loose=true" : ""
|
|
36
|
+
options.loose ? "loose=true" : "",
|
|
37
|
+
options.metadata ? "metadata=true" : ""
|
|
32
38
|
].filter(Boolean).join("&");
|
|
33
39
|
if (query)
|
|
34
40
|
query = `?${query}`;
|