mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Add type annotations
This commit is contained in:
parent
2992d67f14
commit
ce8b0b3154
907
package-lock.json
generated
907
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,9 @@ 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;
|
||||
@ -95,7 +96,7 @@ async function getPaginated(
|
||||
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
|
||||
@ -125,6 +126,42 @@ async function getPaginated(
|
||||
|
||||
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;
|
||||
@ -132,6 +169,15 @@ export interface RequestOptions {
|
||||
access_level?: number;
|
||||
user_id?: UserId;
|
||||
position?: temporaryAny;
|
||||
value?: string;
|
||||
linkUrl?: string;
|
||||
imageUrl?: string;
|
||||
key?: string;
|
||||
action?: string;
|
||||
targetType?: string;
|
||||
email?: string;
|
||||
password?: string;
|
||||
search?: string;
|
||||
}
|
||||
class RequestHelper {
|
||||
static async request(
|
||||
@ -184,7 +230,7 @@ class RequestHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static async handleRequestError(err) {
|
||||
static async handleRequestError(err: temporaryAny) {
|
||||
if (
|
||||
!err.response ||
|
||||
!err.response.headers ||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { StatusCodeError } from 'request-promise-core/errors';
|
||||
import Promisify from 'util.promisify';
|
||||
import { promisify } from 'util';
|
||||
import XHR from 'xhr';
|
||||
import { wait } from './RequestHelper';
|
||||
import { wait, RequestParametersInput } from './RequestHelper';
|
||||
|
||||
function promisifyFn(fn) {
|
||||
const promisifiedFn = Promisify(fn);
|
||||
function promisifyFn<F extends Function>(fn: F) {
|
||||
const promisifiedFn = promisify(fn);
|
||||
|
||||
return async function getResponse(opts) {
|
||||
return async function getResponse(opts: RequestParametersInput) {
|
||||
const response = await promisifiedFn(opts);
|
||||
const sleepTime = parseInt(response.headers['retry-after'], 10);
|
||||
if (response.statusCode === 429 && sleepTime) {
|
||||
|
||||
@ -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: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits`, options);
|
||||
}
|
||||
|
||||
cherryPick(projectId: 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: ProjectId, sha) {
|
||||
comments(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/comments`);
|
||||
}
|
||||
|
||||
create(projectId: 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: 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: ProjectId, sha) {
|
||||
diff(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/diff`);
|
||||
}
|
||||
|
||||
editStatus(projectId: 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: ProjectId, sha) {
|
||||
references(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/refs`);
|
||||
}
|
||||
|
||||
show(projectId: 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: 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,7 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class DeployKeys extends BaseService {
|
||||
add(projectId: ProjectId, options) {
|
||||
add(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/deploy_keys`, options);
|
||||
@ -13,13 +14,13 @@ class DeployKeys extends BaseService {
|
||||
return RequestHelper.get(this, `projects/${pId}/deploy_keys`);
|
||||
}
|
||||
|
||||
show(projectId: 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: 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: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deployments`, options);
|
||||
}
|
||||
|
||||
show(projectId: 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: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/environments`, options);
|
||||
}
|
||||
|
||||
create(projectId: ProjectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/environments`, options);
|
||||
}
|
||||
|
||||
edit(projectId: 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: ProjectId, environmentId) {
|
||||
remove(projectId: ProjectId, environmentId: EnvironmentId) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/environments/${eId}`);
|
||||
}
|
||||
|
||||
stop(projectId: 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,8 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type GroupId = string | number;
|
||||
export type EpicId = string | number;
|
||||
|
||||
class Epics extends BaseService {
|
||||
all(groupId: GroupId) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
@ -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: ProjectId) {
|
||||
add(groupId: GroupProjectId, projectId: ProjectId) {
|
||||
const [gId, pId] = [groupId, projectId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/projects/${pId}`);
|
||||
|
||||
@ -3,7 +3,7 @@ import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
|
||||
class GroupVariables extends ResourceVariables {
|
||||
constructor(baseParams: BaseModelContructorOptions) {
|
||||
super('groups', null, baseParams);
|
||||
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: 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: 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: ProjectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues`, options);
|
||||
}
|
||||
|
||||
edit(projectId: 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: 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: 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: ProjectId, issueId) {
|
||||
remove(projectId: ProjectId, issueId: IssueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
resetSpentTime(projectId: 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: 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: ProjectId, issueId) {
|
||||
show(projectId: ProjectId, issueId: IssueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}`);
|
||||
}
|
||||
|
||||
subscribe(projectId: 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: 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: ProjectId, issueId) {
|
||||
unsubscribe(projectId: ProjectId, issueId: IssueId) {
|
||||
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/issues/${iId}/unsubscribe`);
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
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: ProjectId, options = {}) {
|
||||
@ -7,7 +11,7 @@ class Jobs extends BaseService {
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs`, options);
|
||||
}
|
||||
|
||||
cancel(projectId: ProjectId, jobId) {
|
||||
cancel(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/cancel`);
|
||||
@ -15,8 +19,8 @@ class Jobs extends BaseService {
|
||||
|
||||
downloadSingleArtifactFile(
|
||||
projectId: ProjectId,
|
||||
jobId,
|
||||
artifactPath,
|
||||
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: ProjectId,
|
||||
ref,
|
||||
name,
|
||||
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: 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: 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: 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: 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: 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: ProjectId, jobId) {
|
||||
show(projectId: ProjectId, jobId: JobId) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs/${jId}`);
|
||||
}
|
||||
|
||||
showPipelineJobs(projectId: 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,5 +1,7 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
|
||||
type LabelId = string | number;
|
||||
|
||||
class Labels extends BaseService {
|
||||
all(projectId: ProjectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
@ -13,25 +15,25 @@ class Labels extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/labels`, options);
|
||||
}
|
||||
|
||||
edit(projectId: 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: ProjectId, labelName) {
|
||||
remove(projectId: ProjectId, labelName: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/labels`, { name: labelName });
|
||||
}
|
||||
|
||||
subscribe(projectId: 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: 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 { 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: 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: 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: 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,13 +26,13 @@ class MergeRequests extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
approve(projectId: 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: ProjectId, { mergerequestId }: { mergerequestId?: string } = {}) {
|
||||
approvals(projectId: ProjectId, { mergerequestId }: { mergerequestId?: MergeRequestId } = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const mergeRequest = mergerequestId ? `merge_requests/${encodeURIComponent(mergerequestId)}` : '';
|
||||
|
||||
@ -42,31 +45,37 @@ class MergeRequests extends BaseService {
|
||||
return RequestHelper.get(this, url, options);
|
||||
}
|
||||
|
||||
cancelOnPipelineSucess(projectId: 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: 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: 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: 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: 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,20 +87,20 @@ class MergeRequests extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId: 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: 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: ProjectId, { mergerequestId, ...options }) {
|
||||
editApprovers(projectId: ProjectId, { mergerequestId, ...options }: temporaryAny) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const mergeRequest = mergerequestId ? `merge_requests/${encodeURIComponent(mergerequestId)}` : '';
|
||||
|
||||
@ -105,55 +114,55 @@ class MergeRequests extends BaseService {
|
||||
return RequestHelper.get(this, `projects/${pId}/${mergeRequest}/pipelines`);
|
||||
}
|
||||
|
||||
remove(projectId: 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: 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: 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: 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: 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: 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: 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: 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: 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,5 +1,6 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
const LEVELS = {
|
||||
DISABLED: 'disabled',
|
||||
@ -51,8 +52,8 @@ class NotificationSettings extends BaseService {
|
||||
return RequestHelper.get(this, `${url}notification_settings`);
|
||||
}
|
||||
|
||||
edit(options, { projectId, groupId }: NotificationSettingsOptions = {}) {
|
||||
let url;
|
||||
edit(options: RequestOptions, { projectId, groupId }: NotificationSettingsOptions = {}) {
|
||||
let url = '';
|
||||
|
||||
if (projectId) {
|
||||
url += `projects/${encodeURIComponent(projectId)}/`;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
interface PagesDomainsOptions {
|
||||
projectId?: ProjectId;
|
||||
@ -10,25 +11,25 @@ class PagesDomains extends BaseService {
|
||||
return RequestHelper.get(this, `${url}pages/domains`);
|
||||
}
|
||||
|
||||
create(projectId: 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: 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: ProjectId, domain) {
|
||||
show(projectId: ProjectId, domain: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pages/domains/${domain}`);
|
||||
}
|
||||
|
||||
remove(projectId: 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: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipeline_schedules`, options);
|
||||
}
|
||||
|
||||
create(projectId: 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: 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: 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: 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: 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,4 +1,5 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
export type PipelineId = string | number;
|
||||
|
||||
@ -33,7 +34,7 @@ class Pipelines extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/pipelines/${pipelineId}/cancel`);
|
||||
}
|
||||
|
||||
showJobs(projectId: ProjectId, pipelineId: 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: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks`, options);
|
||||
}
|
||||
|
||||
show(projectId: ProjectId, hookId) {
|
||||
show(projectId: ProjectId, hookId: HookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks/${hId}`);
|
||||
}
|
||||
|
||||
add(projectId: 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: 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: ProjectId, hookId) {
|
||||
remove(projectId: ProjectId, hookId: HookId) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/hooks/${hId}`);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class ProjectImportExport extends BaseService {
|
||||
download(projectId: ProjectId) {
|
||||
@ -13,7 +14,7 @@ class ProjectImportExport extends BaseService {
|
||||
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 });
|
||||
}
|
||||
|
||||
@ -23,7 +24,7 @@ class ProjectImportExport extends BaseService {
|
||||
return RequestHelper.get(this, `projects/${pId}/import`);
|
||||
}
|
||||
|
||||
schedule(projectId: 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,6 +7,8 @@ const VISIBILITY_LEVELS = {
|
||||
PUBLIC: 'public',
|
||||
};
|
||||
|
||||
type SnippetId = string | number;
|
||||
type VisibilityLevel = 'private' | 'public' | 'internal';
|
||||
class ProjectSnippets extends BaseService {
|
||||
all(projectId: ProjectId, options = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
@ -13,13 +16,20 @@ class ProjectSnippets extends BaseService {
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets`, options);
|
||||
}
|
||||
|
||||
content(projectId: 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: 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: 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: ProjectId, snippetId) {
|
||||
remove(projectId: ProjectId, snippetId: SnippetId) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/snippets/${sId}`);
|
||||
}
|
||||
|
||||
show(projectId: ProjectId, snippetId) {
|
||||
show(projectId: ProjectId, snippetId: SnippetId) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets/${sId}`);
|
||||
}
|
||||
|
||||
userAgentDetails(projectId: 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,9 +1,12 @@
|
||||
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?: RequestOptions) {
|
||||
return RequestHelper.get(this, 'projects', options);
|
||||
@ -14,34 +17,36 @@ class Projects extends BaseService {
|
||||
|
||||
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: ProjectId, options) {
|
||||
edit(projectId: ProjectId, options: temporaryAny) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
events(projectId: 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: ProjectId, options) {
|
||||
fork(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/fork`, options);
|
||||
}
|
||||
|
||||
forks(projectId: ProjectId, options) {
|
||||
forks(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/forks`, options);
|
||||
@ -69,7 +74,7 @@ class Projects extends BaseService {
|
||||
return RequestHelper.get(this, 'projects', { search: projectName });
|
||||
}
|
||||
|
||||
share(projectId: 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');
|
||||
@ -77,7 +82,7 @@ class Projects extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/share`, { groupId, groupAccess, ...options });
|
||||
}
|
||||
|
||||
show(projectId: ProjectId, options) {
|
||||
show(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}`, options);
|
||||
@ -89,15 +94,15 @@ class Projects extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/star`);
|
||||
}
|
||||
|
||||
statuses(projectId: 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: 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: ProjectId) {
|
||||
@ -106,7 +111,7 @@ class Projects extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/unarchive`);
|
||||
}
|
||||
|
||||
unshare(projectId: ProjectId, groupId) {
|
||||
unshare(projectId: ProjectId, groupId: GroupId) {
|
||||
const [pId, gId] = [projectId, groupId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/share${gId}`);
|
||||
@ -118,13 +123,13 @@ class Projects extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/unstar`);
|
||||
}
|
||||
|
||||
updatePushRule(projectId: ProjectId, options) {
|
||||
updatePushRule(projectId: ProjectId, options: ProjectOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
|
||||
upload(projectId: 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: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_branches`, options);
|
||||
}
|
||||
|
||||
protect(projectId: 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: 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: ProjectId, branchName) {
|
||||
unprotect(projectId: ProjectId, branchName: string) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/protected_branches/${bName}`);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class PushRule extends BaseService {
|
||||
create(projectId: ProjectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/push_rule`, options);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Repositories extends BaseService {
|
||||
compare(projectId: ProjectId, from, to) {
|
||||
compare(projectId: ProjectId, from: string, to: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/compare`, {
|
||||
@ -16,7 +17,7 @@ class Repositories extends BaseService {
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/contributors`);
|
||||
}
|
||||
|
||||
showArchive(projectId: 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: ProjectId, sha) {
|
||||
showBlob(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/blobs/${sha}`);
|
||||
}
|
||||
|
||||
showBlobRaw(projectId: ProjectId, sha) {
|
||||
showBlobRaw(projectId: ProjectId, sha: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/blobs/${sha}/raw`);
|
||||
}
|
||||
|
||||
tree(projectId: 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: 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: 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: 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: 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: 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,5 +1,7 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type RunnerId = string | number;
|
||||
interface RunnersOptions {
|
||||
projectId?: ProjectId;
|
||||
}
|
||||
@ -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: 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: 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?: ProjectId;
|
||||
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: 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: ProjectId, serviceName) {
|
||||
remove(projectId: ProjectId, serviceName: ServiceName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/services/${serviceName}`);
|
||||
}
|
||||
|
||||
show(projectId: ProjectId, serviceName) {
|
||||
show(projectId: ProjectId, serviceName: ServiceName) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/services/${serviceName}`);
|
||||
|
||||
@ -1,21 +1,23 @@
|
||||
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: ProjectId, hookId) {
|
||||
remove(projectId: ProjectId, hookId: HookId) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.delete(this, `hooks/${hId}`);
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
class Tags extends BaseService {
|
||||
all(projectId: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
create(projectId: ProjectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/tags`, options);
|
||||
|
||||
@ -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: 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,7 +1,10 @@
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
type TriggerId = string | number;
|
||||
|
||||
class Triggers extends BaseService {
|
||||
add(projectId: ProjectId, options) {
|
||||
add(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/triggers`, options);
|
||||
@ -13,19 +16,19 @@ class Triggers extends BaseService {
|
||||
return RequestHelper.get(this, `projects/${pId}/triggers`);
|
||||
}
|
||||
|
||||
edit(projectId: 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: ProjectId, triggerId) {
|
||||
remove(projectId: ProjectId, triggerId: TriggerId) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/triggers/${tId}`);
|
||||
}
|
||||
|
||||
show(projectId: 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,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);
|
||||
}
|
||||
|
||||
@ -36,40 +37,40 @@ class Users extends BaseService {
|
||||
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: ProjectId, options) {
|
||||
all(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/wikis`, options);
|
||||
}
|
||||
|
||||
create(projectId: ProjectId, options) {
|
||||
create(projectId: ProjectId, options: RequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/wikis`, options);
|
||||
}
|
||||
|
||||
edit(projectId: 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: ProjectId, slug) {
|
||||
show(projectId: ProjectId, slug: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/wikis/${slug}`);
|
||||
}
|
||||
|
||||
remove(projectId: ProjectId, slug) {
|
||||
remove(projectId: ProjectId, slug: string) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.delete(this, `projects/${pId}/wikis/${slug}`);
|
||||
|
||||
@ -26,21 +26,21 @@ class ResourceAccessRequests extends BaseService {
|
||||
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: 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`, {
|
||||
accessLevel,
|
||||
access_level: accessLevel,
|
||||
});
|
||||
}
|
||||
|
||||
deny(resourceId: ResourceId, userId) {
|
||||
deny(resourceId: ResourceId, userId: UserId) {
|
||||
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/access_requests/${uId}`);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import URLJoin from 'url-join';
|
||||
import { BaseService, RequestHelper } from '../infrastructure';
|
||||
import { BaseModelContructorOptions } from '../infrastructure/BaseService';
|
||||
import { RequestOptions } from '../infrastructure/RequestHelper';
|
||||
|
||||
function url(
|
||||
projectId: ProjectId,
|
||||
@ -30,21 +31,21 @@ class ResourceAwardsEmojis extends BaseService {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
all(projectId: ProjectId, resourceId: ResourceId, options, noteId: NoteId) {
|
||||
all(projectId: ProjectId, resourceId: ResourceId, options: RequestOptions, noteId: NoteId) {
|
||||
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, noteId), options);
|
||||
}
|
||||
|
||||
award(projectId: ProjectId, resourceId: ResourceId, name, noteId: NoteId) {
|
||||
award(projectId: ProjectId, resourceId: ResourceId, name: string, noteId: NoteId) {
|
||||
return RequestHelper.post(this, url(projectId, this.resourceType, resourceId, noteId), {
|
||||
name,
|
||||
});
|
||||
}
|
||||
|
||||
remove(projectId: ProjectId, resourceId: ResourceId, awardId, noteId: NoteId) {
|
||||
remove(projectId: ProjectId, resourceId: ResourceId, awardId: string | number, noteId: NoteId) {
|
||||
return RequestHelper.delete(this, url(projectId, this.resourceType, resourceId, noteId));
|
||||
}
|
||||
|
||||
show(projectId: ProjectId, resourceId: ResourceId, awardId, noteId: NoteId) {
|
||||
show(projectId: ProjectId, resourceId: ResourceId, awardId: string | number, noteId: NoteId) {
|
||||
return RequestHelper.get(this, url(projectId, this.resourceType, resourceId, noteId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
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: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
@ -9,37 +11,37 @@ class ResourceBadges extends BaseService {
|
||||
this.url = URLJoin(this.url, resourceType);
|
||||
}
|
||||
|
||||
add(resourceId: ResourceId, options) {
|
||||
add(resourceId: ResourceId, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.post(this, `${rId}/badges`, options);
|
||||
}
|
||||
|
||||
all(resourceId: ResourceId, options) {
|
||||
all(resourceId: ResourceId, options: RequestOptions) {
|
||||
const rId = encodeURIComponent(resourceId);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/badges`, options);
|
||||
}
|
||||
|
||||
edit(resourceId: 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: 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: ResourceId, badgeId) {
|
||||
remove(resourceId: ResourceId, badgeId: BadgeId) {
|
||||
const [rId, bId] = [resourceId, badgeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/badges/${bId}`);
|
||||
}
|
||||
|
||||
show(resourceId: ResourceId, badgeId) {
|
||||
show(resourceId: ResourceId, badgeId: BadgeId) {
|
||||
const [rId, bId] = [resourceId, badgeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/badges/${bId}`);
|
||||
|
||||
@ -2,6 +2,7 @@ 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: string, baseParams: BaseModelContructorOptions) {
|
||||
super(baseParams);
|
||||
@ -15,7 +16,7 @@ class ResourceCustomAttributes extends BaseService {
|
||||
return RequestHelper.get(this, `${rId}/custom_attributes`);
|
||||
}
|
||||
|
||||
set(resourceId: 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}`, {
|
||||
@ -23,13 +24,13 @@ class ResourceCustomAttributes extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
remove(resourceId: ResourceId, customAttributeId) {
|
||||
remove(resourceId: ResourceId, customAttributeId: CustomAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.delete(this, `${rId}/custom_attributes/${cId}`);
|
||||
}
|
||||
|
||||
show(resourceId: ResourceId, customAttributeId) {
|
||||
show(resourceId: ResourceId, customAttributeId: CustomAttributeId) {
|
||||
const [rId, cId] = [resourceId, customAttributeId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `${rId}/custom_attributes/${cId}`);
|
||||
|
||||
6
src/types.d.ts
vendored
6
src/types.d.ts
vendored
@ -11,6 +11,12 @@ type Resource2Id = string; // see if we can narrow the type to string liter
|
||||
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).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user