mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Merge pull request #185 from evolution-gaming/add-types
fix: Adding more TS types
This commit is contained in:
commit
fdb84a7b97
@ -141,7 +141,7 @@ Instantiate the library using a basic token created in your [Gitlab Profile](htt
|
||||
// ES6 (>=node 8.0.0)
|
||||
import Gitlab from 'gitlab';
|
||||
|
||||
// ES5, assuming native or polyfilled Promise is available
|
||||
// ES5, assuming Promise and Object.assign are available
|
||||
const Gitlab = require('gitlab/dist/es5').default
|
||||
|
||||
|
||||
|
||||
901
package-lock.json
generated
901
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -78,7 +78,6 @@
|
||||
"request-promise": "^4.2.2",
|
||||
"request-promise-core": "^1.1.1",
|
||||
"url-join": "^4.0.0",
|
||||
"util.promisify": "^1.0.0",
|
||||
"xhr": "^2.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import URLJoin from 'url-join';
|
||||
import Request from 'request-promise';
|
||||
import XMLHttpRequester from './XMLHttpRequester';
|
||||
import XMLHttpRequester, { XhrStaticPromisified } from './XMLHttpRequester';
|
||||
|
||||
interface BaseModelOptions {
|
||||
url?: string;
|
||||
@ -12,15 +12,16 @@ interface BaseModelOptions {
|
||||
rejectUnauthorized?: boolean;
|
||||
}
|
||||
|
||||
export type BaseModelContructorOptions =
|
||||
| BaseModelOptions & Required<Pick<BaseModelOptions, 'token'>>
|
||||
| BaseModelOptions & Required<Pick<BaseModelOptions, 'oauthToken'>>;
|
||||
class BaseModel {
|
||||
protected url: string;
|
||||
public headers: { [header: string]: string | number};
|
||||
public rejectUnauthorized: boolean;
|
||||
protected requester: any;
|
||||
protected useXMLHttpRequest: boolean;
|
||||
public url: string;
|
||||
public readonly headers: { [header: string]: string | number};
|
||||
public readonly rejectUnauthorized: boolean;
|
||||
public readonly requester: XhrStaticPromisified;
|
||||
public readonly useXMLHttpRequest: boolean;
|
||||
|
||||
constructor(options: BaseModelOptions & Required<Pick<BaseModelOptions, 'token'>>);
|
||||
constructor(options: BaseModelOptions & Required<Pick<BaseModelOptions, 'oauthToken'>>);
|
||||
constructor({
|
||||
token,
|
||||
oauthToken,
|
||||
@ -29,10 +30,11 @@ class BaseModel {
|
||||
useXMLHttpRequest = false,
|
||||
version = 'v4',
|
||||
rejectUnauthorized = true,
|
||||
}: BaseModelOptions = {}) {
|
||||
}: BaseModelContructorOptions) {
|
||||
this.url = URLJoin(url, 'api', version);
|
||||
this.headers = {};
|
||||
this.requester = useXMLHttpRequest ? XMLHttpRequester : Request;
|
||||
this.requester = useXMLHttpRequest
|
||||
? XMLHttpRequester : (Request as temporaryAny as XhrStaticPromisified);
|
||||
this.useXMLHttpRequest = useXMLHttpRequest;
|
||||
this.rejectUnauthorized = rejectUnauthorized;
|
||||
|
||||
|
||||
@ -1,13 +1,21 @@
|
||||
function Bundler(services = {}) {
|
||||
const combined = { ...services };
|
||||
import { BaseService } from '.';
|
||||
import { BaseModelContructorOptions } from './BaseService';
|
||||
|
||||
return class Bundle {
|
||||
constructor(options = {}) {
|
||||
function Bundler<T extends { [K: string]: typeof BaseService }>(
|
||||
services: T,
|
||||
): new (baseOptions: BaseModelContructorOptions) => { [K in keyof T]: InstanceType<T[K]> } {
|
||||
const combined = { ...services as object } as T;
|
||||
interface BundleClass {
|
||||
[K: string]: BaseService;
|
||||
}
|
||||
return class Bundle implements BundleClass {
|
||||
[K: string]: any;
|
||||
constructor(baseOptions: BaseModelContructorOptions) {
|
||||
Object.keys(combined).forEach((serviceName) => {
|
||||
this[serviceName] = new combined[serviceName](options);
|
||||
this[serviceName] = new combined[serviceName](baseOptions);
|
||||
});
|
||||
}
|
||||
};
|
||||
} as temporaryAny;
|
||||
}
|
||||
|
||||
export default Bundler;
|
||||
|
||||
@ -3,8 +3,10 @@ import LinkParser from 'parse-link-header';
|
||||
import QS from 'qs';
|
||||
import URLJoin from 'url-join';
|
||||
import StreamableRequest from 'request';
|
||||
import { BaseService } from '.';
|
||||
import { CommitAction } from '../services/Commits';
|
||||
|
||||
interface RequestParametersInput {
|
||||
export interface RequestParametersInput {
|
||||
url?: string;
|
||||
headers: import('./BaseService').default['headers'];
|
||||
json?: boolean;
|
||||
@ -19,19 +21,21 @@ interface RequestParametersInput {
|
||||
interface GetPaginatedOptions {
|
||||
showPagination?: boolean;
|
||||
maxPages?: number;
|
||||
perPage?: number;
|
||||
page?: number;
|
||||
position?: temporaryAny;
|
||||
}
|
||||
|
||||
type RequestParametersOutput = RequestParametersInput &
|
||||
Required<Pick<RequestParametersInput, 'url'>>;
|
||||
|
||||
export async function wait(ms) {
|
||||
export async function wait(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function defaultRequest(
|
||||
{ url, useXMLHttpRequest, rejectUnauthorized },
|
||||
endpoint,
|
||||
{ url, useXMLHttpRequest, rejectUnauthorized }: BaseService,
|
||||
endpoint: string,
|
||||
{ headers, body, qs, formData, resolveWithFullResponse = false }: RequestParametersInput,
|
||||
): RequestParametersOutput {
|
||||
const params: RequestParametersOutput = {
|
||||
@ -61,7 +65,7 @@ function defaultRequest(
|
||||
return params;
|
||||
}
|
||||
|
||||
function getStream(service, endpoint, options = {}) {
|
||||
function getStream(service: BaseService, endpoint: string, options: RequestOptions = {}) {
|
||||
if (service.useXMLHttpRequest) {
|
||||
throw new Error(
|
||||
`Cannot use streaming functionality with XMLHttpRequest. Please instantiate without this
|
||||
@ -77,7 +81,11 @@ function getStream(service, endpoint, options = {}) {
|
||||
return StreamableRequest.get(requestOptions);
|
||||
}
|
||||
|
||||
async function getPaginated(service, endpoint, options: GetPaginatedOptions = {}) {
|
||||
async function getPaginated(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options: GetPaginatedOptions = {},
|
||||
) {
|
||||
const { showPagination, maxPages, ...queryOptions } = options;
|
||||
const requestOptions = defaultRequest(service, endpoint, {
|
||||
headers: service.headers,
|
||||
@ -90,7 +98,7 @@ async function getPaginated(service, endpoint, options: GetPaginatedOptions = {}
|
||||
const page = response.headers['x-page'];
|
||||
const underMaxPageLimit = maxPages ? page < maxPages : true;
|
||||
let more = [];
|
||||
let data;
|
||||
let data: temporaryAny;
|
||||
|
||||
// If not looking for a singular page and still under the max pages limit
|
||||
// AND their is a next page, paginate
|
||||
@ -118,8 +126,74 @@ async function getPaginated(service, endpoint, options: GetPaginatedOptions = {}
|
||||
return data;
|
||||
}
|
||||
|
||||
type RequestType = 'post' | 'get' | 'put' | 'delete';
|
||||
|
||||
export interface RequestOptions {
|
||||
targetIssueId?: string;
|
||||
targetProjectId?: string;
|
||||
content?: string;
|
||||
id?: string;
|
||||
sourceBranch?: string;
|
||||
targetBranch?: string;
|
||||
/** The duration in human format. e.g: 3h30m */
|
||||
duration?: string;
|
||||
domain?: string;
|
||||
cron?: temporaryAny;
|
||||
description?: string;
|
||||
file?: {
|
||||
value: Buffer;
|
||||
options: {
|
||||
filename: string;
|
||||
contentType: 'application/octet-stream';
|
||||
};
|
||||
};
|
||||
path?: string;
|
||||
namespace?: string;
|
||||
visibility?: string;
|
||||
code?: string;
|
||||
fileName?: string;
|
||||
from?: string;
|
||||
to?: string;
|
||||
sha?: string;
|
||||
runnerId?: string;
|
||||
ref?: string;
|
||||
scope?: string;
|
||||
url?: string;
|
||||
scopes?: temporaryAny;
|
||||
expiresAt?: string;
|
||||
note?: string;
|
||||
actions?: CommitAction[];
|
||||
commitMessage?: string;
|
||||
branch?: string;
|
||||
body?: string | temporaryAny;
|
||||
title?: string;
|
||||
name?: string;
|
||||
labelId?: temporaryAny;
|
||||
accessLevel?: number;
|
||||
userId?: UserId;
|
||||
position?: temporaryAny;
|
||||
value?: string;
|
||||
linkUrl?: string;
|
||||
imageUrl?: string;
|
||||
key?: string;
|
||||
action?: string;
|
||||
targetType?: string;
|
||||
email?: string;
|
||||
password?: string;
|
||||
search?: string;
|
||||
public?: boolean;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
class RequestHelper {
|
||||
static async request(type, service, endpoint, options = {}, form = false, stream = false) {
|
||||
static async request(
|
||||
type: RequestType,
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options: RequestOptions = {},
|
||||
form = false,
|
||||
stream = false,
|
||||
): Promise<temporaryAny> {
|
||||
try {
|
||||
switch (type) {
|
||||
case 'get':
|
||||
@ -162,7 +236,7 @@ class RequestHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static async handleRequestError(err) {
|
||||
static async handleRequestError(err: temporaryAny) {
|
||||
if (
|
||||
!err.response ||
|
||||
!err.response.headers ||
|
||||
@ -178,19 +252,24 @@ class RequestHelper {
|
||||
return wait(sleepTime * 1000);
|
||||
}
|
||||
|
||||
static get(service, endpoint, options = {}, { stream = false } = {}) {
|
||||
static get(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options: RequestOptions = {},
|
||||
{ stream = false } = {},
|
||||
) {
|
||||
return RequestHelper.request('get', service, endpoint, options, false, stream);
|
||||
}
|
||||
|
||||
static post(service, endpoint, options = {}, form = false) {
|
||||
static post(service: BaseService, endpoint: string, options: RequestOptions = {}, form = false) {
|
||||
return RequestHelper.request('post', service, endpoint, options, form);
|
||||
}
|
||||
|
||||
static put(service, endpoint, options = {}) {
|
||||
static put(service: BaseService, endpoint: string, options: RequestOptions = {}) {
|
||||
return RequestHelper.request('put', service, endpoint, options);
|
||||
}
|
||||
|
||||
static delete(service, endpoint, options = {}) {
|
||||
static delete(service: BaseService, endpoint: string, options: RequestOptions = {}) {
|
||||
return RequestHelper.request('delete', service, endpoint, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,32 @@
|
||||
import { StatusCodeError } from 'request-promise-core/errors';
|
||||
import Promisify from 'util.promisify';
|
||||
import XHR from 'xhr';
|
||||
import { promisify } from 'util';
|
||||
import XHR, { XhrUriConfig, XhrUrlConfig } from 'xhr';
|
||||
import { wait } from './RequestHelper';
|
||||
|
||||
function promisifyFn(fn) {
|
||||
const promisifiedFn = Promisify(fn);
|
||||
export interface XhrInstancePromisified {
|
||||
(options: XhrUriConfig | XhrUrlConfig): Promise<temporaryAny>;
|
||||
}
|
||||
|
||||
return async function getResponse(opts) {
|
||||
export interface XhrStaticPromisified extends XhrInstancePromisified {
|
||||
del: XhrInstancePromisified;
|
||||
delete: XhrInstancePromisified;
|
||||
get: XhrInstancePromisified;
|
||||
head: XhrInstancePromisified;
|
||||
patch: XhrInstancePromisified;
|
||||
post: XhrInstancePromisified;
|
||||
put: XhrInstancePromisified;
|
||||
}
|
||||
|
||||
interface XhrConfgExtraParams {
|
||||
resolveWithFullResponse?: boolean;
|
||||
}
|
||||
|
||||
function promisifyWithRetry<F extends Function>(fn: F): XhrInstancePromisified {
|
||||
const promisifiedFn = promisify(fn);
|
||||
|
||||
return async function getResponse(
|
||||
opts: XhrUriConfig & XhrConfgExtraParams | XhrUrlConfig & XhrConfgExtraParams,
|
||||
) {
|
||||
const response = await promisifiedFn(opts);
|
||||
const sleepTime = parseInt(response.headers['retry-after'], 10);
|
||||
if (response.statusCode === 429 && sleepTime) {
|
||||
@ -16,25 +36,23 @@ function promisifyFn(fn) {
|
||||
}
|
||||
|
||||
return opts.resolveWithFullResponse ? response : response.body;
|
||||
};
|
||||
} as XhrInstancePromisified;
|
||||
}
|
||||
|
||||
const XMLHttpRequester = promisifyFn(XHR);
|
||||
// Temporarily ignore typechecks, so that we can assign props to `XMLHttpRequester`
|
||||
// typed as `const XMLHttpRequester: (opts: any) => Promise<any>`
|
||||
// @ts-ignore
|
||||
XMLHttpRequester.del = promisifyFn(XHR.del);
|
||||
// @ts-ignore
|
||||
XMLHttpRequester.delete = XMLHttpRequester.del;
|
||||
// @ts-ignore
|
||||
XMLHttpRequester.get = promisifyFn(XHR.get);
|
||||
// @ts-ignore
|
||||
XMLHttpRequester.head = promisifyFn(XHR.head);
|
||||
// @ts-ignore
|
||||
XMLHttpRequester.patch = promisifyFn(XHR.patch);
|
||||
// @ts-ignore
|
||||
XMLHttpRequester.post = promisifyFn(XHR.post);
|
||||
// @ts-ignore
|
||||
XMLHttpRequester.put = promisifyFn(XHR.put);
|
||||
const promisifyWithRetryDelete = promisifyWithRetry(XHR.del);
|
||||
const XMLHttpRequesterPromisifiedExtras = {
|
||||
del: promisifyWithRetryDelete,
|
||||
get: promisifyWithRetryDelete,
|
||||
delete: promisifyWithRetry(XHR.del),
|
||||
head: promisifyWithRetry(XHR.head),
|
||||
patch: promisifyWithRetry(XHR.patch),
|
||||
post: promisifyWithRetry(XHR.post),
|
||||
put: promisifyWithRetry(XHR.put),
|
||||
};
|
||||
|
||||
const XMLHttpRequester: XhrStaticPromisified = Object.assign(
|
||||
promisifyWithRetry(XHR),
|
||||
XMLHttpRequesterPromisifiedExtras,
|
||||
);
|
||||
|
||||
export default XMLHttpRequester;
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class ApplicationSettings extends BaseService {
|
||||
all() {
|
||||
return RequestHelper.get(this, 'application/settings');
|
||||
}
|
||||
|
||||
edit(options) {
|
||||
edit(options: RequestOptions) {
|
||||
return RequestHelper.put(this, 'application/settings', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Branches extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/branches`, options);
|
||||
}
|
||||
|
||||
create(projectId, branchName, ref) {
|
||||
create(projectId: ProjectId, branchName: string, ref: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/branches`, {
|
||||
@ -16,25 +17,25 @@ class Branches extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
protect(projectId, branchName, options) {
|
||||
protect(projectId: ProjectId, branchName: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/protected_branches`, { name: branchName, ...options });
|
||||
}
|
||||
|
||||
remove(projectId, branchName) {
|
||||
remove(projectId: ProjectId, branchName: string) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/repository/branches/${bName}`);
|
||||
}
|
||||
|
||||
show(projectId, branchName) {
|
||||
show(projectId: ProjectId, branchName: string) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/branches/${bName}`);
|
||||
}
|
||||
|
||||
unprotect(projectId, branchName) {
|
||||
unprotect(projectId: ProjectId, branchName: string) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/repository/branches/${bName}/unprotect`);
|
||||
|
||||
@ -1,27 +1,30 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type BroadcastMessageId = string | number;
|
||||
|
||||
class BroadcastMessages extends BaseService {
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'broadcast_messages', options);
|
||||
}
|
||||
|
||||
create(options) {
|
||||
create(options: RequestOptions) {
|
||||
return RequestHelper.post(this, 'broadcast_messages', options);
|
||||
}
|
||||
|
||||
edit(broadcastMessageId, options) {
|
||||
edit(broadcastMessageId: BroadcastMessageId, options: RequestOptions) {
|
||||
const bId = encodeURIComponent(broadcastMessageId);
|
||||
|
||||
return RequestHelper.put(this, `broadcast_messages/${bId}`, options);
|
||||
}
|
||||
|
||||
remove(broadcastMessageId) {
|
||||
remove(broadcastMessageId: BroadcastMessageId) {
|
||||
const bId = encodeURIComponent(broadcastMessageId);
|
||||
|
||||
return RequestHelper.delete(this, `broadcast_messages/${bId}`);
|
||||
}
|
||||
|
||||
show(broadcastMessageId, options) {
|
||||
show(broadcastMessageId: BroadcastMessageId, options: RequestOptions) {
|
||||
const bId = encodeURIComponent(broadcastMessageId);
|
||||
|
||||
return RequestHelper.get(this, `broadcast_messages/${bId}`, options);
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class CommitDiscussions extends ResourceDiscussions {
|
||||
constructor(options) {
|
||||
super('projects', 'commits', options);
|
||||
constructor(baseParams: BaseModelContructorOptions) {
|
||||
super('projects', 'commits', baseParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,25 +1,47 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export interface CommitAction {
|
||||
/** The action to perform */
|
||||
action: 'create' | 'delete' | 'move' | 'update';
|
||||
/** Full path to the file. Ex. lib/class.rb */
|
||||
file_path: string;
|
||||
/** Original full path to the file being moved.Ex.lib / class1.rb */
|
||||
previous_path?: string;
|
||||
/** File content, required for all except delete. Optional for move */
|
||||
content?: string;
|
||||
/** text or base64. text is default. */
|
||||
encoding?: string;
|
||||
/** Last known file commit id. Will be only considered in update, move and delete actions. */
|
||||
last_commit_id?: string;
|
||||
}
|
||||
|
||||
class Commits extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits`, options);
|
||||
}
|
||||
|
||||
cherryPick(projectId, sha, branch) {
|
||||
cherryPick(projectId: ProjectId, sha: string, branch: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/commits/${sha}/cherry_pick`, { branch });
|
||||
}
|
||||
|
||||
comments(projectId, sha) {
|
||||
comments(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/comments`);
|
||||
}
|
||||
|
||||
create(projectId, branch, message, actions = [], options) {
|
||||
create(
|
||||
projectId: ProjectId,
|
||||
branch: string,
|
||||
message: string,
|
||||
actions: CommitAction[] = [],
|
||||
options: RequestOptions,
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/commits`, {
|
||||
@ -30,7 +52,7 @@ class Commits extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
createComment(projectId, sha, note, options) {
|
||||
createComment(projectId: ProjectId, sha: string, note: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/commits/${sha}/comments`, {
|
||||
@ -39,31 +61,31 @@ class Commits extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
diff(projectId, sha) {
|
||||
diff(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/diff`);
|
||||
}
|
||||
|
||||
editStatus(projectId, sha, options) {
|
||||
editStatus(projectId: ProjectId, sha: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/statuses/${sha}`, options);
|
||||
}
|
||||
|
||||
references(projectId, sha) {
|
||||
references(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/refs`);
|
||||
}
|
||||
|
||||
show(projectId, sha, options) {
|
||||
show(projectId: ProjectId, sha: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}`, options);
|
||||
}
|
||||
|
||||
status(projectId, sha, options) {
|
||||
status(projectId: ProjectId, sha: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/statuses`, options);
|
||||
|
||||
@ -1,25 +1,26 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class DeployKeys extends BaseService {
|
||||
add(projectId, options) {
|
||||
add(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/deploy_keys`, options);
|
||||
}
|
||||
|
||||
all(projectId) {
|
||||
all(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deploy_keys`);
|
||||
}
|
||||
|
||||
show(projectId, keyId) {
|
||||
show(projectId: ProjectId, keyId: KeyId) {
|
||||
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deploy_keys/${kId}`);
|
||||
}
|
||||
|
||||
enable(projectId, keyId) {
|
||||
enable(projectId: ProjectId, keyId: KeyId) {
|
||||
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/deploy_keys/${kId}/enable`);
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type DeploymentId = string | number;
|
||||
|
||||
class Deployments extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deployments`, options);
|
||||
}
|
||||
|
||||
show(projectId, deploymentId) {
|
||||
show(projectId: ProjectId, deploymentId: DeploymentId) {
|
||||
const [pId, dId] = [projectId, deploymentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/deployments/${dId}`);
|
||||
|
||||
@ -1,31 +1,34 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type EnvironmentId = string | number;
|
||||
|
||||
class Environments extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/environments`, options);
|
||||
}
|
||||
|
||||
create(projectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/environments`, options);
|
||||
}
|
||||
|
||||
edit(projectId, environmentId, options) {
|
||||
edit(projectId: ProjectId, environmentId: EnvironmentId, options: RequestOptions) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/environments/${eId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, environmentId) {
|
||||
remove(projectId: ProjectId, environmentId: EnvironmentId) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/environments/${eId}`);
|
||||
}
|
||||
|
||||
stop(projectId, environmentId) {
|
||||
stop(projectId: ProjectId, environmentId: EnvironmentId) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/environments/${eId}/stop`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class EpicDiscussions extends ResourceDiscussions {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', 'epics', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +1,29 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type EpicId = string | number;
|
||||
export type IssueId = string | number;
|
||||
|
||||
class EpicIssues extends BaseService {
|
||||
all(groupId, epicId) {
|
||||
all(groupId: GroupId, epicId: EpicId) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/epics/${eId}/issues`);
|
||||
}
|
||||
|
||||
assign(groupId, epicId, issueId) {
|
||||
assign(groupId: GroupId, epicId: EpicId, issueId: IssueId) {
|
||||
const [gId, eId, iId] = [groupId, epicId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `groups/${gId}/epics/${eId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
edit(groupId, epicId, issueId, options) {
|
||||
edit(groupId: GroupId, epicId: EpicId, issueId: IssueId, options: RequestOptions) {
|
||||
const [gId, eId, iId] = [groupId, epicId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `groups/${gId}/epics/${eId}/issues/${iId}`, options);
|
||||
}
|
||||
|
||||
remove(groupId, epicId, issueId) {
|
||||
remove(groupId: GroupId, epicId: EpicId, issueId: IssueId) {
|
||||
const [gId, eId, iId] = [groupId, epicId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `groups/${gId}/epics/${eId}/issues/${iId}`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceNotes } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class EpicNotes extends ResourceNotes {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', 'epics', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,31 +1,34 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type EpicId = string | number;
|
||||
|
||||
class Epics extends BaseService {
|
||||
all(groupId) {
|
||||
all(groupId: GroupId) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/epics`);
|
||||
}
|
||||
|
||||
create(groupId, title, options) {
|
||||
create(groupId: GroupId, title: string, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/epics`, { title, ...options });
|
||||
}
|
||||
|
||||
edit(groupId, epicId, options) {
|
||||
edit(groupId: GroupId, epicId: EpicId, options: RequestOptions) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `groups/${gId}/epics/${eId}`, options);
|
||||
}
|
||||
|
||||
remove(groupId, epicId) {
|
||||
remove(groupId: GroupId, epicId: EpicId) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `groups/${gId}/epics/${eId}`);
|
||||
}
|
||||
|
||||
show(groupId, epicId) {
|
||||
show(groupId: GroupId, epicId: EpicId) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/epics/${eId}`);
|
||||
|
||||
@ -1,46 +1,53 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
const ACTION_TYPES = [
|
||||
'created',
|
||||
'updated',
|
||||
'closed',
|
||||
'reopened',
|
||||
'pushed',
|
||||
'commented',
|
||||
'merged',
|
||||
'joined',
|
||||
'left',
|
||||
'destroyed',
|
||||
'expired',
|
||||
];
|
||||
const ACTION_TYPES = {
|
||||
created: 'created',
|
||||
updated: 'updated',
|
||||
closed: 'closed',
|
||||
reopened: 'reopened',
|
||||
pushed: 'pushed',
|
||||
commented: 'commented',
|
||||
merged: 'merged',
|
||||
joined: 'joined',
|
||||
left: 'left',
|
||||
destroyed: 'destroyed',
|
||||
expired: 'expired',
|
||||
};
|
||||
|
||||
const TARGET_TYPES = [
|
||||
'issue',
|
||||
'milestone',
|
||||
'merge_request',
|
||||
'note',
|
||||
'project',
|
||||
'snippet',
|
||||
'user',
|
||||
];
|
||||
const TARGET_TYPES = {
|
||||
issue: 'issue',
|
||||
milestone: 'milestone',
|
||||
merge_request: 'merge_request',
|
||||
note: 'note',
|
||||
project: 'project',
|
||||
snippet: 'snippet',
|
||||
user: 'user',
|
||||
};
|
||||
|
||||
function validateEventOptions(action, target) {
|
||||
if (action && ACTION_TYPES.indexOf(action) === -1) {
|
||||
throw new Error(`This action is not supported. Pleased use one of following options: ${ACTION_TYPES}`);
|
||||
function assertEventOptions(
|
||||
action: keyof typeof ACTION_TYPES,
|
||||
target: keyof typeof TARGET_TYPES,
|
||||
) {
|
||||
if (!action || !(action in ACTION_TYPES)) {
|
||||
throw new Error(`This action is not supported. Pleased use one of following options: ${Object.keys(ACTION_TYPES)}`);
|
||||
}
|
||||
|
||||
if (target && TARGET_TYPES.indexOf(target) === -1) {
|
||||
throw new Error(`This target is not supported. Pleased use one of following options: ${TARGET_TYPES}`);
|
||||
if (!target || !(target in TARGET_TYPES)) {
|
||||
throw new Error(`This target is not supported. Pleased use one of following options: ${Object.keys(TARGET_TYPES)}`);
|
||||
}
|
||||
}
|
||||
|
||||
export interface EventOptions {
|
||||
action: keyof typeof ACTION_TYPES;
|
||||
targetType: keyof typeof TARGET_TYPES;
|
||||
}
|
||||
class Events extends BaseService {
|
||||
all(options) {
|
||||
validateEventOptions(options.action, options.targetType);
|
||||
all(options: RequestOptions & EventOptions) {
|
||||
assertEventOptions(options.action, options.targetType);
|
||||
|
||||
return RequestHelper.get(this, 'events', options);
|
||||
}
|
||||
}
|
||||
|
||||
export default Events;
|
||||
export { validateEventOptions };
|
||||
export { assertEventOptions };
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class FeatureFlags extends BaseService {
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'features', options);
|
||||
}
|
||||
|
||||
set(name, options) {
|
||||
set(name: string, options: RequestOptions) {
|
||||
const encodedName = encodeURIComponent(name);
|
||||
|
||||
return RequestHelper.post(this, `features/${encodedName}`, options);
|
||||
|
||||
@ -1,45 +1,48 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type GeonodeId = string | number;
|
||||
|
||||
class GeoNodes extends BaseService {
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'geo_nodes', options);
|
||||
}
|
||||
|
||||
create(geonodeId, options) {
|
||||
create(geonodeId: GeonodeId, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.post(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
edit(geonodeId, options) {
|
||||
edit(geonodeId: GeonodeId, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.put(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
failures(options) {
|
||||
failures(options: RequestOptions) {
|
||||
return RequestHelper.post(this, 'geo_nodes/current/failures', options);
|
||||
}
|
||||
|
||||
repair(geonodeId, options) {
|
||||
repair(geonodeId: GeonodeId, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.delete(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
show(geonodeId, options) {
|
||||
show(geonodeId: GeonodeId, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.get(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
status(geonodeId, options) {
|
||||
status(geonodeId: GeonodeId, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.get(this, `geo_nodes/${gId}/status`, options);
|
||||
}
|
||||
|
||||
statuses(options) {
|
||||
statuses(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'geo_nodes/statuses', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceTemplates } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GitLabCIYMLTemplates extends ResourceTemplates {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('gitlab_ci_ymls', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceTemplates } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GitignoreTemplates extends ResourceTemplates {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('gitignores', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceAccessRequests } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupAccessRequests extends ResourceAccessRequests {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceBadges } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupBadges extends ResourceBadges {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupCustomAttributes extends ResourceCustomAttributes {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceIssueBoards } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupIssueBoards extends ResourceIssueBoards {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceMembers } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupMembers extends ResourceMembers {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceMilestones } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupMilestones extends ResourceMilestones {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type GroupProjectId = string | number;
|
||||
|
||||
class GroupProjects extends BaseService {
|
||||
all(groupId, options) {
|
||||
all(groupId: GroupProjectId, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/projects`, options);
|
||||
}
|
||||
|
||||
add(groupId, projectId) {
|
||||
add(groupId: GroupProjectId, projectId: ProjectId) {
|
||||
const [gId, pId] = [groupId, projectId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/projects/${pId}`);
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { ResourceVariables } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupVariables extends ResourceVariables {
|
||||
constructor(options) {
|
||||
super('groups', null, options);
|
||||
constructor(baseParams: BaseModelContructorOptions) {
|
||||
super('groups', null as temporaryAny, baseParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,33 +1,36 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type GroupId = string | number;
|
||||
|
||||
class Groups extends BaseService {
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'groups', options);
|
||||
}
|
||||
|
||||
create(options) {
|
||||
create(options: RequestOptions) {
|
||||
return RequestHelper.post(this, 'groups', options);
|
||||
}
|
||||
|
||||
remove(groupId) {
|
||||
remove(groupId: GroupId) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.delete(this, `groups/${gId}`);
|
||||
}
|
||||
|
||||
search(nameOrPath) {
|
||||
search(nameOrPath: string) {
|
||||
return RequestHelper.get(this, 'groups', {
|
||||
search: nameOrPath,
|
||||
});
|
||||
}
|
||||
|
||||
show(groupId) {
|
||||
show(groupId: GroupId) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}`);
|
||||
}
|
||||
|
||||
subgroups(groupId, options) {
|
||||
subgroups(groupId: GroupId, options: RequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/subgroups`, options);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceAwardEmojis } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class IssueAwardEmojis extends ResourceAwardEmojis {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class IssueDiscussions extends ResourceDiscussions {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', 'issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ResourceNotes } from '../templates';
|
||||
|
||||
class IssueNotes extends ResourceNotes {
|
||||
constructor(options) {
|
||||
constructor(options: temporaryAny) {
|
||||
super('projects', 'issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { IssueId } from './EpicIssues';
|
||||
import { MergeRequestId } from './MergeRequests';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Issues extends BaseService {
|
||||
addSpentTime(projectId, issueId, duration) {
|
||||
addSpentTime(projectId: ProjectId, issueId: IssueId, duration: Duration) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/add_spent_time`, {
|
||||
@ -9,7 +12,7 @@ class Issues extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
addTimeEstimate(projectId, issueId, duration) {
|
||||
addTimeEstimate(projectId: ProjectId, issueId: IssueId, duration: Duration) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/time_estimate`, {
|
||||
@ -17,25 +20,31 @@ class Issues extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
all({ projectId, ...options }) {
|
||||
all({ projectId, ...options }: { projectId: ProjectId } & RequestOptions) {
|
||||
const url = projectId ? `projects/${encodeURIComponent(projectId)}/issues` : 'issues';
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
}
|
||||
|
||||
create(projectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues`, options);
|
||||
}
|
||||
|
||||
edit(projectId, issueId, options) {
|
||||
edit(projectId: ProjectId, issueId: IssueId, options: RequestOptions) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/issues/${iId}`, options);
|
||||
}
|
||||
|
||||
link(projectId, issueIId, targetProjectId, targetIssueId, options = {}) {
|
||||
link(
|
||||
projectId: ProjectId,
|
||||
issueIId: IssueId,
|
||||
targetProjectId: ProjectId,
|
||||
targetIssueId: IssueId,
|
||||
options = {},
|
||||
) {
|
||||
const [pId, iId] = [projectId, issueIId].map(encodeURIComponent);
|
||||
const [targetpId, targetIId] = [targetProjectId, targetIssueId].map(encodeURIComponent);
|
||||
|
||||
@ -46,49 +55,49 @@ class Issues extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
participants(projectId, issueId) {
|
||||
participants(projectId: ProjectId, issueId: IssueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}/participants`);
|
||||
}
|
||||
|
||||
remove(projectId, issueId) {
|
||||
remove(projectId: ProjectId, issueId: IssueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
resetSpentTime(projectId, mergerequestId) {
|
||||
resetSpentTime(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${mId}/reset_spent_time`);
|
||||
}
|
||||
|
||||
resetTimeEstimate(projectId, mergerequestId) {
|
||||
resetTimeEstimate(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${mId}/reset_time_estimate`);
|
||||
}
|
||||
|
||||
show(projectId, issueId) {
|
||||
show(projectId: ProjectId, issueId: IssueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
subscribe(projectId, issueId, options) {
|
||||
subscribe(projectId: ProjectId, issueId: IssueId, options: RequestOptions) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/subscribe`, options);
|
||||
}
|
||||
|
||||
timeStats(projectId, mergerequestId) {
|
||||
timeStats(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${mId}/time_stats`);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, issueId) {
|
||||
unsubscribe(projectId: ProjectId, issueId: IssueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/issues/${iId}/unsubscribe`);
|
||||
|
||||
@ -1,22 +1,26 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { PipelineId } from './Pipelines';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type JobId = string | number;
|
||||
|
||||
class Jobs extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
all(projectId: ProjectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs`, options);
|
||||
}
|
||||
|
||||
cancel(projectId, jobId) {
|
||||
cancel(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/cancel`);
|
||||
}
|
||||
|
||||
downloadSingleArtifactFile(
|
||||
projectId,
|
||||
jobId,
|
||||
artifactPath,
|
||||
projectId: ProjectId,
|
||||
jobId: JobId,
|
||||
artifactPath: string,
|
||||
options = { stream: false },
|
||||
) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
@ -24,15 +28,15 @@ class Jobs extends BaseService {
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/jobs/${jId}/artifacts/${artifactPath}`,
|
||||
options,
|
||||
options as temporaryAny,
|
||||
{ stream: options.stream },
|
||||
);
|
||||
}
|
||||
|
||||
downloadLatestArtifactFile(
|
||||
projectId,
|
||||
ref,
|
||||
name,
|
||||
projectId: ProjectId,
|
||||
ref: string,
|
||||
name: string,
|
||||
options = { stream: false },
|
||||
) {
|
||||
const [pId, rId, jobName] = [projectId, ref, name].map(encodeURIComponent);
|
||||
@ -40,48 +44,48 @@ class Jobs extends BaseService {
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
`projects/${pId}/jobs/artifacts/${rId}/download?job=${jobName}`,
|
||||
options,
|
||||
options as temporaryAny,
|
||||
{ stream: options.stream },
|
||||
);
|
||||
}
|
||||
|
||||
downloadTraceFile(projectId, jobId) {
|
||||
downloadTraceFile(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs/${jId}/trace`);
|
||||
}
|
||||
|
||||
erase(projectId, jobId) {
|
||||
erase(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/erase`);
|
||||
}
|
||||
|
||||
keepArtifacts(projectId, jobId) {
|
||||
keepArtifacts(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/artifacts/keep`);
|
||||
}
|
||||
|
||||
play(projectId, jobId) {
|
||||
play(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/play`);
|
||||
}
|
||||
|
||||
retry(projectId, jobId) {
|
||||
retry(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/retry`);
|
||||
}
|
||||
|
||||
show(projectId, jobId) {
|
||||
show(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs/${jId}`);
|
||||
}
|
||||
|
||||
showPipelineJobs(projectId, pipelineId, options) {
|
||||
showPipelineJobs(projectId: ProjectId, pipelineId: PipelineId, options: RequestOptions) {
|
||||
const [pId, ppId] = [projectId, pipelineId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
class Keys extends BaseService {
|
||||
show(keyId) {
|
||||
show(keyId: KeyId) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.get(this, `keys/${kId}`);
|
||||
|
||||
@ -1,37 +1,39 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
type LabelId = string | number;
|
||||
|
||||
class Labels extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
all(projectId: ProjectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/labels`, options);
|
||||
}
|
||||
|
||||
create(projectId, options = {}) {
|
||||
create(projectId: ProjectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/labels`, options);
|
||||
}
|
||||
|
||||
edit(projectId, labelName, options = {}) {
|
||||
edit(projectId: ProjectId, labelName: string, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/labels`, { name: labelName, ...options });
|
||||
}
|
||||
|
||||
remove(projectId, labelName) {
|
||||
remove(projectId: ProjectId, labelName: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/labels`, { name: labelName });
|
||||
}
|
||||
|
||||
subscribe(projectId, labelId, options = {}) {
|
||||
subscribe(projectId: ProjectId, labelId: LabelId, options = {}) {
|
||||
const [pId, lId] = [projectId, labelId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${lId}/subscribe`, options);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, labelId) {
|
||||
unsubscribe(projectId: ProjectId, labelId: LabelId) {
|
||||
const [pId, lId] = [projectId, labelId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/issues/${lId}/unsubscribe`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceTemplates } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class LicenceTemplates extends ResourceTemplates {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('licences', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
class Lint extends BaseService {
|
||||
lint(content) {
|
||||
lint(content: string) {
|
||||
return RequestHelper.post(this, 'lint', { content });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Markdown extends BaseService {
|
||||
render(text, options) {
|
||||
render(text: string, options: RequestOptions) {
|
||||
return RequestHelper.post(this, 'markdown', { text, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceAwardEmojis } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class MergeRequestAwardEmojis extends ResourceAwardEmojis {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('merge_requests', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class MergeRequestDiscussions extends ResourceDiscussions {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', 'merge_requests', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceNotes } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class MergeRequestNotes extends ResourceNotes {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', 'merge_requests', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type MergeRequestId = string | number;
|
||||
|
||||
class MergeRequests extends BaseService {
|
||||
accept(projectId, mergerequestId, options) {
|
||||
accept(projectId: ProjectId, mergerequestId: MergeRequestId, options: RequestOptions) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/merge_requests/${mId}/merge`, options);
|
||||
}
|
||||
|
||||
addSpentTime(projectId, mergerequestId, duration) {
|
||||
addSpentTime(projectId: ProjectId, mergerequestId: MergeRequestId, duration: Duration) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${mId}/add_spent_time`, {
|
||||
@ -15,7 +18,7 @@ class MergeRequests extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
addTimeEstimate(projectId, mergerequestId, duration) {
|
||||
addTimeEstimate(projectId: ProjectId, mergerequestId: MergeRequestId, duration: Duration) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${mId}/time_estimate`, {
|
||||
@ -23,50 +26,56 @@ class MergeRequests extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
approve(projectId, mergerequestId, { sha }) {
|
||||
approve(projectId: ProjectId, mergerequestId: MergeRequestId, { sha }: { sha: string }) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/approve`, { sha });
|
||||
}
|
||||
|
||||
approvals(projectId, { mergerequestId }: { mergerequestId?: string } = {}) {
|
||||
approvals(projectId: ProjectId, { mergerequestId }: { mergerequestId?: MergeRequestId } = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const mergeRequest = mergerequestId ? `merge_requests/${encodeURIComponent(mergerequestId)}` : '';
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/${mergeRequest}/approvals`);
|
||||
}
|
||||
|
||||
all({ projectId, ...options }: { projectId?: string } = {}) {
|
||||
all({ projectId, ...options }: { projectId?: ProjectId } = {}) {
|
||||
const url = projectId ? `projects/${encodeURIComponent(projectId)}/merge_requests` : 'merge_requests';
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
}
|
||||
|
||||
cancelOnPipelineSucess(projectId, mergerequestId) {
|
||||
cancelOnPipelineSucess(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/merge_requests/${mId}/cancel_merge_when_pipeline_succeeds`);
|
||||
}
|
||||
|
||||
changes(projectId, mergerequestId) {
|
||||
changes(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}/changes`);
|
||||
}
|
||||
|
||||
closesIssues(projectId, mergerequestId) {
|
||||
closesIssues(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}/closes_issues`);
|
||||
}
|
||||
|
||||
commits(projectId, mergerequestId) {
|
||||
commits(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}/commits`);
|
||||
}
|
||||
|
||||
create(projectId, sourceBranch, targetBranch, title, options) {
|
||||
create(
|
||||
projectId: ProjectId,
|
||||
sourceBranch: string,
|
||||
targetBranch: string,
|
||||
title: string,
|
||||
options: RequestOptions,
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests`, {
|
||||
@ -78,82 +87,82 @@ class MergeRequests extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId, mergerequestId, options) {
|
||||
edit(projectId: ProjectId, mergerequestId: MergeRequestId, options: RequestOptions) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/merge_requests/${mId}`, options);
|
||||
}
|
||||
|
||||
editApprovals(projectId, { mergerequestId, ...options }) {
|
||||
editApprovals(projectId: ProjectId, { mergerequestId, ...options }: temporaryAny) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const mergeRequest = mergerequestId ? `merge_requests/${encodeURIComponent(mergerequestId)}/` : '';
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/${mergeRequest}approvals`, options);
|
||||
}
|
||||
|
||||
editApprovers(projectId, { mergerequestId, ...options }) {
|
||||
editApprovers(projectId: ProjectId, { mergerequestId, ...options }: temporaryAny) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const mergeRequest = mergerequestId ? `merge_requests/${encodeURIComponent(mergerequestId)}/` : '';
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/${mergeRequest}approvers`, options);
|
||||
}
|
||||
|
||||
pipelines(projectId, { mergerequestId }: { mergerequestId?: string } = {}) {
|
||||
pipelines(projectId: ProjectId, { mergerequestId }: { mergerequestId?: string } = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const mergeRequest = mergerequestId ? `merge_requests/${encodeURIComponent(mergerequestId)}` : '';
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/${mergeRequest}/pipelines`);
|
||||
}
|
||||
|
||||
remove(projectId, mergerequestId) {
|
||||
remove(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/merge_requests/${mId}`);
|
||||
}
|
||||
|
||||
resetSpentTime(projectId, mergerequestId) {
|
||||
resetSpentTime(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/reset_spent_time`);
|
||||
}
|
||||
|
||||
resetTimeEstimate(projectId, mergerequestId) {
|
||||
resetTimeEstimate(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/reset_time_estimate`);
|
||||
}
|
||||
|
||||
show(projectId, mergerequestId) {
|
||||
show(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}`);
|
||||
}
|
||||
|
||||
timeStats(projectId, mergerequestId) {
|
||||
timeStats(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}/time_stats`);
|
||||
}
|
||||
|
||||
version(projectId, mergerequestId, versionId) {
|
||||
version(projectId: ProjectId, mergerequestId: MergeRequestId, versionId: string | number) {
|
||||
const [pId, mId, vId] = [projectId, mergerequestId, versionId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}/versions/${vId}`);
|
||||
}
|
||||
|
||||
versions(projectId, mergerequestId) {
|
||||
versions(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}/versions`);
|
||||
}
|
||||
|
||||
unapprove(projectId, mergerequestId) {
|
||||
unapprove(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/approve`);
|
||||
}
|
||||
|
||||
unsubscribe(projectId, mergerequestId) {
|
||||
unsubscribe(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/merge_requests/${mId}/unsubscribe`);
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Namespaces extends BaseService {
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'namespaces', options);
|
||||
}
|
||||
|
||||
show(namespaceId) {
|
||||
show(namespaceId: string | number) {
|
||||
const nId = encodeURIComponent(namespaceId);
|
||||
|
||||
return RequestHelper.get(this, `namespaces/${nId}`);
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
const LEVELS = {
|
||||
DISABLED: 'disabled',
|
||||
@ -25,13 +27,13 @@ const EVENTS = {
|
||||
SUCCESS_PIPELINE: 'success_pipeline',
|
||||
};
|
||||
interface NotificationSettingsOptions {
|
||||
projectId?: string;
|
||||
projectId?: ProjectId;
|
||||
groupId?: string;
|
||||
}
|
||||
class NotificationSettings extends BaseService {
|
||||
protected LEVELS: typeof LEVELS;
|
||||
protected EVENTS: typeof EVENTS;
|
||||
constructor(baseParams) {
|
||||
constructor(baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.LEVELS = LEVELS;
|
||||
@ -50,7 +52,7 @@ class NotificationSettings extends BaseService {
|
||||
return RequestHelper.get(this, `${url}notification_settings`);
|
||||
}
|
||||
|
||||
edit(options, { projectId, groupId }: NotificationSettingsOptions = {}) {
|
||||
edit(options: RequestOptions, { projectId, groupId }: NotificationSettingsOptions = {}) {
|
||||
let url = '';
|
||||
|
||||
if (projectId) {
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
interface PagesDomainsOptions {
|
||||
projectId?: string;
|
||||
projectId?: ProjectId;
|
||||
}
|
||||
class PagesDomains extends BaseService {
|
||||
all({ projectId }: PagesDomainsOptions = {}) {
|
||||
@ -10,25 +11,25 @@ class PagesDomains extends BaseService {
|
||||
return RequestHelper.get(this, `${url}pages/domains`);
|
||||
}
|
||||
|
||||
create(projectId, domain, options) {
|
||||
create(projectId: ProjectId, domain: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pages/domains`, { domain, ...options });
|
||||
}
|
||||
|
||||
edit(projectId, domain, options) {
|
||||
edit(projectId: ProjectId, domain: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/pages/domains/${domain}`, options);
|
||||
}
|
||||
|
||||
show(projectId, domain) {
|
||||
show(projectId: ProjectId, domain: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pages/domains/${domain}`);
|
||||
}
|
||||
|
||||
remove(projectId, domain) {
|
||||
remove(projectId: ProjectId, domain: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/pages/domains/${domain}`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceVariables } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class PipelineScheduleVariables extends ResourceVariables {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', 'pipelines', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,22 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type PipelineScheduleId = string | number;
|
||||
|
||||
class PipelineSchedules extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipeline_schedules`, options);
|
||||
}
|
||||
|
||||
create(projectId, description, ref, cron, options) {
|
||||
create(
|
||||
projectId: ProjectId,
|
||||
description: string,
|
||||
ref: string,
|
||||
cron: temporaryAny,
|
||||
options: RequestOptions,
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipeline_schedules`, {
|
||||
@ -18,25 +27,25 @@ class PipelineSchedules extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId, scheduleId, options) {
|
||||
edit(projectId: ProjectId, scheduleId: PipelineScheduleId, options: RequestOptions) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/pipeline_schedules/${sId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, scheduleId) {
|
||||
remove(projectId: ProjectId, scheduleId: PipelineScheduleId) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/pipeline_schedules/${sId}`);
|
||||
}
|
||||
|
||||
show(projectId, scheduleId) {
|
||||
show(projectId: ProjectId, scheduleId: PipelineScheduleId) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipeline_schedules/${sId}`);
|
||||
}
|
||||
|
||||
takeOwnership(projectId, scheduleId) {
|
||||
takeOwnership(projectId: ProjectId, scheduleId: PipelineScheduleId) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipeline_schedules/${sId}/take_ownership`);
|
||||
|
||||
@ -1,37 +1,40 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type PipelineId = string | number;
|
||||
|
||||
class Pipelines extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
all(projectId: ProjectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines`, options);
|
||||
}
|
||||
|
||||
create(projectId, ref) {
|
||||
create(projectId: ProjectId, ref: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipeline`, { ref });
|
||||
}
|
||||
|
||||
show(projectId, pipelineId) {
|
||||
show(projectId: ProjectId, pipelineId: PipelineId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines/${pipelineId}`);
|
||||
}
|
||||
|
||||
retry(projectId, pipelineId) {
|
||||
retry(projectId: ProjectId, pipelineId: PipelineId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipelines/${pipelineId}/retry`);
|
||||
}
|
||||
|
||||
cancel(projectId, pipelineId) {
|
||||
cancel(projectId: ProjectId, pipelineId: PipelineId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipelines/${pipelineId}/cancel`);
|
||||
}
|
||||
|
||||
showJobs(projectId, pipelineId, options) {
|
||||
showJobs(projectId: ProjectId, pipelineId: PipelineId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines/${pipelineId}/jobs`, options);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceAccessRequests } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectAccessRequests extends ResourceAccessRequests {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceBadges } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectBadges extends ResourceBadges {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectCustomAttributes extends ResourceCustomAttributes {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,31 +1,33 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { HookId } from './SystemHooks';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class ProjectHooks extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks`, options);
|
||||
}
|
||||
|
||||
show(projectId, hookId) {
|
||||
show(projectId: ProjectId, hookId: HookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks/${hId}`);
|
||||
}
|
||||
|
||||
add(projectId, url, options) {
|
||||
add(projectId: ProjectId, url: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/hooks`, { url, ...options });
|
||||
}
|
||||
|
||||
edit(projectId, hookId, url, options) {
|
||||
edit(projectId: ProjectId, hookId: HookId, url: string, options: RequestOptions) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/hooks/${hId}`, { url, ...options });
|
||||
}
|
||||
|
||||
remove(projectId, hookId) {
|
||||
remove(projectId: ProjectId, hookId: HookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/hooks/${hId}`);
|
||||
|
||||
@ -1,29 +1,30 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class ProjectImportExport extends BaseService {
|
||||
download(projectId) {
|
||||
download(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/export/download`);
|
||||
}
|
||||
|
||||
exportStatus(projectId) {
|
||||
exportStatus(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/export`);
|
||||
}
|
||||
|
||||
import(file, path, options) {
|
||||
import(file: temporaryAny, path: string, options: RequestOptions) {
|
||||
return RequestHelper.post(this, 'projects/import', { file, path, ...options });
|
||||
}
|
||||
|
||||
importStatus(projectId) {
|
||||
importStatus(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/import`);
|
||||
}
|
||||
|
||||
schedule(projectId, options) {
|
||||
schedule(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/export`, options);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceIssueBoards } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectIssueBoards extends ResourceIssueBoards {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceMembers } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectMembers extends ResourceMembers {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceMilestones } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectMilestones extends ResourceMilestones {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceAwardEmojis } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectSnippetAwardEmojis extends ResourceAwardEmojis {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectSnippetDiscussions extends ResourceDiscussions {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', 'snippets', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceNotes } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectSnippetNotes extends ResourceNotes {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', 'snippets', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
const VISIBILITY_LEVELS = {
|
||||
PRIVATE: 'private',
|
||||
@ -6,20 +7,29 @@ const VISIBILITY_LEVELS = {
|
||||
PUBLIC: 'public',
|
||||
};
|
||||
|
||||
type SnippetId = string | number;
|
||||
type VisibilityLevel = 'private' | 'public' | 'internal';
|
||||
class ProjectSnippets extends BaseService {
|
||||
all(projectId, options = {}) {
|
||||
all(projectId: ProjectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets`, options);
|
||||
}
|
||||
|
||||
content(projectId, snippetId) {
|
||||
content(projectId: ProjectId, snippetId: SnippetId) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets/${sId}/raw`);
|
||||
}
|
||||
|
||||
create(projectId, title, fileName, code, visibility, options = {}) {
|
||||
create(
|
||||
projectId: ProjectId,
|
||||
title: string,
|
||||
fileName: string,
|
||||
code: string,
|
||||
visibility: VisibilityLevel,
|
||||
options: RequestOptions = {},
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/snippets`, {
|
||||
@ -31,25 +41,25 @@ class ProjectSnippets extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId, snippetId, options) {
|
||||
edit(projectId: ProjectId, snippetId: SnippetId, options: RequestOptions) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/snippets/${sId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, snippetId) {
|
||||
remove(projectId: ProjectId, snippetId: SnippetId) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/snippets/${sId}`);
|
||||
}
|
||||
|
||||
show(projectId, snippetId) {
|
||||
show(projectId: ProjectId, snippetId: SnippetId) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets/${sId}`);
|
||||
}
|
||||
|
||||
userAgentDetails(projectId, snippetId) {
|
||||
userAgentDetails(projectId: ProjectId, snippetId: SnippetId) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets/${sId}/user_agent_detail`);
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { ResourceVariables } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class ProjectVariables extends ResourceVariables {
|
||||
constructor(options) {
|
||||
super('projects', null, options);
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('projects', null as temporaryAny, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,74 +1,80 @@
|
||||
import Fs from 'fs';
|
||||
import Path from 'path';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { validateEventOptions } from './Events';
|
||||
import { assertEventOptions } from './Events';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
/** TODO annotate options */
|
||||
type ProjectOptions = temporaryAny;
|
||||
|
||||
class Projects extends BaseService {
|
||||
all(options) {
|
||||
all(options?: RequestOptions) {
|
||||
return RequestHelper.get(this, 'projects', options);
|
||||
}
|
||||
|
||||
archive(projectId) {
|
||||
archive(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/archive`);
|
||||
}
|
||||
|
||||
create(options) {
|
||||
/**
|
||||
* @see https://docs.gitlab.com/ee/api/projects.html#create-project-for-user
|
||||
*/
|
||||
create(options: temporaryAny) {
|
||||
const url = options.userId ? `projects/user/${encodeURIComponent(options.userId)}` : 'projects';
|
||||
|
||||
return RequestHelper.post(this, url, options);
|
||||
}
|
||||
|
||||
edit(projectId, options) {
|
||||
edit(projectId: ProjectId, options: temporaryAny) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
events(projectId, options) {
|
||||
validateEventOptions(options.action, options.targetType);
|
||||
events(projectId: ProjectId, options: ProjectOptions) {
|
||||
assertEventOptions(options.action, options.targetType);
|
||||
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/events`, options);
|
||||
}
|
||||
|
||||
fork(projectId, options) {
|
||||
fork(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/fork`, options);
|
||||
}
|
||||
|
||||
forks(projectId, options) {
|
||||
forks(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/forks`, options);
|
||||
}
|
||||
|
||||
languages(projectId) {
|
||||
languages(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/languages`);
|
||||
}
|
||||
|
||||
mirrorPull(projectId) {
|
||||
mirrorPull(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/mirror/pull`);
|
||||
}
|
||||
|
||||
remove(projectId) {
|
||||
remove(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}`);
|
||||
}
|
||||
|
||||
search(projectName) {
|
||||
search(projectName: string) {
|
||||
return RequestHelper.get(this, 'projects', { search: projectName });
|
||||
}
|
||||
|
||||
share(projectId, groupId, groupAccess, options) {
|
||||
share(projectId: ProjectId, groupId: GroupId, groupAccess: GroupAccess, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
if (!groupId || !groupAccess) throw new Error('Missing required arguments');
|
||||
@ -76,54 +82,54 @@ class Projects extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/share`, { groupId, groupAccess, ...options });
|
||||
}
|
||||
|
||||
show(projectId, options) {
|
||||
show(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
star(projectId) {
|
||||
star(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/star`);
|
||||
}
|
||||
|
||||
statuses(projectId, sha, state, options) {
|
||||
statuses(projectId: ProjectId, sha: string, state: string, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/statuses/${sha}`, { state, ...options });
|
||||
}
|
||||
|
||||
transfer(projectId, namespace) {
|
||||
transfer(projectId: ProjectId, namespace: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
return RequestHelper.put(this, `projects/${pId}/transfer`, namespace);
|
||||
return RequestHelper.put(this, `projects/${pId}/transfer`, { namespace });
|
||||
}
|
||||
|
||||
unarchive(projectId) {
|
||||
unarchive(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/unarchive`);
|
||||
}
|
||||
|
||||
unshare(projectId, groupId) {
|
||||
unshare(projectId: ProjectId, groupId: GroupId) {
|
||||
const [pId, gId] = [projectId, groupId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/share${gId}`);
|
||||
}
|
||||
|
||||
unstar(projectId) {
|
||||
unstar(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/unstar`);
|
||||
}
|
||||
|
||||
updatePushRule(projectId, options) {
|
||||
updatePushRule(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
|
||||
upload(projectId, filePath, { fileName = Path.basename(filePath) } = {}) {
|
||||
upload(projectId: ProjectId, filePath: string, { fileName = Path.basename(filePath) } = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const file = Fs.readFileSync(filePath);
|
||||
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class ProtectedBranches extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_branches`, options);
|
||||
}
|
||||
|
||||
protect(projectId, branchName, options) {
|
||||
protect(projectId: ProjectId, branchName: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/protected_branches`, {
|
||||
@ -16,13 +17,13 @@ class ProtectedBranches extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
show(projectId, branchName) {
|
||||
show(projectId: ProjectId, branchName: string) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_branches/${bName}`);
|
||||
}
|
||||
|
||||
unprotect(projectId, branchName) {
|
||||
unprotect(projectId: ProjectId, branchName: string) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/protected_branches/${bName}`);
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class PushRule extends BaseService {
|
||||
create(projectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
|
||||
async edit(projectId, { upsert = false, ...options } = {}) {
|
||||
async edit(projectId: ProjectId, { upsert = false, ...options } = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
if (upsert) {
|
||||
@ -19,13 +20,13 @@ class PushRule extends BaseService {
|
||||
return RequestHelper.put(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
|
||||
remove(projectId) {
|
||||
remove(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/push_rule`);
|
||||
}
|
||||
|
||||
show(projectId) {
|
||||
show(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/push_rule`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Repositories extends BaseService {
|
||||
compare(projectId, from, to) {
|
||||
compare(projectId: ProjectId, from: string, to: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/compare`, {
|
||||
@ -10,13 +11,13 @@ class Repositories extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
contributors(projectId) {
|
||||
contributors(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/contributors`);
|
||||
}
|
||||
|
||||
showArchive(projectId, { sha }) {
|
||||
showArchive(projectId: ProjectId, { sha }: { sha: string }) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/archive`, {
|
||||
@ -24,19 +25,19 @@ class Repositories extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
showBlob(projectId, sha) {
|
||||
showBlob(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/blobs/${sha}`);
|
||||
}
|
||||
|
||||
showBlobRaw(projectId, sha) {
|
||||
showBlobRaw(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/blobs/${sha}/raw`);
|
||||
}
|
||||
|
||||
tree(projectId, options) {
|
||||
tree(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tree`, options);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class RepositoryFiles extends BaseService {
|
||||
create(projectId, filePath, branch, options) {
|
||||
create(projectId: ProjectId, filePath: string, branch: string, options: RequestOptions) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/files/${path}`, {
|
||||
@ -10,7 +11,7 @@ class RepositoryFiles extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId, filePath, branch, options) {
|
||||
edit(projectId: ProjectId, filePath: string, branch: string, options: RequestOptions) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/repository/files/${path}`, {
|
||||
@ -19,7 +20,7 @@ class RepositoryFiles extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
remove(projectId, filePath, branch, options) {
|
||||
remove(projectId: ProjectId, filePath: string, branch: string, options: RequestOptions) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/repository/files/${path}`, {
|
||||
@ -28,7 +29,7 @@ class RepositoryFiles extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
show(projectId, filePath, ref) {
|
||||
show(projectId: ProjectId, filePath: string, ref: string) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/files/${path}`, {
|
||||
@ -36,7 +37,7 @@ class RepositoryFiles extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
showRaw(projectId, filePath, ref) {
|
||||
showRaw(projectId: ProjectId, filePath: string, ref: string) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/files/${path}/raw`, { ref });
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type RunnerId = string | number;
|
||||
interface RunnersOptions {
|
||||
projectId?: string;
|
||||
projectId?: ProjectId;
|
||||
}
|
||||
class Runners extends BaseService {
|
||||
all({ projectId, ...options }: RunnersOptions = {}) {
|
||||
@ -10,41 +12,41 @@ class Runners extends BaseService {
|
||||
return RequestHelper.get(this, url, options);
|
||||
}
|
||||
|
||||
allOwned(options) {
|
||||
allOwned(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'runners', options);
|
||||
}
|
||||
|
||||
edit(runnerId, attributes) {
|
||||
edit(runnerId: RunnerId, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.put(this, `runners/${rId}`, attributes);
|
||||
return RequestHelper.put(this, `runners/${rId}`, options);
|
||||
}
|
||||
|
||||
enable(projectId, runnerId) {
|
||||
enable(projectId: ProjectId, runnerId: RunnerId) {
|
||||
const [pId, rId] = [projectId, runnerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/runners`, { runnerId: rId });
|
||||
}
|
||||
|
||||
disable(projectId, runnerId) {
|
||||
disable(projectId: ProjectId, runnerId: RunnerId) {
|
||||
const [pId, rId] = [projectId, runnerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/runners/${rId}`);
|
||||
}
|
||||
|
||||
jobs(runnerId) {
|
||||
jobs(runnerId: RunnerId) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.get(this, `runners/${rId}/jobs`);
|
||||
}
|
||||
|
||||
remove(runnerId) {
|
||||
remove(runnerId: RunnerId) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.delete(this, `runners/${rId}`);
|
||||
}
|
||||
|
||||
show(runnerId) {
|
||||
show(runnerId: RunnerId) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.get(this, `runners/${rId}`);
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
interface SearchOptions {
|
||||
projectId?: string;
|
||||
groupId?: string;
|
||||
projectId: ProjectId;
|
||||
groupId: string | number;
|
||||
}
|
||||
class Search extends BaseService {
|
||||
all(scope, search, { projectId, groupId }: SearchOptions = {}) {
|
||||
all(scope: string, search: string, { projectId, groupId }: SearchOptions) {
|
||||
let url = '';
|
||||
|
||||
if (projectId) {
|
||||
|
||||
@ -1,19 +1,29 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type ServiceName = 'asana' | 'assembla' | 'bamboo' | 'bugzilla' | 'buildkite' | 'campfire'
|
||||
| 'custom-issue-tracker' | 'drone-ci' | 'emails-on-push' | 'external-wiki' | 'flowdock'
|
||||
| 'hangouts_chat' | 'hipchat' | 'irker' | 'jira' | 'kubernetes' | 'slack-slash-commands'
|
||||
| 'slack' | 'mattermost-slash-commands' | 'packagist' | 'pipelines-email' | 'pivotaltracker'
|
||||
| 'prometheus' | 'pushover' | 'redmine' | 'microsoft-teams' | 'mattermost'
|
||||
| 'mattermost-slash-commands' | 'teamcity' | 'jenkins' | 'jenkins-deprecated' | 'mock-ci';
|
||||
/**
|
||||
* @see https://docs.gitlab.com/ee/api/services.html
|
||||
*/
|
||||
class Services extends BaseService {
|
||||
edit(projectId, serviceName, options) {
|
||||
edit(projectId: ProjectId, serviceName: ServiceName, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/services/${serviceName}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, serviceName) {
|
||||
remove(projectId: ProjectId, serviceName: ServiceName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/services/${serviceName}`);
|
||||
}
|
||||
|
||||
show(projectId, serviceName) {
|
||||
show(projectId: ProjectId, serviceName: ServiceName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/services/${serviceName}`);
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type SnippetId = string | number;
|
||||
|
||||
class Snippets extends BaseService {
|
||||
all(options = { public: false }) {
|
||||
@ -6,13 +9,13 @@ class Snippets extends BaseService {
|
||||
return RequestHelper.get(this, url, options);
|
||||
}
|
||||
|
||||
content(snippetId) {
|
||||
content(snippetId: SnippetId) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.get(this, `snippets/${sId}/raw`);
|
||||
}
|
||||
|
||||
create(title, fileName, content, visibility, options = {}) {
|
||||
create(title: string, fileName: string, content: string, visibility: string, options = {}) {
|
||||
return RequestHelper.post(this, 'snippets', {
|
||||
title,
|
||||
fileName,
|
||||
@ -22,25 +25,25 @@ class Snippets extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
edit(snippetId, options) {
|
||||
edit(snippetId: SnippetId, options: RequestOptions) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.put(this, `snippets/${sId}`, options);
|
||||
}
|
||||
|
||||
remove(snippetId) {
|
||||
remove(snippetId: SnippetId) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.delete(this, `snippets/${sId}`);
|
||||
}
|
||||
|
||||
show(snippetId) {
|
||||
show(snippetId: SnippetId) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.get(this, `snippets/${sId}`);
|
||||
}
|
||||
|
||||
userAgentDetails(snippetId) {
|
||||
userAgentDetails(snippetId: SnippetId) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.get(this, `snippets/${sId}/user_agent_detail`);
|
||||
|
||||
@ -1,21 +1,27 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type HookId = string | number;
|
||||
class SystemHooks extends BaseService {
|
||||
add(url, options) {
|
||||
add(url: string, options: RequestOptions) {
|
||||
return RequestHelper.post(this, 'hooks', { url, ...options });
|
||||
}
|
||||
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'hooks', options);
|
||||
}
|
||||
|
||||
edit(hookId, url, options) {
|
||||
edit(hookId: HookId, url: string, options: RequestOptions) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.put(this, `hooks/${hId}`, { url, ...options });
|
||||
}
|
||||
|
||||
remove(projectId, hookId) {
|
||||
remove(
|
||||
// @ts-ignore 'projectId' is declared but its value is never read
|
||||
projectId: ProjectId,
|
||||
hookId: HookId,
|
||||
) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.delete(this, `hooks/${hId}`);
|
||||
|
||||
@ -1,25 +1,26 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Tags extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
create(projectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
remove(projectId, tagName) {
|
||||
remove(projectId: ProjectId, tagName: string) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/repository/tags/${tId}`);
|
||||
}
|
||||
|
||||
show(projectId, tagName) {
|
||||
show(projectId: ProjectId, tagName: string) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tags/${tId}`);
|
||||
|
||||
@ -1,20 +1,23 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
import { MergeRequestId } from './MergeRequests';
|
||||
|
||||
type TodoId = string | number;
|
||||
interface TodosOptions {
|
||||
todoId?: string;
|
||||
todoId: TodoId;
|
||||
}
|
||||
class Todos extends BaseService {
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'todos', options);
|
||||
}
|
||||
|
||||
create(projectId, mergerequestId) {
|
||||
create(projectId: ProjectId, mergerequestId: MergeRequestId) {
|
||||
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/todo`);
|
||||
}
|
||||
|
||||
done({ todoId }: TodosOptions = {}) {
|
||||
done({ todoId }: TodosOptions) {
|
||||
const tId = encodeURIComponent(todoId);
|
||||
|
||||
return RequestHelper.delete(this, `todos/${tId}/mark_as_done`);
|
||||
|
||||
@ -1,31 +1,34 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type TriggerId = string | number;
|
||||
|
||||
class Triggers extends BaseService {
|
||||
add(projectId, options) {
|
||||
add(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/triggers`, options);
|
||||
}
|
||||
|
||||
all(projectId) {
|
||||
all(projectId: ProjectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/triggers`);
|
||||
}
|
||||
|
||||
edit(projectId, triggerId, options) {
|
||||
edit(projectId: ProjectId, triggerId: TriggerId, options: RequestOptions) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/triggers/${tId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId, triggerId) {
|
||||
remove(projectId: ProjectId, triggerId: TriggerId) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/triggers/${tId}`);
|
||||
}
|
||||
|
||||
show(projectId, triggerId) {
|
||||
show(projectId: ProjectId, triggerId: TriggerId) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/triggers/${tId}`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class UserCustomAttributes extends ResourceCustomAttributes {
|
||||
constructor(options) {
|
||||
constructor(options: BaseModelContructorOptions) {
|
||||
super('users', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
const url = userId => (userId ? `users/${encodeURIComponent(userId)}/emails` : 'user/emails');
|
||||
const url = (userId?: UserId) => (userId ? `users/${encodeURIComponent(userId)}/emails` : 'user/emails');
|
||||
|
||||
class UserEmails extends BaseService {
|
||||
all({ userId }: UserIdOptions = {}) {
|
||||
return RequestHelper.get(this, url(userId));
|
||||
}
|
||||
|
||||
add(email, { userId }: UserIdOptions = {}) {
|
||||
add(email: string, { userId }: UserIdOptions = {}) {
|
||||
return RequestHelper.post(this, url(userId), {
|
||||
email,
|
||||
});
|
||||
}
|
||||
|
||||
show(emailId) {
|
||||
show(emailId: string) {
|
||||
const eId = encodeURIComponent(emailId);
|
||||
|
||||
return RequestHelper.get(this, `user/emails/${eId}`);
|
||||
}
|
||||
|
||||
remove(emailId, { userId }: UserIdOptions = {}) {
|
||||
remove(emailId: string, { userId }: UserIdOptions = {}) {
|
||||
const eId = encodeURIComponent(emailId);
|
||||
|
||||
return RequestHelper.delete(this, `${url(userId)}/${eId}`);
|
||||
|
||||
@ -1,26 +1,26 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
const url = userId => (userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys');
|
||||
const url = (userId?: UserId) => (userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys');
|
||||
|
||||
class UserGPGKeys extends BaseService {
|
||||
all({ userId }: UserIdOptions = {}) {
|
||||
return RequestHelper.get(this, url(userId));
|
||||
}
|
||||
|
||||
add(title, key, { userId }: UserIdOptions = {}) {
|
||||
add(title: string, key: string, { userId }: UserIdOptions = {}) {
|
||||
return RequestHelper.post(this, url(userId), {
|
||||
title,
|
||||
key,
|
||||
});
|
||||
}
|
||||
|
||||
show(keyId, { userId }: UserIdOptions = {}) {
|
||||
show(keyId: string, { userId }: UserIdOptions = {}) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.get(this, `${url(userId)}/${kId}`);
|
||||
}
|
||||
|
||||
remove(keyId, { userId }: UserIdOptions = {}) {
|
||||
remove(keyId: string, { userId }: UserIdOptions = {}) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.delete(this, `${url(userId)}/${kId}`);
|
||||
|
||||
@ -1,13 +1,24 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
type ImpersonationTokenId = string | number;
|
||||
|
||||
class UserImpersonationTokens extends BaseService {
|
||||
all(userId) {
|
||||
all(userId: UserId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/impersonation_tokens`);
|
||||
}
|
||||
|
||||
add(userId, name, scopes, expiresAt) {
|
||||
/**
|
||||
* It creates a new impersonation token. Note that only administrators can do this.
|
||||
* You are only able to create impersonation tokens to impersonate the user and perform
|
||||
* both API calls and Git reads and writes. The user will not see these tokens
|
||||
* in their profile settings page.
|
||||
* @param userId UserId
|
||||
* @param name The name of the impersonation token
|
||||
* @param scopes The array of scopes of the impersonation token (api, read_user)
|
||||
* @param expiresAt The expiration date of the impersonation token in ISO format (YYYY-MM-DD)
|
||||
*/
|
||||
add(userId: UserId, name: string, scopes: temporaryAny, expiresAt: string) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.post(this, `users/${uId}/impersonation_tokens`, {
|
||||
@ -17,13 +28,13 @@ class UserImpersonationTokens extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
show(userId, tokenId) {
|
||||
show(userId: UserId, tokenId: ImpersonationTokenId) {
|
||||
const [uId, tId] = [userId, tokenId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/impersonation_tokens/${tId}`);
|
||||
}
|
||||
|
||||
revoke(userId, tokenId) {
|
||||
revoke(userId: UserId, tokenId: ImpersonationTokenId) {
|
||||
const [uId, tId] = [userId, tokenId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `users/${uId}/impersonation_tokens/${tId}`);
|
||||
|
||||
@ -1,26 +1,28 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
const url = userId => (userId ? `users/${encodeURIComponent(userId)}/keys` : 'user/keys');
|
||||
const url = (userId?: string) => (userId ? `users/${encodeURIComponent(userId)}/keys` : 'user/keys');
|
||||
|
||||
/** SSH key ID */
|
||||
export type KeyId = string;
|
||||
class UserKeys extends BaseService {
|
||||
all({ userId }) {
|
||||
all({ userId }: UserIdOptions) {
|
||||
return RequestHelper.get(this, url(userId));
|
||||
}
|
||||
|
||||
create(title, key, { userId }: UserIdOptions = {}) {
|
||||
/** Add SSH key for user */
|
||||
create(title: string, key: KeyId, { userId }: UserIdOptions = {}) {
|
||||
return RequestHelper.post(this, url(userId), {
|
||||
title,
|
||||
key,
|
||||
});
|
||||
}
|
||||
|
||||
show(keyId) {
|
||||
show(keyId: KeyId) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.get(this, `user/keys/${kId}`);
|
||||
}
|
||||
|
||||
remove(keyId, { userId }: UserIdOptions = {}) {
|
||||
remove(keyId: KeyId, { userId }: UserIdOptions = {}) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.delete(this, `${url(userId)}/${kId}`);
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { validateEventOptions } from './Events';
|
||||
import { assertEventOptions, EventOptions } from './Events';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Users extends BaseService {
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, 'users', options);
|
||||
}
|
||||
|
||||
@ -10,19 +11,19 @@ class Users extends BaseService {
|
||||
return RequestHelper.get(this, 'users/activities');
|
||||
}
|
||||
|
||||
projects(userId) {
|
||||
projects(userId: UserId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/projects`);
|
||||
}
|
||||
|
||||
block(userId) {
|
||||
block(userId: UserId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.post(this, `users/${uId}/block`);
|
||||
}
|
||||
|
||||
create(options) {
|
||||
create(options: RequestOptions) {
|
||||
return RequestHelper.post(this, 'users', options);
|
||||
}
|
||||
|
||||
@ -30,46 +31,46 @@ class Users extends BaseService {
|
||||
return RequestHelper.get(this, 'user');
|
||||
}
|
||||
|
||||
edit(userId, options) {
|
||||
edit(userId: UserId, options: RequestOptions) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.put(this, `users/${uId}`, options);
|
||||
}
|
||||
|
||||
events(userId, options) {
|
||||
validateEventOptions(options.action, options.targetType);
|
||||
events(userId: UserId, options: RequestOptions & EventOptions) {
|
||||
assertEventOptions(options.action, options.targetType);
|
||||
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/events`, options);
|
||||
}
|
||||
|
||||
session(email, password) {
|
||||
session(email: string, password: string) {
|
||||
return RequestHelper.post(this, 'session', {
|
||||
email,
|
||||
password,
|
||||
});
|
||||
}
|
||||
|
||||
search(emailOrUsername) {
|
||||
search(emailOrUsername: string) {
|
||||
return RequestHelper.get(this, 'users', {
|
||||
search: emailOrUsername,
|
||||
});
|
||||
}
|
||||
|
||||
show(userId, options) {
|
||||
show(userId: UserId, options: RequestOptions) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}`, options);
|
||||
}
|
||||
|
||||
remove(userId) {
|
||||
remove(userId: UserId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.delete(this, `users/${uId}`);
|
||||
}
|
||||
|
||||
unblock(userId) {
|
||||
unblock(userId: UserId) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.post(this, `users/${uId}/unblock`);
|
||||
|
||||
@ -1,31 +1,32 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Wikis extends BaseService {
|
||||
all(projectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/wikis`, options);
|
||||
}
|
||||
|
||||
create(projectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/wikis`, options);
|
||||
}
|
||||
|
||||
edit(projectId, slug, options) {
|
||||
edit(projectId: ProjectId, slug: string, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/wikis/${slug}`, options);
|
||||
}
|
||||
|
||||
show(projectId, slug) {
|
||||
show(projectId: ProjectId, slug: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/wikis/${slug}`);
|
||||
}
|
||||
|
||||
remove(projectId, slug) {
|
||||
remove(projectId: ProjectId, slug: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/wikis/${slug}`);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
export const ACCESS_LEVELS = {
|
||||
GUEST: 10,
|
||||
@ -12,26 +13,26 @@ export const ACCESS_LEVELS = {
|
||||
class ResourceAccessRequests extends BaseService {
|
||||
protected ACCESS_LEVELS: typeof ACCESS_LEVELS;
|
||||
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
this.ACCESS_LEVELS = ACCESS_LEVELS;
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
all(resourceId: ResourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/access_requests`);
|
||||
}
|
||||
|
||||
request(resourceId) {
|
||||
request(resourceId: ResourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/access_requests`);
|
||||
}
|
||||
|
||||
approve(resourceId, userId, { accessLevel = 30 }) {
|
||||
approve(resourceId: ResourceId, userId: UserId, { accessLevel = 30 }) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/access_requests/${uId}/approve`, {
|
||||
@ -39,7 +40,7 @@ class ResourceAccessRequests extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
deny(resourceId, userId) {
|
||||
deny(resourceId: ResourceId, userId: UserId) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/access_requests/${uId}`);
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
function url(projectId, resourceType, resourceId, noteId) {
|
||||
function url(
|
||||
projectId: ProjectId,
|
||||
resourceType: ResourceType,
|
||||
resourceId: ResourceId,
|
||||
noteId: NoteId,
|
||||
) {
|
||||
const [pId, rId] = [projectId, resourceId].map(encodeURIComponent);
|
||||
let output = `${pId}/${resourceType}/${rId}/`;
|
||||
|
||||
@ -17,28 +24,40 @@ function url(projectId, resourceType, resourceId, noteId) {
|
||||
class ResourceAwardsEmojis extends BaseService {
|
||||
protected resourceType: temporaryAny;
|
||||
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, 'projects');
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(projectId, resourceId, options, noteId) {
|
||||
all(projectId: ProjectId, resourceId: ResourceId, options: RequestOptions, noteId: NoteId) {
|
||||
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, noteId), options);
|
||||
}
|
||||
|
||||
award(projectId, resourceId, name, noteId) {
|
||||
award(projectId: ProjectId, resourceId: ResourceId, name: string, noteId: NoteId) {
|
||||
return RequestHelper.post(this, url(projectId, this.resourceType, resourceId, noteId), {
|
||||
name,
|
||||
});
|
||||
}
|
||||
|
||||
remove(projectId, resourceId, awardId, noteId) {
|
||||
remove(
|
||||
projectId: ProjectId,
|
||||
resourceId: ResourceId,
|
||||
// @ts-ignore 'awardId' is declared but its value is never read
|
||||
awardId: string | number,
|
||||
noteId: NoteId,
|
||||
) {
|
||||
return RequestHelper.delete(this, url(projectId, this.resourceType, resourceId, noteId));
|
||||
}
|
||||
|
||||
show(projectId, resourceId, awardId, noteId) {
|
||||
show(
|
||||
projectId: ProjectId,
|
||||
resourceId: ResourceId,
|
||||
// @ts-ignore 'awardId' is declared but its value is never read
|
||||
awardId: string | number,
|
||||
noteId: NoteId,
|
||||
) {
|
||||
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, noteId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,44 +1,47 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type BadgeId = string | number;
|
||||
class ResourceBadges extends BaseService {
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
}
|
||||
|
||||
add(resourceId, options) {
|
||||
add(resourceId: ResourceId, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/badges`, options);
|
||||
}
|
||||
|
||||
all(resourceId, options) {
|
||||
all(resourceId: ResourceId, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/badges`, options);
|
||||
}
|
||||
|
||||
edit(resourceId, badgeId, options) {
|
||||
edit(resourceId: ResourceId, badgeId: BadgeId, options: RequestOptions) {
|
||||
const [rId, bId] = [resourceId, badgeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${rId}/badges/${bId}`, options);
|
||||
}
|
||||
|
||||
preview(resourceId, linkUrl, imageUrl) {
|
||||
preview(resourceId: ResourceId, linkUrl: string, imageUrl: string) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/badges/render`, { linkUrl, imageUrl });
|
||||
}
|
||||
|
||||
remove(resourceId, badgeId) {
|
||||
remove(resourceId: ResourceId, badgeId: BadgeId) {
|
||||
const [rId, bId] = [resourceId, badgeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/badges/${bId}`);
|
||||
}
|
||||
|
||||
show(resourceId, badgeId) {
|
||||
show(resourceId: ResourceId, badgeId: BadgeId) {
|
||||
const [rId, bId] = [resourceId, badgeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/badges/${bId}`);
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
export type CustomAttributeId = string | number;
|
||||
class ResourceCustomAttributes extends BaseService {
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
}
|
||||
|
||||
all(resourceId) {
|
||||
all(resourceId: ResourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/custom_attributes`);
|
||||
}
|
||||
|
||||
set(resourceId, customAttributeId, value) {
|
||||
set(resourceId: ResourceId, customAttributeId: CustomAttributeId, value: string) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${rId}/custom_attributes/${cId}`, {
|
||||
@ -22,13 +24,13 @@ class ResourceCustomAttributes extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
remove(resourceId, customAttributeId) {
|
||||
remove(resourceId: ResourceId, customAttributeId: CustomAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/custom_attributes/${cId}`);
|
||||
}
|
||||
|
||||
show(resourceId, customAttributeId) {
|
||||
show(resourceId: ResourceId, customAttributeId: CustomAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/custom_attributes/${cId}`);
|
||||
|
||||
@ -1,17 +1,26 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type DiscussiodId = string | number;
|
||||
class ResourceDiscussions extends BaseService {
|
||||
protected resource2Type: temporaryAny;
|
||||
protected resource2Type: string;
|
||||
|
||||
constructor(resourceType, resource2Type, baseParams) {
|
||||
constructor(resourceType: string, resource2Type: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
this.resource2Type = resource2Type;
|
||||
}
|
||||
|
||||
addNote(resourceId, resource2Id, discussiodId, noteId, options) {
|
||||
addNote(
|
||||
resourceId: string,
|
||||
resource2Id: string,
|
||||
discussiodId: string,
|
||||
noteId: NoteId,
|
||||
options: RequestOptions,
|
||||
) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id, dId, nId] = [resourceId, resource2Id, discussiodId, noteId]
|
||||
@ -20,13 +29,13 @@ class ResourceDiscussions extends BaseService {
|
||||
return RequestHelper.put(this, `${rId}/${this.resource2Type}/${r2Id}/discussions/${dId}/notes/${nId}`, options);
|
||||
}
|
||||
|
||||
all(resourceId, resource2Id, options) {
|
||||
all(resourceId: ResourceId, resource2Id: Resource2Id, options: RequestOptions) {
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/${this.resource2Type}/${r2Id}/discussions`, options);
|
||||
}
|
||||
|
||||
create(resourceId, resource2Id, options) {
|
||||
create(resourceId: ResourceId, resource2Id: Resource2Id, options: RequestOptions) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(encodeURIComponent);
|
||||
@ -34,21 +43,32 @@ class ResourceDiscussions extends BaseService {
|
||||
return RequestHelper.post(this, `${rId}/${this.resource2Type}/${r2Id}/discussions`, options);
|
||||
}
|
||||
|
||||
editNote(resourceId, resource2Id, discussiodId, noteId, body) {
|
||||
editNote(
|
||||
resourceId: ResourceId,
|
||||
resource2Id: Resource2Id,
|
||||
discussiodId: DiscussiodId,
|
||||
noteId: NoteId,
|
||||
options: RequestOptions,
|
||||
) {
|
||||
const [rId, r2Id, dId, nId] = [resourceId, resource2Id, discussiodId, noteId]
|
||||
.map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${rId}/${this.resource2Type}/${r2Id}/discussions/${dId}/notes/${nId}`, { body });
|
||||
return RequestHelper.put(this, `${rId}/${this.resource2Type}/${r2Id}/discussions/${dId}/notes/${nId}`, { body: options });
|
||||
}
|
||||
|
||||
removeNote(resourceId, resource2Id, discussiodId, noteId) {
|
||||
removeNote(
|
||||
resourceId: ResourceId,
|
||||
resource2Id: Resource2Id,
|
||||
discussiodId: DiscussiodId,
|
||||
noteId: NoteId,
|
||||
) {
|
||||
const [rId, r2Id, dId, nId] = [resourceId, resource2Id, discussiodId, noteId]
|
||||
.map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/${this.resource2Type}/${r2Id}/discussions/${dId}/notes/${nId}`);
|
||||
}
|
||||
|
||||
show(resourceId, resource2Id, discussiodId) {
|
||||
show(resourceId: ResourceId, resource2Id: Resource2Id, discussiodId: DiscussiodId) {
|
||||
const [rId, r2Id, dId] = [resourceId, resource2Id, discussiodId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/${this.resource2Type}/${r2Id}/discussions/${dId}`);
|
||||
|
||||
@ -1,68 +1,75 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type BoardId = string | number;
|
||||
export type ListId = string | number;
|
||||
export type LabelId = string | number;
|
||||
/** The position of the list */
|
||||
export type Position = string | number;
|
||||
class ResourceIssueBoards extends BaseService {
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
}
|
||||
|
||||
all(resourceId, options) {
|
||||
all(resourceId: ResourceId, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/boards`, options);
|
||||
}
|
||||
|
||||
create(resourceId, name) {
|
||||
create(resourceId: ResourceId, name: string) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/boards`, { name });
|
||||
}
|
||||
|
||||
createList(resourceId, boardId, labelId) {
|
||||
createList(resourceId: ResourceId, boardId: BoardId, labelId: LabelId) {
|
||||
const [rId, bId] = [resourceId, boardId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/boards/${bId}/lists`, { labelId });
|
||||
}
|
||||
|
||||
edit(resourceId, boardId, options) {
|
||||
edit(resourceId: ResourceId, boardId: BoardId, options: RequestOptions) {
|
||||
const [rId, bId] = [resourceId, boardId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${rId}/boards/${bId}`, options);
|
||||
}
|
||||
|
||||
editList(resourceId, boardId, listId, position) {
|
||||
editList(resourceId: ResourceId, boardId: BoardId, listId: ListId, position: Position) {
|
||||
const [rId, bId, lId] = [resourceId, boardId, listId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${rId}/boards/${bId}/lists/${lId}`, { position });
|
||||
}
|
||||
|
||||
lists(resourceId, boardId) {
|
||||
lists(resourceId: ResourceId, boardId: BoardId) {
|
||||
const [rId, bId] = [resourceId, boardId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/boards/${bId}/lists`);
|
||||
}
|
||||
|
||||
remove(resourceId, boardId) {
|
||||
remove(resourceId: ResourceId, boardId: BoardId) {
|
||||
const [rId, bId] = [resourceId, boardId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/boards/${bId}`);
|
||||
}
|
||||
|
||||
removeList(resourceId, boardId, listId) {
|
||||
removeList(resourceId: ResourceId, boardId: BoardId, listId: ListId) {
|
||||
const [rId, bId, lId] = [resourceId, boardId, listId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/boards/${bId}/lists/${lId}`);
|
||||
}
|
||||
|
||||
show(resourceId, boardId) {
|
||||
show(resourceId: ResourceId, boardId: BoardId) {
|
||||
const [rId, bId] = [resourceId, boardId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/boards/${bId}`);
|
||||
}
|
||||
|
||||
showList(resourceId, boardId, listId) {
|
||||
showList(resourceId: ResourceId, boardId: BoardId, listId: ListId) {
|
||||
const [rId, bId, lId] = [resourceId, boardId, listId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/boards/${bId}/lists/${lId}`);
|
||||
|
||||
@ -1,47 +1,51 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
/** A valid access level */
|
||||
export type AccessLevel = number;
|
||||
class ResourceMembers extends BaseService {
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
}
|
||||
|
||||
all(resourceId, includeInherited = false, options = {}) {
|
||||
all(resourceId: ResourceId, includeInherited = false, options = {}) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
const url = includeInherited ? `${rId}/members/all` : `${rId}/members`;
|
||||
|
||||
return RequestHelper.get(this, url, { options });
|
||||
return RequestHelper.get(this, url, options);
|
||||
}
|
||||
|
||||
add(resourceId, userId, accessLevel, options) {
|
||||
add(resourceId: ResourceId, userId: UserId, accessLevel: AccessLevel, options: RequestOptions) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/members`, {
|
||||
user_id: uId,
|
||||
access_level: parseInt(accessLevel, 10),
|
||||
userId: uId,
|
||||
accessLevel,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
edit(resourceId, userId, accessLevel, options) {
|
||||
edit(resourceId: ResourceId, userId: UserId, accessLevel: AccessLevel, options: RequestOptions) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${rId}/members/${uId}`, {
|
||||
access_level: parseInt(accessLevel, 10),
|
||||
accessLevel,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
show(resourceId, userId) {
|
||||
show(resourceId: ResourceId, userId: UserId) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/members/${uId}`);
|
||||
}
|
||||
|
||||
remove(resourceId, userId) {
|
||||
remove(resourceId: ResourceId, userId: UserId) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/members/${uId}`);
|
||||
|
||||
@ -1,44 +1,47 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type MilestoneId = string;
|
||||
class ResourceMilestones extends BaseService {
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
}
|
||||
|
||||
all(resourceId, options) {
|
||||
all(resourceId: ResourceId, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/milestones`, options);
|
||||
}
|
||||
|
||||
create(resourceId, title, options) {
|
||||
create(resourceId: ResourceId, title: string, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/milestones`, { title, ...options });
|
||||
}
|
||||
|
||||
edit(resourceId, milestoneId, options) {
|
||||
edit(resourceId: ResourceId, milestoneId: MilestoneId, options: RequestOptions) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `${rId}/milestones/${mId}`, options);
|
||||
}
|
||||
|
||||
issues(resourceId, milestoneId) {
|
||||
issues(resourceId: ResourceId, milestoneId: MilestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/milestones/${mId}/issues`);
|
||||
}
|
||||
|
||||
mergeRequests(resourceId, milestoneId) {
|
||||
mergeRequests(resourceId: ResourceId, milestoneId: MilestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/milestones/${mId}/merge_requests`);
|
||||
}
|
||||
|
||||
show(resourceId, milestoneId) {
|
||||
show(resourceId: ResourceId, milestoneId: MilestoneId) {
|
||||
const [rId, mId] = [resourceId, milestoneId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/milestones/${mId}`);
|
||||
|
||||
@ -1,23 +1,25 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class ResourceNotes extends BaseService {
|
||||
protected resource2Type: temporaryAny;
|
||||
protected resource2Type: string;
|
||||
|
||||
constructor(resourceType, resource2Type, baseParams) {
|
||||
constructor(resourceType: string, resource2Type: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
this.resource2Type = resource2Type;
|
||||
}
|
||||
|
||||
all(resourceId, resource2Id, options) {
|
||||
all(resourceId: ResourceId, resource2Id: Resource2Id, options: RequestOptions) {
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/${this.resource2Type}/${r2Id}/notes`, options);
|
||||
}
|
||||
|
||||
create(resourceId, resource2Id, options) {
|
||||
create(resourceId: ResourceId, resource2Id: Resource2Id, options: RequestOptions) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(encodeURIComponent);
|
||||
@ -25,7 +27,7 @@ class ResourceNotes extends BaseService {
|
||||
return RequestHelper.post(this, `${rId}/${this.resource2Type}/${r2Id}/notes`, options);
|
||||
}
|
||||
|
||||
edit(resourceId, resource2Id, noteId, options) {
|
||||
edit(resourceId: ResourceId, resource2Id: Resource2Id, noteId: NoteId, options: RequestOptions) {
|
||||
if (!options.body) throw new Error('Missing required property: body');
|
||||
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(encodeURIComponent);
|
||||
@ -33,13 +35,13 @@ class ResourceNotes extends BaseService {
|
||||
return RequestHelper.put(this, `${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`, options);
|
||||
}
|
||||
|
||||
remove(resourceId, resource2Id, noteId) {
|
||||
remove(resourceId: ResourceId, resource2Id: Resource2Id, noteId: NoteId) {
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
|
||||
}
|
||||
|
||||
show(resourceId, resource2Id, noteId) {
|
||||
show(resourceId: ResourceId, resource2Id: Resource2Id, noteId: NoteId) {
|
||||
const [rId, r2Id, nId] = [resourceId, resource2Id, noteId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/${this.resource2Type}/${r2Id}/notes/${nId}`);
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class ResourceTemplates extends BaseService {
|
||||
constructor(resourceType, baseParams) {
|
||||
constructor(resourceType: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
|
||||
this.url = URLJoin(this.url, 'templates', resourceType);
|
||||
}
|
||||
|
||||
all(options) {
|
||||
all(options: RequestOptions) {
|
||||
return RequestHelper.get(this, '', options);
|
||||
}
|
||||
|
||||
show(resourceId) {
|
||||
show(resourceId: ResourceId) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(this, `${rId}`);
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
const url = (resourceType, resourceId, resource2Type, resource2Id) => {
|
||||
function url(
|
||||
resourceType: ResourceType,
|
||||
resourceId: ResourceId,
|
||||
resource2Type: Resource2Type,
|
||||
resource2Id: Resource2Id) {
|
||||
const [rId, r2Id] = [resourceId, resource2Id].map(encodeURIComponent);
|
||||
|
||||
let output = `${resourceType}/${rId}/`;
|
||||
@ -12,27 +18,31 @@ const url = (resourceType, resourceId, resource2Type, resource2Id) => {
|
||||
output += 'variables';
|
||||
|
||||
return output;
|
||||
};
|
||||
}
|
||||
|
||||
class ResourceVariables extends BaseService {
|
||||
protected resourceType: temporaryAny;
|
||||
protected resource2Type: temporaryAny;
|
||||
protected resourceType: ResourceType;
|
||||
protected resource2Type: Resource2Type;
|
||||
|
||||
constructor(resourceType, resource2Type, baseParams) {
|
||||
constructor(
|
||||
resourceType: ResourceType,
|
||||
resource2Type: Resource2Type,
|
||||
baseParams: BaseModelContructorOptions,
|
||||
) {
|
||||
super(baseParams);
|
||||
|
||||
this.resourceType = resourceType;
|
||||
this.resource2Type = resource2Type;
|
||||
}
|
||||
|
||||
all(resourceId, resource2Id) {
|
||||
all(resourceId: ResourceType, resource2Id: Resource2Id) {
|
||||
return RequestHelper.get(
|
||||
this,
|
||||
url(this.resourceType, resourceId, this.resource2Type, resource2Id),
|
||||
);
|
||||
}
|
||||
|
||||
create(resourceId, resource2Id, options) {
|
||||
create(resourceId: ResourceType, resource2Id: Resource2Id, options: RequestOptions) {
|
||||
return RequestHelper.post(
|
||||
this,
|
||||
url(this.resourceType, resourceId, this.resource2Type, resource2Id),
|
||||
@ -40,7 +50,7 @@ class ResourceVariables extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
edit(resourceId, resource2Id, keyId, options) {
|
||||
edit(resourceId: ResourceType, resource2Id: Resource2Id, keyId: string, options: RequestOptions) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.put(
|
||||
@ -50,7 +60,7 @@ class ResourceVariables extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
show(resourceId, resource2Id, keyId) {
|
||||
show(resourceId: ResourceType, resource2Id: Resource2Id, keyId: string) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.get(
|
||||
@ -59,7 +69,7 @@ class ResourceVariables extends BaseService {
|
||||
);
|
||||
}
|
||||
|
||||
remove(resourceId, resource2Id, keyId) {
|
||||
remove(resourceId: ResourceType, resource2Id: Resource2Id, keyId: string) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.delete(
|
||||
|
||||
67
src/types.d.ts
vendored
Normal file
67
src/types.d.ts
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/// <reference path="../node_modules/jest-extended/types/index.d.ts" />
|
||||
|
||||
type temporaryAny = any;
|
||||
type UserIdOptions = { userId?: string };
|
||||
type UserId = string;
|
||||
|
||||
type ResourceType = string; // see if we can narrow the type to string literals
|
||||
type ResourceId = string; // see if we can narrow the type to string literals
|
||||
type Resource2Type = string; // see if we can narrow the type to string literals
|
||||
type Resource2Id = string; // see if we can narrow the type to string literals
|
||||
|
||||
type NoteId = string; // see if `| number` is a valid type
|
||||
type ProjectId = string | number;
|
||||
type KeyId = string; // see if `| number` is a valid type
|
||||
type GroupId = string | number;
|
||||
|
||||
type GroupAccess = temporaryAny;
|
||||
|
||||
/** The duration in human format. e.g: 3h30m */
|
||||
type Duration = string;
|
||||
|
||||
/**
|
||||
* Encodes a text string as a valid component of a Uniform Resource Identifier (URI).
|
||||
* @param uriComponent A value representing an encoded URI component.
|
||||
*/
|
||||
declare function encodeURIComponent(uriComponent: number | string): string;
|
||||
|
||||
declare module 'request-promise-core/errors';
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source The source object from which to copy properties.
|
||||
*/
|
||||
assign<T, U>(target: T, source: U): T & U;
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
*/
|
||||
assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param source1 The first source object from which to copy properties.
|
||||
* @param source2 The second source object from which to copy properties.
|
||||
* @param source3 The third source object from which to copy properties.
|
||||
*/
|
||||
assign<T, U, V, W>(
|
||||
target: T,
|
||||
source1: U,
|
||||
source2: V,
|
||||
source3: W,
|
||||
): T & U & V & W;
|
||||
/**
|
||||
* Copy the values of all of the enumerable own properties from one or more source objects to a
|
||||
* target object. Returns the target object.
|
||||
* @param target The target object to copy to.
|
||||
* @param sources One or more source objects from which to copy properties
|
||||
*/
|
||||
assign(target: any, ...sources: any[]): any;
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
import {} from '../src/index';
|
||||
|
||||
declare global {
|
||||
type temporaryAny = any;
|
||||
type UserIdOptions = { userId?: string };
|
||||
}
|
||||
@ -25,7 +25,7 @@ test('All the correct service keys are included in the groups bundle', async ()
|
||||
test('All the correct service instances are included in the groups bundle', async () => {
|
||||
const bundle = new GroupsBundle({ token: 'test' });
|
||||
|
||||
Object.keys(bundle).forEach((key) => {
|
||||
(Object.keys(bundle) as (keyof typeof bundle)[]).forEach((key) => {
|
||||
expect(bundle[key]).toBeInstanceOf(Services[key]);
|
||||
});
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user