libraries.io
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.1.0](https://github.com/ffflorian/api-clients/tree/master/packages/libraries.io/compare/libraries.io@2.0.1...libraries.io@2.1.0) (2019-09-01) | ||
### Features | ||
* Use axios instead of api-client ([#158](https://github.com/ffflorian/api-clients/tree/master/packages/libraries.io/issues/158)) ([53beba6](https://github.com/ffflorian/api-clients/tree/master/packages/libraries.io/commit/53beba6)) | ||
## [2.0.1](https://github.com/ffflorian/api-clients/tree/master/packages/libraries.io/compare/libraries.io@2.0.0...libraries.io@2.0.1) (2019-07-25) | ||
@@ -8,0 +19,0 @@ |
@@ -1,8 +0,13 @@ | ||
import { APIClient } from '@ffflorian/api-client'; | ||
import { ClientOptions, RequestOptions } from '../interfaces'; | ||
import { AxiosInstance } from 'axios'; | ||
import { ClientOptions } from '../interfaces'; | ||
export declare class APIBase { | ||
protected readonly apiClient: APIClient<RequestOptions>; | ||
protected readonly apiClient: AxiosInstance; | ||
protected readonly options: ClientOptions; | ||
constructor(apiClient: APIClient, options: ClientOptions); | ||
constructor(apiClient: AxiosInstance, options: ClientOptions); | ||
/** | ||
* Set a new API key. | ||
* @param apiKey The new API key | ||
*/ | ||
setApiKey(apiKey: string): void; | ||
/** | ||
* Set a new API URL. | ||
@@ -12,8 +17,3 @@ * @param newUrl The new API url | ||
setApiUrl(newUrl: string): void; | ||
/** | ||
* Set a new API key. | ||
* @param apiKey The new API key | ||
*/ | ||
setApiKey(apiKey: string): void; | ||
protected checkApiKey(apiName?: string): void; | ||
} |
@@ -9,9 +9,2 @@ "use strict"; | ||
/** | ||
* Set a new API URL. | ||
* @param newUrl The new API url | ||
*/ | ||
setApiUrl(newUrl) { | ||
this.apiClient.setApiUrl(newUrl); | ||
} | ||
/** | ||
* Set a new API key. | ||
@@ -23,2 +16,9 @@ * @param apiKey The new API key | ||
} | ||
/** | ||
* Set a new API URL. | ||
* @param newUrl The new API url | ||
*/ | ||
setApiUrl(newUrl) { | ||
this.apiClient.defaults.baseURL = newUrl; | ||
} | ||
checkApiKey(apiName) { | ||
@@ -25,0 +25,0 @@ apiName = `the "${apiName}"` || 'this'; |
@@ -1,7 +0,15 @@ | ||
import { APIClient } from '@ffflorian/api-client'; | ||
import { ClientOptions, PaginationOptions, Project, RepositoryWithDependencies } from '../../interfaces/'; | ||
import { AxiosInstance } from 'axios'; | ||
import { ClientOptions, LibrariesIOResult, PaginationOptions, Project, RepositoryWithDependencies } from '../../interfaces/'; | ||
import { APIBase } from '../APIBase'; | ||
export declare class GitHubRepositoryAPI extends APIBase { | ||
constructor(apiClient: APIClient, options: ClientOptions); | ||
constructor(apiClient: AxiosInstance, options: ClientOptions); | ||
/** | ||
* Get a list of packages referencing the given repository. | ||
* @see https://libraries.io/api#repository-projects | ||
* @param repositoryOwner The repository owner | ||
* @param repositoryName The repository name | ||
* @param options Pagination Options | ||
*/ | ||
getProjects(repositoryOwner: string, repositoryName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
/** | ||
* Get a info for a repository. Currently only works for open source repositories. | ||
@@ -12,3 +20,3 @@ * @see https://libraries.io/api#repository | ||
*/ | ||
getRepository(repositoryOwner: string, repositoryName: string): Promise<RepositoryWithDependencies>; | ||
getRepository(repositoryOwner: string, repositoryName: string): Promise<LibrariesIOResult<RepositoryWithDependencies>>; | ||
/** | ||
@@ -20,11 +28,3 @@ * Get a list of dependencies for a repositories. Currently only works for open source repositories. | ||
*/ | ||
getRepositoryWithDependencies(repositoryOwner: string, repositoryName: string): Promise<RepositoryWithDependencies>; | ||
/** | ||
* Get a list of packages referencing the given repository. | ||
* @see https://libraries.io/api#repository-projects | ||
* @param repositoryOwner The repository owner | ||
* @param repositoryName The repository name | ||
* @param options Pagination Options | ||
*/ | ||
getProjects(repositoryOwner: string, repositoryName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getRepositoryWithDependencies(repositoryOwner: string, repositoryName: string): Promise<LibrariesIOResult<RepositoryWithDependencies>>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,2 +19,16 @@ const Endpoints_1 = require("../../Endpoints"); | ||
/** | ||
* Get a list of packages referencing the given repository. | ||
* @see https://libraries.io/api#repository-projects | ||
* @param repositoryOwner The repository owner | ||
* @param repositoryName The repository name | ||
* @param options Pagination Options | ||
*/ | ||
getProjects(repositoryOwner, repositoryName, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.Repository.projects(repositoryOwner, repositoryName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get a info for a repository. Currently only works for open source repositories. | ||
@@ -17,4 +40,7 @@ * @see https://libraries.io/api#repository | ||
getRepository(repositoryOwner, repositoryName) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.Repository.repository(repositoryOwner, repositoryName); | ||
return this.apiClient.requestService.get(endpoint); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.Repository.repository(repositoryOwner, repositoryName); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
@@ -28,18 +54,10 @@ /** | ||
getRepositoryWithDependencies(repositoryOwner, repositoryName) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.Repository.dependencies(repositoryOwner, repositoryName); | ||
return this.apiClient.requestService.get(endpoint); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.Repository.dependencies(repositoryOwner, repositoryName); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get a list of packages referencing the given repository. | ||
* @see https://libraries.io/api#repository-projects | ||
* @param repositoryOwner The repository owner | ||
* @param repositoryName The repository name | ||
* @param options Pagination Options | ||
*/ | ||
getProjects(repositoryOwner, repositoryName, options) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.Repository.projects(repositoryOwner, repositoryName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
} | ||
} | ||
exports.GitHubRepositoryAPI = GitHubRepositoryAPI; | ||
//# sourceMappingURL=GitHubRepositoryAPI.js.map |
@@ -1,19 +0,22 @@ | ||
import { APIClient } from '@ffflorian/api-client'; | ||
import { ClientOptions, Contributor, PaginationOptions, PlatformType, Project, Repository } from '../../interfaces/'; | ||
import { AxiosInstance } from 'axios'; | ||
import { ClientOptions, Contributor, LibrariesIOResult, PaginationOptions, PlatformType, Project, Repository } from '../../interfaces/'; | ||
import { APIBase } from '../APIBase'; | ||
export declare class GitHubUserAPI extends APIBase { | ||
constructor(apiClient: APIClient, options: ClientOptions); | ||
constructor(apiClient: AxiosInstance, options: ClientOptions); | ||
/** | ||
* Get information for a given user or organization. | ||
* @see https://libraries.io/api#user | ||
* Get a list of packages that the given user has contributed to. | ||
* @see https://libraries.io/api#user-project-contributions | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getUser(userName: string): Promise<Contributor>; | ||
getContributedProjects(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
/** | ||
* Get repositories owned by a user. | ||
* @see https://libraries.io/api#user-repositories | ||
* Get a list of repositories that the given user has contributed to. | ||
* @see https://libraries.io/api#user-repository-contributions | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getRepositories(userName: string, options?: PaginationOptions): Promise<Repository[]>; | ||
getContributedRepositories(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>; | ||
getDependencies(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
getDependencies(userName: string, platform?: PlatformType, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
/** | ||
@@ -25,19 +28,16 @@ * Get a list of packages referencing the given user's repositories. | ||
*/ | ||
getProjects(userName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getProjects(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
/** | ||
* Get a list of packages that the given user has contributed to. | ||
* @see https://libraries.io/api#user-project-contributions | ||
* Get repositories owned by a user. | ||
* @see https://libraries.io/api#user-repositories | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getContributedProjects(userName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getRepositories(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>; | ||
/** | ||
* Get a list of repositories that the given user has contributed to. | ||
* @see https://libraries.io/api#user-repository-contributions | ||
* Get information for a given user or organization. | ||
* @see https://libraries.io/api#user | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getContributedRepositories(userName: string, options?: PaginationOptions): Promise<Repository[]>; | ||
getDependencies(userName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getDependencies(userName: string, platform?: PlatformType, options?: PaginationOptions): Promise<Project[]>; | ||
getUser(userName: string): Promise<LibrariesIOResult<Contributor>>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,69 +19,87 @@ const Endpoints_1 = require("../../Endpoints"); | ||
/** | ||
* Get information for a given user or organization. | ||
* @see https://libraries.io/api#user | ||
* Get a list of packages that the given user has contributed to. | ||
* @see https://libraries.io/api#user-project-contributions | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getUser(userName) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.user(userName); | ||
return this.apiClient.requestService.get(endpoint); | ||
getContributedProjects(userName, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedProjects(userName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get repositories owned by a user. | ||
* @see https://libraries.io/api#user-repositories | ||
* Get a list of repositories that the given user has contributed to. | ||
* @see https://libraries.io/api#user-repository-contributions | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getRepositories(userName, options) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.repositories(userName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
getContributedRepositories(userName, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedRepositories(userName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get a list of packages referencing the given user's repositories. | ||
* @see https://libraries.io/api#user-projects | ||
* Get a list of unique packages that the given user's repositories list as a dependency. Ordered by frequency of use in those repositories. | ||
* @see https://libraries.io/api#user-dependencies | ||
* @param userName The username | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param options Pagination options | ||
*/ | ||
getProjects(userName, options) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.repositories(userName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
getDependencies(userName, platformOrOptions, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedRepositories(userName); | ||
let parameters = {}; | ||
if (platformOrOptions) { | ||
if (typeof platformOrOptions === 'string') { | ||
parameters = Object.assign({ platform: platformOrOptions }, options); | ||
} | ||
else { | ||
parameters = platformOrOptions; | ||
} | ||
} | ||
const { data } = yield this.apiClient.get(endpoint, { data: parameters }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get a list of packages that the given user has contributed to. | ||
* @see https://libraries.io/api#user-project-contributions | ||
* Get a list of packages referencing the given user's repositories. | ||
* @see https://libraries.io/api#user-projects | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getContributedProjects(userName, options) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedProjects(userName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
getProjects(userName, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.repositories(userName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get a list of repositories that the given user has contributed to. | ||
* @see https://libraries.io/api#user-repository-contributions | ||
* Get repositories owned by a user. | ||
* @see https://libraries.io/api#user-repositories | ||
* @param userName The username | ||
* @param options Pagination options | ||
*/ | ||
getContributedRepositories(userName, options) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedRepositories(userName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
getRepositories(userName, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.repositories(userName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get a list of unique packages that the given user's repositories list as a dependency. Ordered by frequency of use in those repositories. | ||
* @see https://libraries.io/api#user-dependencies | ||
* Get information for a given user or organization. | ||
* @see https://libraries.io/api#user | ||
* @param userName The username | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param options Pagination options | ||
*/ | ||
getDependencies(userName, platformOrOptions, options) { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.contributedRepositories(userName); | ||
let parameters = {}; | ||
if (platformOrOptions) { | ||
if (typeof platformOrOptions === 'string') { | ||
parameters = Object.assign({ platform: platformOrOptions }, options); | ||
} | ||
else { | ||
parameters = platformOrOptions; | ||
} | ||
} | ||
return this.apiClient.requestService.get(endpoint, { data: parameters }); | ||
getUser(userName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.GitHub.User.user(userName); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
@@ -79,0 +106,0 @@ } |
@@ -1,6 +0,6 @@ | ||
import { APIClient } from '@ffflorian/api-client'; | ||
import { ClientOptions, PaginationOptions, Platform } from '../interfaces/'; | ||
import { AxiosInstance } from 'axios'; | ||
import { ClientOptions, LibrariesIOResult, PaginationOptions, Platform } from '../interfaces/'; | ||
import { APIBase } from './APIBase'; | ||
export declare class PlatformAPI extends APIBase { | ||
constructor(apiClient: APIClient, options: ClientOptions); | ||
constructor(apiClient: AxiosInstance, options: ClientOptions); | ||
/** | ||
@@ -11,3 +11,3 @@ * Get list of supported package managers. | ||
*/ | ||
getPlatforms(options?: PaginationOptions): Promise<Platform[]>; | ||
getPlatforms(options?: PaginationOptions): Promise<LibrariesIOResult<Platform[]>>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -15,4 +24,7 @@ const Endpoints_1 = require("../Endpoints"); | ||
getPlatforms(options) { | ||
const endpoint = Endpoints_1.Endpoint.platforms(); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.platforms(); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
@@ -19,0 +31,0 @@ } |
@@ -1,21 +0,21 @@ | ||
import { APIClient } from '@ffflorian/api-client'; | ||
import { ClientOptions, Contributor, PaginationOptions, PlatformType, Project, ProjectUsage, ProjectWithDependencies, Repository, SearchOptions } from '../interfaces/'; | ||
import { AxiosInstance } from 'axios'; | ||
import { ClientOptions, Contributor, LibrariesIOResult, PaginationOptions, PlatformType, Project, ProjectUsage, ProjectWithDependencies, Repository, SearchOptions } from '../interfaces/'; | ||
import { APIBase } from './APIBase'; | ||
export declare class ProjectAPI extends APIBase { | ||
constructor(apiClient: APIClient, options: ClientOptions); | ||
constructor(apiClient: AxiosInstance, options: ClientOptions); | ||
/** | ||
* Get information about a package and it's versions. | ||
* @see https://libraries.io/api#project | ||
* Get users that have contributed to a given project. | ||
* @see https://libraries.io/api#project-contributors | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param options Pagination options | ||
*/ | ||
getProject(platform: PlatformType, projectName: string): Promise<Project>; | ||
getContributors(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Contributor[]>>; | ||
/** | ||
* Get a list of dependencies for a version of a project, pass `latest` as version to get dependency info for the latest available version | ||
* @see https://libraries.io/api#project-dependencies | ||
* Get repositories that depend on a given project. | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param projectVersion | ||
* @param options Pagination options | ||
*/ | ||
getProjectWithDependencies(platform: PlatformType, projectName: string, projectVersion: string): Promise<ProjectWithDependencies>; | ||
getDependendentRepositories(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>; | ||
/** | ||
@@ -28,18 +28,18 @@ * Get packages that have at least one version that depends on a given project. | ||
*/ | ||
getDependendents(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getDependendents(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
/** | ||
* Get repositories that depend on a given project. | ||
* Get information about a package and it's versions. | ||
* @see https://libraries.io/api#project | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param options Pagination options | ||
*/ | ||
getDependendentRepositories(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<Repository[]>; | ||
getProject(platform: PlatformType, projectName: string): Promise<LibrariesIOResult<Project>>; | ||
/** | ||
* Get users that have contributed to a given project. | ||
* @see https://libraries.io/api#project-contributors | ||
* Get a list of dependencies for a version of a project, pass `latest` as version to get dependency info for the latest available version | ||
* @see https://libraries.io/api#project-dependencies | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param options Pagination options | ||
* @param projectVersion | ||
*/ | ||
getContributors(platform: PlatformType, projectName: string, options?: PaginationOptions): Promise<Contributor[]>; | ||
getProjectWithDependencies(platform: PlatformType, projectName: string, projectVersion: string): Promise<LibrariesIOResult<ProjectWithDependencies>>; | ||
/** | ||
@@ -51,3 +51,3 @@ * Get breakdown of SourceRank score for a given project. | ||
*/ | ||
getSourceRank(platform: PlatformType, projectName: string): Promise<number>; | ||
getSourceRank(platform: PlatformType, projectName: string): Promise<LibrariesIOResult<number>>; | ||
/** | ||
@@ -58,3 +58,3 @@ * Get breakdown of version usage for a given project. | ||
*/ | ||
getUsage(platform: PlatformType, projectName: string): Promise<ProjectUsage>; | ||
getUsage(platform: PlatformType, projectName: string): Promise<LibrariesIOResult<ProjectUsage>>; | ||
/** | ||
@@ -66,3 +66,3 @@ * Search for projects. | ||
*/ | ||
search(query: string, options?: SearchOptions): Promise<Project[]>; | ||
search(query: string, options?: SearchOptions): Promise<LibrariesIOResult<Project[]>>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,21 +19,27 @@ const Endpoints_1 = require("../Endpoints"); | ||
/** | ||
* Get information about a package and it's versions. | ||
* @see https://libraries.io/api#project | ||
* Get users that have contributed to a given project. | ||
* @see https://libraries.io/api#project-contributors | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param options Pagination options | ||
*/ | ||
getProject(platform, projectName) { | ||
const endpoint = Endpoints_1.Endpoint.Project.project(platform, projectName); | ||
return this.apiClient.requestService.get(endpoint); | ||
getContributors(platform, projectName, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependents(platform, projectName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get a list of dependencies for a version of a project, pass `latest` as version to get dependency info for the latest available version | ||
* @see https://libraries.io/api#project-dependencies | ||
* Get repositories that depend on a given project. | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param projectVersion | ||
* @param options Pagination options | ||
*/ | ||
getProjectWithDependencies(platform, projectName, projectVersion) { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependencies(platform, projectName, projectVersion); | ||
return this.apiClient.requestService.get(endpoint); | ||
getDependendentRepositories(platform, projectName, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependents(platform, projectName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
@@ -39,25 +54,34 @@ /** | ||
getDependendents(platform, projectName, options) { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependents(platform, projectName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependents(platform, projectName); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get repositories that depend on a given project. | ||
* Get information about a package and it's versions. | ||
* @see https://libraries.io/api#project | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param options Pagination options | ||
*/ | ||
getDependendentRepositories(platform, projectName, options) { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependents(platform, projectName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
getProject(platform, projectName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.project(platform, projectName); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Get users that have contributed to a given project. | ||
* @see https://libraries.io/api#project-contributors | ||
* Get a list of dependencies for a version of a project, pass `latest` as version to get dependency info for the latest available version | ||
* @see https://libraries.io/api#project-dependencies | ||
* @param platform The project platform (e.g. "npm", "cargo", ...) | ||
* @param projectName The project name | ||
* @param options Pagination options | ||
* @param projectVersion | ||
*/ | ||
getContributors(platform, projectName, options) { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependents(platform, projectName); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
getProjectWithDependencies(platform, projectName, projectVersion) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.dependencies(platform, projectName, projectVersion); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
@@ -71,4 +95,7 @@ /** | ||
getSourceRank(platform, projectName) { | ||
const endpoint = Endpoints_1.Endpoint.Project.sourceRank(platform, projectName); | ||
return this.apiClient.requestService.get(endpoint); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.sourceRank(platform, projectName); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
@@ -81,4 +108,7 @@ /** | ||
getUsage(platform, projectName) { | ||
const endpoint = Endpoints_1.Endpoint.Project.sourceRank(platform, projectName); | ||
return this.apiClient.requestService.get(endpoint); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.sourceRank(platform, projectName); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
@@ -92,4 +122,7 @@ /** | ||
search(query, options) { | ||
const endpoint = Endpoints_1.Endpoint.Project.search(); | ||
return this.apiClient.requestService.get(endpoint, { data: Object.assign({}, options, { q: query }) }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.Project.search(); | ||
const { data } = yield this.apiClient.get(endpoint, { data: Object.assign(Object.assign({}, options), { q: query }) }); | ||
return data; | ||
}); | ||
} | ||
@@ -96,0 +129,0 @@ } |
@@ -1,7 +0,13 @@ | ||
import { APIClient } from '@ffflorian/api-client'; | ||
import { ClientOptions, LibrariesIOHeaders, PaginationOptions, PlatformType, PreReleaseOptions, Subscription } from '../interfaces/'; | ||
import { AxiosInstance } from 'axios'; | ||
import { ClientOptions, LibrariesIOHeaders, LibrariesIOResult, PaginationOptions, PlatformType, PreReleaseOptions, Subscription } from '../interfaces/'; | ||
import { APIBase } from './APIBase'; | ||
export declare class UserAPI extends APIBase { | ||
constructor(apiClient: APIClient, options: ClientOptions); | ||
constructor(apiClient: AxiosInstance, options: ClientOptions); | ||
/** | ||
* List packages that a user is subscribed to recieved notifications about new releases. | ||
* @see https://libraries.io/api#subscriptions-index | ||
* @param options Pagination options | ||
*/ | ||
getAllSubscriptions(options?: PaginationOptions): Promise<LibrariesIOResult<Subscription[]>>; | ||
/** | ||
* Check if a users is subscribed to receive notifications about new releases of a project. | ||
@@ -12,10 +18,4 @@ * @see https://libraries.io/api#subscriptions-show | ||
*/ | ||
getSubscription(platform: PlatformType, projectName: string): Promise<Subscription | null>; | ||
getSubscription(platform: PlatformType, projectName: string): Promise<LibrariesIOResult<Subscription | null>>; | ||
/** | ||
* List packages that a user is subscribed to recieved notifications about new releases. | ||
* @see https://libraries.io/api#subscriptions-index | ||
* @param options Pagination options | ||
*/ | ||
getAllSubscriptions(options?: PaginationOptions): Promise<Subscription[]>; | ||
/** | ||
* Subscribe to receive notifications about new releases of a project. | ||
@@ -27,3 +27,3 @@ * @see https://libraries.io/api#subscriptions-create | ||
*/ | ||
subscribe(platform: PlatformType, projectName: string, options?: PreReleaseOptions): Promise<Subscription>; | ||
subscribe(platform: PlatformType, projectName: string, options?: PreReleaseOptions): Promise<LibrariesIOResult<Subscription>>; | ||
/** | ||
@@ -43,3 +43,3 @@ * Stop receiving release notifications from a project. | ||
*/ | ||
updateSubscription(platform: PlatformType, projectName: string, options?: PreReleaseOptions): Promise<Subscription>; | ||
updateSubscription(platform: PlatformType, projectName: string, options?: PreReleaseOptions): Promise<LibrariesIOResult<Subscription>>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -10,2 +19,14 @@ const Endpoints_1 = require("../Endpoints"); | ||
/** | ||
* List packages that a user is subscribed to recieved notifications about new releases. | ||
* @see https://libraries.io/api#subscriptions-index | ||
* @param options Pagination options | ||
*/ | ||
getAllSubscriptions(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(); | ||
const { data } = yield this.apiClient.get(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* Check if a users is subscribed to receive notifications about new releases of a project. | ||
@@ -17,15 +38,9 @@ * @see https://libraries.io/api#subscriptions-show | ||
getSubscription(platform, projectName) { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
return this.apiClient.requestService.get(endpoint); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
const { data } = yield this.apiClient.get(endpoint); | ||
return data; | ||
}); | ||
} | ||
/** | ||
* List packages that a user is subscribed to recieved notifications about new releases. | ||
* @see https://libraries.io/api#subscriptions-index | ||
* @param options Pagination options | ||
*/ | ||
getAllSubscriptions(options) { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(); | ||
return this.apiClient.requestService.get(endpoint, { data: options }); | ||
} | ||
/** | ||
* Subscribe to receive notifications about new releases of a project. | ||
@@ -38,4 +53,7 @@ * @see https://libraries.io/api#subscriptions-create | ||
subscribe(platform, projectName, options) { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
return this.apiClient.requestService.post(endpoint, { data: options }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
const { data } = yield this.apiClient.post(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
@@ -49,4 +67,7 @@ /** | ||
unsubscribe(platform, projectName) { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
return this.apiClient.requestService.delete(endpoint); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
const { data } = yield this.apiClient.delete(endpoint); | ||
return data; | ||
}); | ||
} | ||
@@ -61,4 +82,7 @@ /** | ||
updateSubscription(platform, projectName, options) { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
return this.apiClient.requestService.put(endpoint, { data: options }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
const { data } = yield this.apiClient.put(endpoint, { data: options }); | ||
return data; | ||
}); | ||
} | ||
@@ -65,0 +89,0 @@ } |
@@ -6,1 +6,4 @@ export interface LibrariesIOHeaders { | ||
} | ||
export interface LibrariesIOResult<T> extends LibrariesIOHeaders { | ||
data: T; | ||
} |
@@ -20,5 +20,5 @@ export declare type SortType = 'contributions_count' | 'created_at' | 'dependent_repos_count' | 'dependents_count' | 'latest_release_published_at' | 'rank' | 'stars'; | ||
export interface SearchOptions extends PaginationOptions { | ||
filter?: FilterOptions; | ||
/** sort by */ | ||
sort?: SortType; | ||
filter?: FilterOptions; | ||
} | ||
@@ -25,0 +25,0 @@ export interface RequestOptions extends SearchOptions, PreReleaseOptions { |
@@ -25,4 +25,4 @@ import { PlatformType } from './Options'; | ||
export interface ProjectWithDependencies extends Project { | ||
dependencies: ProjectDependency[]; | ||
dependencies_for_version: string; | ||
dependencies: ProjectDependency[]; | ||
dependent_repos_count: number; | ||
@@ -35,4 +35,4 @@ dependents_count: number; | ||
kind: 'Development' | 'runtime' | 'Optional'; | ||
latest: string; | ||
latest_stable: string; | ||
latest: string; | ||
name: string; | ||
@@ -57,4 +57,4 @@ outdated: boolean; | ||
export interface ProjectVersion { | ||
number: string; | ||
published_at: string; | ||
number: string; | ||
} |
@@ -7,4 +7,4 @@ import { ProjectDependency } from '../interfaces/Project'; | ||
description: string; | ||
fork: false; | ||
fork_policy: string | null; | ||
fork: false; | ||
forks_count: number; | ||
@@ -11,0 +11,0 @@ full_name: string; |
import { Project } from './Project'; | ||
export interface Subscription { | ||
created_at: string; | ||
include_prerelease: boolean; | ||
created_at: string; | ||
project: Project; | ||
updated_at: string; | ||
project: Project; | ||
} |
@@ -9,2 +9,7 @@ import { API, ClientOptions } from './interfaces/'; | ||
/** | ||
* Set a new API key. | ||
* @param apiKey The new API key | ||
*/ | ||
setApiKey(apiKey: string): void; | ||
/** | ||
* Set a new API URL. | ||
@@ -14,7 +19,2 @@ * @param newUrl The new API url | ||
setApiUrl(newUrl: string): void; | ||
/** | ||
* Set a new API key. | ||
* @param apiKey The new API key | ||
*/ | ||
setApiKey(apiKey: string): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const api_client_1 = require("@ffflorian/api-client"); | ||
const axios_1 = require("axios"); | ||
const api_1 = require("./api"); | ||
@@ -11,18 +11,14 @@ class LibrariesIO { | ||
this.options = Object.assign({ apiUrl: 'https://libraries.io/api' }, options); | ||
const requestInjector = config => { | ||
config.data = Object.assign({}, config.data, { api_key: this.options.apiKey }); | ||
this.apiClient = axios_1.default.create({ | ||
baseURL: this.options.apiUrl, | ||
}); | ||
this.apiClient.interceptors.request.use(config => { | ||
config.data = Object.assign(Object.assign({}, config.data), { api_key: this.options.apiKey }); | ||
return config; | ||
}; | ||
// const responseInjector = (response: AxiosResponseWithoutData<LibrariesIOHeaders>) => { | ||
// const headers = response.headers; | ||
// const contentType = headers['content-type'] ? String(headers['content-type']) : undefined; | ||
// const rateLimit = Number(headers['x-ratelimit-limit']); | ||
// const rateLimitRemaining = Number(headers['x-ratelimit-remaining']); | ||
// const totalResults = headers['total'] ? Number(headers['total']) : undefined; | ||
// return {...response, d: 2} | ||
// } | ||
this.apiClient = new api_client_1.APIClient({ | ||
apiUrl: this.options.apiUrl, | ||
requestInjector, | ||
}); | ||
this.apiClient.interceptors.response.use(response => { | ||
const headers = response.headers; | ||
const totalResults = headers['total'] ? Number(headers['total']) : undefined; | ||
return Object.assign(Object.assign({}, response), { totalResults }); | ||
}); | ||
this.api = { | ||
@@ -38,2 +34,9 @@ github: { | ||
} | ||
/** | ||
* Set a new API key. | ||
* @param apiKey The new API key | ||
*/ | ||
setApiKey(apiKey) { | ||
this.options.apiKey = apiKey; | ||
} | ||
/* | ||
@@ -51,13 +54,6 @@ | ||
setApiUrl(newUrl) { | ||
this.apiClient.setApiUrl(newUrl); | ||
this.apiClient.defaults.baseURL = newUrl; | ||
} | ||
/** | ||
* Set a new API key. | ||
* @param apiKey The new API key | ||
*/ | ||
setApiKey(apiKey) { | ||
this.options.apiKey = apiKey; | ||
} | ||
} | ||
exports.LibrariesIO = LibrariesIO; | ||
//# sourceMappingURL=LibrariesIO.js.map |
{ | ||
"author": "Florian Keller <github@floriankeller.de>", | ||
"dependencies": { | ||
"@ffflorian/api-client": "1.0.0" | ||
"axios": "0.19.0" | ||
}, | ||
"description": "A libraries.io API client", | ||
"devDependencies": { | ||
"@types/jasmine": "3.3.15", | ||
"@types/jasmine": "3.4.0", | ||
"@types/node": "~12", | ||
"jasmine": "3.4.0", | ||
"rimraf": "2.6.3", | ||
"rimraf": "3.0.0", | ||
"ts-node": "8.3.0", | ||
"typedoc": "0.14.2", | ||
"typescript": "3.5.3" | ||
"typedoc": "0.15.0", | ||
"typescript": "3.6.2" | ||
}, | ||
@@ -39,4 +39,4 @@ "engines": { | ||
}, | ||
"version": "2.0.1", | ||
"gitHead": "318999608e0833ffe5b78f1e331148ac76aa0709" | ||
"version": "2.1.0", | ||
"gitHead": "e39d15d0699fc660a7748c09462005cf997ab6b2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72798
1128
64
+ Addedaxios@0.19.0
- Removed@ffflorian/api-client@1.0.0
- Removed@ffflorian/api-client@1.0.0(transitive)
- Removedhttp-status-codes@1.3.2(transitive)