Socket
Socket
Sign inDemoInstall

gitlab-fetch

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitlab-fetch - npm Package Compare versions

Comparing version 0.1.0-dev.5758803 to 0.1.0-dev.5793073

lib/apis/labels.d.ts

1

lib/apis/branches.d.ts

@@ -15,2 +15,3 @@ import { AbstractApi, Config } from '../common';

create(name: string, ref: string): Promise<Branch>;
delete(name: string): Promise<void>;
}

11

lib/apis/branches.js

@@ -6,3 +6,3 @@ "use strict";

constructor(config, idOrNamespace, projectName) {
super(config, `/projects/${project_1.ProjectApi.toProjectId(idOrNamespace, projectName)}/branches`);
super(config, `/projects/${project_1.ProjectApi.toProjectId(idOrNamespace, projectName)}/repository/branches`);
}

@@ -13,9 +13,9 @@ getAll() {

get(name) {
return this.fetch('GET', `/${name}`);
return this.fetch('GET', `/${encodeURIComponent(name)}`);
}
protect(name, params = {}) {
return this.fetch('PUT', `/${name}/protect`, params);
return this.fetch('PUT', `/${encodeURIComponent(name)}/protect`, params);
}
unprotect(name) {
return this.fetch('PUT', `/${name}/unprotect`);
return this.fetch('PUT', `/${encodeURIComponent(name)}/unprotect`);
}

@@ -25,4 +25,7 @@ create(name, ref) {

}
delete(name) {
return this.fetch('DELETE', `/${encodeURIComponent(name)}`);
}
}
exports.BranchesApi = BranchesApi;
//# sourceMappingURL=branches.js.map

@@ -0,4 +1,9 @@

export * from './branches';
export * from './hooks';
export * from './labels';
export * from './merge-requests';
export * from './project';
export * from './projects';
export * from './branches';
export * from './hooks';
export * from './repository';
export * from './tags';
export * from './users';

@@ -5,6 +5,11 @@ "use strict";

}
__export(require("./branches"));
__export(require("./hooks"));
__export(require("./labels"));
__export(require("./merge-requests"));
__export(require("./project"));
__export(require("./projects"));
__export(require("./branches"));
__export(require("./hooks"));
__export(require("./repository"));
__export(require("./tags"));
__export(require("./users"));
//# sourceMappingURL=index.js.map

@@ -15,3 +15,3 @@ import { AbstractApi, Config } from '../common';

milestone_id?: number;
remove_source_branch?: boolean;
remove_source_branch?: true | undefined;
}

@@ -18,0 +18,0 @@ export interface EditMergeRequestParams extends CreateMergeRequestsParams {

import { AbstractApi, Config } from '../common';
import { Project, User, Event, UploadedFile } from '../models';
import { Project, UserSummary, Event, UploadedFile } from '../models';
export interface EditProjectParams {

@@ -37,9 +37,9 @@ name?: string;

unarchive(): Promise<Project>;
getUsers(): Promise<User[]>;
getUsers(): Promise<UserSummary[]>;
getEvents(): Promise<Event[]>;
uploadFile(file: string): Promise<UploadedFile>;
share(groupId: number, groupAccess: number, params?: ShareProjectParams): Promise<void>;
unshare(groupId: string): Promise<void>;
unshare(groupId: number): Promise<void>;
createForkRelation(forkedFromId: number): Promise<void>;
deleteForkRelation(): Promise<void>;
}

@@ -12,3 +12,3 @@ "use strict";

else {
return `${idOrNamespace}%2F${projectName}`;
return encodeURIComponent(`${idOrNamespace}/${projectName}`);
}

@@ -15,0 +15,0 @@ }

@@ -23,3 +23,3 @@ "use strict";

search(query, params = {}) {
return this.fetch('GET', `/projects/search/${query}`, params);
return this.fetch('GET', `/projects/search/${encodeURIComponent(query)}`, params);
}

@@ -26,0 +26,0 @@ create(name, params = {}) {

@@ -1,2 +0,2 @@

import { Config } from './configuration';
import { Config } from './config';
export declare abstract class AbstractApi {

@@ -3,0 +3,0 @@ config: Config;

@@ -7,3 +7,3 @@ "use strict";

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());
step((generator = generator.apply(thisArg, _arguments || [])).next());
});

@@ -13,3 +13,3 @@ };

const query_string_1 = require("query-string");
const configuration_1 = require("./configuration");
const config_1 = require("./config");
const debug_1 = require("./debug");

