libraries.io 3.4.6 → 3.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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/Endpoints.d.ts +45 -0
  3. package/dist/Endpoints.js +95 -0
  4. package/dist/LibrariesIO.d.ts +18 -0
  5. package/dist/LibrariesIO.js +64 -0
  6. package/dist/api/APIBase.d.ts +18 -0
  7. package/dist/api/APIBase.js +30 -0
  8. package/dist/api/GitHub/GitHubRepositoryAPI.d.ts +28 -0
  9. package/dist/api/GitHub/GitHubRepositoryAPI.js +60 -0
  10. package/dist/api/GitHub/GitHubUserAPI.d.ts +42 -0
  11. package/dist/api/GitHub/GitHubUserAPI.js +107 -0
  12. package/dist/api/GitHub/index.d.ts +2 -0
  13. package/dist/api/GitHub/index.js +18 -0
  14. package/dist/api/PlatformAPI.d.ts +12 -0
  15. package/dist/api/PlatformAPI.js +32 -0
  16. package/dist/api/ProjectAPI.d.ts +64 -0
  17. package/dist/api/ProjectAPI.js +127 -0
  18. package/dist/api/UserAPI.d.ts +42 -0
  19. package/dist/api/UserAPI.js +86 -0
  20. package/dist/api/index.d.ts +4 -0
  21. package/dist/api/index.js +20 -0
  22. package/dist/index.d.ts +3 -0
  23. package/dist/index.js +19 -0
  24. package/dist/interfaces/API.d.ts +10 -0
  25. package/dist/interfaces/API.js +2 -0
  26. package/dist/interfaces/Contributor.d.ts +19 -0
  27. package/dist/interfaces/Contributor.js +2 -0
  28. package/dist/interfaces/LibrariesIOHeaders.d.ts +8 -0
  29. package/dist/interfaces/LibrariesIOHeaders.js +2 -0
  30. package/dist/interfaces/Options.d.ts +31 -0
  31. package/dist/interfaces/Options.js +2 -0
  32. package/dist/interfaces/Platform.d.ts +7 -0
  33. package/dist/interfaces/Platform.js +2 -0
  34. package/dist/interfaces/Project.d.ts +57 -0
  35. package/dist/interfaces/Project.js +2 -0
  36. package/dist/interfaces/Repository.d.ts +49 -0
  37. package/dist/interfaces/Repository.js +2 -0
  38. package/dist/interfaces/Subscription.d.ts +7 -0
  39. package/dist/interfaces/Subscription.js +2 -0
  40. package/dist/interfaces/index.d.ts +8 -0
  41. package/dist/interfaces/index.js +24 -0
  42. package/package.json +7 -6
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # libraries.io [![npm version](https://img.shields.io/npm/v/libraries.io.svg)](https://www.npmjs.com/package/libraries.io)
2
2
 
