libraries.io
Advanced tools
Comparing version 1.0.0 to 1.1.0
import { RequestService } from '../../RequestService'; | ||
import { PaginationOptions, Project, RepositoryWithDependencies } from '../../interfaces/'; | ||
import { PaginationOptions, LibrariesIOResult, Project, RepositoryWithDependencies } from '../../interfaces/'; | ||
export declare class GitHubRepositoryAPI { | ||
@@ -12,3 +12,3 @@ private readonly requestService; | ||
*/ | ||
getRepository(repositoryOwner: string, repositoryName: string): Promise<RepositoryWithDependencies>; | ||
getRepository(repositoryOwner: string, repositoryName: string): Promise<LibrariesIOResult<RepositoryWithDependencies>>; | ||
/** | ||
@@ -20,3 +20,3 @@ * Get a list of dependencies for a repositories. Currently only works for open source repositories. | ||
*/ | ||
getRepositoryWithDependencies(repositoryOwner: string, repositoryName: string): Promise<RepositoryWithDependencies>; | ||
getRepositoryWithDependencies(repositoryOwner: string, repositoryName: string): Promise<LibrariesIOResult<RepositoryWithDependencies>>; | ||
/** | ||
@@ -29,3 +29,3 @@ * Get a list of packages referencing the given repository. | ||
*/ | ||
getProjects(repositoryOwner: string, repositoryName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getProjects(repositoryOwner: string, repositoryName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
} |
import { RequestService } from '../../RequestService'; | ||
import { Contributor, PaginationOptions, Project, Repository } from '../../interfaces/'; | ||
import { Contributor, LibrariesIOResult, PaginationOptions, Project, Repository } from '../../interfaces/'; | ||
export declare class GitHubUserAPI { | ||
@@ -11,3 +11,3 @@ private readonly requestService; | ||
*/ | ||
getUser(userName: string): Promise<Contributor>; | ||
getUser(userName: string): Promise<LibrariesIOResult<Contributor>>; | ||
/** | ||
@@ -19,3 +19,3 @@ * Get repositories owned by a user. | ||
*/ | ||
getRepositories(userName: string, options?: PaginationOptions): Promise<Repository[]>; | ||
getRepositories(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>; | ||
/** | ||
@@ -27,3 +27,3 @@ * 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[]>>; | ||
/** | ||
@@ -35,3 +35,3 @@ * Get a list of packages that the given user has contributed to. | ||
*/ | ||
getContributedProjects(userName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getContributedProjects(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
/** | ||
@@ -43,5 +43,5 @@ * Get a list of repositories that the given user has contributed to. | ||
*/ | ||
getContributedRepositories(userName: string, options?: PaginationOptions): Promise<Repository[]>; | ||
getDependencies(userName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getDependencies(userName: string, platform?: string, options?: PaginationOptions): Promise<Project[]>; | ||
getContributedRepositories(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>; | ||
getDependencies(userName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
getDependencies(userName: string, platform?: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
} |
import { RequestService } from '../RequestService'; | ||
import { Platform, PaginationOptions } from '../interfaces/'; | ||
import { LibrariesIOResult, Platform, PaginationOptions } from '../interfaces/'; | ||
export declare class PlatformAPI { | ||
@@ -11,3 +11,3 @@ private readonly requestService; | ||
*/ | ||
getPlatforms(options?: PaginationOptions): Promise<Platform[]>; | ||
getPlatforms(options?: PaginationOptions): Promise<LibrariesIOResult<Platform[]>>; | ||
} |
import { RequestService } from '../RequestService'; | ||
import { Contributor, PaginationOptions, Project, ProjectUsage, ProjectWithDependencies, Repository, SearchOptions } from '../interfaces/'; | ||
import { Contributor, LibrariesIOResult, PaginationOptions, Project, ProjectUsage, ProjectWithDependencies, Repository, SearchOptions } from '../interfaces/'; | ||
export declare class ProjectAPI { | ||
@@ -12,3 +12,3 @@ private readonly requestService; | ||
*/ | ||
getProject(platform: string, projectName: string): Promise<Project>; | ||
getProject(platform: string, projectName: string): Promise<LibrariesIOResult<Project>>; | ||
/** | ||
@@ -21,3 +21,3 @@ * Get a list of dependencies for a version of a project, pass `latest` as version to get dependency info for the latest available version | ||
*/ | ||
getProjectWithDependencies(platform: string, projectName: string, projectVersion: string): Promise<ProjectWithDependencies>; | ||
getProjectWithDependencies(platform: string, projectName: string, projectVersion: string): Promise<LibrariesIOResult<ProjectWithDependencies>>; | ||
/** | ||
@@ -30,3 +30,3 @@ * Get packages that have at least one version that depends on a given project. | ||
*/ | ||
getDependendents(platform: string, projectName: string, options?: PaginationOptions): Promise<Project[]>; | ||
getDependendents(platform: string, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Project[]>>; | ||
/** | ||
@@ -38,3 +38,3 @@ * Get repositories that depend on a given project. | ||
*/ | ||
getDependendentRepositories(platform: string, projectName: string, options?: PaginationOptions): Promise<Repository[]>; | ||
getDependendentRepositories(platform: string, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Repository[]>>; | ||
/** | ||
@@ -47,3 +47,3 @@ * Get users that have contributed to a given project. | ||
*/ | ||
getContributors(platform: string, projectName: string, options?: PaginationOptions): Promise<Contributor[]>; | ||
getContributors(platform: string, projectName: string, options?: PaginationOptions): Promise<LibrariesIOResult<Contributor[]>>; | ||
/** | ||
@@ -55,3 +55,3 @@ * Get breakdown of SourceRank score for a given project. | ||
*/ | ||
getSourceRank(platform: string, projectName: string): Promise<number>; | ||
getSourceRank(platform: string, projectName: string): Promise<LibrariesIOResult<number>>; | ||
/** | ||
@@ -62,3 +62,3 @@ * Get breakdown of version usage for a given project. | ||
*/ | ||
getUsage(platform: string, projectName: string): Promise<ProjectUsage>; | ||
getUsage(platform: string, projectName: string): Promise<LibrariesIOResult<ProjectUsage>>; | ||
/** | ||
@@ -70,3 +70,3 @@ * Search for projects. | ||
*/ | ||
search(query: string, options?: SearchOptions): Promise<Project[]>; | ||
search(query: string, options?: SearchOptions): Promise<LibrariesIOResult<Project[]>>; | ||
} |
import { RequestService } from '../RequestService'; | ||
import { PaginationOptions, PreReleaseOptions, Subscription } from '../interfaces/'; | ||
import { LibrariesIOHeaders, LibrariesIOResult, PaginationOptions, PreReleaseOptions, Subscription } from '../interfaces/'; | ||
export declare class UserAPI { | ||
@@ -12,3 +12,3 @@ private readonly requestService; | ||
*/ | ||
getSubscription(platform: string, projectName: string): Promise<Subscription | null>; | ||
getSubscription(platform: string, projectName: string): Promise<LibrariesIOResult<Subscription | null>>; | ||
/** | ||
@@ -19,3 +19,3 @@ * List packages that a user is subscribed to recieved notifications about new releases. | ||
*/ | ||
getAllSubscriptions(options?: PaginationOptions): Promise<Subscription[]>; | ||
getAllSubscriptions(options?: PaginationOptions): Promise<LibrariesIOResult<Subscription[]>>; | ||
/** | ||
@@ -28,3 +28,3 @@ * Subscribe to receive notifications about new releases of a project. | ||
*/ | ||
subscribe(platform: string, projectName: string, options?: PreReleaseOptions): Promise<Subscription>; | ||
subscribe(platform: string, projectName: string, options?: PreReleaseOptions): Promise<LibrariesIOResult<Subscription>>; | ||
/** | ||
@@ -36,3 +36,3 @@ * Stop receiving release notifications from a project. | ||
*/ | ||
unsubscribe(platform: string, projectName: string): Promise<void>; | ||
unsubscribe(platform: string, projectName: string): Promise<LibrariesIOHeaders>; | ||
/** | ||
@@ -45,3 +45,3 @@ * Update the options for a subscription. | ||
*/ | ||
updateSubscription(platform: string, projectName: string, options?: PreReleaseOptions): Promise<Subscription>; | ||
updateSubscription(platform: string, projectName: string, options?: PreReleaseOptions): Promise<LibrariesIOResult<Subscription>>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -80,15 +45,4 @@ var Endpoints_1 = require("../Endpoints"); | ||
UserAPI.prototype.unsubscribe = function (platform, projectName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var endpoint; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
return [4 /*yield*/, this.requestService.delete(endpoint)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
var endpoint = Endpoints_1.Endpoint.subscriptions(platform, projectName); | ||
return this.requestService.delete(endpoint); | ||
}; | ||
@@ -95,0 +49,0 @@ /** |
export * from './API'; | ||
export * from './Contributor'; | ||
export * from './LibrariesIOResult'; | ||
export * from './Options'; | ||
@@ -4,0 +5,0 @@ export * from './Platform'; |
/// <reference types="node" /> | ||
import { URL } from 'url'; | ||
import { ClientOptions, RequestOptions } from './interfaces/'; | ||
import { ClientOptions, LibrariesIOHeaders, LibrariesIOResult, RequestOptions } from './interfaces/'; | ||
export declare type HttpMethod = 'delete' | 'get' | 'post' | 'put'; | ||
@@ -9,6 +9,6 @@ export declare class RequestService { | ||
constructor(options: ClientOptions); | ||
delete<T>(endpoint: string, parameters?: RequestOptions): Promise<T>; | ||
get<T>(endpoint: string, parameters?: RequestOptions): Promise<T>; | ||
post<T>(endpoint: string, parameters?: RequestOptions): Promise<T>; | ||
put<T>(endpoint: string, parameters?: RequestOptions): Promise<T>; | ||
delete<T>(endpoint: string, parameters?: RequestOptions): Promise<LibrariesIOHeaders>; | ||
get<T>(endpoint: string, parameters?: RequestOptions): Promise<LibrariesIOResult<T>>; | ||
post<T>(endpoint: string, parameters?: RequestOptions): Promise<LibrariesIOResult<T>>; | ||
put<T>(endpoint: string, parameters?: RequestOptions): Promise<LibrariesIOResult<T>>; | ||
setApiUrl(apiUrl: URL): void; | ||
@@ -15,0 +15,0 @@ private static mapParameters; |
@@ -61,3 +61,13 @@ "use strict"; | ||
RequestService.prototype.delete = function (endpoint, parameters) { | ||
return this.request('delete', endpoint, parameters); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, rateLimit, rateLimitRemaining; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.request('delete', endpoint, parameters)]; | ||
case 1: | ||
_a = _b.sent(), rateLimit = _a.rateLimit, rateLimitRemaining = _a.rateLimitRemaining; | ||
return [2 /*return*/, { rateLimit: rateLimit, rateLimitRemaining: rateLimitRemaining }]; | ||
} | ||
}); | ||
}); | ||
}; | ||
@@ -111,5 +121,5 @@ RequestService.prototype.get = function (endpoint, parameters) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var params, config, response, contentType, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var params, config, _a, data, headers, status, contentType, rateLimit, rateLimitRemaining, totalResults, error_1; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -122,12 +132,15 @@ params = RequestService.mapParameters(__assign({}, parameters, { apiKey: this.apiKey })); | ||
}; | ||
_a.label = 1; | ||
_b.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
_b.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, axios_1.default.request(config)]; | ||
case 2: | ||
response = _a.sent(); | ||
contentType = response.headers['content-type']; | ||
_a = _b.sent(), data = _a.data, headers = _a.headers, status = _a.status; | ||
contentType = headers['content-type'] ? String(headers['content-type']) : undefined; | ||
rateLimit = Number(headers['x-ratelimit-limit']); | ||
rateLimitRemaining = Number(headers['x-ratelimit-remaining']); | ||
totalResults = headers['total'] ? Number(headers['total']) : undefined; | ||
if (contentType) { | ||
if (contentType.includes('application/json')) { | ||
return [2 /*return*/, response.data]; | ||
return [2 /*return*/, { data: data, rateLimit: rateLimit, rateLimitRemaining: rateLimitRemaining, totalResults: totalResults }]; | ||
} | ||
@@ -138,2 +151,5 @@ else { | ||
} | ||
else if (status === 204) { | ||
return [2 /*return*/, { data: data, rateLimit: rateLimit, rateLimitRemaining: rateLimitRemaining }]; | ||
} | ||
else { | ||
@@ -144,3 +160,3 @@ throw new APIException_1.InvalidResponseError('The server responded with invalid data: No Content-Type set.'); | ||
case 3: | ||
error_1 = _a.sent(); | ||
error_1 = _b.sent(); | ||
throw APIException_1.ExceptionMapper(error_1); | ||
@@ -147,0 +163,0 @@ case 4: return [2 /*return*/]; |
@@ -13,2 +13,3 @@ { | ||
"rimraf": "2.6.2", | ||
"touch": "3.1.0", | ||
"typedoc": "0.12.0", | ||
@@ -32,5 +33,8 @@ "typescript": "3.0.1" | ||
"build": "tsc", | ||
"build:docs": "typedoc --out docs/ --mode modules --excludePrivate --excludeExternals --exclude \"**/*(index|Endpoints|RequestService).ts\"", | ||
"clear": "rimraf dist", | ||
"clear:docs": "rimraf docs", | ||
"deploy:docs": "git subtree push --prefix docs origin gh-pages", | ||
"dist": "yarn clear && yarn build", | ||
"docs": "typedoc --out docs/ --mode modules --excludePrivate --excludeExternals --exclude \"**/*(index|Endpoints|RequestService).ts\"", | ||
"dist:docs": "yarn clear:docs && yarn build:docs && nodetouch docs/.nojekyll", | ||
"prettier": "prettier --write \"src/**/*.ts\" \"spec/**/*.js\"", | ||
@@ -40,3 +44,3 @@ "test": "yarn dist && jasmine" | ||
"types": "dist/index.d.ts", | ||
"version": "1.0.0" | ||
"version": "1.1.0" | ||
} |
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
75276
66
7
1243