@@ -71,5 +71,5 @@ class AbstractApi {

*/
fetch(method, path, params = {}) {
fetch(method, path, params = {}, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const [response, body] = yield this.fetchBody(method, path, params);
const [response, body] = yield this.fetchBody(method, path, params, options);
if (response.status < 200 || response.status >= 300) {

@@ -85,5 +85,5 @@ debug_1.network(response);

*/
fetchBody(method, path, params = {}) {
fetchBody(method, path, params = {}, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.rawFetch(method, path || '', params);
const response = yield this.rawFetch(method, path || '', params, undefined, options);
const body = yield AbstractApi.parseBody(response);

@@ -98,3 +98,3 @@ return [response, body];

const { auth } = this.config;
if (configuration_1.isPrivateKeyAuthentication(auth)) {
if (config_1.isPrivateKeyAuthentication(auth)) {
headers.append('PRIVATE-TOKEN', auth.privateToken);

@@ -109,6 +109,7 @@ }

*/
rawFetch(method, path, params, headers = new node_fetch_1.Headers()) {
rawFetch(method, path, params, headers = new node_fetch_1.Headers(), options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const { baseApiPath = this.baseApiPath } = options;
this.enhanceHeaders(headers);
let url = `${this.config.baseUrl}${this.baseApiPath}${path}`;
let url = `${this.config.baseUrl}${baseApiPath}${path}`;
const query = query_string_1.stringify(AbstractApi.cleanParams(params));

@@ -115,0 +116,0 @@ if (query) {

@@ -7,2 +7,6 @@ "use strict";

exports.network = createDebug('gitlab-fetch:network');
/**
* @internal
*/
exports.loadConfig = createDebug('gitlab-fetch:load-config');
//# sourceMappingURL=debug.js.map
export * from './abstract-api';
export * from './configuration';
export * from './config';
export { default as loadConfig } from './load-config';

@@ -6,3 +6,5 @@ "use strict";

__export(require("./abstract-api"));
__export(require("./configuration"));
__export(require("./config"));
var load_config_1 = require("./load-config");
exports.loadConfig = load_config_1.default;
//# sourceMappingURL=index.js.map

@@ -1,14 +0,5 @@

interface Branch {
import { Commit } from './commit';
export interface Branch {
name: string;
commit: {
id: string;
parent_ids: string[];
message: string;
author_name: string;
author_email: string;
authored_date: string;
committer_name: string;
committer_email: string;
committed_date: string;
};
commit: Commit;
protected: boolean;

@@ -18,2 +9,1 @@ developers_can_push: boolean;

}
export default Branch;

@@ -1,11 +0,15 @@

interface Commit {
export interface Commit {
id: string;
short_id: string;
short_id?: string;
parent_ids?: string;
title: string;
author_name: string;
author_email: string;
created_at: string;
authored_date?: string;
committer_name?: string;
committer_email?: string;
committed_date?: string;
created_at?: string;
message: string;
}
export default Commit;
export interface Diff {

@@ -12,0 +16,0 @@ old_path: string;

@@ -1,3 +0,3 @@

import User from './user';
interface Event {
import { UserSummary } from './user';
export interface Event {
'title'?: string;

@@ -11,5 +11,4 @@ project_id: number;

target_title: string;
author: User;
author: UserSummary;
author_username: string;
}
export default Event;

@@ -1,2 +0,2 @@

interface Hook {
export interface Hook {
id: number;

@@ -16,2 +16,1 @@ url: string;

}
export default Hook;

@@ -1,11 +0,15 @@

export { default as Project } from './project';
export { default as User } from './user';
export { default as Event } from './event';
export { default as UploadedFile } from './uploaded-file';
export { default as Hook } from './hook';
export { default as Branch } from './branch';
export { default as MergeRequest, MergeRequestVersion, MergeRequestVersionSummary } from './merge-requests';
export { default as Milestone } from './milestone';
export { default as Commit, Diff } from './commit';
export { default as Issue } from './issue';
export { default as Todo } from './todo';
export * from './branch';
export * from './commit';
export * from './compare-repository';
export * from './event';
export * from './hook';
export * from './issue';
export * from './label';
export * from './merge-requests';
export * from './milestone';
export * from './project';
export * from './repository-file';
export * from './tag';
export * from './todo';
export * from './uploaded-file';
export * from './user';

@@ -1,10 +0,10 @@

import User from './user';
import Milestone from './milestone';
interface Issue {
import { UserSummary } from './user';
import { Milestone } from './milestone';
export interface Issue {
state: 'opened' | 'closed';
description: string;
author: User;
author: UserSummary;
milestone: Milestone;
project_id: number;
assignee?: User;
assignee?: UserSummary;
updated_at: string;

@@ -18,2 +18,1 @@ id: number;

}
export default Issue;

@@ -1,5 +0,5 @@

import User from './user';
import Milestone from './milestone';
import Commit, { Diff } from './commit';
interface MergeRequests {
import { UserSummary } from './user';
import { Milestone } from './milestone';
import { Commit, Diff } from './commit';
export interface MergeRequest {
id: number;

@@ -14,4 +14,4 @@ iid: number;

downvotes: number;
author: User;
assignee?: User;
author: UserSummary;
assignee?: UserSummary;
source_project_id: number;

@@ -33,3 +33,2 @@ target_project_id: number;

}
export default MergeRequests;
export interface MergeRequestVersionSummary {

@@ -36,0 +35,0 @@ id: number;

@@ -1,2 +0,2 @@

interface Milestone {
export interface Milestone {
id: number;

@@ -12,2 +12,1 @@ iid: number;

}
export default Milestone;

@@ -1,3 +0,3 @@

import User from './user';
interface Project {
import { UserSummary } from './user';
export interface Project {
id: number;

@@ -12,4 +12,4 @@ description?: string;

tag_list: string[];
owner?: User;
namespace?: {
owner?: UserSummary;
namespace: {
created_at: string;

@@ -38,2 +38,1 @@ description: string;

}
export default Project;

@@ -1,7 +0,7 @@

import Project from './project';
import User from './project';
interface Todo<T> {
import { Project } from './project';
import { UserSummary } from './user';
export interface Todo<T> {
id: number;
project: Project;
author: User;
author: UserSummary;
action_name: string;

@@ -15,2 +15,1 @@ target_type: string;

}
export default Todo;

@@ -1,2 +0,2 @@

interface UploadedFile {
export interface UploadedFile {
alt: string;

@@ -6,2 +6,1 @@ url: string;

}
export default UploadedFile;

@@ -1,10 +0,41 @@

interface User {
export interface UserSummary {
id: number;
username: string;
name: string;
state: string;
state: 'active';
created_at?: string;
avatar_url?: string;
web_url?: string;
is_admin?: boolean;
bio?: string;
location?: string;
skype?: string;
linkedin?: string;
twitter?: string;
}
export default User;
export interface User extends UserSummary {
website_url: string;
organization: string;
last_signed_in_at: string;
confirmed_at: string;
theme_id: number;
color_scheme_id: number;
projects_limit: number;
current_sign_in_at: string;
identities: UserIdentity[];
can_create_group: boolean;
can_create_project: boolean;
two_factor_enabled: boolean;
external: boolean;
}
export interface UserIdentity {
provider: string;
extern_uid: string;
}
export interface Contributor {
name: string;
email: string;
commits: number;
additions: number;
deletions: number;
}
{
"name": "gitlab-fetch",
"version": "0.1.0-dev.5758803",
"version": "0.1.0-dev.5793073",
"author": "Jay Anslow <jay@anslow.me.uk>",

@@ -49,6 +49,8 @@ "licence": "MIT",

"@types/query-string": "^3.0.31",
"@types/rc": "0.0.1",
"debug": "^2.6.0",
"node-fetch": "^1.6.3",
"query-string": "^4.2.3"
"query-string": "^4.2.3",
"rc": "^1.1.6"
}
}

@@ -6,7 +6,11 @@ A GitLab API client using the [whatwg-fetch API](https://github.com/whatwg/fetch) (written in TypeScript).

* [Branches](https://docs.gitlab.com/ce/api/branches.html)
* [Tags](https://docs.gitlab.com/ce/api/tags.html)
* [Repositories](https://docs.gitlab.com/ce/api/repositories.html)
* [Repository Files](https://docs.gitlab.com/ce/api/repository_files.html)
* [Merge Requests](https://docs.gitlab.com/ce/api/merge_requests.html)
* [Labels](https://docs.gitlab.com/ce/api/labels.html)
## Usage
```typescript
import { ProjectsApi, Config, Project } from 'gitlab-fetch';
import { ProjectsApi, Config, Project, loadConfig } from 'gitlab-fetch';

@@ -19,6 +23,8 @@ async function run(): Project[] {

}
}
};
// Load from `~/.gitlab-fetchrc` (or similar, see https://www.npmjs.com/package/rc)
// const config = loadConfig();
const projectsApi = new ProjectsApi(config);
return await projectsApi.getProjects());
return await projectsApi.getAll());
}
```

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc