crates.io 2.4.6 → 2.5.0
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.d.ts +22 -0
- package/dist/CratesIO.js +50 -0
- package/dist/Endpoints.d.ts +48 -0
- package/dist/Endpoints.js +99 -0
- package/dist/api/CratesAPI.d.ts +132 -0
- package/dist/api/CratesAPI.js +336 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +17 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/interfaces/API.d.ts +4 -0
- package/dist/interfaces/API.js +2 -0
- package/dist/interfaces/Category.d.ts +8 -0
- package/dist/interfaces/Category.js +2 -0
- package/dist/interfaces/Crate.d.ts +28 -0
- package/dist/interfaces/Crate.js +2 -0
- package/dist/interfaces/Dependency.d.ts +12 -0
- package/dist/interfaces/Dependency.js +2 -0
- package/dist/interfaces/Download.d.ts +6 -0
- package/dist/interfaces/Download.js +2 -0
- package/dist/interfaces/Keyword.d.ts +6 -0
- package/dist/interfaces/Keyword.js +2 -0
- package/dist/interfaces/Options.d.ts +19 -0
- package/dist/interfaces/Options.js +2 -0
- package/dist/interfaces/Result.d.ts +72 -0
- package/dist/interfaces/Result.js +2 -0
- package/dist/interfaces/Summary.d.ts +13 -0
- package/dist/interfaces/Summary.js +2 -0
- package/dist/interfaces/Team.d.ts +8 -0
- package/dist/interfaces/Team.js +2 -0
- package/dist/interfaces/User.d.ts +8 -0
- package/dist/interfaces/User.js +2 -0
- package/dist/interfaces/Version.d.ts +23 -0
- package/dist/interfaces/Version.js +2 -0
- package/dist/interfaces/index.d.ts +12 -0
- package/dist/interfaces/index.js +28 -0
- package/package.json +9 -6
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`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { API, ClientOptions, Summary } from './interfaces';
|
|
2
|
+
export declare class CratesIO {
|
|
3
|
+
readonly api: API;
|
|
4
|
+
private readonly apiClient;
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(apiKey?: string);
|
|
7
|
+
constructor(options?: ClientOptions);
|
|
8
|
+
/**
|
|
9
|
+
* Set a new API key.
|
|
10
|
+
* @param apiKey The API key
|
|
11
|
+
*/
|
|
12
|
+
setApiKey(apiKey: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Set a new API URL.
|
|
15
|
+
* @param newURL The new API url
|
|
16
|
+
*/
|
|
17
|
+
setApiUrl(newURL: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve a summary containing crates.io wide information.
|
|
20
|
+
*/
|
|
21
|
+
summary(): Promise<Summary>;
|
|
22
|
+
}
|
package/dist/CratesIO.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CratesIO = void 0;
|
|
13
|
+
const api_client_1 = require("@ffflorian/api-client");
|
|
14
|
+
const api_1 = require("./api");
|
|
15
|
+
const Endpoints_1 = require("./Endpoints");
|
|
16
|
+
class CratesIO {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = typeof options === 'string' ? { apiKey: options } : options || {};
|
|
19
|
+
this.apiClient = new api_client_1.APIClient(this.options.apiUrl || 'https://crates.io/api/v1');
|
|
20
|
+
this.api = {
|
|
21
|
+
crates: new api_1.CratesAPI(this.apiClient, this.options.apiKey),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Set a new API key.
|
|
26
|
+
* @param apiKey The API key
|
|
27
|
+
*/
|
|
28
|
+
setApiKey(apiKey) {
|
|
29
|
+
this.options.apiKey = apiKey;
|
|
30
|
+
this.api.crates.setApiKey(apiKey);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set a new API URL.
|
|
34
|
+
* @param newURL The new API url
|
|
35
|
+
*/
|
|
36
|
+
setApiUrl(newURL) {
|
|
37
|
+
this.apiClient.setBaseURL(newURL);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve a summary containing crates.io wide information.
|
|
41
|
+
*/
|
|
42
|
+
summary() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const endpoint = Endpoints_1.Endpoint.summary();
|
|
45
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
46
|
+
return data;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.CratesIO = CratesIO;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const Endpoint: {
|
|
2
|
+
AUTHORS: string;
|
|
3
|
+
CATEGORIES: string;
|
|
4
|
+
Categories: {
|
|
5
|
+
categories(): string;
|
|
6
|
+
category(category: string): string;
|
|
7
|
+
};
|
|
8
|
+
CRATES: string;
|
|
9
|
+
Crates: {
|
|
10
|
+
authors(packageName: string, version: string): string;
|
|
11
|
+
crate(packageName: string): string;
|
|
12
|
+
crates(): string;
|
|
13
|
+
dependencies(packageName: string): string;
|
|
14
|
+
dependenciesByVersion(packageName: string, version: string): string;
|
|
15
|
+
download(packageName: string, version: string): string;
|
|
16
|
+
downloads(packageName: string): string;
|
|
17
|
+
follow(packageName: string): string;
|
|
18
|
+
following(packageName: string): string;
|
|
19
|
+
owners(packageName: string): string;
|
|
20
|
+
ownerTeam(packageName: string): string;
|
|
21
|
+
ownerUser(packageName: string): string;
|
|
22
|
+
reverseDependencies(packageName: string): string;
|
|
23
|
+
unyank(packageName: string, version: string): string;
|
|
24
|
+
version(packageName: string, version: string): string;
|
|
25
|
+
versionDownloads(packageName: string, version: string): string;
|
|
26
|
+
versions(packageName: string): string;
|
|
27
|
+
yank(packageName: string, version: string): string;
|
|
28
|
+
};
|
|
29
|
+
DEPENDENCIES: string;
|
|
30
|
+
DOWNLOAD: string;
|
|
31
|
+
DOWNLOADS: string;
|
|
32
|
+
FOLLOW: string;
|
|
33
|
+
FOLLOWING: string;
|
|
34
|
+
KEYWORDS: string;
|
|
35
|
+
Keywords: {
|
|
36
|
+
keyword(keyword: string): string;
|
|
37
|
+
keywords(): string;
|
|
38
|
+
};
|
|
39
|
+
OWNER_TEAM: string;
|
|
40
|
+
OWNER_USER: string;
|
|
41
|
+
OWNERS: string;
|
|
42
|
+
REVERSE_DEPENDENCIES: string;
|
|
43
|
+
SUMMARY: string;
|
|
44
|
+
summary(): string;
|
|
45
|
+
UNYANK: string;
|
|
46
|
+
VERSIONS: string;
|
|
47
|
+
YANK: string;
|
|
48
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Endpoint = void 0;
|
|
4
|
+
const encode = encodeURIComponent;
|
|
5
|
+
const apiPrefix = '/api/v1';
|
|
6
|
+
exports.Endpoint = {
|
|
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
|
+
},
|
|
17
|
+
CRATES: 'crates',
|
|
18
|
+
Crates: {
|
|
19
|
+
authors(packageName, version) {
|
|
20
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.AUTHORS}`;
|
|
21
|
+
},
|
|
22
|
+
crate(packageName) {
|
|
23
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}`;
|
|
24
|
+
},
|
|
25
|
+
crates() {
|
|
26
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}`;
|
|
27
|
+
},
|
|
28
|
+
dependencies(packageName) {
|
|
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}`;
|
|
33
|
+
},
|
|
34
|
+
download(packageName, version) {
|
|
35
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${encode(version)}/${exports.Endpoint.DOWNLOAD}`;
|
|
36
|
+
},
|
|
37
|
+
downloads(packageName) {
|
|
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}`;
|
|
42
|
+
},
|
|
43
|
+
following(packageName) {
|
|
44
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.FOLLOWING}`;
|
|
45
|
+
},
|
|
46
|
+
owners(packageName) {
|
|
47
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.OWNERS}`;
|
|
48
|
+
},
|
|
49
|
+
ownerTeam(packageName) {
|
|
50
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.OWNER_TEAM}`;
|
|
51
|
+
},
|
|
52
|
+
ownerUser(packageName) {
|
|
53
|
+
return `${apiPrefix}/${exports.Endpoint.CRATES}/${encode(packageName)}/${exports.Endpoint.OWNER_USER}`;
|
|
54
|
+
},
|
|
55
|
+
reverseDependencies(packageName) {
|
|
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}`;
|
|
60
|
+
},
|
|
61
|
+
version(packageName, version) {
|
|
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}`;
|
|
66
|
+
},
|
|
67
|
+
versions(packageName) {
|
|
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}`;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
DEPENDENCIES: 'dependencies',
|
|
75
|
+
DOWNLOAD: 'download',
|
|
76
|
+
DOWNLOADS: 'downloads',
|
|
77
|
+
FOLLOW: 'follow',
|
|
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
|
+
},
|
|
88
|
+
OWNER_TEAM: 'owner_team',
|
|
89
|
+
OWNER_USER: 'owner_user',
|
|
90
|
+
OWNERS: 'owners',
|
|
91
|
+
REVERSE_DEPENDENCIES: 'reverse_dependencies',
|
|
92
|
+
SUMMARY: 'summary',
|
|
93
|
+
summary() {
|
|
94
|
+
return `${apiPrefix}/${exports.Endpoint.SUMMARY}`;
|
|
95
|
+
},
|
|
96
|
+
UNYANK: 'unyank',
|
|
97
|
+
VERSIONS: 'versions',
|
|
98
|
+
YANK: 'yank',
|
|
99
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { APIClient } from '@ffflorian/api-client';
|
|
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
|
+
export declare class CratesAPI {
|
|
4
|
+
private readonly apiClient;
|
|
5
|
+
private apiKey?;
|
|
6
|
+
constructor(apiClient: APIClient, apiKey?: string);
|
|
7
|
+
/**
|
|
8
|
+
* Follow a crate.
|
|
9
|
+
* @param packageName The package name
|
|
10
|
+
*/
|
|
11
|
+
follow(packageName: string): Promise<OkResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieve the owners of a crate.
|
|
14
|
+
* @param packageName The package name
|
|
15
|
+
*/
|
|
16
|
+
following(packageName: string): Promise<FollowingResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieve the owners of a crate.
|
|
19
|
+
* @param packageName The package name
|
|
20
|
+
*/
|
|
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>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieve information of a crate.
|
|
34
|
+
* @param packageName The package name
|
|
35
|
+
*/
|
|
36
|
+
getCrate(packageName: string): Promise<CrateResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve a page of crates, optionally constrained by a query.
|
|
39
|
+
* @param query The search query
|
|
40
|
+
* @param options The search options
|
|
41
|
+
*/
|
|
42
|
+
getCrates(query: string, options?: SearchOptions): Promise<SearchResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve the dependencies of a crate version.
|
|
45
|
+
* @param packageName The package name
|
|
46
|
+
*/
|
|
47
|
+
getDependencies(packageName: string): Promise<DependenciesResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve download stats for a crate.
|
|
50
|
+
* @param packageName The package name
|
|
51
|
+
*/
|
|
52
|
+
getDownloads(packageName: string): Promise<DownloadsResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve a download link for a certain version of a crate.
|
|
55
|
+
* @param packageName The package name
|
|
56
|
+
*/
|
|
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>;
|
|
68
|
+
/**
|
|
69
|
+
* Retrieve the owners of a crate.
|
|
70
|
+
* @param packageName The package name
|
|
71
|
+
*/
|
|
72
|
+
getOwners(packageName: string): Promise<UsersResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Retrieve the reverse dependencies of a crate version.
|
|
75
|
+
* @param packageName The package name
|
|
76
|
+
*/
|
|
77
|
+
getReverseDependencies(packageName: string): Promise<ReverseDependenciesResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieve the team owner of a crate.
|
|
80
|
+
* @param packageName The package name
|
|
81
|
+
*/
|
|
82
|
+
getTeamOwner(packageName: string): Promise<TeamsResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Retrieve the user owner of a crate.
|
|
85
|
+
* @param packageName The package name
|
|
86
|
+
*/
|
|
87
|
+
getUserOwner(packageName: string): Promise<UsersResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Retrieve a specific version of a crate.
|
|
90
|
+
* @param packageName The package name
|
|
91
|
+
*/
|
|
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>;
|
|
105
|
+
/**
|
|
106
|
+
* Retrieve all versions of a crate.
|
|
107
|
+
* @param packageName The package name
|
|
108
|
+
*/
|
|
109
|
+
getVersions(packageName: string): Promise<VersionsResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Set a new API key.
|
|
112
|
+
* @param apiKey The API key
|
|
113
|
+
*/
|
|
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>;
|
|
132
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CratesAPI = void 0;
|
|
13
|
+
const Endpoints_1 = require("../Endpoints");
|
|
14
|
+
class CratesAPI {
|
|
15
|
+
constructor(apiClient, apiKey) {
|
|
16
|
+
this.apiClient = apiClient;
|
|
17
|
+
this.apiKey = apiKey;
|
|
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
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the owners of a crate.
|
|
40
|
+
* @param packageName The package name
|
|
41
|
+
*/
|
|
42
|
+
following(packageName) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const endpoint = Endpoints_1.Endpoint.Crates.following(packageName);
|
|
45
|
+
if (!this.apiKey) {
|
|
46
|
+
throw new Error('You need to set an API key to use this endpoint.');
|
|
47
|
+
}
|
|
48
|
+
const additionalConfig = {
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: this.apiKey,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const { data } = yield this.apiClient.get(endpoint, additionalConfig);
|
|
54
|
+
return data;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve the owners of a crate.
|
|
59
|
+
* @param packageName The package name
|
|
60
|
+
*/
|
|
61
|
+
getAuthors(packageName, version) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const endpoint = Endpoints_1.Endpoint.Crates.authors(packageName, version);
|
|
64
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
65
|
+
return data;
|
|
66
|
+
});
|
|
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
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve information of a crate.
|
|
95
|
+
* @param packageName The package name
|
|
96
|
+
*/
|
|
97
|
+
getCrate(packageName) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const endpoint = Endpoints_1.Endpoint.Crates.crate(packageName);
|
|
100
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
101
|
+
return data;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Retrieve a page of crates, optionally constrained by a query.
|
|
106
|
+
* @param query The search query
|
|
107
|
+
* @param options The search options
|
|
108
|
+
*/
|
|
109
|
+
getCrates(query, options) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const endpoint = Endpoints_1.Endpoint.Crates.crates();
|
|
112
|
+
const additionalConfig = {
|
|
113
|
+
params: Object.assign(Object.assign({}, options), {
|
|
114
|
+
// eslint-disable-next-line id-length
|
|
115
|
+
q: query }),
|
|
116
|
+
};
|
|
117
|
+
const { data } = yield this.apiClient.get(endpoint, additionalConfig);
|
|
118
|
+
return data;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Retrieve the dependencies of a crate version.
|
|
123
|
+
* @param packageName The package name
|
|
124
|
+
*/
|
|
125
|
+
getDependencies(packageName) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const endpoint = Endpoints_1.Endpoint.Crates.dependencies(packageName);
|
|
128
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
129
|
+
return data;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Retrieve download stats for a crate.
|
|
134
|
+
* @param packageName The package name
|
|
135
|
+
*/
|
|
136
|
+
getDownloads(packageName) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const endpoint = Endpoints_1.Endpoint.Crates.downloads(packageName);
|
|
139
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
140
|
+
return data;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Retrieve a download link for a certain version of a crate.
|
|
145
|
+
* @param packageName The package name
|
|
146
|
+
*/
|
|
147
|
+
getDownloadUrl(packageName, version) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const endpoint = Endpoints_1.Endpoint.Crates.download(packageName, version);
|
|
150
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
151
|
+
return data;
|
|
152
|
+
});
|
|
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
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Retrieve the owners of a crate.
|
|
181
|
+
* @param packageName The package name
|
|
182
|
+
*/
|
|
183
|
+
getOwners(packageName) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
const endpoint = Endpoints_1.Endpoint.Crates.owners(packageName);
|
|
186
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
187
|
+
return data;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Retrieve the reverse dependencies of a crate version.
|
|
192
|
+
* @param packageName The package name
|
|
193
|
+
*/
|
|
194
|
+
getReverseDependencies(packageName) {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
const endpoint = Endpoints_1.Endpoint.Crates.reverseDependencies(packageName);
|
|
197
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
198
|
+
return data;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Retrieve the team owner of a crate.
|
|
203
|
+
* @param packageName The package name
|
|
204
|
+
*/
|
|
205
|
+
getTeamOwner(packageName) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
const endpoint = Endpoints_1.Endpoint.Crates.ownerTeam(packageName);
|
|
208
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
209
|
+
return data;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Retrieve the user owner of a crate.
|
|
214
|
+
* @param packageName The package name
|
|
215
|
+
*/
|
|
216
|
+
getUserOwner(packageName) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
const endpoint = Endpoints_1.Endpoint.Crates.ownerUser(packageName);
|
|
219
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
220
|
+
return data;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Retrieve a specific version of a crate.
|
|
225
|
+
* @param packageName The package name
|
|
226
|
+
*/
|
|
227
|
+
getVersion(packageName, version) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
+
const endpoint = Endpoints_1.Endpoint.Crates.version(packageName, version);
|
|
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);
|
|
255
|
+
return data;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Retrieve all versions of a crate.
|
|
260
|
+
* @param packageName The package name
|
|
261
|
+
*/
|
|
262
|
+
getVersions(packageName) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
264
|
+
const endpoint = Endpoints_1.Endpoint.Crates.versions(packageName);
|
|
265
|
+
const { data } = yield this.apiClient.get(endpoint);
|
|
266
|
+
return data;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Set a new API key.
|
|
271
|
+
* @param apiKey The API key
|
|
272
|
+
*/
|
|
273
|
+
setApiKey(apiKey) {
|
|
274
|
+
this.apiKey = apiKey;
|
|
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
|
+
}
|
|
335
|
+
}
|
|
336
|
+
exports.CratesAPI = CratesAPI;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CratesAPI';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CratesAPI"), exports);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api/"), exports);
|
|
18
|
+
__exportStar(require("./CratesIO"), exports);
|
|
19
|
+
__exportStar(require("./interfaces/"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface Crate {
|
|
2
|
+
badges: object[];
|
|
3
|
+
categories: null | string[];
|
|
4
|
+
created_at: string;
|
|
5
|
+
description: null | string;
|
|
6
|
+
documentation: null | string;
|
|
7
|
+
downloads: number;
|
|
8
|
+
exact_match: boolean;
|
|
9
|
+
homepage: null | string;
|
|
10
|
+
id: string;
|
|
11
|
+
keywords: null | string[];
|
|
12
|
+
links: {
|
|
13
|
+
owner_team: string;
|
|
14
|
+
owner_user: string;
|
|
15
|
+
owners: string;
|
|
16
|
+
reverse_dependencies: string;
|
|
17
|
+
version_downloads: string;
|
|
18
|
+
versions: string;
|
|
19
|
+
};
|
|
20
|
+
max_version: string;
|
|
21
|
+
name: string;
|
|
22
|
+
recent_downloads: null | number;
|
|
23
|
+
repository: null | string;
|
|
24
|
+
trustpub_only: boolean;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
versions: null | number[];
|
|
27
|
+
yanked: boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Dependency {
|
|
2
|
+
crate_id: string;
|
|
3
|
+
default_features: boolean;
|
|
4
|
+
downloads: number;
|
|
5
|
+
features: string[];
|
|
6
|
+
id: number;
|
|
7
|
+
kind: 'build' | 'dev' | 'normal';
|
|
8
|
+
optional: boolean;
|
|
9
|
+
req: string;
|
|
10
|
+
target: null | string;
|
|
11
|
+
version_id: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ClientOptions {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
apiUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface PaginationOptions {
|
|
6
|
+
page?: number;
|
|
7
|
+
per_page?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SearchOptions {
|
|
10
|
+
category?: string;
|
|
11
|
+
following?: string;
|
|
12
|
+
keyword?: string;
|
|
13
|
+
letter?: string;
|
|
14
|
+
page?: number;
|
|
15
|
+
per_page?: number;
|
|
16
|
+
sort?: string;
|
|
17
|
+
team_id?: number;
|
|
18
|
+
user_id?: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Category, Crate, Dependency, Download, Keyword, Team, User, Version } from '.';
|
|
2
|
+
export interface AuthorsResult {
|
|
3
|
+
meta: {
|
|
4
|
+
names: string[];
|
|
5
|
+
};
|
|
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;
|
|
16
|
+
}
|
|
17
|
+
export interface CrateResult {
|
|
18
|
+
categories: Category[];
|
|
19
|
+
crate: Crate;
|
|
20
|
+
keywords: Keyword[];
|
|
21
|
+
}
|
|
22
|
+
export interface DependenciesResult {
|
|
23
|
+
dependencies: Dependency[];
|
|
24
|
+
}
|
|
25
|
+
export interface DownloadsResult {
|
|
26
|
+
meta?: {
|
|
27
|
+
extra_downloads?: Download[];
|
|
28
|
+
};
|
|
29
|
+
version_downloads: Download[];
|
|
30
|
+
}
|
|
31
|
+
export interface FollowingResult {
|
|
32
|
+
following: boolean;
|
|
33
|
+
}
|
|
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 {
|
|
47
|
+
meta: {
|
|
48
|
+
total: number;
|
|
49
|
+
};
|
|
50
|
+
versions: Version[];
|
|
51
|
+
}
|
|
52
|
+
export interface SearchResult {
|
|
53
|
+
crates: Crate[];
|
|
54
|
+
meta: {
|
|
55
|
+
total: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface TeamsResult {
|
|
59
|
+
teams: Team[];
|
|
60
|
+
}
|
|
61
|
+
export interface UrlResult {
|
|
62
|
+
url: string;
|
|
63
|
+
}
|
|
64
|
+
export interface UsersResult {
|
|
65
|
+
users: User[];
|
|
66
|
+
}
|
|
67
|
+
export interface VersionResult {
|
|
68
|
+
version: Version;
|
|
69
|
+
}
|
|
70
|
+
export interface VersionsResult {
|
|
71
|
+
versions: Version[];
|
|
72
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Category } from './Category';
|
|
2
|
+
import type { Crate } from './Crate';
|
|
3
|
+
import type { Keyword } from './Keyword';
|
|
4
|
+
export interface Summary {
|
|
5
|
+
just_updated: Crate[];
|
|
6
|
+
most_downloaded: Crate[];
|
|
7
|
+
most_recently_downloaded: Crate[];
|
|
8
|
+
new_crates: Crate[];
|
|
9
|
+
num_crates: number;
|
|
10
|
+
num_downloads: number;
|
|
11
|
+
popular_categories: Category[];
|
|
12
|
+
popular_keywords: Keyword[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { User } from './User';
|
|
2
|
+
export interface Version {
|
|
3
|
+
crate: string;
|
|
4
|
+
crate_size: number;
|
|
5
|
+
created_at: string;
|
|
6
|
+
dl_path: string;
|
|
7
|
+
downloads: number;
|
|
8
|
+
features: {
|
|
9
|
+
[key: string]: string[];
|
|
10
|
+
};
|
|
11
|
+
id: number;
|
|
12
|
+
license: string;
|
|
13
|
+
links: {
|
|
14
|
+
authors: string;
|
|
15
|
+
dependencies: string;
|
|
16
|
+
version_downloads: string;
|
|
17
|
+
};
|
|
18
|
+
num: string;
|
|
19
|
+
published_by: null | User;
|
|
20
|
+
readme_path: string;
|
|
21
|
+
updated_at: string;
|
|
22
|
+
yanked: boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './API';
|
|
2
|
+
export * from './Category';
|
|
3
|
+
export * from './Crate';
|
|
4
|
+
export * from './Dependency';
|
|
5
|
+
export * from './Download';
|
|
6
|
+
export * from './Keyword';
|
|
7
|
+
export * from './Options';
|
|
8
|
+
export * from './Result';
|
|
9
|
+
export * from './Summary';
|
|
10
|
+
export * from './Team';
|
|
11
|
+
export * from './User';
|
|
12
|
+
export * from './Version';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./API"), exports);
|
|
18
|
+
__exportStar(require("./Category"), exports);
|
|
19
|
+
__exportStar(require("./Crate"), exports);
|
|
20
|
+
__exportStar(require("./Dependency"), exports);
|
|
21
|
+
__exportStar(require("./Download"), exports);
|
|
22
|
+
__exportStar(require("./Keyword"), exports);
|
|
23
|
+
__exportStar(require("./Options"), exports);
|
|
24
|
+
__exportStar(require("./Result"), exports);
|
|
25
|
+
__exportStar(require("./Summary"), exports);
|
|
26
|
+
__exportStar(require("./Team"), exports);
|
|
27
|
+
__exportStar(require("./User"), exports);
|
|
28
|
+
__exportStar(require("./Version"), exports);
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
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.1"
|
|
5
5
|
},
|
|
6
6
|
"description": "A crates.io API client",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@types/node": "~24",
|
|
9
|
+
"nock": "14.0.12",
|
|
9
10
|
"rimraf": "6.1.3",
|
|
10
|
-
"typedoc": "0.28.
|
|
11
|
-
"typescript": "6.0.
|
|
11
|
+
"typedoc": "0.28.19",
|
|
12
|
+
"typescript": "6.0.3",
|
|
13
|
+
"vitest": "4.1.4"
|
|
12
14
|
},
|
|
13
15
|
"engines": {
|
|
14
16
|
"node": ">= 21"
|
|
@@ -29,11 +31,12 @@
|
|
|
29
31
|
"readme": "https://github.com/ffflorian/api-clients#readme",
|
|
30
32
|
"repository": "https://github.com/ffflorian/api-clients.git",
|
|
31
33
|
"scripts": {
|
|
34
|
+
"build": "yarn build:ts",
|
|
32
35
|
"build:ts": "tsc -p tsconfig.build.json",
|
|
33
36
|
"build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/crates.io src/index.ts",
|
|
34
37
|
"clean": "rimraf dist",
|
|
35
|
-
"dist": "yarn clean && yarn build
|
|
36
|
-
"test": "
|
|
38
|
+
"dist": "yarn clean && yarn build",
|
|
39
|
+
"test": "vitest"
|
|
37
40
|
},
|
|
38
|
-
"version": "2.
|
|
41
|
+
"version": "2.5.0"
|
|
39
42
|
}
|