crates.io 2.4.7 → 2.5.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/README.md +8 -0
- package/dist/CratesIO.js +2 -2
- package/dist/Endpoints.d.ts +18 -0
- package/dist/Endpoints.js +51 -14
- package/dist/api/CratesAPI.d.ts +56 -4
- package/dist/api/CratesAPI.js +152 -0
- package/dist/interfaces/Crate.d.ts +6 -8
- package/dist/interfaces/Keyword.d.ts +1 -1
- package/dist/interfaces/Options.d.ts +10 -0
- package/dist/interfaces/Result.d.ts +27 -2
- package/dist/interfaces/Team.d.ts +6 -0
- package/dist/interfaces/User.d.ts +1 -1
- package/dist/interfaces/Version.d.ts +2 -1
- package/package.json +13 -7
package/README.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
A [crates.io](https://crates.io) API client.
|
|
4
4
|
|
|
5
|
+
API references:
|
|
6
|
+
|
|
7
|
+
- [Data access policy](https://crates.io/data-access)
|
|
8
|
+
- [OpenAPI specification](https://crates.io/api/openapi.json)
|
|
9
|
+
- [Historical HTTP API reference](https://github.com/hcpl/crates.io-http-api-reference)
|
|
10
|
+
|
|
11
|
+
Some endpoints in this client require an API token (for example `following`, `follow`, `unfollow`, `yank`, and `unyank`).
|
|
12
|
+
|
|
5
13
|
### Installation
|
|
6
14
|
|
|
7
15
|
Run `yarn add crates.io` or `npm install crates.io`.
|
package/dist/CratesIO.js
CHANGED
|
@@ -16,9 +16,9 @@ const Endpoints_1 = require("./Endpoints");
|
|
|
16
16
|
class CratesIO {
|
|
17
17
|
constructor(options) {
|
|
18
18
|
this.options = typeof options === 'string' ? { apiKey: options } : options || {};
|
|
19
|
-
this.apiClient = new api_client_1.APIClient('https://crates.io/api/v1');
|
|
19
|
+
this.apiClient = new api_client_1.APIClient(this.options.apiUrl || 'https://crates.io/api/v1');
|
|
20
20
|
this.api = {
|
|
21
|
-
crates: new api_1.CratesAPI(this.apiClient),
|
|
21
|
+
crates: new api_1.CratesAPI(this.apiClient, this.options.apiKey),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
/**
|
package/dist/Endpoints.d.ts
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
1
|
export declare const Endpoint: {
|
|
2
2
|
AUTHORS: string;
|
|
3
|
+
CATEGORIES: string;
|
|
4
|
+
Categories: {
|
|
5
|
+
categories(): string;
|
|
6
|
+
category(category: string): string;
|
|
7
|
+
};
|
|
3
8
|
CRATES: string;
|
|
4
9
|
Crates: {
|
|
5
10
|
authors(packageName: string, version: string): string;
|
|
6
11
|
crate(packageName: string): string;
|
|
7
12
|
crates(): string;
|
|
8
13
|
dependencies(packageName: string): string;
|
|
14
|
+
dependenciesByVersion(packageName: string, version: string): string;
|
|
9
15
|
download(packageName: string, version: string): string;
|
|
10
16
|
downloads(packageName: string): string;
|
|
17
|
+
follow(packageName: string): string;
|
|
11
18
|
following(packageName: string): string;
|
|
12
19
|
owners(packageName: string): string;
|
|
13
20
|
ownerTeam(packageName: string): string;
|
|
14
21
|
ownerUser(packageName: string): string;
|
|
15
22
|
reverseDependencies(packageName: string): string;
|
|
23
|
+
unyank(packageName: string, version: string): string;
|
|
16
24
|
version(packageName: string, version: string): string;
|
|
25
|
+
versionDownloads(packageName: string, version: string): string;
|
|
17
26
|
versions(packageName: string): string;
|
|
27
|
+
yank(packageName: string, version: string): string;
|
|
18
28
|
};
|
|
19
29
|
DEPENDENCIES: string;
|
|
20
30
|
DOWNLOAD: string;
|
|
21
31
|
DOWNLOADS: string;
|
|
32
|
+
FOLLOW: string;
|
|
22
33
|
FOLLOWING: string;
|
|
34
|
+
KEYWORDS: string;
|
|
35
|
+
Keywords: {
|
|
36
|
+
keyword(keyword: string): string;
|
|
37
|
+
keywords(): string;
|
|
38
|
+
};
|
|
23
39
|
OWNER_TEAM: string;
|
|
24
40
|
OWNER_USER: string;
|
|
25
41
|
OWNERS: string;
|
|
26
42
|
REVERSE_DEPENDENCIES: string;
|
|
27
43
|
SUMMARY: string;
|
|
28
44
|
summary(): string;
|
|
45
|
+
UNYANK: string;
|
|
29
46
|
VERSIONS: string;
|
|
47
|
+
YANK: string;
|
|
30
48
|
};
|
package/dist/Endpoints.js
CHANGED
|
@@ -2,61 +2,98 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Endpoint = void 0;
|
|
4
4
|
const encode = encodeURIComponent;
|
|
5
|
+
const apiPrefix = '/api/v1';
|
|
5
6
|
exports.Endpoint = {
|
|
6
7
|
AUTHORS: 'authors',
|
|
8
|
+
CATEGORIES: 'categories',
|
|
9
|
+
Categories: {
|
|
10
|
+
categories() {
|
|
11
|
+
return `${apiPrefix}/${exports.Endpoint.CATEGORIES}`;
|
|
12
|
+
},
|
|
13
|
+
category(category) {
|
|
14
|
+
return `${apiPrefix}/${exports.Endpoint.CATEGORIES}/${encode(category)}`;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
7
17
|
CRATES: 'crates',
|
|
8
18
|
Crates: {
|
|
9
19
|
authors(packageName, version) {
|
|
10
|
-
return
|
|
20
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.AUTHORS}`;
|
|
11
21
|
},
|
|
12
22
|
crate(packageName) {
|
|
13
|
-
return
|
|
23
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}`;
|
|
14
24
|
},
|
|
15
25
|
crates() {
|
|
16
|
-
return
|
|
26
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}`;
|
|
17
27
|
},
|
|
18
28
|
dependencies(packageName) {
|
|
19
|
-
return
|
|
29
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.DEPENDENCIES}`;
|
|
30
|
+
},
|
|
31
|
+
dependenciesByVersion(packageName, version) {
|
|
32
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.DEPENDENCIES}`;
|
|
20
33
|
},
|
|
21
34
|
download(packageName, version) {
|
|
22
|
-
return
|
|
35
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.DOWNLOAD}`;
|
|
23
36
|
},
|
|
24
37
|
downloads(packageName) {
|
|
25
|
-
return
|
|
38
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.DOWNLOADS}`;
|
|
39
|
+
},
|
|
40
|
+
follow(packageName) {
|
|
41
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.FOLLOW}`;
|
|
26
42
|
},
|
|
27
43
|
following(packageName) {
|
|
28
|
-
return
|
|
44
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.FOLLOWING}`;
|
|
29
45
|
},
|
|
30
46
|
owners(packageName) {
|
|
31
|
-
return
|
|
47
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.OWNERS}`;
|
|
32
48
|
},
|
|
33
49
|
ownerTeam(packageName) {
|
|
34
|
-
return
|
|
50
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.OWNER_TEAM}`;
|
|
35
51
|
},
|
|
36
52
|
ownerUser(packageName) {
|
|
37
|
-
return
|
|
53
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.OWNER_USER}`;
|
|
38
54
|
},
|
|
39
55
|
reverseDependencies(packageName) {
|
|
40
|
-
return
|
|
56
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.REVERSE_DEPENDENCIES}`;
|
|
57
|
+
},
|
|
58
|
+
unyank(packageName, version) {
|
|
59
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.UNYANK}`;
|
|
41
60
|
},
|
|
42
61
|
version(packageName, version) {
|
|
43
|
-
return
|
|
62
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}`;
|
|
63
|
+
},
|
|
64
|
+
versionDownloads(packageName, version) {
|
|
65
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.DOWNLOADS}`;
|
|
44
66
|
},
|
|
45
67
|
versions(packageName) {
|
|
46
|
-
return
|
|
68
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.VERSIONS}`;
|
|
69
|
+
},
|
|
70
|
+
yank(packageName, version) {
|
|
71
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.YANK}`;
|
|
47
72
|
},
|
|
48
73
|
},
|
|
49
74
|
DEPENDENCIES: 'dependencies',
|
|
50
75
|
DOWNLOAD: 'download',
|
|
51
76
|
DOWNLOADS: 'downloads',
|
|
77
|
+
FOLLOW: 'follow',
|
|
52
78
|
FOLLOWING: 'following',
|
|
79
|
+
KEYWORDS: 'keywords',
|
|
80
|
+
Keywords: {
|
|
81
|
+
keyword(keyword) {
|
|
82
|
+
return `${apiPrefix}/${exports.Endpoint.KEYWORDS}/${encode(keyword)}`;
|
|
83
|
+
},
|
|
84
|
+
keywords() {
|
|
85
|
+
return `${apiPrefix}/${exports.Endpoint.KEYWORDS}`;
|
|
86
|
+
},
|
|
87
|
+
},
|
|
53
88
|
OWNER_TEAM: 'owner_team',
|
|
54
89
|
OWNER_USER: 'owner_user',
|
|
55
90
|
OWNERS: 'owners',
|
|
56
91
|
REVERSE_DEPENDENCIES: 'reverse_dependencies',
|
|
57
92
|
SUMMARY: 'summary',
|
|
58
93
|
summary() {
|
|
59
|
-
return
|
|
94
|
+
return `${apiPrefix}/${exports.Endpoint.SUMMARY}`;
|
|
60
95
|
},
|
|
96
|
+
UNYANK: 'unyank',
|
|
61
97
|
VERSIONS: 'versions',
|
|
98
|
+
YANK: 'yank',
|
|
62
99
|
};
|
package/dist/api/CratesAPI.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { APIClient } from '@ffflorian/api-client';
|
|
2
|
-
import type { AuthorsResult, CrateResult, DependenciesResult, DownloadsResult, FollowingResult, ReverseDependenciesResult, SearchOptions, SearchResult, TeamsResult, UrlResult, UsersResult, Version } from '../interfaces/';
|
|
2
|
+
import type { AuthorsResult, CategoriesResult, CategoryResult, CrateResult, DependenciesResult, DownloadsResult, FollowingResult, KeywordResult, KeywordsResult, OkResult, PaginationOptions, ReverseDependenciesResult, SearchOptions, SearchResult, TeamsResult, UrlResult, UsersResult, Version, VersionsResult } from '../interfaces/';
|
|
3
3
|
export declare class CratesAPI {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
private apiKey?;
|
|
6
6
|
constructor(apiClient: APIClient, apiKey?: string);
|
|
7
|
+
/**
|
|
8
|
+
* Follow a crate.
|
|
9
|
+
* @param packageName The package name
|
|
10
|
+
*/
|
|
11
|
+
follow(packageName: string): Promise<OkResult>;
|
|
7
12
|
/**
|
|
8
13
|
* Retrieve the owners of a crate.
|
|
9
14
|
* @param packageName The package name
|
|
@@ -14,6 +19,16 @@ export declare class CratesAPI {
|
|
|
14
19
|
* @param packageName The package name
|
|
15
20
|
*/
|
|
16
21
|
getAuthors(packageName: string, version: string): Promise<AuthorsResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve categories.
|
|
24
|
+
* @param options Pagination options
|
|
25
|
+
*/
|
|
26
|
+
getCategories(options?: PaginationOptions): Promise<CategoriesResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieve a category.
|
|
29
|
+
* @param category The category slug
|
|
30
|
+
*/
|
|
31
|
+
getCategory(category: string): Promise<CategoryResult>;
|
|
17
32
|
/**
|
|
18
33
|
* Retrieve information of a crate.
|
|
19
34
|
* @param packageName The package name
|
|
@@ -40,6 +55,16 @@ export declare class CratesAPI {
|
|
|
40
55
|
* @param packageName The package name
|
|
41
56
|
*/
|
|
42
57
|
getDownloadUrl(packageName: string, version: string): Promise<UrlResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve a keyword.
|
|
60
|
+
* @param keyword The keyword
|
|
61
|
+
*/
|
|
62
|
+
getKeyword(keyword: string): Promise<KeywordResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Retrieve keywords.
|
|
65
|
+
* @param options Pagination options
|
|
66
|
+
*/
|
|
67
|
+
getKeywords(options?: PaginationOptions): Promise<KeywordsResult>;
|
|
43
68
|
/**
|
|
44
69
|
* Retrieve the owners of a crate.
|
|
45
70
|
* @param packageName The package name
|
|
@@ -65,16 +90,43 @@ export declare class CratesAPI {
|
|
|
65
90
|
* @param packageName The package name
|
|
66
91
|
*/
|
|
67
92
|
getVersion(packageName: string, version: string): Promise<Version>;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve the dependencies of a specific crate version.
|
|
95
|
+
* @param packageName The package name
|
|
96
|
+
* @param version The version
|
|
97
|
+
*/
|
|
98
|
+
getVersionDependencies(packageName: string, version: string): Promise<DependenciesResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieve download stats for a specific crate version.
|
|
101
|
+
* @param packageName The package name
|
|
102
|
+
* @param version The version
|
|
103
|
+
*/
|
|
104
|
+
getVersionDownloads(packageName: string, version: string): Promise<DownloadsResult>;
|
|
68
105
|
/**
|
|
69
106
|
* Retrieve all versions of a crate.
|
|
70
107
|
* @param packageName The package name
|
|
71
108
|
*/
|
|
72
|
-
getVersions(packageName: string): Promise<
|
|
73
|
-
versions: Version[];
|
|
74
|
-
}>;
|
|
109
|
+
getVersions(packageName: string): Promise<VersionsResult>;
|
|
75
110
|
/**
|
|
76
111
|
* Set a new API key.
|
|
77
112
|
* @param apiKey The API key
|
|
78
113
|
*/
|
|
79
114
|
setApiKey(apiKey: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Unfollow a crate.
|
|
117
|
+
* @param packageName The package name
|
|
118
|
+
*/
|
|
119
|
+
unfollow(packageName: string): Promise<OkResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Unyank a specific crate version.
|
|
122
|
+
* @param packageName The package name
|
|
123
|
+
* @param version The version
|
|
124
|
+
*/
|
|
125
|
+
unyank(packageName: string, version: string): Promise<OkResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Yank a specific crate version.
|
|
128
|
+
* @param packageName The package name
|
|
129
|
+
* @param version The version
|
|
130
|
+
*/
|
|
131
|
+
yank(packageName: string, version: string): Promise<OkResult>;
|
|
80
132
|
}
|
package/dist/api/CratesAPI.js
CHANGED
|
@@ -16,6 +16,25 @@ class CratesAPI {
|
|
|
16
16
|
this.apiClient = apiClient;
|
|
17
17
|
this.apiKey = apiKey;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Follow a crate.
|
|
21
|
+
* @param packageName The package name
|
|
22
|
+
*/
|
|
23
|
+
follow(packageName) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const endpoint = Endpoints_1.Endpoint.Crates.follow(packageName);
|
|
26
|
+
if (!this.apiKey) {
|
|
27
|
+
throw new Error('You need to set an API key to use this endpoint.');
|
|
28
|
+
}
|
|
29
|
+
const additionalConfig = {
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: this.apiKey,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const { data } = yield this.apiClient.put(endpoint, undefined, additionalConfig);
|
|
35
|
+
return data;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
19
38
|
/**
|
|
20
39
|
* Retrieve the owners of a crate.
|
|
21
40
|
* @param packageName The package name
|
|
@@ -46,6 +65,31 @@ class CratesAPI {
|
|
|
46
65
|
return data;
|
|
47
66
|
});
|
|
48
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Retrieve categories.
|
|
70
|
+
* @param options Pagination options
|
|
71
|
+
*/
|
|
72
|
+
getCategories(options) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const endpoint = Endpoints_1.Endpoint.Categories.categories();
|
|
75
|
+
const additionalConfig = {
|
|
76
|
+
params: Object.assign({}, options),
|
|
77
|
+
};
|
|
78
|
+
const { data } = yield this.apiClient.get(endpoint, additionalConfig);
|
|
79
|
+
return data;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieve a category.
|
|
84
|
+
* @param category The category slug
|
|
85
|
+
*/
|
|
86
|
+
getCategory(category) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const endpoint = Endpoints_1.Endpoint.Categories.category(category);
|
|
89
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
90
|
+
return data;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
49
93
|
/**
|
|
50
94
|
* Retrieve information of a crate.
|
|
51
95
|
* @param packageName The package name
|
|
@@ -107,6 +151,31 @@ class CratesAPI {
|
|
|
107
151
|
return data;
|
|
108
152
|
});
|
|
109
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Retrieve a keyword.
|
|
156
|
+
* @param keyword The keyword
|
|
157
|
+
*/
|
|
158
|
+
getKeyword(keyword) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
const endpoint = Endpoints_1.Endpoint.Keywords.keyword(keyword);
|
|
161
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
162
|
+
return data;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Retrieve keywords.
|
|
167
|
+
* @param options Pagination options
|
|
168
|
+
*/
|
|
169
|
+
getKeywords(options) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const endpoint = Endpoints_1.Endpoint.Keywords.keywords();
|
|
172
|
+
const additionalConfig = {
|
|
173
|
+
params: Object.assign({}, options),
|
|
174
|
+
};
|
|
175
|
+
const { data } = yield this.apiClient.get(endpoint, additionalConfig);
|
|
176
|
+
return data;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
110
179
|
/**
|
|
111
180
|
* Retrieve the owners of a crate.
|
|
112
181
|
* @param packageName The package name
|
|
@@ -159,6 +228,30 @@ class CratesAPI {
|
|
|
159
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
229
|
const endpoint = Endpoints_1.Endpoint.Crates.version(packageName, version);
|
|
161
230
|
const { data } = yield this.apiClient.get(endpoint);
|
|
231
|
+
return data.version;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Retrieve the dependencies of a specific crate version.
|
|
236
|
+
* @param packageName The package name
|
|
237
|
+
* @param version The version
|
|
238
|
+
*/
|
|
239
|
+
getVersionDependencies(packageName, version) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
const endpoint = Endpoints_1.Endpoint.Crates.dependenciesByVersion(packageName, version);
|
|
242
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
243
|
+
return data;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Retrieve download stats for a specific crate version.
|
|
248
|
+
* @param packageName The package name
|
|
249
|
+
* @param version The version
|
|
250
|
+
*/
|
|
251
|
+
getVersionDownloads(packageName, version) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
+
const endpoint = Endpoints_1.Endpoint.Crates.versionDownloads(packageName, version);
|
|
254
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
162
255
|
return data;
|
|
163
256
|
});
|
|
164
257
|
}
|
|
@@ -180,5 +273,64 @@ class CratesAPI {
|
|
|
180
273
|
setApiKey(apiKey) {
|
|
181
274
|
this.apiKey = apiKey;
|
|
182
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Unfollow a crate.
|
|
278
|
+
* @param packageName The package name
|
|
279
|
+
*/
|
|
280
|
+
unfollow(packageName) {
|
|
281
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
+
const endpoint = Endpoints_1.Endpoint.Crates.follow(packageName);
|
|
283
|
+
if (!this.apiKey) {
|
|
284
|
+
throw new Error('You need to set an API key to use this endpoint.');
|
|
285
|
+
}
|
|
286
|
+
const additionalConfig = {
|
|
287
|
+
headers: {
|
|
288
|
+
Authorization: this.apiKey,
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
const { data } = yield this.apiClient.delete(endpoint, additionalConfig);
|
|
292
|
+
return data;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Unyank a specific crate version.
|
|
297
|
+
* @param packageName The package name
|
|
298
|
+
* @param version The version
|
|
299
|
+
*/
|
|
300
|
+
unyank(packageName, version) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
const endpoint = Endpoints_1.Endpoint.Crates.unyank(packageName, version);
|
|
303
|
+
if (!this.apiKey) {
|
|
304
|
+
throw new Error('You need to set an API key to use this endpoint.');
|
|
305
|
+
}
|
|
306
|
+
const additionalConfig = {
|
|
307
|
+
headers: {
|
|
308
|
+
Authorization: this.apiKey,
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
const { data } = yield this.apiClient.put(endpoint, undefined, additionalConfig);
|
|
312
|
+
return data;
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Yank a specific crate version.
|
|
317
|
+
* @param packageName The package name
|
|
318
|
+
* @param version The version
|
|
319
|
+
*/
|
|
320
|
+
yank(packageName, version) {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
322
|
+
const endpoint = Endpoints_1.Endpoint.Crates.yank(packageName, version);
|
|
323
|
+
if (!this.apiKey) {
|
|
324
|
+
throw new Error('You need to set an API key to use this endpoint.');
|
|
325
|
+
}
|
|
326
|
+
const additionalConfig = {
|
|
327
|
+
headers: {
|
|
328
|
+
Authorization: this.apiKey,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
const { data } = yield this.apiClient.delete(endpoint, additionalConfig);
|
|
332
|
+
return data;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
183
335
|
}
|
|
184
336
|
exports.CratesAPI = CratesAPI;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
export interface Crate {
|
|
2
|
-
badges:
|
|
3
|
-
|
|
4
|
-
[key: string]: string;
|
|
5
|
-
};
|
|
6
|
-
} | null;
|
|
7
|
-
categories: null | string;
|
|
2
|
+
badges: object[];
|
|
3
|
+
categories: null | string[];
|
|
8
4
|
created_at: string;
|
|
9
|
-
description: string;
|
|
5
|
+
description: null | string;
|
|
10
6
|
documentation: null | string;
|
|
11
7
|
downloads: number;
|
|
12
8
|
exact_match: boolean;
|
|
13
9
|
homepage: null | string;
|
|
14
10
|
id: string;
|
|
15
|
-
keywords: null | string;
|
|
11
|
+
keywords: null | string[];
|
|
16
12
|
links: {
|
|
17
13
|
owner_team: string;
|
|
18
14
|
owner_user: string;
|
|
@@ -25,6 +21,8 @@ export interface Crate {
|
|
|
25
21
|
name: string;
|
|
26
22
|
recent_downloads: null | number;
|
|
27
23
|
repository: null | string;
|
|
24
|
+
trustpub_only: boolean;
|
|
28
25
|
updated_at: string;
|
|
29
26
|
versions: null | number[];
|
|
27
|
+
yanked: boolean;
|
|
30
28
|
}
|
|
@@ -2,8 +2,18 @@ export interface ClientOptions {
|
|
|
2
2
|
apiKey?: string;
|
|
3
3
|
apiUrl?: string;
|
|
4
4
|
}
|
|
5
|
+
export interface PaginationOptions {
|
|
6
|
+
page?: number;
|
|
7
|
+
per_page?: number;
|
|
8
|
+
}
|
|
5
9
|
export interface SearchOptions {
|
|
10
|
+
category?: string;
|
|
11
|
+
following?: string;
|
|
12
|
+
keyword?: string;
|
|
13
|
+
letter?: string;
|
|
6
14
|
page?: number;
|
|
7
15
|
per_page?: number;
|
|
8
16
|
sort?: string;
|
|
17
|
+
team_id?: number;
|
|
18
|
+
user_id?: number;
|
|
9
19
|
}
|
|
@@ -3,7 +3,16 @@ export interface AuthorsResult {
|
|
|
3
3
|
meta: {
|
|
4
4
|
names: string[];
|
|
5
5
|
};
|
|
6
|
-
users:
|
|
6
|
+
users: User[];
|
|
7
|
+
}
|
|
8
|
+
export interface CategoriesResult {
|
|
9
|
+
categories: Category[];
|
|
10
|
+
meta: {
|
|
11
|
+
total: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface CategoryResult {
|
|
15
|
+
category: Category;
|
|
7
16
|
}
|
|
8
17
|
export interface CrateResult {
|
|
9
18
|
categories: Category[];
|
|
@@ -14,15 +23,31 @@ export interface DependenciesResult {
|
|
|
14
23
|
dependencies: Dependency[];
|
|
15
24
|
}
|
|
16
25
|
export interface DownloadsResult {
|
|
26
|
+
meta?: {
|
|
27
|
+
extra_downloads?: Download[];
|
|
28
|
+
};
|
|
17
29
|
version_downloads: Download[];
|
|
18
30
|
}
|
|
19
31
|
export interface FollowingResult {
|
|
20
32
|
following: boolean;
|
|
21
33
|
}
|
|
22
|
-
export interface
|
|
34
|
+
export interface KeywordResult {
|
|
35
|
+
keyword: Keyword;
|
|
36
|
+
}
|
|
37
|
+
export interface KeywordsResult {
|
|
38
|
+
keywords: Keyword[];
|
|
39
|
+
meta: {
|
|
40
|
+
total: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface OkResult {
|
|
44
|
+
ok: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface ReverseDependenciesResult extends DependenciesResult {
|
|
23
47
|
meta: {
|
|
24
48
|
total: number;
|
|
25
49
|
};
|
|
50
|
+
versions: Version[];
|
|
26
51
|
}
|
|
27
52
|
export interface SearchResult {
|
|
28
53
|
crates: Crate[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { User } from './User';
|
|
1
2
|
export interface Version {
|
|
2
3
|
crate: string;
|
|
3
4
|
crate_size: number;
|
|
@@ -15,7 +16,7 @@ export interface Version {
|
|
|
15
16
|
version_downloads: string;
|
|
16
17
|
};
|
|
17
18
|
num: string;
|
|
18
|
-
published_by: null |
|
|
19
|
+
published_by: null | User;
|
|
19
20
|
readme_path: string;
|
|
20
21
|
updated_at: string;
|
|
21
22
|
yanked: boolean;
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Florian Imdahl <git@ffflorian.de>",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@ffflorian/api-client": "2.5.
|
|
4
|
+
"@ffflorian/api-client": "2.5.3"
|
|
5
5
|
},
|
|
6
6
|
"description": "A crates.io API client",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@types/node": "~
|
|
8
|
+
"@types/node": "~26",
|
|
9
|
+
"nock": "14.0.17",
|
|
9
10
|
"rimraf": "6.1.3",
|
|
10
|
-
"typedoc": "0.28.
|
|
11
|
-
"typescript": "
|
|
11
|
+
"typedoc": "0.28.20",
|
|
12
|
+
"typescript": "7.0.2",
|
|
13
|
+
"vite": "8.2.2",
|
|
14
|
+
"vitest": "5.0.0"
|
|
12
15
|
},
|
|
13
16
|
"engines": {
|
|
14
17
|
"node": ">= 21"
|
|
@@ -27,14 +30,17 @@
|
|
|
27
30
|
"license": "GPL-3.0",
|
|
28
31
|
"name": "crates.io",
|
|
29
32
|
"readme": "https://github.com/ffflorian/api-clients#readme",
|
|
30
|
-
"repository":
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/ffflorian/api-clients.git"
|
|
36
|
+
},
|
|
31
37
|
"scripts": {
|
|
32
38
|
"build": "yarn build:ts",
|
|
33
39
|
"build:ts": "tsc -p tsconfig.build.json",
|
|
34
40
|
"build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/crates.io src/index.ts",
|
|
35
41
|
"clean": "rimraf dist",
|
|
36
42
|
"dist": "yarn clean && yarn build",
|
|
37
|
-
"test": "
|
|
43
|
+
"test": "vitest"
|
|
38
44
|
},
|
|
39
|
-
"version": "2.
|
|
45
|
+
"version": "2.5.1"
|
|
40
46
|
}
|