3
- A [libraries.io](https://libraries.io) API client. For a documentation on the API see https://libraries.io/api/.
3
+ A [libraries.io](https://libraries.io) API client. For a documentation on the API see [the libraries.io API reference](https://libraries.io/api/).
4
4
 
5
5
  ### Installation
6
6
 
@@ -0,0 +1,45 @@
1
+ export declare const Endpoint: {
2
+ CONTRIBUTORS: string;
3
+ DEPENDENCIES: string;
4
+ DEPENDENT_REPOSITORIES: string;
5
+ DEPENDENTS: string;
6
+ GITHUB: string;
7
+ GitHub: {
8
+ Repository: {
9
+ dependencies(owner: string, name: string): string;
10
+ projects(owner: string, name: string): string;
11
+ repository(owner: string, name: string): string;
12
+ };
13
+ User: {
14
+ contributedProjects(login: string): string;
15
+ contributedRepositories(login: string): string;
16
+ dependencies(login: string): string;
17
+ packages(login: string): string;
18
+ projects(login: string): string;
19
+ repositories(login: string): string;
20
+ user(login: string): string;
21
+ };
22
+ };
23
+ PLATFORMS: string;
24
+ platforms(): string;
25
+ Project: {
26
+ contributors(platform: string, name: string): string;
27
+ dependencies(platform: string, name: string, version: string): string;
28
+ dependentRepositories(platform: string, name: string): string;
29
+ dependents(platform: string, name: string): string;
30
+ project(platform: string, name: string): string;
31
+ search(): string;
32
+ sourceRank(platform: string, name: string): string;
33
+ subscriptions(platform: string, name: string): string;
34
+ usage(platform: string, name: string): string;
35
+ };
36
+ PROJECT_CONTRIBUTIONS: string;
37
+ PROJECTS: string;
38
+ REPOSITORIES: string;
39
+ REPOSITORY_CONTRIBUTIONS: string;
40
+ SEARCH: string;
41
+ SOURCERANK: string;
42
+ SUBSCRIPTIONS: string;
43
+ subscriptions(platform?: string, name?: string): string;
44
+ USAGE: string;
45
+ };
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Endpoint = void 0;
4
+ const encode = encodeURIComponent;
5
+ exports.Endpoint = {
6
+ CONTRIBUTORS: 'contributors',
7
+ DEPENDENCIES: 'dependencies',
8
+ DEPENDENT_REPOSITORIES: 'dependent_repositories',
9
+ DEPENDENTS: 'dependents',
10
+ GITHUB: 'github',
11
+ GitHub: {
12
+ Repository: {
13
+ dependencies(owner, name) {
14
+ return `/${exports.Endpoint.GITHUB}/${encode(owner)}/${encode(name)}/${exports.Endpoint.DEPENDENCIES}/`;
15
+ },
16
+ projects(owner, name) {
17
+ return `/${exports.Endpoint.GITHUB}/${encode(owner)}/${encode(name)}/${exports.Endpoint.PROJECTS}/`;
18
+ },
19
+ repository(owner, name) {
20
+ return `/${exports.Endpoint.GITHUB}/${encode(owner)}/${encode(name)}/`;
21
+ },
22
+ },
23
+ User: {
24
+ contributedProjects(login) {
25
+ return `/${exports.Endpoint.GITHUB}/${encode(login)}/${exports.Endpoint.PROJECT_CONTRIBUTIONS}/`;
26
+ },
27
+ contributedRepositories(login) {
28
+ return `/${exports.Endpoint.GITHUB}/${encode(login)}/${exports.Endpoint.REPOSITORY_CONTRIBUTIONS}/`;
29
+ },
30
+ dependencies(login) {
31
+ return `/${exports.Endpoint.GITHUB}/${encode(login)}/${exports.Endpoint.DEPENDENCIES}/`;
32
+ },
33
+ packages(login) {
34
+ return `/${exports.Endpoint.GITHUB}/${encode(login)}/${exports.Endpoint.PROJECTS}/`;
35
+ },
36
+ projects(login) {
37
+ return `/${exports.Endpoint.GITHUB}/${encode(login)}/${exports.Endpoint.PROJECTS}/`;
38
+ },
39
+ repositories(login) {
40
+ return `/${exports.Endpoint.GITHUB}/${encode(login)}/${exports.Endpoint.REPOSITORIES}/`;
41
+ },
42
+ user(login) {
43
+ return `/${exports.Endpoint.GITHUB}/${encode(login)}/`;
44
+ },
45
+ },
46
+ },
47
+ PLATFORMS: 'platforms',
48
+ platforms() {
49
+ return `/${exports.Endpoint.PLATFORMS}/`;
50
+ },
51
+ Project: {
52
+ contributors(platform, name) {
53
+ return `/${encode(platform)}/${encode(name)}/${exports.Endpoint.CONTRIBUTORS}/`;
54
+ },
55
+ dependencies(platform, name, version) {
56
+ return `/${encode(platform)}/${encode(name)}/${encode(version)}/${exports.Endpoint.DEPENDENCIES}/`;
57
+ },
58
+ dependentRepositories(platform, name) {
59
+ return `/${encode(platform)}/${encode(name)}/${exports.Endpoint.DEPENDENT_REPOSITORIES}/`;
60
+ },
61
+ dependents(platform, name) {
62
+ return `/${encode(platform)}/${encode(name)}/${exports.Endpoint.DEPENDENTS}/`;
63
+ },
64
+ project(platform, name) {
65
+ return `/${encode(platform)}/${encode(name)}/`;
66
+ },
67
+ search() {
68
+ return `/${exports.Endpoint.SEARCH}/`;
69
+ },
70
+ sourceRank(platform, name) {
71
+ return `/${encode(platform)}/${encode(name)}/${exports.Endpoint.SOURCERANK}/`;
72
+ },
73
+ subscriptions(platform, name) {
74
+ return `/${exports.Endpoint.SUBSCRIPTIONS}/${encode(platform)}/${encode(name)}/`;
75
+ },
76
+ usage(platform, name) {
77
+ return `/${encode(platform)}/${encode(name)}/${exports.Endpoint.USAGE}/`;
78
+ },
79
+ },
80
+ PROJECT_CONTRIBUTIONS: 'project-contributions',
81
+ PROJECTS: 'projects',
82
+ REPOSITORIES: 'repositories',
83
+ REPOSITORY_CONTRIBUTIONS: 'repository-contributions',
84
+ SEARCH: 'search',
85
+ SOURCERANK: 'sourcerank',
86
+ SUBSCRIPTIONS: 'subscriptions',
87
+ subscriptions(platform, name) {
88
+ let endpoint = `/${exports.Endpoint.SUBSCRIPTIONS}/`;
89
+ if (platform && name) {
90
+ endpoint += `${encode(platform)}/${encode(name)}/`;
91
+ }
92
+ return endpoint;
93
+ },
94
+ USAGE: 'usage',
95
+ };
@@ -0,0 +1,18 @@
1
+ import type { API, ClientOptions } from './interfaces/';
2
+ export declare class LibrariesIO {
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 new 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
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LibrariesIO = void 0;
4
+ const api_client_1 = require("@ffflorian/api-client");
5
+ const api_1 = require("./api");
6
+ class LibrariesIO {
7
+ constructor(options) {
8
+ if (typeof options === 'string') {
9
+ options = { apiKey: options };
10
+ }
11
+ this.options = Object.assign({ apiUrl: 'https://libraries.io/api' }, options);
12
+ this.apiClient = new api_client_1.APIClient(this.options.apiUrl);
13
+ this.apiClient.interceptors.request.push(options => {
14
+ if (options.body) {
15
+ const body = JSON.parse(options.body.toString());
16
+ body.api_key = this.options.apiKey;
17
+ options.body = JSON.stringify(body);
18
+ }
19
+ else {
20
+ const body = { api_key: this.options.apiKey };
21
+ options.body = JSON.stringify(body);
22
+ }
23
+ return options;
24
+ });
25
+ this.apiClient.interceptors.response.push(response => {
26
+ const headers = response.headers;
27
+ if (headers.get('total')) {
28
+ return Object.assign(Object.assign({}, response), { totalResults: Number(headers.get('total')) });
29
+ }
30
+ return response;
31
+ });
32
+ this.api = {
33
+ github: {
34
+ repository: new api_1.GitHubRepositoryAPI(this.apiClient, this.options),
35
+ user: new api_1.GitHubUserAPI(this.apiClient, this.options),
36
+ },
37
+ platform: new api_1.PlatformAPI(this.apiClient, this.options),
38
+ project: new api_1.ProjectAPI(this.apiClient, this.options),
39
+ user: new api_1.UserAPI(this.apiClient, this.options),
40
+ };
41
+ }
42
+ /**
43
+ * Set a new API key.
44
+ * @param apiKey The new API key
45
+ */
46
+ setApiKey(apiKey) {
47
+ this.options.apiKey = apiKey;
48
+ }
49
+ /*
50
+
51
+ const contentType = headers['content-type'] ? String(headers['content-type']) : undefined;
52
+ const rateLimit = Number(headers['x-ratelimit-limit']);
53
+ const rateLimitRemaining = Number(headers['x-ratelimit-remaining']);
54
+ const totalResults = headers['total'] ? Number(headers['total']) : undefined;
55
+ */
56
+ /**
57
+ * Set a new API URL.
58
+ * @param newURL The new API url
59
+ */
60
+ setApiUrl(newURL) {
61
+ this.apiClient.setBaseURL(newURL);
62
+ }
63
+ }
64
+ exports.LibrariesIO = LibrariesIO;
@@ -0,0 +1,18 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { ClientOptions } from '../interfaces';
3
+ export declare class APIBase {
4
+ protected readonly apiClient: APIClient;
5
+ protected readonly options: ClientOptions;
6
+ constructor(apiClient: APIClient, options: ClientOptions);
7
+ /**
8
+ * Set a new API key.
9
+ * @param apiKey The new API key
10
+ */
11
+ setApiKey(apiKey: string): void;
12
+ /**
13
+ * Set a new API URL.
14
+ * @param newURL The new API url
15
+ */
16
+ setApiUrl(newURL: string): void;
17
+ protected checkApiKey(apiName?: string): void;
18
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APIBase = void 0;
4
+ class APIBase {
5
+ constructor(apiClient, options) {
6
+ this.apiClient = apiClient;
7
+ this.options = options;
8
+ }
9
+ /**
10
+ * Set a new API key.
11
+ * @param apiKey The new API key
12
+ */
13
+ setApiKey(apiKey) {
14
+ this.options.apiKey = apiKey;
15
+ }
16
+ /**
17
+ * Set a new API URL.
18
+ * @param newURL The new API url
19
+ */
20
+ setApiUrl(newURL) {
21
+ this.apiClient.setBaseURL(newURL);
22
+ }
23
+ checkApiKey(apiName) {
24
+ const name = apiName ? `the "${apiName}"` : 'this';
25
+ if (!this.options.apiKey) {
26
+ throw new Error(`An API key needs to be set in order to use ${name} API`);
27
+ }
28
+ }
29
+ }
30
+ exports.APIBase = APIBase;
@@ -0,0 +1,28 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { ClientOptions, LibrariesIOResult, PaginationOptions, Project, RepositoryWithDependencies } from '../../interfaces/';
3
+ import { APIBase } from '../APIBase';
4
+ export declare class GitHubRepositoryAPI extends APIBase {
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
+ /**
7
+ * Get a list of packages referencing the given repository.
8
+ * @see https://libraries.io/api#repository-projects
9
+ * @param repositoryOwner The repository owner
10
+ * @param repositoryName The repository name
11
+ * @param options Pagination Options
12
+ */
13
+ getProjects(repositoryOwner: string, repositoryName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>;
14
+ /**
15
+ * Get a info for a repository. Currently only works for open source repositories.
16
+ * @see https://libraries.io/api#repository
17
+ * @param repositoryOwner The repository owner
18
+ * @param repositoryName The repository name
19
+ */
20
+ getRepository(repositoryOwner: string, repositoryName: string): Promise<LibrariesIOResult<RepositoryWithDependencies>>;
21
+ /**
22
+ * Get a list of dependencies for a repositories. Currently only works for open source repositories.
23
+ * @see https://libraries.io/api#repository-dependencies
24
+ * @param repositoryOwner The repository owner
25
+ * @param repositoryName The repository name
26
+ */
27
+ getRepositoryWithDependencies(repositoryOwner: string, repositoryName: string): Promise<LibrariesIOResult<RepositoryWithDependencies>>;
28
+ }
@@ -0,0 +1,60 @@
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.GitHubRepositoryAPI = void 0;
13
+ const Endpoints_1 = require("../../Endpoints");
14
+ const APIBase_1 = require("../APIBase");
15
+ class GitHubRepositoryAPI extends APIBase_1.APIBase {
16
+ constructor(apiClient, options) {
17
+ super(apiClient, options);
18
+ }
19
+ /**
20
+ * Get a list of packages referencing the given repository.
21
+ * @see https://libraries.io/api#repository-projects
22
+ * @param repositoryOwner The repository owner
23
+ * @param repositoryName The repository name
24
+ * @param options Pagination Options
25
+ */
26
+ getProjects(repositoryOwner, repositoryName, options) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const endpoint = Endpoints_1.Endpoint.GitHub.Repository.projects(repositoryOwner, repositoryName);
29
+ const { data } = yield this.apiClient.get(endpoint, { data: options });
30
+ return data;
31
+ });
32
+ }
33
+ /**
34
+ * Get a info for a repository. Currently only works for open source repositories.
35
+ * @see https://libraries.io/api#repository
36
+ * @param repositoryOwner The repository owner
37
+ * @param repositoryName The repository name
38
+ */
39
+ getRepository(repositoryOwner, repositoryName) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const endpoint = Endpoints_1.Endpoint.GitHub.Repository.repository(repositoryOwner, repositoryName);
42
+ const { data } = yield this.apiClient.get(endpoint);
43
+ return data;
44
+ });
45
+ }
46
+ /**
47
+ * Get a list of dependencies for a repositories. Currently only works for open source repositories.
48
+ * @see https://libraries.io/api#repository-dependencies
49
+ * @param repositoryOwner The repository owner
50
+ * @param repositoryName The repository name
51
+ */
52
+ getRepositoryWithDependencies(repositoryOwner, repositoryName) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const endpoint = Endpoints_1.Endpoint.GitHub.Repository.dependencies(repositoryOwner, repositoryName);
55
+ const { data } = yield this.apiClient.get(endpoint);
56
+ return data;
57
+ });
58
+ }
59
+ }
60
+ exports.GitHubRepositoryAPI = GitHubRepositoryAPI;
@@ -0,0 +1,42 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { ClientOptions, Contributor, LibrariesIOResult, PaginationOptions, PlatformType, Project, Repository } from '../../interfaces/';
3
+ import { APIBase } from '../APIBase';
4
+ export declare class GitHubUserAPI extends APIBase {
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
+ /**
7
+ * Get a list of packages that the given user has contributed to.
8
+ * @see https://libraries.io/api#user-project-contributions
9
+ * @param userName The username
10
+ * @param options Pagination options
11
+ */
12
+ getContributedProjects(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>;
13
+ /**
14
+ * Get a list of repositories that the given user has contributed to.
15
+ * @see https://libraries.io/api#user-repository-contributions
16
+ * @param userName The username
17
+ * @param options Pagination options
18
+ */
19
+ getContributedRepositories(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>;
20
+ getDependencies(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>;
21
+ getDependencies(userName: string, platform?: PlatformType, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>;
22
+ /**
23
+ * Get a list of packages referencing the given user's repositories.
24
+ * @see https://libraries.io/api#user-projects
25
+ * @param userName The username
26
+ * @param options Pagination options
27
+ */
28
+ getProjects(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>;
29
+ /**
30
+ * Get repositories owned by a user.
31
+ * @see https://libraries.io/api#user-repositories
32
+ * @param userName The username
33
+ * @param options Pagination options
34
+ */
35
+ getRepositories(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>;
36
+ /**
37
+ * Get information for a given user or organization.
38
+ * @see https://libraries.io/api#user
39
+ * @param userName The username
40
+ */
41
+ getUser(userName: string): Promise<LibrariesIOResult<Contributor>>;
42
+ }
@@ -0,0 +1,107 @@
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.GitHubUserAPI = void 0;
13
+ const Endpoints_1 = require("../../Endpoints");
14
+ const APIBase_1 = require("../APIBase");
15
+ class GitHubUserAPI extends APIBase_1.APIBase {
16
+ constructor(apiClient, options) {
17
+ super(apiClient, options);
18
+ }
19
+ /**
20
+ * Get a list of packages that the given user has contributed to.
21
+ * @see https://libraries.io/api#user-project-contributions
22
+ * @param userName The username
23
+ * @param options Pagination options
24
+ */
25
+ getContributedProjects(userName, options) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedProjects(userName);
28
+ const { data } = yield this.apiClient.get(endpoint, { data: options });
29
+ return data;
30
+ });
31
+ }
32
+ /**
33
+ * Get a list of repositories that the given user has contributed to.
34
+ * @see https://libraries.io/api#user-repository-contributions
35
+ * @param userName The username
36
+ * @param options Pagination options
37
+ */
38
+ getContributedRepositories(userName, options) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedRepositories(userName);
41
+ const { data } = yield this.apiClient.get(endpoint, { data: options });
42
+ return data;
43
+ });
44
+ }
45
+ /**
46
+ * Get a list of unique packages that the given user's repositories list as a dependency. Ordered by frequency of use in those repositories.
47
+ * @see https://libraries.io/api#user-dependencies
48
+ * @param userName The username
49
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
50
+ * @param options Pagination options
51
+ */
52
+ getDependencies(userName, platformOrOptions, options) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ const endpoint = Endpoints_1.Endpoint.GitHub.User.dependencies(userName);
55
+ let parameters = {};
56
+ if (platformOrOptions) {
57
+ if (typeof platformOrOptions === 'string') {
58
+ parameters = Object.assign({ platform: platformOrOptions }, options);
59
+ }
60
+ else {
61
+ parameters = platformOrOptions;
62
+ }
63
+ }
64
+ const { data } = yield this.apiClient.get(endpoint, { data: parameters });
65
+ return data;
66
+ });
67
+ }
68
+ /**
69
+ * Get a list of packages referencing the given user's repositories.
70
+ * @see https://libraries.io/api#user-projects
71
+ * @param userName The username
72
+ * @param options Pagination options
73
+ */
74
+ getProjects(userName, options) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ const endpoint = Endpoints_1.Endpoint.GitHub.User.projects(userName);
77
+ const { data } = yield this.apiClient.get(endpoint, { data: options });
78
+ return data;
79
+ });
80
+ }
81
+ /**
82
+ * Get repositories owned by a user.
83
+ * @see https://libraries.io/api#user-repositories
84
+ * @param userName The username
85
+ * @param options Pagination options
86
+ */
87
+ getRepositories(userName, options) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ const endpoint = Endpoints_1.Endpoint.GitHub.User.repositories(userName);
90
+ const { data } = yield this.apiClient.get(endpoint, { data: options });
91
+ return data;
92
+ });
93
+ }
94
+ /**
95
+ * Get information for a given user or organization.
96
+ * @see https://libraries.io/api#user
97
+ * @param userName The username
98
+ */
99
+ getUser(userName) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ const endpoint = Endpoints_1.Endpoint.GitHub.User.user(userName);
102
+ const { data } = yield this.apiClient.get(endpoint);
103
+ return data;
104
+ });
105
+ }
106
+ }
107
+ exports.GitHubUserAPI = GitHubUserAPI;
@@ -0,0 +1,2 @@
1
+ export * from './GitHubRepositoryAPI';
2
+ export * from './GitHubUserAPI';
@@ -0,0 +1,18 @@
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("./GitHubRepositoryAPI"), exports);
18
+ __exportStar(require("./GitHubUserAPI"), exports);
@@ -0,0 +1,12 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { ClientOptions, LibrariesIOResult, PaginationOptions, Platform } from '../interfaces/';
3
+ import { APIBase } from './APIBase';
4
+ export declare class PlatformAPI extends APIBase {
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
+ /**
7
+ * Get list of supported package managers.
8
+ * @see https://libraries.io/api#platforms
9
+ * @param options Pagination options
10
+ */
11
+ getPlatforms(options?: PaginationOptions): Promise<LibrariesIOResult<Platform[]>>;
12
+ }
@@ -0,0 +1,32 @@
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.PlatformAPI = void 0;
13
+ const Endpoints_1 = require("../Endpoints");
14
+ const APIBase_1 = require("./APIBase");
15
+ class PlatformAPI extends APIBase_1.APIBase {
16
+ constructor(apiClient, options) {
17
+ super(apiClient, options);
18
+ }
19
+ /**
20
+ * Get list of supported package managers.
21
+ * @see https://libraries.io/api#platforms
22
+ * @param options Pagination options
23
+ */
24
+ getPlatforms(options) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const endpoint = Endpoints_1.Endpoint.platforms();
27
+ const { data } = yield this.apiClient.get(endpoint, { data: options });
28
+ return data;
29
+ });
30
+ }
31
+ }
32
+ exports.PlatformAPI = PlatformAPI;
@@ -0,0 +1,64 @@
1
+ import type { APIClient } from '@ffflorian/api-client';
2
+ import type { ClientOptions, Contributor, LibrariesIOResult, PaginationOptions, PlatformType, Project, ProjectUsage, ProjectWithDependencies, Repository, SearchOptions } from '../interfaces/';
3
+ import { APIBase } from './APIBase';
4
+ export declare class ProjectAPI extends APIBase {
5
+ constructor(apiClient: APIClient, options: ClientOptions);
6
+ /**
7
+ * Get users that have contributed to a given project.
8
+ * @see https://libraries.io/api#project-contributors
9
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
10
+ * @param projectName The project name
11
+ * @param options Pagination options
12
+ */
13
+ getContributors(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Contributor[]>>;
14
+ /**
15
+ * Get repositories that depend on a given project.
16
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
17
+ * @param projectName The project name
18
+ * @param options Pagination options
19
+ */
20
+ getDependentRepositories(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>;
21
+ /**
22
+ * Get packages that have at least one version that depends on a given project.
23
+ * @see https://libraries.io/api#project-dependents
24
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
25
+ * @param projectName The project name
26
+ * @param options Pagination options
27
+ */
28
+ getDependents(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>;
29
+ /**
30
+ * Get information about a package and it's versions.
31
+ * @see https://libraries.io/api#project
32
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
33
+ * @param projectName The project name
34
+ */
35
+ getProject(platform: PlatformType, projectName: string): Promise<LibrariesIOResult<Project>>;
36
+ /**
37
+ * Get a list of dependencies for a version of a project, pass `latest` as version to get dependency info for the latest available version
38
+ * @see https://libraries.io/api#project-dependencies
39
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
40
+ * @param projectName The project name
41
+ * @param projectVersion
42
+ */
43
+ getProjectWithDependencies(platform: PlatformType, projectName: string, projectVersion: string): Promise<LibrariesIOResult<ProjectWithDependencies>>;
44
+ /**
45
+ * Get breakdown of SourceRank score for a given project.
46
+ * @see https://libraries.io/api#project-sourcerank
47
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
48
+ * @param projectName The project name
49
+ */
50
+ getSourceRank(platform: PlatformType, projectName: string): Promise<LibrariesIOResult<number>>;
51
+ /**
52
+ * Get breakdown of version usage for a given project.
53
+ * @param platform The project platform (e.g. "npm", "cargo", ...)
54
+ * @param projectName The project name
55
+ */
56
+ getUsage(platform: PlatformType, projectName: string): Promise<LibrariesIOResult<ProjectUsage>>;
57
+ /**
58
+ * Search for projects.
59
+ * @see https://libraries.io/api#project-search
60
+ * @param query The search query
61
+ * @param options Sorting, filter and pagination options
62
+ */
63
+ search(query: string, options?: SearchOptions): Promise<LibrariesIOResult<Project[]>>;
64
+ }