mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-02-01 16:47:23 +00:00
Update service typing and peripheral endpoints (#1768)
* Dependency and Configuration updates * CHANGELOG and README updates * Added support for camel case and snake case response types in the request helper and base service * Added support for the Dockerfile Templates API * Added support for the Issue Note Award Emojis API * Removed redundant Group Projects service * Updated types for a variety of services * Added type updates and removed protect and unprotect endpoints from the Branches API * Added type updates and signature endpoint to the Commits API * Added type updates and edit support to the Deployments API * Added type updates and a showRepository function to the Container Registry API * Added type updates and updated the service support to include create, edit, show and remove for the Feature Flags API * Added type updates and support for the removal of geonodes with the Geo Nodes API * Renamed UserKeys to UserSSHKeys and added type updates for the User SSH Keys API * Added type updates for the License Templates API and renamed the export to fix the spelling error * Added type updates and support for the transfer projects endpoint for the Groups API * Added type updates and removed removed events endpoint on the Projects API * Added type updates and modified the create function to require a resource name in the Todos API
This commit is contained in:
parent
0c9dabac9a
commit
502d8180a7
@ -34,6 +34,7 @@ rules:
|
||||
import/no-default-export: error
|
||||
import/prefer-default-export: off
|
||||
'@typescript-eslint/explicit-function-return-type': off
|
||||
'@typescript-eslint/explicit-module-boundary-types': off
|
||||
import/no-extraneous-dependencies:
|
||||
- error
|
||||
- devDependencies:
|
||||
@ -52,6 +53,16 @@ overrides:
|
||||
- '**/*.tsx'
|
||||
rules:
|
||||
camelcase: 'off'
|
||||
- files:
|
||||
- '**/test/**/*.ts'
|
||||
rules:
|
||||
'@typescript-eslint/no-var-requires': 'off'
|
||||
global-require: 'off'
|
||||
jest/no-mocks-import: 'off'
|
||||
- files:
|
||||
- '**/__mocks__/**/*.ts'
|
||||
rules:
|
||||
import/no-default-export: 'off'
|
||||
|
||||
settings:
|
||||
import/resolver:
|
||||
|
||||
@ -202,7 +202,7 @@ GitignoreTemplates
|
||||
GitLabCIYMLTemplates
|
||||
Keys
|
||||
License
|
||||
LicenceTemplates
|
||||
LicenseTemplates
|
||||
Lint
|
||||
Markdown
|
||||
Namespaces
|
||||
@ -223,7 +223,6 @@ GroupCustomAttributes
|
||||
GroupIssueBoards
|
||||
GroupMembers
|
||||
GroupMilestones
|
||||
GroupProjects
|
||||
GroupRunners
|
||||
GroupVariables
|
||||
GroupLabels
|
||||
|
||||
@ -28,7 +28,8 @@
|
||||
"lint-staged": "^11.0.0",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-jest": "^26.5.3",
|
||||
"typescript": "^4.2.3"
|
||||
"typescript": "^4.2.3",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
|
||||
@ -14,7 +14,6 @@ export const {
|
||||
GroupIssueBoards,
|
||||
GroupMembers,
|
||||
GroupMilestones,
|
||||
GroupProjects,
|
||||
GroupRunners,
|
||||
GroupVariables,
|
||||
GroupLabels,
|
||||
@ -28,7 +27,7 @@ export const {
|
||||
UserCustomAttributes,
|
||||
UserEmails,
|
||||
UserImpersonationTokens,
|
||||
UserKeys,
|
||||
UserSSHKeys,
|
||||
UserGPGKeys,
|
||||
|
||||
// Projects
|
||||
@ -43,6 +42,7 @@ export const {
|
||||
Issues,
|
||||
IssuesStatistics,
|
||||
IssueNotes,
|
||||
IssueNoteAwardEmojis,
|
||||
IssueDiscussions,
|
||||
IssueAwardEmojis,
|
||||
Jobs,
|
||||
@ -94,7 +94,7 @@ export const {
|
||||
GitLabCIYMLTemplates,
|
||||
Keys,
|
||||
License,
|
||||
LicenceTemplates,
|
||||
LicenseTemplates,
|
||||
Lint,
|
||||
Namespaces,
|
||||
NotificationSettings,
|
||||
|
||||
@ -24,7 +24,6 @@ export const GroupsBundle = bundler({
|
||||
GroupIssueBoards: APIServices.GroupIssueBoards,
|
||||
GroupMembers: APIServices.GroupMembers,
|
||||
GroupMilestones: APIServices.GroupMilestones,
|
||||
GroupProjects: APIServices.GroupProjects,
|
||||
GroupRunners: APIServices.GroupRunners,
|
||||
GroupVariables: APIServices.GroupVariables,
|
||||
GroupLabels: APIServices.GroupLabels,
|
||||
@ -41,7 +40,7 @@ export const UsersBundle = bundler({
|
||||
UserCustomAttributes: APIServices.UserCustomAttributes,
|
||||
UserEmails: APIServices.UserEmails,
|
||||
UserImpersonationTokens: APIServices.UserImpersonationTokens,
|
||||
UserKeys: APIServices.UserKeys,
|
||||
UserSSHKeys: APIServices.UserSSHKeys,
|
||||
UserGPGKeys: APIServices.UserGPGKeys,
|
||||
});
|
||||
|
||||
@ -59,6 +58,7 @@ export const ProjectsBundle = bundler({
|
||||
IssuesStatistics: APIServices.IssuesStatistics,
|
||||
IssueAwardEmojis: APIServices.IssueAwardEmojis,
|
||||
IssueNotes: APIServices.IssueNotes,
|
||||
IssueNoteAwardEmojis: APIServices.IssueNoteAwardEmojis,
|
||||
IssueDiscussions: APIServices.IssueDiscussions,
|
||||
Jobs: APIServices.Jobs,
|
||||
Labels: APIServices.Labels,
|
||||
|
||||
@ -1,44 +1,40 @@
|
||||
import { parse as parseLink } from 'li';
|
||||
import { camelizeKeys } from 'xcase';
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { appendFormFromObject } from './Utils';
|
||||
import { appendFormFromObject, Camelize } from './Utils';
|
||||
|
||||
export type True = true;
|
||||
export type False = false;
|
||||
|
||||
export interface PaginationInformation {
|
||||
total: number;
|
||||
next: number | null;
|
||||
current: number;
|
||||
previous: number | null;
|
||||
perPage: number;
|
||||
totalPages: number;
|
||||
}
|
||||
|
||||
// Options
|
||||
export interface Sudo {
|
||||
sudo?: string | number;
|
||||
}
|
||||
export interface IsForm {
|
||||
// Request Options
|
||||
export type IsForm = {
|
||||
isForm?: boolean;
|
||||
}
|
||||
export interface ShowExpanded {
|
||||
showExpanded?: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any:0 */
|
||||
export type BaseRequestOptions = Sudo & Record<string, any>;
|
||||
export type Sudo = {
|
||||
sudo?: string | number;
|
||||
};
|
||||
|
||||
export interface PaginatedRequestOptions extends BaseRequestOptions {
|
||||
pagination?: 'keyset' | 'offset';
|
||||
export type ShowExpanded<T extends boolean = boolean> = {
|
||||
showExpanded?: T;
|
||||
};
|
||||
|
||||
export type BaseRequestOptions = Sudo & Record<string, unknown>;
|
||||
|
||||
export type BasePaginationRequestOptions<
|
||||
P extends 'keyset' | 'offset' = 'keyset' | 'offset'
|
||||
> = BaseRequestOptions & {
|
||||
pagination?: P;
|
||||
perPage?: number;
|
||||
}
|
||||
};
|
||||
|
||||
export interface OffsetPaginatedRequestOptions extends PaginatedRequestOptions {
|
||||
pagination: 'offset';
|
||||
export type OffsetPaginationRequestOptions = {
|
||||
page?: number;
|
||||
maxPages?: number;
|
||||
}
|
||||
};
|
||||
|
||||
export type PaginatedRequestOptions<
|
||||
P extends 'keyset' | 'offset' = 'keyset' | 'offset'
|
||||
> = P extends 'keyset'
|
||||
? BasePaginationRequestOptions<P>
|
||||
: BasePaginationRequestOptions<P> & OffsetPaginationRequestOptions;
|
||||
|
||||
// Response Formats
|
||||
export interface ExpandedResponse<T = Record<string, unknown>> {
|
||||
@ -48,19 +44,59 @@ export interface ExpandedResponse<T = Record<string, unknown>> {
|
||||
}
|
||||
export interface PaginationResponse<T = Record<string, unknown>[]> {
|
||||
data: T;
|
||||
paginationInfo: PaginationInformation;
|
||||
paginationInfo: {
|
||||
total: number;
|
||||
next: number | null;
|
||||
current: number;
|
||||
previous: number | null;
|
||||
perPage: number;
|
||||
totalPages: number;
|
||||
};
|
||||
}
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any:0 */
|
||||
async function getHelper<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
export type CamelizedRecord<C, T> = C extends true ? Camelize<T> : T;
|
||||
|
||||
export type ExtendedRecordReturn<
|
||||
C extends boolean,
|
||||
E extends boolean,
|
||||
T extends Record<string, unknown> | void
|
||||
> = T extends void
|
||||
? void
|
||||
: E extends false
|
||||
? CamelizedRecord<C, T>
|
||||
: ExpandedResponse<CamelizedRecord<C, T>>;
|
||||
|
||||
type ExtendedArrayReturn<
|
||||
C extends boolean,
|
||||
E extends boolean,
|
||||
T,
|
||||
P extends 'keyset' | 'offset'
|
||||
> = E extends false
|
||||
? CamelizedRecord<C, T>[]
|
||||
: P extends 'keyset'
|
||||
? CamelizedRecord<C, T>[]
|
||||
: PaginationResponse<CamelizedRecord<C, T>[]>;
|
||||
|
||||
type ExtendedReturn<
|
||||
C extends boolean,
|
||||
E extends boolean,
|
||||
P extends 'keyset' | 'offset',
|
||||
T extends Record<string, unknown> | Record<string, unknown>[]
|
||||
> = T extends Record<string, unknown>
|
||||
? ExtendedRecordReturn<C, E, T>
|
||||
: T extends (infer R)[]
|
||||
? ExtendedArrayReturn<C, E, R, P>
|
||||
: never;
|
||||
|
||||
async function getHelper<P extends 'keyset' | 'offset', E extends boolean>(
|
||||
service: BaseService<boolean>,
|
||||
endpoint: string,
|
||||
{
|
||||
sudo,
|
||||
showExpanded,
|
||||
maxPages,
|
||||
...query
|
||||
}: PaginatedRequestOptions | OffsetPaginatedRequestOptions = {},
|
||||
}: BasePaginationRequestOptions<P> & ShowExpanded<E> & { maxPages?: number } = {},
|
||||
acc: any[] = [],
|
||||
): Promise<any> {
|
||||
const response = await service.requester.get(endpoint, { query, sudo });
|
||||
@ -72,18 +108,18 @@ async function getHelper<T = Record<string, unknown>>(
|
||||
|
||||
// Handle object responses
|
||||
if (!Array.isArray(body)) {
|
||||
if (!showExpanded) return body as T;
|
||||
if (!showExpanded) return body;
|
||||
|
||||
return {
|
||||
data: body,
|
||||
headers,
|
||||
status,
|
||||
} as ExpandedResponse<T>;
|
||||
};
|
||||
}
|
||||
|
||||
// Handle array responses
|
||||
const newAcc = [...acc, ...body] as T[];
|
||||
const { next } = parseLink(headers.link);
|
||||
const newAcc = [...acc, ...body];
|
||||
const { next }: { next: string } = parseLink(headers.link);
|
||||
const withinBounds = maxPages ? newAcc.length / (query.perPage || 20) < maxPages : true;
|
||||
|
||||
// Recurse through pagination results
|
||||
@ -102,7 +138,7 @@ async function getHelper<T = Record<string, unknown>>(
|
||||
);
|
||||
}
|
||||
|
||||
if (!showExpanded || query.pagination === 'keyset') return newAcc as T[];
|
||||
if (!showExpanded || query.pagination === 'keyset') return newAcc;
|
||||
|
||||
return {
|
||||
data: newAcc,
|
||||
@ -114,118 +150,94 @@ async function getHelper<T = Record<string, unknown>>(
|
||||
perPage: parseInt(headers['x-per-page'], 10),
|
||||
totalPages: parseInt(headers['x-total-pages'], 10),
|
||||
},
|
||||
} as PaginationResponse<T[]>;
|
||||
};
|
||||
}
|
||||
|
||||
export async function get<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<T | T[]>;
|
||||
export async function get<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<ExpandedResponse<T> | PaginationResponse<T>>;
|
||||
export async function get<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options?: OffsetPaginatedRequestOptions & { showExpanded: true },
|
||||
): Promise<ExpandedResponse<T> | PaginationResponse<T>>;
|
||||
/* eslint @typescript-eslint/no-explicit-any:0 */
|
||||
export async function get<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options: PaginatedRequestOptions | OffsetPaginatedRequestOptions = {},
|
||||
): Promise<any> {
|
||||
return getHelper<T>(service, endpoint, options);
|
||||
export function get<
|
||||
T extends Record<string, unknown> | Record<string, unknown>[] = Record<string, unknown>
|
||||
>() {
|
||||
return async function <
|
||||
C extends boolean,
|
||||
P extends 'keyset' | 'offset' = 'offset',
|
||||
E extends boolean = false
|
||||
>(
|
||||
service: BaseService<C>,
|
||||
endpoint: string,
|
||||
options?: PaginatedRequestOptions<P> & ShowExpanded<E> & Record<string, any>,
|
||||
): Promise<ExtendedReturn<C, E, P, T>> {
|
||||
return getHelper(service, endpoint, options);
|
||||
};
|
||||
}
|
||||
|
||||
async function post<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options?: IsForm & BaseRequestOptions,
|
||||
): Promise<T>;
|
||||
async function post<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options?: IsForm & BaseRequestOptions & { showExpanded: true },
|
||||
): Promise<ExpandedResponse<T>>;
|
||||
export function post<T extends Record<string, unknown> | void = Record<string, unknown>>() {
|
||||
return async function <C extends boolean, E extends boolean = false>(
|
||||
service: BaseService<C>,
|
||||
endpoint: string,
|
||||
{ isForm, sudo, showExpanded, ...options }: IsForm & BaseRequestOptions & ShowExpanded<E> = {},
|
||||
): Promise<ExtendedRecordReturn<C, E, T>> {
|
||||
const body = isForm ? appendFormFromObject(options) : options;
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any:0 */
|
||||
async function post(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
{ isForm, sudo, showExpanded, ...options }: IsForm & ShowExpanded & BaseRequestOptions = {},
|
||||
): Promise<any> {
|
||||
const body = isForm ? appendFormFromObject(options) : options;
|
||||
const r = await service.requester.post(endpoint, {
|
||||
body,
|
||||
sudo,
|
||||
});
|
||||
|
||||
const r = await service.requester.post(endpoint, {
|
||||
body,
|
||||
sudo,
|
||||
});
|
||||
|
||||
return showExpanded
|
||||
? {
|
||||
data: r.body,
|
||||
status: r.status,
|
||||
headers: r.headers,
|
||||
}
|
||||
: r.body;
|
||||
return showExpanded
|
||||
? {
|
||||
data: r.body,
|
||||
status: r.status,
|
||||
headers: r.headers,
|
||||
}
|
||||
: r.body;
|
||||
};
|
||||
}
|
||||
|
||||
async function put<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<T>;
|
||||
async function put<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
{ showExpanded }: BaseRequestOptions & { showExpanded: true },
|
||||
): Promise<ExpandedResponse<T>>;
|
||||
export function put<T extends Record<string, unknown> = Record<string, unknown>>() {
|
||||
return async function <C extends boolean, E extends boolean = false>(
|
||||
service: BaseService<C>,
|
||||
endpoint: string,
|
||||
{ isForm, sudo, showExpanded, ...options }: IsForm & BaseRequestOptions & ShowExpanded<E> = {},
|
||||
): Promise<ExtendedRecordReturn<C, E, T>> {
|
||||
const body = isForm ? appendFormFromObject(options) : options;
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any:0 */
|
||||
async function put(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
{ sudo, showExpanded, ...body }: ShowExpanded & BaseRequestOptions = {},
|
||||
): Promise<any> {
|
||||
const r = await service.requester.put(endpoint, {
|
||||
body,
|
||||
sudo,
|
||||
});
|
||||
const r = await service.requester.put(endpoint, {
|
||||
body,
|
||||
sudo,
|
||||
});
|
||||
|
||||
return showExpanded ? { data: r.body, status: r.status, headers: r.headers } : r.body;
|
||||
return showExpanded
|
||||
? {
|
||||
data: r.body,
|
||||
status: r.status,
|
||||
headers: r.headers,
|
||||
}
|
||||
: r.body;
|
||||
};
|
||||
}
|
||||
|
||||
async function del<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<T>;
|
||||
async function del<T = Record<string, unknown>>(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
{ showExpanded }: BaseRequestOptions & { showExpanded: true },
|
||||
): Promise<ExpandedResponse<T>>;
|
||||
export function del<T extends Record<string, unknown> | void = void>() {
|
||||
return async function <C extends boolean, E extends boolean = false>(
|
||||
service: BaseService<C>,
|
||||
endpoint: string,
|
||||
{ sudo, showExpanded, ...query }: BaseRequestOptions & ShowExpanded<E> = {},
|
||||
): Promise<ExtendedRecordReturn<C, E, T>> {
|
||||
const r = await service.requester.delete(endpoint, {
|
||||
query,
|
||||
sudo,
|
||||
});
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any:0 */
|
||||
async function del(
|
||||
service: BaseService,
|
||||
endpoint: string,
|
||||
{ sudo, showExpanded, ...query }: ShowExpanded & BaseRequestOptions = {},
|
||||
): Promise<any> {
|
||||
const r = await service.requester.delete(endpoint, {
|
||||
query,
|
||||
sudo,
|
||||
});
|
||||
|
||||
return showExpanded ? { data: r.body, status: r.status, headers: r.headers } : r.body;
|
||||
return showExpanded
|
||||
? {
|
||||
data: r.body,
|
||||
status: r.status,
|
||||
headers: r.headers,
|
||||
}
|
||||
: r.body;
|
||||
};
|
||||
}
|
||||
|
||||
function stream(
|
||||
service: BaseService,
|
||||
function stream<C extends boolean>(
|
||||
service: BaseService<C>,
|
||||
endpoint: string,
|
||||
options?: BaseRequestOptions,
|
||||
): NodeJS.ReadableStream {
|
||||
|
||||
@ -1,5 +1,15 @@
|
||||
import FormData from 'form-data';
|
||||
|
||||
export type CamelizeString<T extends PropertyKey> = T extends string
|
||||
? string extends T
|
||||
? string
|
||||
: T extends `${infer F}_${infer R}`
|
||||
? `${F}${Capitalize<CamelizeString<R>>}`
|
||||
: T
|
||||
: T;
|
||||
|
||||
export type Camelize<T> = { [K in keyof T as CamelizeString<K>]: T[K] };
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
||||
interface Constructor {
|
||||
new (...args: any): any;
|
||||
|
||||
@ -1,12 +1,76 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, Sudo, BaseRequestOptions } from '../infrastructure';
|
||||
|
||||
export class ApplicationSettings extends BaseService {
|
||||
export interface SettingsSchema extends Record<string, unknown> {
|
||||
default_projects_limit: number;
|
||||
signup_enabled: boolean;
|
||||
id: number;
|
||||
default_branch_protection: number;
|
||||
restricted_visibility_levels?: string[];
|
||||
password_authentication_enabled_for_web: boolean;
|
||||
after_sign_out_path?: string;
|
||||
max_attachment_size: number;
|
||||
max_import_size: number;
|
||||
user_oauth_applications: boolean;
|
||||
updated_at: string;
|
||||
session_expire_delay: number;
|
||||
home_page_url?: string;
|
||||
default_snippet_visibility: string;
|
||||
outbound_local_requests_whitelist?: string[];
|
||||
domain_allowlist?: string[];
|
||||
domain_denylist_enabled: boolean;
|
||||
domain_denylist?: string[];
|
||||
created_at: string;
|
||||
default_ci_config_path?: string;
|
||||
default_project_visibility: string;
|
||||
default_group_visibility: string;
|
||||
gravatar_enabled: boolean;
|
||||
sign_in_text?: string;
|
||||
container_expiration_policies_enable_historic_entries: boolean;
|
||||
container_registry_token_expire_delay: number;
|
||||
repository_storages_weighted: {
|
||||
[name: string]: number;
|
||||
};
|
||||
plantuml_enabled: boolean;
|
||||
plantuml_url?: string;
|
||||
kroki_enabled: boolean;
|
||||
kroki_url?: string;
|
||||
terminal_max_session_time: number;
|
||||
polling_interval_multiplier: number;
|
||||
rsa_key_restriction: number;
|
||||
dsa_key_restriction: number;
|
||||
ecdsa_key_restriction: number;
|
||||
ed25519_key_restriction: number;
|
||||
first_day_of_week: number;
|
||||
enforce_terms: boolean;
|
||||
terms: string;
|
||||
performance_bar_allowed_group_id: number;
|
||||
user_show_add_ssh_key_message: boolean;
|
||||
local_markdown_version: number;
|
||||
allow_local_requests_from_hooks_and_services: boolean;
|
||||
allow_local_requests_from_web_hooks_and_services: boolean;
|
||||
allow_local_requests_from_system_hooks: boolean;
|
||||
asset_proxy_enabled: boolean;
|
||||
asset_proxy_url: string;
|
||||
asset_proxy_whitelist?: string[];
|
||||
asset_proxy_allowlist?: string[];
|
||||
npm_package_requests_forwarding: boolean;
|
||||
snippet_size_limit: number;
|
||||
issues_create_limit: number;
|
||||
raw_blob_request_limit: number;
|
||||
wiki_page_max_content_bytes: number;
|
||||
require_admin_approval_after_user_signup: boolean;
|
||||
personal_access_token_prefix: string;
|
||||
rate_limiting_response_text?: string;
|
||||
keep_latest_artifact: boolean;
|
||||
}
|
||||
|
||||
export class ApplicationSettings<C extends boolean = false> extends BaseService<C> {
|
||||
all(options?: Sudo) {
|
||||
return RequestHelper.get(this, 'application/settings', options);
|
||||
return RequestHelper.get<SettingsSchema>()(this, 'application/settings', options);
|
||||
}
|
||||
|
||||
edit(options?: BaseRequestOptions) {
|
||||
return RequestHelper.put(this, 'application/settings', options);
|
||||
return RequestHelper.put<SettingsSchema>()(this, 'application/settings', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,56 +1,53 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
import { CommitSchema } from './Commits';
|
||||
import { PaginatedRequestOptions, RequestHelper, Sudo } from '../infrastructure';
|
||||
|
||||
export class Branches extends BaseService {
|
||||
all(projectId: string | number, options?: { search?: string } & PaginatedRequestOptions) {
|
||||
export interface BranchSchema extends Record<string, unknown> {
|
||||
name: string;
|
||||
merged: boolean;
|
||||
protected: boolean;
|
||||
default: boolean;
|
||||
developers_can_push: boolean;
|
||||
developers_can_merge: boolean;
|
||||
can_push: boolean;
|
||||
web_url: string;
|
||||
commit: Omit<CommitSchema, 'web_url' | 'created_at'>;
|
||||
}
|
||||
|
||||
export class Branches<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/branches`, options);
|
||||
return RequestHelper.get<BranchSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/repository/branches`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
create(projectId: string | number, branchName: string, ref: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
const branchKey = this.url.includes('v3') ? 'branchName' : 'branch';
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/branches`, {
|
||||
return RequestHelper.post<BranchSchema>()(this, `projects/${pId}/repository/branches`, {
|
||||
[branchKey]: branchName,
|
||||
ref,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
protect(projectId: string | number, branchName: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/protected_branches`, {
|
||||
name: branchName,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
remove(projectId: string | number, branchName: string, options?: Sudo) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/repository/branches/${bName}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/repository/branches/${bName}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, branchName: string, options?: Sudo) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/branches/${bName}`, options);
|
||||
}
|
||||
|
||||
unprotect(projectId: string | number, branchName: string, options?: Sudo) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
return RequestHelper.get<BranchSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/branches/${bName}/unprotect`,
|
||||
`projects/${pId}/repository/branches/${bName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
@ -4,32 +4,46 @@ import {
|
||||
PaginatedRequestOptions,
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
Camelize,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class BroadcastMessages extends BaseService {
|
||||
export interface BroadcastMessageSchema extends Record<string, unknown> {
|
||||
message: string;
|
||||
starts_at: string;
|
||||
ends_at: string;
|
||||
color: string;
|
||||
font: string;
|
||||
id: number;
|
||||
active: boolean;
|
||||
target_path: string;
|
||||
broadcast_type: string;
|
||||
dismissable: boolean;
|
||||
}
|
||||
|
||||
export class BroadcastMessages<C extends boolean = false> extends BaseService<C> {
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'broadcast_messages', options);
|
||||
return RequestHelper.get<BroadcastMessageSchema[]>()(this, 'broadcast_messages', options);
|
||||
}
|
||||
|
||||
create(options?: BaseRequestOptions) {
|
||||
return RequestHelper.post(this, 'broadcast_messages', options);
|
||||
create(options?: Camelize<Omit<BroadcastMessageSchema, 'id'>> & Sudo) {
|
||||
return RequestHelper.post<BroadcastMessageSchema>()(this, 'broadcast_messages', options);
|
||||
}
|
||||
|
||||
edit(broadcastMessageId: number, options?: BaseRequestOptions) {
|
||||
edit(broadcastMessageId: number, options?: Camelize<Omit<BroadcastMessageSchema, 'id'>> & Sudo) {
|
||||
const bId = encodeURIComponent(broadcastMessageId);
|
||||
|
||||
return RequestHelper.put(this, `broadcast_messages/${bId}`, options);
|
||||
return RequestHelper.put<BroadcastMessageSchema>()(this, `broadcast_messages/${bId}`, options);
|
||||
}
|
||||
|
||||
remove(broadcastMessageId: number, options?: Sudo) {
|
||||
const bId = encodeURIComponent(broadcastMessageId);
|
||||
|
||||
return RequestHelper.del(this, `broadcast_messages/${bId}`, options);
|
||||
return RequestHelper.del()(this, `broadcast_messages/${bId}`, options);
|
||||
}
|
||||
|
||||
show(broadcastMessageId: number, options?: BaseRequestOptions) {
|
||||
const bId = encodeURIComponent(broadcastMessageId);
|
||||
|
||||
return RequestHelper.get(this, `broadcast_messages/${bId}`, options);
|
||||
return RequestHelper.get<BroadcastMessageSchema>()(this, `broadcast_messages/${bId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,53 +1,63 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceDiscussions, DiscussionSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface CommitDiscussions extends ResourceDiscussions {
|
||||
export interface CommitDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
addNote(
|
||||
projectId: string | number,
|
||||
commitId: string | number,
|
||||
discussionId: string | number,
|
||||
commitId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
all(projectId: string | number, commitId: string | number, options?: PaginatedRequestOptions);
|
||||
all(
|
||||
projectId: string | number,
|
||||
commitId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
commitId: string | number,
|
||||
commitId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
editNote(
|
||||
projectId: string | number,
|
||||
commitId: string | number,
|
||||
discussionId: string | number,
|
||||
commitId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
removeNote(
|
||||
projectId: string | number,
|
||||
commitId: string | number,
|
||||
discussionId: string | number,
|
||||
commitId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
commitId: string | number,
|
||||
discussionId: string | number,
|
||||
commitId: number,
|
||||
discussionId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
}
|
||||
|
||||
export class CommitDiscussions extends ResourceDiscussions {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export class CommitDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', 'repository/commits', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { MergeRequestSchema } from './MergeRequests';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,39 +8,6 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
// As of GitLab v12.6.2
|
||||
export interface CommitSchemaDefault {
|
||||
id: string;
|
||||
short_id: string;
|
||||
created_at: Date;
|
||||
parent_ids?: string[];
|
||||
title: string;
|
||||
message: string;
|
||||
author_name: string;
|
||||
author_email: string;
|
||||
authored_date?: Date;
|
||||
committer_name?: string;
|
||||
committer_email?: string;
|
||||
committed_date?: Date;
|
||||
}
|
||||
|
||||
export interface CommitSchemaCamelized {
|
||||
id: string;
|
||||
shortId: string;
|
||||
createdAt: Date;
|
||||
parentIds?: string[];
|
||||
title: string;
|
||||
message: string;
|
||||
authorName: string;
|
||||
authorEmail: string;
|
||||
authoredDate?: Date;
|
||||
committerName?: string;
|
||||
committerEmail?: string;
|
||||
committedDate?: Date;
|
||||
}
|
||||
|
||||
export type CommitSchema = CommitSchemaDefault | CommitSchemaCamelized;
|
||||
|
||||
export interface CommitAction {
|
||||
/** The action to perform */
|
||||
action: 'create' | 'delete' | 'move' | 'update';
|
||||
@ -54,18 +23,50 @@ export interface CommitAction {
|
||||
lastCommitId?: string;
|
||||
}
|
||||
|
||||
export interface GPGSignature {
|
||||
// Response structures
|
||||
export interface CommitSchema extends Record<string, unknown> {
|
||||
id: string;
|
||||
short_id: string;
|
||||
created_at: Date;
|
||||
parent_ids?: string[];
|
||||
title: string;
|
||||
message: string;
|
||||
author_name: string;
|
||||
author_email: string;
|
||||
authored_date?: Date;
|
||||
committer_name?: string;
|
||||
committer_email?: string;
|
||||
committed_date?: Date;
|
||||
web_url: string;
|
||||
}
|
||||
|
||||
export interface CommitExtendedSchema extends CommitSchema {
|
||||
last_pipeline: {
|
||||
id: number;
|
||||
ref: string;
|
||||
sha: string;
|
||||
status: string;
|
||||
};
|
||||
stats: {
|
||||
additions: number;
|
||||
deletions: number;
|
||||
total: number;
|
||||
};
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface GPGSignatureSchema extends Record<string, unknown> {
|
||||
signature_type: 'PGP';
|
||||
verification_status: 'verified' | 'unverified';
|
||||
gpg_key_id: number;
|
||||
gpg_key_primary_keyid: string;
|
||||
gpg_key_user_name: string;
|
||||
gpg_key_user_email: string;
|
||||
gpg_key_subkey_id: number | null;
|
||||
gpg_key_subkey_id?: number;
|
||||
commit_source: string;
|
||||
}
|
||||
|
||||
export interface X509Signature {
|
||||
export interface X509SignatureSchema extends Record<string, unknown> {
|
||||
signature_type: 'X509';
|
||||
verification_status: 'verified' | 'unverified';
|
||||
x509_certificate: {
|
||||
@ -85,32 +86,82 @@ export interface X509Signature {
|
||||
commit_source: string;
|
||||
}
|
||||
|
||||
export interface MissingSignature {
|
||||
export interface MissingSignatureSchema extends Record<string, unknown> {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type CommitSignature = GPGSignature | X509Signature | MissingSignature;
|
||||
export type CommitSignatureSchema =
|
||||
| GPGSignatureSchema
|
||||
| X509SignatureSchema
|
||||
| MissingSignatureSchema;
|
||||
|
||||
export class Commits extends BaseService {
|
||||
export interface CommentSchema extends Record<string, unknown> {
|
||||
note: string;
|
||||
line_type: 'new' | 'old';
|
||||
path: string;
|
||||
line: number;
|
||||
author: Omit<UserSchema, 'created_at'>;
|
||||
}
|
||||
|
||||
export interface CommitDiffSchema extends Record<string, unknown> {
|
||||
diff: string;
|
||||
new_path: string;
|
||||
old_path: string;
|
||||
a_mode?: string;
|
||||
b_mode: string;
|
||||
new_file: boolean;
|
||||
renamed_file: boolean;
|
||||
deleted_file: boolean;
|
||||
}
|
||||
|
||||
export interface CommitStatusSchema extends Record<string, unknown> {
|
||||
status: string;
|
||||
created_at: string;
|
||||
started_at?: string;
|
||||
name: string;
|
||||
allow_failure: boolean;
|
||||
author: Omit<UserSchema, 'created_at'>;
|
||||
description?: string;
|
||||
sha: string;
|
||||
target_url: string;
|
||||
finished_at?: string;
|
||||
id: number;
|
||||
ref: string;
|
||||
}
|
||||
|
||||
export interface CommitReferenceSchema extends Record<string, unknown> {
|
||||
type: 'branch' | 'tag' | 'all';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class Commits<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits`, options);
|
||||
return RequestHelper.get<CommitSchema[]>()(this, `projects/${pId}/repository/commits`, options);
|
||||
}
|
||||
|
||||
cherryPick(projectId: string | number, sha: string, branch: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/commits/${sha}/cherry_pick`, {
|
||||
branch,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<CommitSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/cherry_pick`,
|
||||
{
|
||||
branch,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
comments(projectId: string | number, sha: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/comments`, options);
|
||||
return RequestHelper.get<CommentSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/comments`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
create(
|
||||
@ -122,7 +173,7 @@ export class Commits extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/commits`, {
|
||||
return RequestHelper.post<CommitExtendedSchema>()(this, `projects/${pId}/repository/commits`, {
|
||||
branch,
|
||||
commitMessage: message,
|
||||
actions,
|
||||
@ -138,69 +189,93 @@ export class Commits extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/commits/${sha}/comments`, {
|
||||
note,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<CommentSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/comments`,
|
||||
{
|
||||
note,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
diff(projectId: string | number, sha: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/diff`, options);
|
||||
return RequestHelper.get<CommitDiffSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/diff`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
editStatus(projectId: string | number, sha: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/statuses/${sha}`, options);
|
||||
return RequestHelper.post<CommitStatusSchema>()(
|
||||
this,
|
||||
`projects/${pId}/statuses/${sha}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
references(projectId: string | number, sha: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/refs`, options);
|
||||
return RequestHelper.get<CommitReferenceSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/refs`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
revert(projectId: string | number, sha: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/commits/${sha}/revert`, options);
|
||||
return RequestHelper.post<CommitSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/revert`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId: string | number, sha: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}`, options);
|
||||
return RequestHelper.get<CommitExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
status(projectId: string | number, sha: string, options?: BaseRequestOptions) {
|
||||
statuses(projectId: string | number, sha: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/commits/${sha}/statuses`, options);
|
||||
return RequestHelper.get<CommitStatusSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/statuses`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
mergeRequests(projectId: string | number, sha: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
return RequestHelper.get<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/merge_requests`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
signature(
|
||||
projectId: string | number,
|
||||
sha: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CommitSignature> {
|
||||
signature(projectId: string | number, sha: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(
|
||||
return RequestHelper.get<CommitSignatureSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/commits/${sha}/signature`,
|
||||
options,
|
||||
) as Promise<CommitSignature>;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,80 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
|
||||
export class ContainerRegistry extends BaseService {
|
||||
repositories(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
export interface TagSchema extends Record<string, unknown> {
|
||||
name: string;
|
||||
path: string;
|
||||
location: string;
|
||||
revision: string;
|
||||
short_revision: string;
|
||||
digest: string;
|
||||
created_at: string;
|
||||
total_size: number;
|
||||
}
|
||||
|
||||
export interface RepositorySchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
project_id: number;
|
||||
location: string;
|
||||
created_at: string;
|
||||
cleanup_policy_started_at: string;
|
||||
tags_count?: number;
|
||||
tags?: Pick<TagSchema, 'name' | 'path' | 'location'>[];
|
||||
}
|
||||
|
||||
export class ContainerRegistry<C extends boolean = false> extends BaseService<C> {
|
||||
projectRepositories(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/registry/repositories`, options);
|
||||
return RequestHelper.get<Omit<RepositorySchema, 'tags' | 'tags_count'>[]>()(
|
||||
this,
|
||||
`projects/${pId}/registry/repositories`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
groupRepositories(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get<Omit<RepositorySchema, 'tags' | 'tags_count'>[]>()(
|
||||
this,
|
||||
`groups/${pId}/registry/repositories`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
showRepository(projectId: string | number, repositoryId: number, options?: Sudo) {
|
||||
const [pId, rId] = [projectId, repositoryId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get<RepositorySchema>()(
|
||||
this,
|
||||
`projects/${pId}/registry/repositories/${rId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
tags(projectId: string | number, repositoryId: number, options?: PaginatedRequestOptions) {
|
||||
const [pId, rId] = [projectId, repositoryId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/registry/repositories/${rId}/tags`, options);
|
||||
return RequestHelper.get<Pick<TagSchema, 'name' | 'path' | 'location'>[]>()(
|
||||
this,
|
||||
`projects/${pId}/registry/repositories/${rId}/tags`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
removeRepository(projectId: string | number, repositoryId: number, options?: Sudo) {
|
||||
const [pId, rId] = [projectId, repositoryId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/registry/repositories/${rId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/registry/repositories/${rId}`, options);
|
||||
}
|
||||
|
||||
removeTag(projectId: string | number, repositoryId: number, tagName: string, options?: Sudo) {
|
||||
const [pId, rId, tId] = [projectId, repositoryId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(
|
||||
return RequestHelper.del()(
|
||||
this,
|
||||
`projects/${pId}/registry/repositories/${rId}/tags/${tId}`,
|
||||
options,
|
||||
@ -38,7 +89,7 @@ export class ContainerRegistry extends BaseService {
|
||||
) {
|
||||
const [pId, rId] = [projectId, repositoryId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/registry/repositories/${rId}/tags`, {
|
||||
return RequestHelper.del()(this, `projects/${pId}/registry/repositories/${rId}/tags`, {
|
||||
nameRegexDelete,
|
||||
...options,
|
||||
});
|
||||
@ -47,7 +98,7 @@ export class ContainerRegistry extends BaseService {
|
||||
showTag(projectId: string | number, repositoryId: number, tagName: string, options?: Sudo) {
|
||||
const [pId, rId, tId] = [projectId, repositoryId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
return RequestHelper.get<TagSchema>()(
|
||||
this,
|
||||
`projects/${pId}/registry/repositories/${rId}/tags/${tId}`,
|
||||
options,
|
||||
|
||||
@ -6,15 +6,23 @@ import {
|
||||
PaginatedRequestOptions,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class DeployKeys extends BaseService {
|
||||
export interface DeployKey extends Record<string, unknown> {
|
||||
id: number;
|
||||
title: string;
|
||||
key: string;
|
||||
can_push?: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export class DeployKeys<C extends boolean = false> extends BaseService<C> {
|
||||
add(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/deploy_keys`, options);
|
||||
return RequestHelper.post<DeployKey>()(this, `projects/${pId}/deploy_keys`, options);
|
||||
}
|
||||
|
||||
all({ projectId, ...options }: { projectId?: string | number } & PaginatedRequestOptions = {}) {
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (projectId) {
|
||||
url = `projects/${encodeURIComponent(projectId)}/deploy_keys`;
|
||||
@ -22,30 +30,34 @@ export class DeployKeys extends BaseService {
|
||||
url = 'deploy_keys';
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get<Omit<DeployKey, 'can_push'>[]>()(this, url, options);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, keyId: string, options?: BaseRequestOptions) {
|
||||
edit(projectId: string | number, keyId: number, options?: BaseRequestOptions) {
|
||||
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/deploy_keys/${kId}`, options);
|
||||
return RequestHelper.put<DeployKey>()(this, `projects/${pId}/deploy_keys/${kId}`, options);
|
||||
}
|
||||
|
||||
enable(projectId: string | number, keyId: string, options?: Sudo) {
|
||||
enable(projectId: string | number, keyId: number, options?: Sudo) {
|
||||
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/deploy_keys/${kId}/enable`, options);
|
||||
return RequestHelper.post<Omit<DeployKey, 'can_push'>>()(
|
||||
this,
|
||||
`projects/${pId}/deploy_keys/${kId}/enable`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, keyId: string, options?: Sudo) {
|
||||
remove(projectId: string | number, keyId: number, options?: Sudo) {
|
||||
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/deploy_keys/${kId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/deploy_keys/${kId}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, keyId: string, options?: Sudo) {
|
||||
show(projectId: string | number, keyId: number, options?: Sudo) {
|
||||
const [pId, kId] = [projectId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deploy_keys/${kId}`, options);
|
||||
return RequestHelper.get<DeployKey>()(this, `projects/${pId}/deploy_keys/${kId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,81 +1,98 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { CommitSchemaDefault, CommitSchemaCamelized } from './Commits';
|
||||
import { PipelineSchemaDefault, PipelineSchemaCamelized } from './Pipelines';
|
||||
import { UserSchemaDefault, UserSchemaCamelized } from './Users';
|
||||
import { RunnerSchemaDefault, RunnerSchemaCamelized } from './Runners';
|
||||
import { CommitSchema } from './Commits';
|
||||
import { PipelineSchema } from './Pipelines';
|
||||
import { UserSchema } from './Users';
|
||||
import { RunnerSchema } from './Runners';
|
||||
import { EnvironmentSchema } from './Environments';
|
||||
import { MergeRequestSchema } from './MergeRequests';
|
||||
|
||||
export type DeploymentStatus = 'created' | 'running' | 'success' | 'failed' | 'canceled';
|
||||
|
||||
// Ref: https://docs.gitlab.com/12.6/ee/api/deployments.html#list-project-deployments
|
||||
export interface DeploymentSchemaDefault {
|
||||
id: number;
|
||||
iid: number;
|
||||
ref: string;
|
||||
sha: string;
|
||||
user: UserSchemaDefault;
|
||||
}
|
||||
|
||||
export interface DeploymentSchemaCamelized {
|
||||
id: number;
|
||||
iid: number;
|
||||
ref: string;
|
||||
sha: string;
|
||||
user: UserSchemaCamelized;
|
||||
}
|
||||
|
||||
export interface DeployableDefault {
|
||||
export interface DeployableSchema {
|
||||
id: number;
|
||||
ref: string;
|
||||
name: string;
|
||||
runner?: RunnerSchemaDefault;
|
||||
runner?: RunnerSchema;
|
||||
stage?: string;
|
||||
started_at?: Date;
|
||||
status?: DeploymentStatus;
|
||||
tag: boolean;
|
||||
commit?: CommitSchemaDefault;
|
||||
commit?: CommitSchema;
|
||||
coverage?: string;
|
||||
created_at?: Date;
|
||||
finished_at?: Date;
|
||||
user?: UserSchemaDefault;
|
||||
pipeline?: PipelineSchemaDefault;
|
||||
user?: UserSchema;
|
||||
pipeline?: PipelineSchema;
|
||||
}
|
||||
|
||||
export interface DeployableCamelized {
|
||||
export type DeploymentSchema = {
|
||||
id: number;
|
||||
iid: number;
|
||||
ref: string;
|
||||
name: string;
|
||||
runner?: RunnerSchemaCamelized;
|
||||
stage?: string;
|
||||
startedAt?: Date;
|
||||
status?: DeploymentStatus;
|
||||
tag: boolean;
|
||||
commit?: CommitSchemaCamelized;
|
||||
coverage?: string;
|
||||
createdAt?: Date;
|
||||
finishedAt?: Date;
|
||||
user?: UserSchemaCamelized;
|
||||
pipeline?: PipelineSchemaCamelized;
|
||||
}
|
||||
sha: string;
|
||||
user: UserSchema;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
status: DeploymentStatus;
|
||||
deployable: DeployableSchema;
|
||||
environment: EnvironmentSchema;
|
||||
};
|
||||
|
||||
export type Deployable = DeployableDefault | DeployableCamelized;
|
||||
|
||||
export class Deployments extends BaseService {
|
||||
export class Deployments<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deployments`, options);
|
||||
return RequestHelper.get<DeploymentSchema[]>()(this, `projects/${pId}/deployments`, options);
|
||||
}
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
environment: string,
|
||||
sha: string,
|
||||
ref: string,
|
||||
tag: string,
|
||||
status: DeploymentStatus,
|
||||
options?: Sudo,
|
||||
) {
|
||||
const [pId] = [projectId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post<DeploymentSchema>()(this, `projects/${pId}/deployments`, {
|
||||
environment,
|
||||
sha,
|
||||
ref,
|
||||
tag,
|
||||
status,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId: string | number, deploymentId: number, status: DeploymentStatus, options?: Sudo) {
|
||||
const [pId, dId] = [projectId, deploymentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put<DeploymentSchema>()(this, `projects/${pId}/deployments/${dId}`, {
|
||||
status,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
show(projectId: string | number, deploymentId: number, options?: Sudo) {
|
||||
const [pId, dId] = [projectId, deploymentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deployments/${dId}`, options);
|
||||
return RequestHelper.get<DeploymentSchema>()(
|
||||
this,
|
||||
`projects/${pId}/deployments/${dId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
mergeRequests(projectId: string | number, deploymentId: number, options?: Sudo) {
|
||||
const [pId, dId] = [projectId, deploymentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/deployments/${dId}/merge_requests`, options);
|
||||
return RequestHelper.get<MergeRequestSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/deployments/${dId}/merge_requests`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceTemplates } from '../templates';
|
||||
|
||||
export class DockerfileTemplates<C extends boolean = false> extends ResourceTemplates<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('dockerfiles', options);
|
||||
}
|
||||
}
|
||||
@ -5,92 +5,73 @@ import {
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
import {
|
||||
DeploymentSchemaDefault,
|
||||
DeploymentSchemaCamelized,
|
||||
DeployableDefault,
|
||||
DeployableCamelized,
|
||||
} from './Deployments';
|
||||
import { ProjectSchemaDefault, ProjectSchemaCamelized } from './Projects';
|
||||
import { DeploymentSchema, DeployableSchema } from './Deployments';
|
||||
import { ProjectSchema } from './Projects';
|
||||
|
||||
export interface EnvironmentSchemaDefault {
|
||||
export interface EnvironmentSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
slug?: string;
|
||||
external_url?: string;
|
||||
project?: ProjectSchemaDefault;
|
||||
project?: ProjectSchema;
|
||||
state?: string;
|
||||
last_deployment?: DeploymentSchema;
|
||||
deployable?: DeployableSchema;
|
||||
}
|
||||
|
||||
export interface EnvironmentSchemaCamelized {
|
||||
id: number;
|
||||
name: string;
|
||||
slug?: string;
|
||||
externalUrl?: string;
|
||||
project?: ProjectSchemaCamelized;
|
||||
state?: string;
|
||||
}
|
||||
|
||||
// ref: https://docs.gitlab.com/12.6/ee/api/environments.html#list-environments
|
||||
export type EnvironmentSchema = EnvironmentSchemaDefault | EnvironmentSchemaCamelized;
|
||||
|
||||
export interface EnvironmentDetailSchemaDefault extends EnvironmentSchemaDefault {
|
||||
last_deployment?: DeploymentSchemaDefault;
|
||||
deployable?: DeployableDefault;
|
||||
}
|
||||
|
||||
export interface EnvironmentDetailSchemaCamelized extends EnvironmentSchemaCamelized {
|
||||
lastDeployment?: DeploymentSchemaCamelized;
|
||||
deployable?: DeployableCamelized;
|
||||
}
|
||||
|
||||
export type EnvironmentDetailSchema =
|
||||
| EnvironmentDetailSchemaDefault
|
||||
| EnvironmentDetailSchemaCamelized;
|
||||
|
||||
export class Environments extends BaseService {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions): Promise<EnvironmentSchema[]> {
|
||||
export class Environments<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/environments`, options) as Promise<
|
||||
EnvironmentSchema[]
|
||||
>;
|
||||
return RequestHelper.get<Omit<EnvironmentSchema, 'last_deployment' | 'deployable'>[]>()(
|
||||
this,
|
||||
`projects/${pId}/environments`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
environmentId: number,
|
||||
options?: Sudo,
|
||||
): Promise<EnvironmentDetailSchema> {
|
||||
show(projectId: string | number, environmentId: number, options?: Sudo) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
return RequestHelper.get(
|
||||
return RequestHelper.get<EnvironmentSchema>()(
|
||||
this,
|
||||
`projects/${pId}/environments/${eId}`,
|
||||
options,
|
||||
) as Promise<EnvironmentDetailSchema>;
|
||||
);
|
||||
}
|
||||
|
||||
create(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/environments`, options);
|
||||
return RequestHelper.post<Omit<EnvironmentSchema, 'last_deployment' | 'deployable'>>()(
|
||||
this,
|
||||
`projects/${pId}/environments`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, environmentId: number, options?: BaseRequestOptions) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/environments/${eId}`, options);
|
||||
return RequestHelper.put<Omit<EnvironmentSchema, 'last_deployment' | 'deployable'>>()(
|
||||
this,
|
||||
`projects/${pId}/environments/${eId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, environmentId: number, options?: Sudo) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/environments/${eId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/environments/${eId}`, options);
|
||||
}
|
||||
|
||||
stop(projectId: string | number, environmentId: number, options?: Sudo) {
|
||||
const [pId, eId] = [projectId, environmentId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/environments/${eId}/stop`, options);
|
||||
return RequestHelper.post<Omit<EnvironmentSchema, 'last_deployment' | 'deployable'>>()(
|
||||
this,
|
||||
`projects/${pId}/environments/${eId}/stop`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,53 +1,63 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceDiscussions, DiscussionSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface EpicDiscussions extends ResourceDiscussions {
|
||||
export interface EpicDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
addNote(
|
||||
groupId: string | number,
|
||||
epicId: string | number,
|
||||
discussionId: string | number,
|
||||
epicId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
all(groupId: string | number, epicId: string | number, options?: PaginatedRequestOptions);
|
||||
all(
|
||||
groupId: string | number,
|
||||
epicId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>[]>;
|
||||
|
||||
create(
|
||||
groupId: string | number,
|
||||
epicId: string | number,
|
||||
epicId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
editNote(
|
||||
groupId: string | number,
|
||||
epicId: string | number,
|
||||
discussionId: string | number,
|
||||
epicId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
removeNote(
|
||||
groupId: string | number,
|
||||
epicId: string | number,
|
||||
discussionId: string | number,
|
||||
epicId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
groupId: string | number,
|
||||
epicId: string | number,
|
||||
discussionId: string | number,
|
||||
epicId: number,
|
||||
discussionId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
}
|
||||
|
||||
export class EpicDiscussions extends ResourceDiscussions {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export class EpicDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', 'epics', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { IssueSchema } from './Issues';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,28 +7,50 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class EpicIssues extends BaseService {
|
||||
all(groupId: string | number, epicId: number, options?: PaginatedRequestOptions) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
export interface EpicIssueSchema
|
||||
extends Omit<IssueSchema, 'references' | 'task_completion_status'> {
|
||||
epic_issue_id: number;
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/epics/${eId}/issues`, options);
|
||||
export class EpicIssues<C extends boolean = false> extends BaseService<C> {
|
||||
all(groupId: string | number, epicIId: number, options?: PaginatedRequestOptions) {
|
||||
const [gId, eId] = [groupId, epicIId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get<EpicIssueSchema[]>()(
|
||||
this,
|
||||
`groups/${gId}/epics/${eId}/issues`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
assign(groupId: string | number, epicId: number, issueId: number, options?: Sudo) {
|
||||
const [gId, eId, iId] = [groupId, epicId, issueId].map(encodeURIComponent);
|
||||
assign(groupId: string | number, epicIId: number, epicIssueId: number, options?: Sudo) {
|
||||
const [gId, eId, iId] = [groupId, epicIId, epicIssueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/epics/${eId}/issues/${iId}`, options);
|
||||
return RequestHelper.post<EpicIssueSchema>()(
|
||||
this,
|
||||
`groups/${gId}/epics/${eId}/issues/${iId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
edit(groupId: string | number, epicId: number, issueId: number, options?: BaseRequestOptions) {
|
||||
const [gId, eId, iId] = [groupId, epicId, issueId].map(encodeURIComponent);
|
||||
edit(
|
||||
groupId: string | number,
|
||||
epicIId: number,
|
||||
epicIssueId: number,
|
||||
options?: BaseRequestOptions,
|
||||
) {
|
||||
const [gId, eId, iId] = [groupId, epicIId, epicIssueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `groups/${gId}/epics/${eId}/issues/${iId}`, options);
|
||||
return RequestHelper.put<EpicIssueSchema>()(
|
||||
this,
|
||||
`groups/${gId}/epics/${eId}/issues/${iId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(groupId: string | number, epicId: number, issueId: number, options?: Sudo) {
|
||||
const [gId, eId, iId] = [groupId, epicId, issueId].map(encodeURIComponent);
|
||||
remove(groupId: string | number, epicIId: number, epicIssueId: number, options?: Sudo) {
|
||||
const [gId, eId, iId] = [groupId, epicIId, epicIssueId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `groups/${gId}/epics/${eId}/issues/${iId}`, options);
|
||||
return RequestHelper.del()(this, `groups/${gId}/epics/${eId}/issues/${iId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,32 +1,52 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceNotes } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceNotes, NoteSchema } from '../templates';
|
||||
import {
|
||||
PaginatedRequestOptions,
|
||||
BaseRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface EpicNotes extends ResourceNotes {
|
||||
all(groupId: string | number, epicId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface EpicNoteSchema extends NoteSchema {
|
||||
file_name: string;
|
||||
expires_at: string;
|
||||
}
|
||||
|
||||
export interface EpicNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
all(
|
||||
groupId: string | number,
|
||||
epicId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, EpicNoteSchema>[]>;
|
||||
|
||||
create(
|
||||
groupId: string | number,
|
||||
epicId: string | number,
|
||||
epicId: number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, EpicNoteSchema>>;
|
||||
|
||||
edit(
|
||||
groupId: string | number,
|
||||
epicId: string | number,
|
||||
epicId: number,
|
||||
noteId: number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, EpicNoteSchema>>;
|
||||
|
||||
remove(groupId: string | number, epicId: string | number, noteId: number, options?: Sudo);
|
||||
remove(groupId: string | number, epicId: number, noteId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
show(groupId: string | number, epicId: string | number, noteId: number, options?: Sudo);
|
||||
show(
|
||||
groupId: string | number,
|
||||
epicId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, EpicNoteSchema>>;
|
||||
}
|
||||
|
||||
export class EpicNotes extends ResourceNotes {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export class EpicNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', 'epics', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,34 +7,72 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class Epics extends BaseService {
|
||||
export interface EpicSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
iid: number;
|
||||
group_id: number;
|
||||
parent_id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
state: string;
|
||||
confidential: string;
|
||||
web_url: string;
|
||||
reference: string;
|
||||
references: {
|
||||
short: string;
|
||||
relative: string;
|
||||
full: string;
|
||||
};
|
||||
author: Omit<UserSchema, 'created_at'>;
|
||||
start_date?: string;
|
||||
start_date_is_fixed: boolean;
|
||||
start_date_fixed?: string;
|
||||
start_date_from_inherited_source?: string;
|
||||
due_date: string;
|
||||
due_date_is_fixed: boolean;
|
||||
due_date_fixed?: string;
|
||||
due_date_from_inherited_source: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
closed_at: string;
|
||||
labels?: string[];
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
_links: {
|
||||
self: string;
|
||||
epic_issues: string;
|
||||
group: string;
|
||||
};
|
||||
}
|
||||
|
||||
export class Epics<C extends boolean = false> extends BaseService<C> {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/epics`, options);
|
||||
return RequestHelper.get<EpicSchema[]>()(this, `groups/${gId}/epics`, options);
|
||||
}
|
||||
|
||||
create(groupId: string | number, title: string, options?: BaseRequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/epics`, { title, ...options });
|
||||
return RequestHelper.post<EpicSchema>()(this, `groups/${gId}/epics`, { title, ...options });
|
||||
}
|
||||
|
||||
edit(groupId: string | number, epicId: number, options?: BaseRequestOptions) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `groups/${gId}/epics/${eId}`, options);
|
||||
return RequestHelper.put<EpicSchema>()(this, `groups/${gId}/epics/${eId}`, options);
|
||||
}
|
||||
|
||||
remove(groupId: string | number, epicId: number, options?: Sudo) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `groups/${gId}/epics/${eId}`, options);
|
||||
return RequestHelper.del()(this, `groups/${gId}/epics/${eId}`, options);
|
||||
}
|
||||
|
||||
show(groupId: string | number, epicId: number, options?: Sudo) {
|
||||
const [gId, eId] = [groupId, epicId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/epics/${eId}`, options);
|
||||
return RequestHelper.get<EpicSchema>()(this, `groups/${gId}/epics/${eId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { RequestHelper, PaginatedRequestOptions } from '../infrastructure';
|
||||
|
||||
export interface EventOptions {
|
||||
@ -15,10 +16,41 @@ export interface EventOptions {
|
||||
| 'destroyed'
|
||||
| 'expired';
|
||||
targetType?: 'issue' | 'milestone' | 'merge_request' | 'note' | 'project' | 'snippet' | 'user';
|
||||
before?: string;
|
||||
after?: string;
|
||||
scope?: string;
|
||||
sort?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export class Events extends BaseService {
|
||||
all(options?: PaginatedRequestOptions & EventOptions) {
|
||||
return RequestHelper.get(this, 'events', options);
|
||||
export interface EventSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
title?: string;
|
||||
project_id: number;
|
||||
action_name: string;
|
||||
target_id: number;
|
||||
target_type: string;
|
||||
author_id: number;
|
||||
target_title: string;
|
||||
created_at: string;
|
||||
author: Omit<UserSchema, 'created_at'>;
|
||||
author_username: string;
|
||||
}
|
||||
|
||||
export class Events<C extends boolean = false> extends BaseService<C> {
|
||||
all({
|
||||
projectId,
|
||||
...options
|
||||
}: { projectId?: string | number } & PaginatedRequestOptions & EventOptions = {}) {
|
||||
let url: string;
|
||||
|
||||
if (projectId) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
url = `projects/${pId}/events`;
|
||||
} else {
|
||||
url = 'events';
|
||||
}
|
||||
|
||||
return RequestHelper.get<EventSchema[]>()(this, url, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,87 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, RequestHelper } from '../infrastructure';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class FeatureFlags extends BaseService {
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'features', options);
|
||||
export interface ScopeSchema {
|
||||
id: number;
|
||||
environment_scope: string;
|
||||
}
|
||||
export interface StrategySchema {
|
||||
id: number;
|
||||
name: string;
|
||||
parameters: {
|
||||
user_ids: string;
|
||||
};
|
||||
scopes?: ScopeSchema[];
|
||||
}
|
||||
|
||||
export interface FeatureFlagSchema extends Record<string, unknown> {
|
||||
name: string;
|
||||
description: string;
|
||||
active: boolean;
|
||||
version: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
scopes?: string[];
|
||||
strategies?: StrategySchema[];
|
||||
}
|
||||
|
||||
export class FeatureFlags<C extends boolean = false> extends BaseService<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
options: { scopes?: 'enabled' | 'disabled' } & PaginatedRequestOptions = {},
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get<FeatureFlagSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/features_flags`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
set(name: string, options?: BaseRequestOptions) {
|
||||
const encodedName = encodeURIComponent(name);
|
||||
create(
|
||||
projectId: string | number,
|
||||
flagName: string,
|
||||
version: string,
|
||||
options?: BaseRequestOptions,
|
||||
) {
|
||||
const [pId, fName, ver] = [projectId, flagName, version].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `features/${encodedName}`, options);
|
||||
return RequestHelper.post<FeatureFlagSchema>()(this, `projects/${pId}/features_flags`, {
|
||||
version: ver,
|
||||
name: fName,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId: string | number, flagName: string, options?: BaseRequestOptions) {
|
||||
const [pId, fName] = [projectId, flagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put<FeatureFlagSchema>()(
|
||||
this,
|
||||
`projects/${pId}/features_flags/${fName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, flagName: string, options?: Sudo) {
|
||||
const [pId, fName] = [projectId, flagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del()(this, `projects/${pId}/features_flags/${fName}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, flagName: string, options?: Sudo) {
|
||||
const [pId, fName] = [projectId, flagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get<FeatureFlagSchema>()(
|
||||
this,
|
||||
`projects/${pId}/features_flags/${fName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,38 +1,45 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, RequestHelper } from '../infrastructure';
|
||||
import { BaseRequestOptions, RequestHelper, Camelize } from '../infrastructure';
|
||||
|
||||
export interface CreateFreezePeriodOptions {
|
||||
cronTimezone?: string;
|
||||
export interface FreezePeriodSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
freeze_start: string;
|
||||
freeze_end: string;
|
||||
cron_timezone: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface EditFreezePeriodOptions {
|
||||
cronTimezone?: string;
|
||||
freezeStart?: string;
|
||||
freezeEnd?: string;
|
||||
}
|
||||
|
||||
export class FreezePeriods extends BaseService {
|
||||
export class FreezePeriods<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/freeze_periods`, options);
|
||||
return RequestHelper.get<FreezePeriodSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/freeze_periods`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId: string | number, freezePeriodId: number, options?: BaseRequestOptions) {
|
||||
const [pId, fId] = [projectId, freezePeriodId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/freeze_periods/${fId}`, options);
|
||||
return RequestHelper.get<FreezePeriodSchema>()(
|
||||
this,
|
||||
`projects/${pId}/freeze_periods/${fId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
create(
|
||||
projectId: number | string,
|
||||
freezeStart: string,
|
||||
freezeEnd: string,
|
||||
options?: CreateFreezePeriodOptions & BaseRequestOptions,
|
||||
options?: Camelize<Pick<FreezePeriodSchema, 'cron_timezone'>> & BaseRequestOptions,
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/freeze_periods`, {
|
||||
return RequestHelper.post<FreezePeriodSchema>()(this, `projects/${pId}/freeze_periods`, {
|
||||
freezeStart,
|
||||
freezeEnd,
|
||||
...options,
|
||||
@ -42,16 +49,21 @@ export class FreezePeriods extends BaseService {
|
||||
edit(
|
||||
projectId: number | string,
|
||||
freezePeriodId: number,
|
||||
options?: EditFreezePeriodOptions & BaseRequestOptions,
|
||||
options?: Camelize<Omit<FreezePeriodSchema, 'id' | 'created_at' | 'updated_at'>> &
|
||||
BaseRequestOptions,
|
||||
) {
|
||||
const [pId, fId] = [projectId, freezePeriodId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/freeze_periods/${fId}`, options);
|
||||
return RequestHelper.put<FreezePeriodSchema>()(
|
||||
this,
|
||||
`projects/${pId}/freeze_periods/${fId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
delete(projectId: number | string, freezePeriodId: number, options?: BaseRequestOptions) {
|
||||
const [pId, fId] = [projectId, freezePeriodId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/freeze_periods/${fId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/freeze_periods/${fId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,46 +6,185 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class GeoNodes extends BaseService {
|
||||
export interface GeoNodeSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
internal_url: string;
|
||||
primary: boolean;
|
||||
enabled: boolean;
|
||||
current: boolean;
|
||||
files_max_capacity: number;
|
||||
repos_max_capacity: number;
|
||||
verification_max_capacity: number;
|
||||
selective_sync_type: string;
|
||||
selective_sync_shards?: string[];
|
||||
selective_sync_namespace_ids?: number[];
|
||||
minimum_reverification_interval: number;
|
||||
container_repositories_max_capacity: number;
|
||||
sync_object_storage: boolean;
|
||||
clone_protocol: string;
|
||||
web_edit_url: string;
|
||||
web_geo_projects_url: string;
|
||||
_links: {
|
||||
self: string;
|
||||
status: string;
|
||||
repair: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface GeoNodeFailureSchema extends Record<string, unknown> {
|
||||
project_id: number;
|
||||
last_repository_synced_at: string;
|
||||
last_repository_successful_sync_at: string;
|
||||
last_wiki_synced_at: string;
|
||||
last_wiki_successful_sync_at: string;
|
||||
repository_retry_count?: number;
|
||||
wiki_retry_count: number;
|
||||
last_repository_sync_failure?: string;
|
||||
last_wiki_sync_failure: string;
|
||||
last_repository_verification_failure: string;
|
||||
last_wiki_verification_failure: string;
|
||||
repository_verification_checksum_sha: string;
|
||||
wiki_verification_checksum_sha: string;
|
||||
repository_checksum_mismatch: boolean;
|
||||
wiki_checksum_mismatch: boolean;
|
||||
}
|
||||
|
||||
export interface GeoNodeStatusSchema extends Record<string, unknown> {
|
||||
geo_node_id: number;
|
||||
healthy: boolean;
|
||||
health: string;
|
||||
health_status: string;
|
||||
missing_oauth_application: boolean;
|
||||
attachments_count: number;
|
||||
attachments_synced_count?: number;
|
||||
attachments_failed_count?: number;
|
||||
attachments_synced_missing_on_primary_count: number;
|
||||
attachments_synced_in_percentage: string;
|
||||
db_replication_lag_seconds?: number;
|
||||
lfs_objects_count: number;
|
||||
lfs_objects_synced_count?: number;
|
||||
lfs_objects_failed_count?: number;
|
||||
lfs_objects_synced_missing_on_primary_count: number;
|
||||
lfs_objects_synced_in_percentage: string;
|
||||
job_artifacts_count: number;
|
||||
job_artifacts_synced_count?: number;
|
||||
job_artifacts_failed_count?: number;
|
||||
job_artifacts_synced_missing_on_primary_count: number;
|
||||
job_artifacts_synced_in_percentage: string;
|
||||
container_repositories_count: number;
|
||||
container_repositories_synced_count?: number;
|
||||
container_repositories_failed_count?: number;
|
||||
container_repositories_synced_in_percentage: string;
|
||||
design_repositories_count: number;
|
||||
design_repositories_synced_count?: number;
|
||||
design_repositories_failed_count?: number;
|
||||
design_repositories_synced_in_percentage: string;
|
||||
projects_count: number;
|
||||
repositories_count: number;
|
||||
repositories_failed_count?: number;
|
||||
repositories_synced_count?: number;
|
||||
repositories_synced_in_percentage: string;
|
||||
wikis_count: number;
|
||||
wikis_failed_count?: number;
|
||||
wikis_synced_count?: number;
|
||||
wikis_synced_in_percentage: string;
|
||||
replication_slots_count: number;
|
||||
replication_slots_used_count: number;
|
||||
replication_slots_used_in_percentage: string;
|
||||
replication_slots_max_retained_wal_bytes: number;
|
||||
repositories_checked_count: number;
|
||||
repositories_checked_failed_count: number;
|
||||
repositories_checked_in_percentage: string;
|
||||
repositories_checksummed_count: number;
|
||||
repositories_checksum_failed_count: number;
|
||||
repositories_checksummed_in_percentage: string;
|
||||
wikis_checksummed_count: number;
|
||||
wikis_checksum_failed_count: number;
|
||||
wikis_checksummed_in_percentage: string;
|
||||
repositories_verified_count: number;
|
||||
repositories_verification_failed_count: number;
|
||||
repositories_verified_in_percentage: string;
|
||||
repositories_checksum_mismatch_count: number;
|
||||
wikis_verified_count: number;
|
||||
wikis_verification_failed_count: number;
|
||||
wikis_verified_in_percentage: string;
|
||||
wikis_checksum_mismatch_count: number;
|
||||
repositories_retrying_verification_count: number;
|
||||
wikis_retrying_verification_count: number;
|
||||
last_event_id: number;
|
||||
last_event_timestamp: number;
|
||||
cursor_last_event_id?: number;
|
||||
cursor_last_event_timestamp: number;
|
||||
last_successful_status_check_timestamp: number;
|
||||
version: string;
|
||||
revision: string;
|
||||
package_files_count: number;
|
||||
package_files_checksummed_count: number;
|
||||
package_files_checksum_failed_count: number;
|
||||
package_files_registry_count: number;
|
||||
package_files_synced_count: number;
|
||||
package_files_failed_count: number;
|
||||
snippet_repositories_count: number;
|
||||
snippet_repositories_checksummed_count: number;
|
||||
snippet_repositories_checksum_failed_count: number;
|
||||
snippet_repositories_registry_count: number;
|
||||
snippet_repositories_synced_count: number;
|
||||
snippet_repositories_failed_count: number;
|
||||
group_wiki_repositories_checksummed_count: number;
|
||||
group_wiki_repositories_checksum_failed_count: number;
|
||||
group_wiki_repositories_registry_count: number;
|
||||
group_wiki_repositories_synced_count: number;
|
||||
group_wiki_repositories_failed_count: number;
|
||||
}
|
||||
|
||||
export class GeoNodes<C extends boolean = false> extends BaseService<C> {
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'geo_nodes', options);
|
||||
return RequestHelper.get<GeoNodeSchema[]>()(this, 'geo_nodes', options);
|
||||
}
|
||||
|
||||
create(geonodeId: number, options?: BaseRequestOptions) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.post(this, `geo_nodes/${gId}`, options);
|
||||
return RequestHelper.post<GeoNodeSchema>()(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
edit(geonodeId: number, options?: BaseRequestOptions) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.put(this, `geo_nodes/${gId}`, options);
|
||||
return RequestHelper.put<GeoNodeSchema>()(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
failures(options?: BaseRequestOptions) {
|
||||
return RequestHelper.post(this, 'geo_nodes/current/failures', options);
|
||||
return RequestHelper.get<GeoNodeFailureSchema[]>()(this, 'geo_nodes/current/failures', options);
|
||||
}
|
||||
|
||||
repair(geonodeId: number, options?: Sudo) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.del(this, `geo_nodes/${gId}`, options);
|
||||
return RequestHelper.post<GeoNodeSchema>()(this, `geo_nodes/${gId}/repair`, options);
|
||||
}
|
||||
|
||||
remove(geonodeId: number, options?: Sudo) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.del<GeoNodeSchema>()(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
show(geonodeId: number, options?: Sudo) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.get(this, `geo_nodes/${gId}`, options);
|
||||
return RequestHelper.get<GeoNodeSchema>()(this, `geo_nodes/${gId}`, options);
|
||||
}
|
||||
|
||||
status(geonodeId: number, options?: Sudo) {
|
||||
const gId = encodeURIComponent(geonodeId);
|
||||
|
||||
return RequestHelper.get(this, `geo_nodes/${gId}/status`, options);
|
||||
return RequestHelper.get<GeoNodeStatusSchema>()(this, `geo_nodes/${gId}/status`, options);
|
||||
}
|
||||
|
||||
statuses(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'geo_nodes/statuses', options);
|
||||
return RequestHelper.get<GeoNodeStatusSchema[]>()(this, 'geo_nodes/statuses', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceTemplates } from '../templates';
|
||||
|
||||
export class GitLabCIYMLTemplates extends ResourceTemplates {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export class GitLabCIYMLTemplates<C extends boolean = false> extends ResourceTemplates<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('gitlab_ci_ymls', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceTemplates } from '../templates';
|
||||
|
||||
export class GitignoreTemplates extends ResourceTemplates {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export class GitignoreTemplates<C extends boolean = false> extends ResourceTemplates<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('gitignores', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,24 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceAccessRequests } from '../templates';
|
||||
import { ResourceAccessRequests, AccessRequestSchema, AccessLevel } from '../templates';
|
||||
import { Sudo, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export class GroupAccessRequests extends ResourceAccessRequests {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export interface GroupAccessRequests<C extends boolean = false> extends ResourceAccessRequests<C> {
|
||||
all(groupId: string | number): Promise<CamelizedRecord<C, AccessRequestSchema>[]>;
|
||||
|
||||
request(groupId: string | number): Promise<CamelizedRecord<C, AccessRequestSchema>>;
|
||||
|
||||
approve(
|
||||
groupId: string | number,
|
||||
userId: number,
|
||||
options?: { accessLevel?: AccessLevel } & Sudo,
|
||||
): Promise<CamelizedRecord<C, AccessRequestSchema>>;
|
||||
|
||||
deny(groupId: string | number, userId: number): Promise<void>;
|
||||
}
|
||||
|
||||
export class GroupAccessRequests<C extends boolean = false> extends ResourceAccessRequests<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,23 +1,52 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceBadges } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceBadges, BadgeSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface GroupBadges extends ResourceBadges {
|
||||
add(groupId: string | number, options?: BaseRequestOptions);
|
||||
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions);
|
||||
|
||||
edit(groupId: string | number, badgeId: number, options?: BaseRequestOptions);
|
||||
|
||||
preview(groupId: string | number, linkUrl: string, imageUrl: string, options?: Sudo);
|
||||
|
||||
remove(groupId: string | number, badgeId: number, options?: Sudo);
|
||||
|
||||
show(groupId: string | number, badgeId: number, options?: Sudo);
|
||||
export interface GroupBadgeSchema extends BadgeSchema {
|
||||
kind: 'group';
|
||||
}
|
||||
|
||||
export class GroupBadges extends ResourceBadges {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export interface GroupBadges<C extends boolean = false> extends ResourceBadges<C> {
|
||||
add(
|
||||
groupId: string | number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, GroupBadgeSchema>>;
|
||||
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, GroupBadgeSchema>[]>;
|
||||
|
||||
edit(
|
||||
groupId: string | number,
|
||||
badgeId: number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, GroupBadgeSchema>>;
|
||||
|
||||
preview(
|
||||
groupId: string | number,
|
||||
linkUrl: string,
|
||||
imageUrl: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, Omit<GroupBadgeSchema, 'id' | 'name' | 'kind'>>>;
|
||||
|
||||
remove(groupId: string | number, badgeId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
show(
|
||||
groupId: string | number,
|
||||
badgeId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, GroupBadgeSchema>>;
|
||||
}
|
||||
|
||||
export class GroupBadges<C extends boolean = false> extends ResourceBadges<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,33 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceCustomAttributes, CustomAttributeSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export interface GroupCustomAttributes extends ResourceCustomAttributes {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface GroupCustomAttributes<C extends boolean = false>
|
||||
extends ResourceCustomAttributes<C> {
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>[]>;
|
||||
|
||||
set(groupId: string | number, customAttributeId: number, value: string, options?: Sudo);
|
||||
set(
|
||||
groupId: string | number,
|
||||
customAttributeId: number,
|
||||
value: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>>;
|
||||
|
||||
remove(groupId: string | number, customAttributeId: number, options?: Sudo);
|
||||
remove(groupId: string | number, customAttributeId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
show(groupId: string | number, customAttributeId: number, options?: Sudo);
|
||||
show(
|
||||
groupId: string | number,
|
||||
customAttributeId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>>;
|
||||
}
|
||||
|
||||
export class GroupCustomAttributes extends ResourceCustomAttributes {
|
||||
constructor(options: BaseServiceOptions) {
|
||||
export class GroupCustomAttributes<C extends boolean = false> extends ResourceCustomAttributes<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,33 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceDeployTokens } from '../templates';
|
||||
import { ResourceDeployTokens, DeployTokenScope, DeployTokenSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
CamelizedRecord,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class GroupDeployTokens extends ResourceDeployTokens {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export interface GroupDeployTokens<C extends boolean = false> extends ResourceDeployTokens<C> {
|
||||
add(
|
||||
groupId: string | number,
|
||||
tokenName: string,
|
||||
tokenScopes: DeployTokenScope[],
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, DeployTokenSchema>>;
|
||||
|
||||
all({
|
||||
groupId,
|
||||
...options
|
||||
}: { groupId?: string | number } & PaginatedRequestOptions): Promise<
|
||||
CamelizedRecord<C, DeployTokenSchema>[]
|
||||
>;
|
||||
|
||||
remove(groupId: string | number, tokenId: number, options?: Sudo): Promise<void>;
|
||||
}
|
||||
|
||||
export class GroupDeployTokens<C extends boolean = false> extends ResourceDeployTokens<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,41 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceIssueBoards } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { GroupSchema } from './Groups';
|
||||
import { ResourceIssueBoards, IssueBoardSchema, IssueBoardListSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface GroupIssueBoards extends ResourceIssueBoards {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface GroupIssueBoardSchema extends IssueBoardSchema {
|
||||
group: Pick<GroupSchema, 'id' | 'name' | 'web_url'>;
|
||||
}
|
||||
|
||||
create(groupId: string | number, name: string, options?: Sudo);
|
||||
export interface GroupIssueBoards<C extends boolean = false> extends ResourceIssueBoards<C> {
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, IssueBoardSchema>[]>;
|
||||
|
||||
createList(groupId: string | number, boardId: number, labelId: number, options?: Sudo);
|
||||
create(
|
||||
groupId: string | number,
|
||||
name: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, GroupIssueBoardSchema>>;
|
||||
|
||||
edit(groupId: string | number, boardId: number, options?: BaseRequestOptions);
|
||||
createList(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
labelId: number | string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>>;
|
||||
|
||||
edit(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, GroupIssueBoardSchema>>;
|
||||
|
||||
editList(
|
||||
groupId: string | number,
|
||||
@ -17,21 +43,40 @@ export interface GroupIssueBoards extends ResourceIssueBoards {
|
||||
listId: number,
|
||||
position: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>>;
|
||||
|
||||
lists(groupId: string | number, boardId: number, options?: Sudo);
|
||||
lists(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>[]>;
|
||||
|
||||
remove(groupId: string | number, boardId: number, options?: Sudo);
|
||||
remove(groupId: string | number, boardId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
removeList(groupId: string | number, boardId: number, listId: number, options?: Sudo);
|
||||
removeList(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
listId: number,
|
||||
options?: Sudo,
|
||||
): Promise<void>;
|
||||
|
||||
show(groupId: string | number, boardId: number, options?: Sudo);
|
||||
show(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, GroupIssueBoardSchema>>;
|
||||
|
||||
showList(groupId: string | number, boardId: number, listId: number, options?: Sudo);
|
||||
showList(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
listId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>>;
|
||||
}
|
||||
|
||||
export class GroupIssueBoards extends ResourceIssueBoards {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class GroupIssueBoards<C extends boolean = false> extends ResourceIssueBoards<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,23 +1,49 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceLabels } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
CamelizedRecord,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
import { ResourceLabels, LabelSchema } from '../templates';
|
||||
|
||||
export interface GroupLabels extends ResourceLabels {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface GroupLabels<C extends boolean = false> extends ResourceLabels<C> {
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>[]>;
|
||||
|
||||
create(groupId: string | number, labelName: string, color: string, options?: BaseRequestOptions);
|
||||
create(
|
||||
groupId: string | number,
|
||||
labelName: string,
|
||||
color: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
|
||||
edit(groupId: string | number, labelName: string, options?: BaseRequestOptions);
|
||||
edit(
|
||||
groupId: string | number,
|
||||
labelId: number | string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
|
||||
remove(groupId: string | number, labelName: string, options?: Sudo);
|
||||
remove(groupId: string | number, labelId: number | string, options?: Sudo): Promise<void>;
|
||||
|
||||
subscribe(groupId: string | number, labelId: number, options?: Sudo);
|
||||
subscribe(
|
||||
groupId: string | number,
|
||||
labelId: number | string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
|
||||
unsubscribe(groupId: string | number, labelId: number, options?: Sudo);
|
||||
unsubscribe(
|
||||
groupId: string | number,
|
||||
labelId: number | string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
}
|
||||
|
||||
export class GroupLabels extends ResourceLabels {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class GroupLabels<C extends boolean = false> extends ResourceLabels<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,44 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceMembers } from '../templates';
|
||||
import { ResourceMembers, MembersSchema, IncludeInherited, AccessLevel } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
CamelizedRecord,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class GroupMembers extends ResourceMembers {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export interface GroupMembers<C extends boolean = false> extends ResourceMembers<C> {
|
||||
add(
|
||||
groupId: string | number,
|
||||
userId: number,
|
||||
accessLevel: AccessLevel,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>>;
|
||||
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: IncludeInherited & PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>[]>;
|
||||
|
||||
edit(
|
||||
groupId: string | number,
|
||||
userId: number,
|
||||
accessLevel: AccessLevel,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>>;
|
||||
|
||||
show(
|
||||
groupId: string | number,
|
||||
userId: number,
|
||||
options?: IncludeInherited & Sudo,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>>;
|
||||
|
||||
remove(groupId: string | number, userId: number, options?: Sudo): Promise<void>;
|
||||
}
|
||||
|
||||
export class GroupMembers<C extends boolean = false> extends ResourceMembers<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,23 +1,54 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceMilestones } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceMilestones, MilestoneSchema } from '../templates';
|
||||
import {
|
||||
PaginatedRequestOptions,
|
||||
BaseRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
import type { IssueSchema } from './Issues';
|
||||
import type { MergeRequestSchema } from './MergeRequests';
|
||||
|
||||
export interface GroupMilestones extends ResourceMilestones {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface GroupMilestones<C extends boolean = false> extends ResourceMilestones<C> {
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>[]>;
|
||||
|
||||
create(groupId: string | number, title: string, options?: BaseRequestOptions);
|
||||
create(
|
||||
groupId: string | number,
|
||||
title: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>>;
|
||||
|
||||
edit(groupId: string | number, milestoneId: number, options?: BaseRequestOptions);
|
||||
edit(
|
||||
groupId: string | number,
|
||||
milestoneId: number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>>;
|
||||
|
||||
issues(groupId: string | number, milestoneId: number, options?: Sudo);
|
||||
issues(
|
||||
groupId: string | number,
|
||||
milestoneId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueSchema>[]>;
|
||||
|
||||
mergeRequests(groupId: string | number, milestoneId: number, options?: Sudo);
|
||||
mergeRequests(
|
||||
groupId: string | number,
|
||||
milestoneId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, MergeRequestSchema>[]>;
|
||||
|
||||
show(groupId: string | number, milestoneId: number, options?: Sudo);
|
||||
show(
|
||||
groupId: string | number,
|
||||
milestoneId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>>;
|
||||
}
|
||||
|
||||
export class GroupMilestones extends ResourceMilestones {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class GroupMilestones<C extends boolean = false> extends ResourceMilestones<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, RequestHelper } from '../infrastructure';
|
||||
import { ProjectSchema } from './Projects';
|
||||
|
||||
export class GroupProjects extends BaseService {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions): Promise<ProjectSchema[]> {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/projects`, options) as Promise<ProjectSchema[]>;
|
||||
}
|
||||
|
||||
add(groupId: string | number, projectId: string | number, options?: BaseRequestOptions) {
|
||||
const [gId, pId] = [groupId, projectId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/projects/${pId}`, options);
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { PaginatedRequestOptions, RequestHelper } from '../infrastructure';
|
||||
import { PaginatedRequestOptions, ShowExpanded, RequestHelper } from '../infrastructure';
|
||||
import { RunnerSchema } from './Runners';
|
||||
|
||||
export class GroupRunners extends BaseService {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions): Promise<RunnerSchema[]> {
|
||||
export class GroupRunners<C extends boolean = false> extends BaseService<C> {
|
||||
all(groupId: string | number, options?: PaginatedRequestOptions & ShowExpanded) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/runners`, options) as Promise<RunnerSchema[]>;
|
||||
return RequestHelper.get<RunnerSchema[]>()(this, `groups/${gId}/runners`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,36 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceVariables, ResourceVariableSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions } from '../infrastructure';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export interface GroupVariables extends ResourceVariables {
|
||||
export interface GroupVariables<C extends boolean = false> extends ResourceVariables<C> {
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<ResourceVariableSchema[]>;
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>[]>;
|
||||
|
||||
create(groupId: string | number, options?: BaseRequestOptions);
|
||||
create(
|
||||
groupId: string | number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>>;
|
||||
|
||||
edit(groupId: string | number, keyId: string, options?: BaseRequestOptions);
|
||||
edit(
|
||||
groupId: string | number,
|
||||
key: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>>;
|
||||
|
||||
show(
|
||||
groupId: string | number,
|
||||
keyId: string,
|
||||
key: string,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<ResourceVariableSchema>;
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>>;
|
||||
|
||||
remove(groupId: string | number, keyId: string, options?: PaginatedRequestOptions);
|
||||
remove(groupId: string | number, key: string, options?: PaginatedRequestOptions): Promise<void>;
|
||||
}
|
||||
|
||||
export class GroupVariables extends ResourceVariables {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class GroupVariables<C extends boolean = false> extends ResourceVariables<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,13 @@ import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
ShowExpanded,
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
ShowExpanded,
|
||||
} from '../infrastructure';
|
||||
import { ProjectSchema } from './Projects';
|
||||
|
||||
export interface GroupSchemaDefault {
|
||||
export interface GroupSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
@ -18,45 +18,65 @@ export interface GroupSchemaDefault {
|
||||
visibility: string;
|
||||
avatar_url: string;
|
||||
web_url: string;
|
||||
description: string;
|
||||
share_with_group_lock: boolean;
|
||||
require_two_factor_authentication: boolean;
|
||||
two_factor_grace_period: number;
|
||||
project_creation_level: string;
|
||||
auto_devops_enabled: boolean;
|
||||
subgroup_creation_level: string;
|
||||
emails_disabled: boolean;
|
||||
mentions_disabled: boolean;
|
||||
lfs_enabled: boolean;
|
||||
default_branch_protection: number;
|
||||
request_access_enabled: boolean;
|
||||
file_template_project_id: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface GroupSchemaCamelized {
|
||||
export type GroupDetailSchema = {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
fullName: string;
|
||||
fullPath: string;
|
||||
parentId: number;
|
||||
full_name: string;
|
||||
full_path: string;
|
||||
parent_id: number;
|
||||
visibility: string;
|
||||
avatarUrl: string;
|
||||
webUrl: string;
|
||||
}
|
||||
|
||||
export type GroupSchema = GroupSchemaDefault | GroupSchemaCamelized;
|
||||
|
||||
export type GroupDetailSchema = GroupSchema & {
|
||||
projects: ProjectSchema[];
|
||||
avatar_url: string;
|
||||
web_url: string;
|
||||
description: string;
|
||||
request_access_enabled: boolean;
|
||||
file_template_project_id: number;
|
||||
runners_token: string;
|
||||
shared_with_groups: {
|
||||
group_id: number;
|
||||
group_name: string;
|
||||
group_full_path: string;
|
||||
group_access_level: number;
|
||||
expires_at: string;
|
||||
}[];
|
||||
created_at: string;
|
||||
};
|
||||
|
||||
export class Groups extends BaseService {
|
||||
all(options?: PaginatedRequestOptions): Promise<GroupSchema[]> {
|
||||
return RequestHelper.get<GroupSchema>(this, 'groups', options) as Promise<GroupSchema[]>;
|
||||
export class Groups<C extends boolean = false> extends BaseService<C> {
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get<GroupSchema[]>()(this, 'groups', options);
|
||||
}
|
||||
|
||||
create(name: string, path: string, options?: BaseRequestOptions & ShowExpanded) {
|
||||
return RequestHelper.post(this, 'groups', { name, path, ...options });
|
||||
create(name: string, path: string, options?: BaseRequestOptions) {
|
||||
return RequestHelper.post<GroupSchema>()(this, 'groups', { name, path, ...options });
|
||||
}
|
||||
|
||||
createLDAPLink(
|
||||
groupId: string | number,
|
||||
cn,
|
||||
groupAccess,
|
||||
cn: string,
|
||||
groupAccess: number,
|
||||
provider: string,
|
||||
options?: Sudo & ShowExpanded,
|
||||
) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/ldap_group_links`, {
|
||||
return RequestHelper.post()(this, `groups/${gId}/ldap_group_links`, {
|
||||
cn,
|
||||
groupAccess,
|
||||
provider,
|
||||
@ -64,63 +84,71 @@ export class Groups extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
edit(groupId: string | number, options?: BaseRequestOptions & ShowExpanded) {
|
||||
edit(groupId: string | number, options?: BaseRequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.put(this, `groups/${gId}`, options);
|
||||
return RequestHelper.put()(this, `groups/${gId}`, options);
|
||||
}
|
||||
|
||||
projects(groupId: string | number, options?: BaseRequestOptions): Promise<ProjectSchema[]> {
|
||||
projects(groupId: string | number, options?: BaseRequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get<ProjectSchema>(this, `groups/${gId}/projects`, options) as Promise<
|
||||
ProjectSchema[]
|
||||
>;
|
||||
return RequestHelper.get<ProjectSchema[]>()(this, `groups/${gId}/projects`, options);
|
||||
}
|
||||
|
||||
remove(groupId: string | number, options?: Sudo & ShowExpanded) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.del(this, `groups/${gId}`, options);
|
||||
return RequestHelper.del()(this, `groups/${gId}`, options);
|
||||
}
|
||||
|
||||
removeLDAPLink(
|
||||
groupId: string | number,
|
||||
cn,
|
||||
cn: string,
|
||||
{ provider, ...options }: Sudo & ShowExpanded & { provider?: string } = {},
|
||||
) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
const url = provider ? `${provider}/${cn}` : `${cn}`;
|
||||
|
||||
return RequestHelper.del(this, `groups/${gId}/ldap_group_links/${url}`, options);
|
||||
return RequestHelper.del()(
|
||||
this,
|
||||
`groups/${gId}/ldap_group_links/${url}`,
|
||||
options as Record<string, unknown>,
|
||||
);
|
||||
}
|
||||
|
||||
search(nameOrPath: string, options?: Sudo) {
|
||||
return RequestHelper.get(this, 'groups', {
|
||||
return RequestHelper.get()(this, 'groups', {
|
||||
search: nameOrPath,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
show(groupId: string | number, options?: BaseRequestOptions): Promise<GroupDetailSchema> {
|
||||
show(groupId: string | number, options?: BaseRequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get<GroupDetailSchema>(
|
||||
this,
|
||||
`groups/${gId}`,
|
||||
options,
|
||||
) as Promise<GroupDetailSchema>;
|
||||
return RequestHelper.get<GroupDetailSchema>()(this, `groups/${gId}`, options);
|
||||
}
|
||||
|
||||
subgroups(groupId: string | number, options?: PaginatedRequestOptions) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.get(this, `groups/${gId}/subgroups`, options);
|
||||
return RequestHelper.get()(this, `groups/${gId}/subgroups`, options);
|
||||
}
|
||||
|
||||
syncLDAP(groupId: string | number, options?: Sudo & ShowExpanded) {
|
||||
const gId = encodeURIComponent(groupId);
|
||||
|
||||
return RequestHelper.post(this, `groups/${gId}/ldap_sync`, options);
|
||||
return RequestHelper.post()(this, `groups/${gId}/ldap_sync`, options);
|
||||
}
|
||||
|
||||
transferProject(
|
||||
groupId: string | number,
|
||||
projectId: string | number,
|
||||
options?: BaseRequestOptions & ShowExpanded,
|
||||
) {
|
||||
const [gId, pId] = [groupId, projectId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post()(this, `groups/${gId}/projects/${pId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +1,39 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceAwardEmojis } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceAwardEmojis, AwardEmojiSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export interface IssueAwardEmojis extends ResourceAwardEmojis {
|
||||
export interface IssueAwardEmojis<C extends boolean = false> extends ResourceAwardEmojis<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
noteId: number,
|
||||
issueIId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>[]>;
|
||||
|
||||
award(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
noteId: number,
|
||||
issueIId: number,
|
||||
name: string,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
|
||||
remove(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
issueIId: number,
|
||||
awardId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
issueIId: number,
|
||||
awardId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
}
|
||||
|
||||
export class IssueAwardEmojis extends ResourceAwardEmojis {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class IssueAwardEmojis<C extends boolean = false> extends ResourceAwardEmojis<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,53 +1,63 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceDiscussions, DiscussionSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface IssueDiscussions extends ResourceDiscussions {
|
||||
export interface IssueDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
addNote(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
discussionId: string | number,
|
||||
issueIId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
all(projectId: string | number, issueId: string | number, options?: PaginatedRequestOptions);
|
||||
all(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
issueIId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
editNote(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
discussionId: string | number,
|
||||
issueIId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
removeNote(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
discussionId: string | number,
|
||||
issueIId: number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
discussionId: string | number,
|
||||
issueIId: number,
|
||||
discussionId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
}
|
||||
|
||||
export class IssueDiscussions extends ResourceDiscussions {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class IssueDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', 'issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
44
packages/gitbeaker-core/src/services/IssueNoteAwardEmojis.ts
Normal file
44
packages/gitbeaker-core/src/services/IssueNoteAwardEmojis.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceNoteAwardEmojis, AwardEmojiSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, CamelizedRecord, Sudo } from '../infrastructure';
|
||||
|
||||
export interface IssueNoteAwardEmojis<C extends boolean = false>
|
||||
extends ResourceNoteAwardEmojis<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
noteId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>[]>;
|
||||
|
||||
award(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
noteId: number,
|
||||
name: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
|
||||
remove(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
noteId: number,
|
||||
awardId: number,
|
||||
options?: Sudo,
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
noteId: number,
|
||||
awardId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
}
|
||||
|
||||
export class IssueNoteAwardEmojis<C extends boolean = false> extends ResourceNoteAwardEmojis<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('issues', options);
|
||||
}
|
||||
}
|
||||
@ -1,32 +1,61 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceNotes } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceNotes, NoteSchema } from '../templates';
|
||||
import {
|
||||
PaginatedRequestOptions,
|
||||
BaseRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface IssueNotes extends ResourceNotes {
|
||||
all(projectId: string | number, issueId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface IssueNoteSchema extends NoteSchema {
|
||||
attachment?: string;
|
||||
system: boolean;
|
||||
noteable_id: number;
|
||||
noteable_type: string;
|
||||
noteable_iid: number;
|
||||
resolvable: boolean;
|
||||
}
|
||||
|
||||
export interface IssueNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, IssueNoteSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
issueIId: number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, IssueNoteSchema>>;
|
||||
|
||||
edit(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
issueIId: number,
|
||||
noteId: number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, IssueNoteSchema>>;
|
||||
|
||||
remove(projectId: string | number, issueId: string | number, noteId: number, options?: Sudo);
|
||||
remove(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
): Promise<void>;
|
||||
|
||||
show(projectId: string | number, issueId: string | number, noteId: number, options?: Sudo);
|
||||
show(
|
||||
projectId: string | number,
|
||||
issueIId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueNoteSchema>>;
|
||||
}
|
||||
|
||||
export class IssueNotes extends ResourceNotes {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class IssueNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', 'issues', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { MergeRequestSchema } from './MergeRequests';
|
||||
import { MilestoneSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,29 +9,98 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
type ProjectOrGroup = { projectId?: string | number } | { groupId?: string | number };
|
||||
type ProjectOrGroup = { projectId?: string | number; groupId?: string | number };
|
||||
|
||||
export class Issues extends BaseService {
|
||||
export interface TimeStatsSchema extends Record<string, unknown> {
|
||||
human_time_estimate?: string;
|
||||
human_total_time_spent?: string;
|
||||
time_estimate?: number;
|
||||
total_time_spent?: number;
|
||||
}
|
||||
|
||||
export interface IssueSchema extends Record<string, unknown> {
|
||||
state: string;
|
||||
description: string;
|
||||
weight?: number;
|
||||
health_status?: string;
|
||||
author: Omit<UserSchema, 'created_at'>;
|
||||
milestone: MilestoneSchema;
|
||||
project_id: number;
|
||||
assignees?: Omit<UserSchema, 'created_at'>[];
|
||||
updated_at: string;
|
||||
closed_at?: string;
|
||||
closed_by?: string;
|
||||
id: number;
|
||||
title: string;
|
||||
created_at: string;
|
||||
moved_to_id?: string;
|
||||
iid: number;
|
||||
labels?: string[];
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
merge_requests_count: number;
|
||||
user_notes_count: number;
|
||||
due_date: string;
|
||||
web_url: string;
|
||||
references: {
|
||||
short: string;
|
||||
relative: string;
|
||||
full: string;
|
||||
};
|
||||
time_stats: TimeStatsSchema;
|
||||
has_tasks: boolean;
|
||||
task_status: string;
|
||||
confidential: boolean;
|
||||
discussion_locked: boolean;
|
||||
_links: {
|
||||
self: string;
|
||||
notes: string;
|
||||
award_emoji: string;
|
||||
project: string;
|
||||
};
|
||||
task_completion_status: {
|
||||
count: number;
|
||||
completed_count: number;
|
||||
};
|
||||
subscribed: boolean;
|
||||
epic?: {
|
||||
id: number;
|
||||
iid: number;
|
||||
title: string;
|
||||
url: string;
|
||||
group_id: number;
|
||||
};
|
||||
}
|
||||
|
||||
export class Issues<C extends boolean = false> extends BaseService<C> {
|
||||
addSpentTime(projectId: string | number, issueIid: number, duration: string, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/add_spent_time`, {
|
||||
duration,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/add_spent_time`,
|
||||
{
|
||||
duration,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
addTimeEstimate(projectId: string | number, issueIid: number, duration: string, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/time_estimate`, {
|
||||
duration,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/time_estimate`,
|
||||
{
|
||||
duration,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
all({ projectId, groupId, ...options }: ProjectOrGroup & PaginatedRequestOptions = {}) {
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (projectId) {
|
||||
url = `projects/${encodeURIComponent(projectId)}/issues`;
|
||||
@ -38,62 +110,77 @@ export class Issues extends BaseService {
|
||||
url = 'issues';
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get<Omit<IssueSchema, 'epic'>[]>()(this, url, options);
|
||||
}
|
||||
|
||||
create(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues`, options);
|
||||
return RequestHelper.post<IssueSchema>()(this, `projects/${pId}/issues`, options);
|
||||
}
|
||||
|
||||
closedBy(projectId: string | number, issueIid: number, options?: BaseRequestOptions) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}/closed_by`, options);
|
||||
return RequestHelper.get<MergeRequestSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/closed_by`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, issueIid: number, options?: BaseRequestOptions) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/issues/${iId}`, options);
|
||||
return RequestHelper.put<IssueSchema>()(this, `projects/${pId}/issues/${iId}`, options);
|
||||
}
|
||||
|
||||
// TODO move
|
||||
link(
|
||||
projectId: string | number,
|
||||
issueIid: number,
|
||||
issueIId: number,
|
||||
targetProjectId: string | number,
|
||||
targetIssueIid: number,
|
||||
targetIssueIId: number,
|
||||
options?: BaseRequestOptions,
|
||||
) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
const [targetpId, targetIid] = [targetProjectId, targetIssueIid].map(encodeURIComponent);
|
||||
const [pId, iIId] = [projectId, issueIId].map(encodeURIComponent);
|
||||
const [targetPId, targetIId] = [targetProjectId, targetIssueIId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/links`, {
|
||||
targetProjectId: targetpId,
|
||||
targetIssueIid: targetIid,
|
||||
return RequestHelper.post()(this, `projects/${pId}/issues/${iIId}/links`, {
|
||||
targetProjectId: targetPId,
|
||||
targetIssueIid: targetIId,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
// TODO move
|
||||
links(projectId: string | number, issueIid: number) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}/links`);
|
||||
return RequestHelper.get()(this, `projects/${pId}/issues/${iId}/links`);
|
||||
}
|
||||
|
||||
participants(projectId: string | number, issueIid: number, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}/participants`, options);
|
||||
return RequestHelper.get<Omit<UserSchema, 'created_at'>>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/participants`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
relatedMergeRequests(projectId: string | number, issueIid: number, options?: BaseRequestOptions) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}/related_merge_requests`, options);
|
||||
return RequestHelper.get<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/related_merge_requests`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO move
|
||||
removeLink(
|
||||
projectId: string | number,
|
||||
issueIid: number,
|
||||
@ -102,7 +189,7 @@ export class Issues extends BaseService {
|
||||
) {
|
||||
const [pId, iId, iLinkId] = [projectId, issueIid, issueLinkId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/issues/${iId}/links/${iLinkId}`, {
|
||||
return RequestHelper.del()(this, `projects/${pId}/issues/${iId}/links/${iLinkId}`, {
|
||||
...options,
|
||||
});
|
||||
}
|
||||
@ -110,42 +197,62 @@ export class Issues extends BaseService {
|
||||
remove(projectId: string | number, issueIid: number, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/issues/${iId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/issues/${iId}`, options);
|
||||
}
|
||||
|
||||
resetSpentTime(projectId: string | number, issueIid: number, options?: BaseRequestOptions) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/reset_spent_time`, options);
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/reset_spent_time`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
resetTimeEstimate(projectId: string | number, issueIid: number, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/reset_time_estimate`, options);
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/reset_time_estimate`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId: string | number, issueIid: number, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}`, options);
|
||||
return RequestHelper.get<IssueSchema>()(this, `projects/${pId}/issues/${iId}`, options);
|
||||
}
|
||||
|
||||
subscribe(projectId: string | number, issueIid: number, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/subscribe`, options);
|
||||
return RequestHelper.post<IssueSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/subscribe`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
timeStats(projectId: string | number, issueIid: number, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/issues/${iId}/time_stats`, options);
|
||||
return RequestHelper.get<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/time_stats`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
unsubscribe(projectId: string | number, issueIid: number, options?: Sudo) {
|
||||
const [pId, iId] = [projectId, issueIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/unsubscribe`, options);
|
||||
return RequestHelper.post<IssueSchema>()(
|
||||
this,
|
||||
`projects/${pId}/issues/${iId}/unsubscribe`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,21 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, BaseRequestOptions } from '../infrastructure';
|
||||
|
||||
type ProjectOrGroup = { projectId?: string | number } | { groupId?: string | number };
|
||||
type ProjectOrGroup = { projectId?: string | number; groupId?: string | number };
|
||||
|
||||
export class IssuesStatistics extends BaseService {
|
||||
export interface StatisticsSchema extends Record<string, unknown> {
|
||||
statistics: {
|
||||
counts: {
|
||||
all: number;
|
||||
closed: number;
|
||||
opened: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export class IssuesStatistics<C extends boolean = false> extends BaseService<C> {
|
||||
all({ projectId, groupId, ...options }: ProjectOrGroup & BaseRequestOptions = {}) {
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (projectId) {
|
||||
url = `projects/${encodeURIComponent(projectId)}/issues_statistics`;
|
||||
@ -15,6 +25,6 @@ export class IssuesStatistics extends BaseService {
|
||||
url = 'issues_statistics';
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get<StatisticsSchema>()(this, url, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,10 @@ import {
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
import { CommitSchemaDefault, CommitSchemaCamelized } from './Commits';
|
||||
import { RunnerSchemaDefault, RunnerSchemaCamelized } from './Runners';
|
||||
import { UserSchemaDefault, UserSchemaCamelized } from './Users';
|
||||
import { PipelineBase } from './Pipelines';
|
||||
import { CommitSchema } from './Commits';
|
||||
import { RunnerSchema } from './Runners';
|
||||
import { UserSchema } from './Users';
|
||||
import { PipelineSchema } from './Pipelines';
|
||||
|
||||
export type JobScope =
|
||||
| 'created'
|
||||
@ -20,24 +20,14 @@ export type JobScope =
|
||||
| 'skipped'
|
||||
| 'manual';
|
||||
|
||||
export interface ArtifactSchemaDefault {
|
||||
export interface ArtifactSchema extends Record<string, unknown> {
|
||||
file_type: string;
|
||||
size: number;
|
||||
filename: string;
|
||||
file_format?: string;
|
||||
}
|
||||
|
||||
export interface ArtifactSchemaCamelized {
|
||||
fileType: string;
|
||||
size: number;
|
||||
filename: string;
|
||||
fileFormat?: string;
|
||||
}
|
||||
|
||||
// As of GitLab v12.6.2
|
||||
export type ArtifactSchema = ArtifactSchemaDefault | ArtifactSchemaCamelized;
|
||||
|
||||
export interface JobSchemaDefault {
|
||||
export interface JobSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
status: string;
|
||||
stage: string;
|
||||
@ -50,53 +40,30 @@ export interface JobSchemaDefault {
|
||||
started_at?: Date;
|
||||
finished_at?: Date;
|
||||
duration?: number;
|
||||
user: UserSchemaDefault;
|
||||
commit: CommitSchemaDefault;
|
||||
pipeline: PipelineBase;
|
||||
user: UserSchema;
|
||||
commit: CommitSchema;
|
||||
pipeline: PipelineSchema;
|
||||
web_url: string;
|
||||
artifacts: ArtifactSchemaDefault[];
|
||||
runner: RunnerSchemaDefault;
|
||||
artifacts: ArtifactSchema[];
|
||||
runner: RunnerSchema;
|
||||
artifacts_expire_at?: Date;
|
||||
tag_list?: string[];
|
||||
}
|
||||
|
||||
export interface JobSchemaCamelized {
|
||||
id: number;
|
||||
status: string;
|
||||
stage: string;
|
||||
name: string;
|
||||
ref: string;
|
||||
tag: boolean;
|
||||
coverage?: string;
|
||||
allowFailure: boolean;
|
||||
createdAt: Date;
|
||||
startedAt?: Date;
|
||||
finishedAt?: Date;
|
||||
duration?: number;
|
||||
user: UserSchemaCamelized;
|
||||
commit: CommitSchemaCamelized;
|
||||
pipeline: PipelineBase;
|
||||
webUrl: string;
|
||||
artifacts: ArtifactSchemaCamelized[];
|
||||
runner: RunnerSchemaCamelized;
|
||||
artifactsExpireAt?: Date;
|
||||
}
|
||||
|
||||
// As of GitLab v12.6.2
|
||||
export type JobSchema = JobSchemaDefault | JobSchemaCamelized;
|
||||
|
||||
export class Jobs extends BaseService {
|
||||
export class Jobs<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs`, options);
|
||||
return RequestHelper.get<JobSchema[]>()(this, `projects/${pId}/jobs`, options);
|
||||
}
|
||||
|
||||
cancel(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/cancel`, options);
|
||||
return RequestHelper.post<JobSchema>()(this, `projects/${pId}/jobs/${jId}/cancel`, options);
|
||||
}
|
||||
|
||||
// TODO move
|
||||
downloadSingleArtifactFile(
|
||||
projectId: string | number,
|
||||
jobId: number,
|
||||
@ -104,15 +71,22 @@ export class Jobs extends BaseService {
|
||||
{ stream = false, ...options }: { stream?: boolean } & BaseRequestOptions = {},
|
||||
) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
const method = stream ? 'stream' : 'get';
|
||||
|
||||
return RequestHelper[method](
|
||||
if (stream) {
|
||||
return RequestHelper.stream(
|
||||
this,
|
||||
`projects/${pId}/jobs/${jId}/artifacts/${artifactPath}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
return RequestHelper.get()(
|
||||
this,
|
||||
`projects/${pId}/jobs/${jId}/artifacts/${artifactPath}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO move
|
||||
downloadSingleArtifactFileFromRef(
|
||||
projectId: string | number,
|
||||
ref: string,
|
||||
@ -121,15 +95,22 @@ export class Jobs extends BaseService {
|
||||
{ stream = false, ...options }: { stream?: boolean } & BaseRequestOptions = {},
|
||||
) {
|
||||
const [pId, rId, name] = [projectId, ref, jobName].map(encodeURIComponent);
|
||||
const method = stream ? 'stream' : 'get';
|
||||
|
||||
return RequestHelper[method](
|
||||
if (stream) {
|
||||
return RequestHelper.stream(
|
||||
this,
|
||||
`projects/${pId}/jobs/artifacts/${rId}/raw/${artifactPath}?job=${name}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
return RequestHelper.get()(
|
||||
this,
|
||||
`projects/${pId}/jobs/artifacts/${rId}/raw/${artifactPath}?job=${name}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO move
|
||||
downloadLatestArtifactFile(
|
||||
projectId: string | number,
|
||||
ref: string,
|
||||
@ -137,9 +118,15 @@ export class Jobs extends BaseService {
|
||||
{ stream = false, ...options }: { stream?: boolean } & BaseRequestOptions = {},
|
||||
) {
|
||||
const [pId, rId, name] = [projectId, ref, jobName].map(encodeURIComponent);
|
||||
const method = stream ? 'stream' : 'get';
|
||||
|
||||
return RequestHelper[method](
|
||||
if (stream) {
|
||||
return RequestHelper.stream(
|
||||
this,
|
||||
`projects/${pId}/jobs/artifacts/${rId}/download?job=${name}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
return RequestHelper.get()(
|
||||
this,
|
||||
`projects/${pId}/jobs/artifacts/${rId}/download?job=${name}`,
|
||||
options,
|
||||
@ -149,43 +136,45 @@ export class Jobs extends BaseService {
|
||||
downloadTraceFile(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs/${jId}/trace`, options);
|
||||
return RequestHelper.get()(this, `projects/${pId}/jobs/${jId}/trace`, options);
|
||||
}
|
||||
|
||||
erase(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/erase`, options);
|
||||
return RequestHelper.post<JobSchema>()(this, `projects/${pId}/jobs/${jId}/erase`, options);
|
||||
}
|
||||
|
||||
// TODO move
|
||||
eraseArtifacts(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/jobs/${jId}/artifacts`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/jobs/${jId}/artifacts`, options);
|
||||
}
|
||||
|
||||
// TODO move
|
||||
keepArtifacts(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/artifacts/keep`, options);
|
||||
return RequestHelper.post()(this, `projects/${pId}/jobs/${jId}/artifacts/keep`, options);
|
||||
}
|
||||
|
||||
play(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/play`, options);
|
||||
return RequestHelper.post<JobSchema>()(this, `projects/${pId}/jobs/${jId}/play`, options);
|
||||
}
|
||||
|
||||
retry(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/jobs/${jId}/retry`, options);
|
||||
return RequestHelper.post<JobSchema>()(this, `projects/${pId}/jobs/${jId}/retry`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, jobId: number, options?: Sudo) {
|
||||
const [pId, jId] = [projectId, jobId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/jobs/${jId}`, options);
|
||||
return RequestHelper.get<JobSchema>()(this, `projects/${pId}/jobs/${jId}`, options);
|
||||
}
|
||||
|
||||
showPipelineJobs(
|
||||
@ -195,6 +184,6 @@ export class Jobs extends BaseService {
|
||||
) {
|
||||
const [pId, ppId] = [projectId, pipelineId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines/${ppId}/jobs`, options);
|
||||
return RequestHelper.get<JobSchema>()(this, `projects/${pId}/pipelines/${ppId}/jobs`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,20 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserExtendedSchema } from './Users';
|
||||
import { RequestHelper, Sudo } from '../infrastructure';
|
||||
|
||||
export class Keys extends BaseService {
|
||||
export interface KeySchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
title: string;
|
||||
key: string;
|
||||
created_at: string;
|
||||
expires_at: string;
|
||||
user: UserExtendedSchema;
|
||||
}
|
||||
|
||||
export class Keys<C extends boolean = false> extends BaseService<C> {
|
||||
show(keyId: string, options?: Sudo) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.get(this, `keys/${kId}`, options);
|
||||
return RequestHelper.get<KeySchema>()(this, `keys/${kId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,49 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceLabels } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
CamelizedRecord,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
import { ResourceLabels, LabelSchema } from '../templates';
|
||||
|
||||
export interface Labels extends ResourceLabels {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface Labels<C extends boolean = false> extends ResourceLabels<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
labelName: string,
|
||||
color: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
|
||||
edit(projectId: string | number, labelName: string, options?: BaseRequestOptions);
|
||||
edit(
|
||||
projectId: string | number,
|
||||
labelId: number | string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
|
||||
remove(projectId: string | number, labelName: string, options?: Sudo);
|
||||
remove(projectId: string | number, labelId: number | string, options?: Sudo): Promise<void>;
|
||||
|
||||
subscribe(projectId: string | number, labelId: number, options?: Sudo);
|
||||
subscribe(
|
||||
projectId: string | number,
|
||||
labelId: number | string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
|
||||
unsubscribe(projectId: string | number, labelId: number, options?: Sudo);
|
||||
unsubscribe(
|
||||
projectId: string | number,
|
||||
labelId: number | string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, LabelSchema>>;
|
||||
}
|
||||
|
||||
export class Labels extends ResourceLabels {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class Labels<C extends boolean = false> extends ResourceLabels<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceTemplates } from '../templates';
|
||||
|
||||
export class LicenceTemplates extends ResourceTemplates {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
super('licences', options);
|
||||
}
|
||||
}
|
||||
@ -1,22 +1,43 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, Sudo } from '../infrastructure';
|
||||
|
||||
export class License extends BaseService {
|
||||
export interface LicenseSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
plan: string;
|
||||
created_at: string;
|
||||
starts_at: string;
|
||||
expires_at: string;
|
||||
historical_max: number;
|
||||
maximum_user_count: number;
|
||||
expired: boolean;
|
||||
overage: number;
|
||||
user_limit: number;
|
||||
active_users: number;
|
||||
licensee: {
|
||||
Name: string;
|
||||
};
|
||||
add_ons: {
|
||||
GitLab_FileLocks: number;
|
||||
GitLab_Auditor_User: number;
|
||||
};
|
||||
}
|
||||
|
||||
export class License<C extends boolean = false> extends BaseService<C> {
|
||||
add(license: string, options?: Sudo) {
|
||||
return RequestHelper.post(this, 'license', { license, ...options });
|
||||
return RequestHelper.post<LicenseSchema>()(this, 'license', { license, ...options });
|
||||
}
|
||||
|
||||
all(options?: Sudo) {
|
||||
return RequestHelper.get(this, 'licenses', options);
|
||||
return RequestHelper.get<LicenseSchema[]>()(this, 'licenses', options);
|
||||
}
|
||||
|
||||
show(options?: Sudo) {
|
||||
return RequestHelper.get(this, 'license', options);
|
||||
return RequestHelper.get<LicenseSchema>()(this, 'license', options);
|
||||
}
|
||||
|
||||
remove(licenceId: number, options?: Sudo) {
|
||||
const lId = encodeURIComponent(licenceId);
|
||||
|
||||
return RequestHelper.del(this, `license/${lId}`, options);
|
||||
return RequestHelper.del<LicenseSchema>()(this, `license/${lId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
29
packages/gitbeaker-core/src/services/LicenseTemplates.ts
Normal file
29
packages/gitbeaker-core/src/services/LicenseTemplates.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceTemplates } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export interface LicenseTemplateSchema extends Record<string, unknown> {
|
||||
key: string;
|
||||
name: string;
|
||||
nickname?: string;
|
||||
featured: boolean;
|
||||
html_url: string;
|
||||
source_url: string;
|
||||
description: string;
|
||||
conditions?: string[];
|
||||
permissions?: string[];
|
||||
limitations?: string[];
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface LicenseTemplates<C extends boolean = false> extends ResourceTemplates<C> {
|
||||
all(options?: PaginatedRequestOptions): Promise<CamelizedRecord<C, LicenseTemplateSchema>[]>;
|
||||
show(key: string | number, options?: Sudo): Promise<CamelizedRecord<C, LicenseTemplateSchema>>;
|
||||
}
|
||||
|
||||
export class LicenseTemplates<C extends boolean = false> extends ResourceTemplates<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('Licenses', options);
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,14 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, Sudo } from '../infrastructure';
|
||||
|
||||
export class Lint extends BaseService {
|
||||
export interface LintSchema extends Record<string, unknown> {
|
||||
status: string;
|
||||
errors?: string[];
|
||||
warnings?: string[];
|
||||
}
|
||||
|
||||
export class Lint<C extends boolean = false> extends BaseService<C> {
|
||||
lint(content: string, options?: Sudo) {
|
||||
return RequestHelper.post(this, 'ci/lint', { content, ...options });
|
||||
return RequestHelper.post<LintSchema>()(this, 'ci/lint', { content, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, Sudo } from '../infrastructure';
|
||||
|
||||
export class Markdown extends BaseService {
|
||||
export interface MarkdownSchema extends Record<string, unknown> {
|
||||
html: string;
|
||||
}
|
||||
|
||||
export class Markdown<C extends boolean = false> extends BaseService<C> {
|
||||
render(text: string, options?: { gfm?: string; project?: string | number } & Sudo) {
|
||||
return RequestHelper.post(this, 'markdown', { text, ...options });
|
||||
return RequestHelper.post<MarkdownSchema>()(this, 'markdown', { text, ...options });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,25 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, RequestHelper, Sudo } from '../infrastructure';
|
||||
|
||||
// TODO: This one is has changed quite a bit, requires a deeper look
|
||||
// https://docs.gitlab.com/ee/api/merge_request_approvals.html#project-level-mr-approvals
|
||||
|
||||
export interface MergeRequestApprovalSchema extends Record<string, unknown> {
|
||||
approvals_before_merge: number;
|
||||
reset_approvals_on_push: boolean;
|
||||
disable_overriding_approvers_per_merge_request: boolean;
|
||||
merge_requests_author_approval: boolean;
|
||||
merge_requests_disable_committers_approval: boolean;
|
||||
require_password_to_approve: boolean;
|
||||
}
|
||||
|
||||
export type ApprovalRulesRequestOptions = {
|
||||
userIds?: number[];
|
||||
groupIds?: number[];
|
||||
protectedBranchIds?: number[];
|
||||
};
|
||||
|
||||
export class MergeRequestApprovals extends BaseService {
|
||||
export class MergeRequestApprovals<C extends boolean = false> extends BaseService<C> {
|
||||
addApprovalRule(
|
||||
projectId: string | number,
|
||||
name: string,
|
||||
@ -19,7 +31,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (mergerequestIid) {
|
||||
const mIid = encodeURIComponent(mergerequestIid);
|
||||
@ -28,7 +40,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
url = `projects/${pId}/approval_rules`;
|
||||
}
|
||||
|
||||
return RequestHelper.post(this, url, { name, approvalsRequired, ...options });
|
||||
return RequestHelper.post()(this, url, { name, approvalsRequired, ...options });
|
||||
}
|
||||
|
||||
approvalRules(
|
||||
@ -37,7 +49,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (mergerequestIid) {
|
||||
const mIid = encodeURIComponent(mergerequestIid);
|
||||
@ -45,7 +57,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
} else {
|
||||
url = `projects/${pId}/approval_rules`;
|
||||
}
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get()(this, url, options);
|
||||
}
|
||||
|
||||
approvals(
|
||||
@ -54,7 +66,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (mergerequestIid) {
|
||||
const mIid = encodeURIComponent(mergerequestIid);
|
||||
@ -63,7 +75,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
url = `projects/${pId}/approvals`;
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get()(this, url, options);
|
||||
}
|
||||
|
||||
approvalState(
|
||||
@ -73,7 +85,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
return RequestHelper.get()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/approval_state`,
|
||||
options,
|
||||
@ -87,7 +99,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mIid}/approve`, options);
|
||||
return RequestHelper.post()(this, `projects/${pId}/merge_requests/${mIid}/approve`, options);
|
||||
}
|
||||
|
||||
approvers(
|
||||
@ -98,7 +110,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (mergerequestIid) {
|
||||
const mIid = encodeURIComponent(mergerequestIid);
|
||||
@ -107,7 +119,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
url = `projects/${pId}/approvers`;
|
||||
}
|
||||
|
||||
return RequestHelper.put(this, url, { approverIds, approverGroupIds, ...options });
|
||||
return RequestHelper.put()(this, url, { approverIds, approverGroupIds, ...options });
|
||||
}
|
||||
|
||||
editApprovalRule(
|
||||
@ -122,7 +134,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const [pId, aId] = [projectId, approvalRuleId].map(encodeURIComponent);
|
||||
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (mergerequestIid) {
|
||||
const mIid = encodeURIComponent(mergerequestIid);
|
||||
@ -131,7 +143,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
url = `projects/${pId}/approval_rules/${aId}`;
|
||||
}
|
||||
|
||||
return RequestHelper.put(this, url, { name, approvalsRequired, ...options });
|
||||
return RequestHelper.put()(this, url, { name, approvalsRequired, ...options });
|
||||
}
|
||||
|
||||
editApprovals(
|
||||
@ -140,7 +152,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (mergerequestIid) {
|
||||
const mIid = encodeURIComponent(mergerequestIid);
|
||||
@ -149,7 +161,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
url = `projects/${pId}/approvals`;
|
||||
}
|
||||
|
||||
return RequestHelper.post(this, url, options);
|
||||
return RequestHelper.post()(this, url, options);
|
||||
}
|
||||
|
||||
removeApprovalRule(
|
||||
@ -159,7 +171,7 @@ export class MergeRequestApprovals extends BaseService {
|
||||
) {
|
||||
const [pId, aId] = [projectId, approvalRuleId].map(encodeURIComponent);
|
||||
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (mergerequestIid) {
|
||||
const mIid = encodeURIComponent(mergerequestIid);
|
||||
@ -168,12 +180,12 @@ export class MergeRequestApprovals extends BaseService {
|
||||
url = `projects/${pId}/approval_rules/${aId}`;
|
||||
}
|
||||
|
||||
return RequestHelper.del(this, url, options);
|
||||
return RequestHelper.del()(this, url, options);
|
||||
}
|
||||
|
||||
unapprove(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mIid}/unapprove`, options);
|
||||
return RequestHelper.post()(this, `projects/${pId}/merge_requests/${mIid}/unapprove`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +1,39 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceAwardEmojis } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceAwardEmojis, AwardEmojiSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export interface MergeRequestAwardEmojis extends ResourceAwardEmojis {
|
||||
export interface MergeRequestAwardEmojis<C extends boolean = false> extends ResourceAwardEmojis<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
noteId: number,
|
||||
mergerequestIId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>[]>;
|
||||
|
||||
award(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
noteId: number,
|
||||
mergerequestIId: number,
|
||||
name: string,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
|
||||
remove(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
mergerequestIId: number,
|
||||
awardId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
mergerequestIId: number,
|
||||
awardId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
}
|
||||
|
||||
export class MergeRequestAwardEmojis extends ResourceAwardEmojis {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class MergeRequestAwardEmojis<C extends boolean = false> extends ResourceAwardEmojis<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('merge_requests', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,57 +1,63 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceDiscussions, DiscussionSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface MergeRequestDiscussions extends ResourceDiscussions {
|
||||
export interface MergeRequestDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
addNote(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
discussionId: string | number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
all(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
issueId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
editNote(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
discussionId: string | number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
removeNote(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
discussionId: string | number,
|
||||
issueId: string | number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
mergerequestId: string | number,
|
||||
discussionId: string | number,
|
||||
discussionId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
}
|
||||
|
||||
export class MergeRequestDiscussions extends ResourceDiscussions {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class MergeRequestDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', 'merge_requests', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,46 +1,61 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceNotes } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceNotes, NoteSchema } from '../templates';
|
||||
import {
|
||||
PaginatedRequestOptions,
|
||||
BaseRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface MergeRequestNotes extends ResourceNotes {
|
||||
export interface MergeRequestNoteSchema extends NoteSchema {
|
||||
attachment?: string;
|
||||
system: boolean;
|
||||
noteable_id: number;
|
||||
noteable_type: string;
|
||||
noteable_iid: number;
|
||||
resolvable: boolean;
|
||||
}
|
||||
|
||||
export interface MergeRequestNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
mergerequestIid: string | number,
|
||||
mergerequestId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, MergeRequestNoteSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
mergerequestIid: string | number,
|
||||
mergerequestId: string | number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, MergeRequestNoteSchema>>;
|
||||
|
||||
edit(
|
||||
projectId: string | number,
|
||||
mergerequestIid: string | number,
|
||||
mergerequestId: string | number,
|
||||
noteId: number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, MergeRequestNoteSchema>>;
|
||||
|
||||
remove(
|
||||
projectId: string | number,
|
||||
mergerequestIid: string | number,
|
||||
mergerequestId: string | number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
mergerequestIid: string | number,
|
||||
mergerequestIdepicId: string | number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, MergeRequestNoteSchema>>;
|
||||
}
|
||||
|
||||
export class MergeRequestNotes extends ResourceNotes {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class MergeRequestNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', 'merge_requests', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { IssueSchema } from './Issues';
|
||||
import { CommitSchema, CommitDiffSchema } from './Commits';
|
||||
import { MilestoneSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -72,7 +76,96 @@ export interface AllMergeRequestsOptions {
|
||||
wip?: string;
|
||||
}
|
||||
|
||||
export class MergeRequests extends BaseService {
|
||||
// Response Schemas
|
||||
export interface ReferenceSchema {
|
||||
short: string;
|
||||
relative: string;
|
||||
full: string;
|
||||
}
|
||||
|
||||
export interface TaskCompletionStatusSchema {
|
||||
count: number;
|
||||
completed_count: number;
|
||||
}
|
||||
|
||||
export interface PipelineSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
sha: string;
|
||||
ref: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface TimeStatsSchema extends Record<string, unknown> {
|
||||
time_estimate: number;
|
||||
total_time_spent: number;
|
||||
human_time_estimate: string;
|
||||
human_total_time_spent: string;
|
||||
}
|
||||
|
||||
export interface RebaseSchema extends Record<string, unknown> {
|
||||
rebase_in_progress?: boolean;
|
||||
merge_error?: string;
|
||||
}
|
||||
|
||||
export interface DiffSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
head_commit_sha: string;
|
||||
base_commit_sha: string;
|
||||
start_commit_sha: string;
|
||||
created_at: string;
|
||||
merge_request_id: number;
|
||||
state: string;
|
||||
real_size: string;
|
||||
commits?: CommitSchema[];
|
||||
diffs?: CommitDiffSchema[];
|
||||
}
|
||||
|
||||
export interface MergeRequestSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
iid: number;
|
||||
project_id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
state: string;
|
||||
merged_by: Omit<UserSchema, 'created_at'>;
|
||||
merged_at: string;
|
||||
closed_by?: string;
|
||||
closed_at?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
target_branch: string;
|
||||
source_branch: string;
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
author: Omit<UserSchema, 'created_at'>;
|
||||
assignee: Omit<UserSchema, 'created_at'>;
|
||||
assignees?: Omit<UserSchema, 'created_at'>[];
|
||||
reviewers?: Omit<UserSchema, 'created_at'>[];
|
||||
source_project_id: number;
|
||||
target_project_id: number;
|
||||
labels?: string[];
|
||||
work_in_progress: boolean;
|
||||
milestone: MilestoneSchema;
|
||||
merge_when_pipeline_succeeds: boolean;
|
||||
merge_status: string;
|
||||
sha: string;
|
||||
merge_commit_sha?: string;
|
||||
squash_commit_sha?: string;
|
||||
user_notes_count: number;
|
||||
discussion_locked?: string;
|
||||
should_remove_source_branch: boolean;
|
||||
force_remove_source_branch: boolean;
|
||||
web_url: string;
|
||||
references: ReferenceSchema;
|
||||
time_stats: TimeStatsSchema;
|
||||
squash: boolean;
|
||||
task_completion_status: TaskCompletionStatusSchema;
|
||||
has_conflicts: boolean;
|
||||
blocking_discussions_resolved: boolean;
|
||||
changes?: CommitDiffSchema[];
|
||||
}
|
||||
|
||||
export class MergeRequests<C extends boolean = false> extends BaseService<C> {
|
||||
accept(
|
||||
projectId: string | number,
|
||||
mergerequestIid: number,
|
||||
@ -80,7 +173,11 @@ export class MergeRequests extends BaseService {
|
||||
) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/merge_requests/${mIid}/merge`, options);
|
||||
return RequestHelper.put<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/merge`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
addSpentTime(
|
||||
@ -91,10 +188,14 @@ export class MergeRequests extends BaseService {
|
||||
) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mIid}/add_spent_time`, {
|
||||
duration,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/add_spent_time`,
|
||||
{
|
||||
duration,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
addTimeEstimate(
|
||||
@ -105,20 +206,23 @@ export class MergeRequests extends BaseService {
|
||||
) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mIid}/time_estimate`, {
|
||||
duration,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/time_estimate`,
|
||||
{
|
||||
duration,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
all({
|
||||
projectId,
|
||||
groupId,
|
||||
...options
|
||||
}: ({ projectId?: string | number } | { groupId?: string | number }) &
|
||||
AllMergeRequestsOptions &
|
||||
}: { projectId?: string | number; groupId?: string | number } & AllMergeRequestsOptions &
|
||||
PaginatedRequestOptions = {}) {
|
||||
let url;
|
||||
let url: string;
|
||||
|
||||
if (projectId) {
|
||||
url = `projects/${encodeURIComponent(projectId)}/merge_requests`;
|
||||
@ -128,13 +232,13 @@ export class MergeRequests extends BaseService {
|
||||
url = 'merge_requests';
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get<MergeRequestSchema[]>()(this, url, options);
|
||||
}
|
||||
|
||||
cancelOnPipelineSucess(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
return RequestHelper.put<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/cancel_merge_when_pipeline_succeeds`,
|
||||
options,
|
||||
@ -144,19 +248,31 @@ export class MergeRequests extends BaseService {
|
||||
changes(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}/changes`, options);
|
||||
return RequestHelper.get<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/changes`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
closesIssues(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}/closes_issues`, options);
|
||||
return RequestHelper.get<IssueSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/closes_issues`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
commits(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}/commits`, options);
|
||||
return RequestHelper.get<CommitSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/commits`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
create(
|
||||
@ -168,8 +284,7 @@ export class MergeRequests extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests`, {
|
||||
id: pId,
|
||||
return RequestHelper.post<MergeRequestSchema>()(this, `projects/${pId}/merge_requests`, {
|
||||
sourceBranch,
|
||||
targetBranch,
|
||||
title,
|
||||
@ -184,37 +299,53 @@ export class MergeRequests extends BaseService {
|
||||
) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/merge_requests/${mIid}`, options);
|
||||
return RequestHelper.put<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
participants(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}/participants`, options);
|
||||
return RequestHelper.get<Omit<UserSchema, 'created_at'>[]>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/participants`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
pipelines(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}/pipelines`, options);
|
||||
return RequestHelper.get<PipelineSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/pipelines`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
rebase(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/merge_requests/${mIid}/rebase`, options);
|
||||
return RequestHelper.put<RebaseSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/rebase`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/merge_requests/${mIid}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/merge_requests/${mIid}`, options);
|
||||
}
|
||||
|
||||
resetSpentTime(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/reset_spent_time`,
|
||||
options,
|
||||
@ -224,7 +355,7 @@ export class MergeRequests extends BaseService {
|
||||
resetTimeEstimate(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
return RequestHelper.post<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/reset_time_estimate`,
|
||||
options,
|
||||
@ -238,25 +369,37 @@ export class MergeRequests extends BaseService {
|
||||
) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}`, options);
|
||||
return RequestHelper.get<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
subscribe(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mIid}/subscribe`, options);
|
||||
return RequestHelper.post<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/subscribe`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
timeStats(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}/time_stats`, options);
|
||||
return RequestHelper.get<TimeStatsSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/time_stats`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
version(projectId: string | number, mergerequestIid: number, versionId: number, options?: Sudo) {
|
||||
const [pId, mIid, vId] = [projectId, mergerequestIid, versionId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
return RequestHelper.get<DiffSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/versions/${vId}`,
|
||||
options,
|
||||
@ -266,12 +409,20 @@ export class MergeRequests extends BaseService {
|
||||
versions(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mIid}/versions`, options);
|
||||
return RequestHelper.get<DiffSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/versions`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
unsubscribe(projectId: string | number, mergerequestIid: number, options?: Sudo) {
|
||||
const [pId, mIid] = [projectId, mergerequestIid].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/merge_requests/${mIid}/unsubscribe`, options);
|
||||
return RequestHelper.post<MergeRequestSchema>()(
|
||||
this,
|
||||
`projects/${pId}/merge_requests/${mIid}/unsubscribe`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,30 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
|
||||
export class Namespaces extends BaseService {
|
||||
export interface NamespaceSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
kind: string;
|
||||
full_path: string;
|
||||
parent_id?: number;
|
||||
avatar_url: string;
|
||||
web_url: string;
|
||||
billable_members_count: number;
|
||||
plan: string;
|
||||
trial_ends_on?: string;
|
||||
trial: boolean;
|
||||
}
|
||||
|
||||
// TODO: Add missing functions
|
||||
export class Namespaces<C extends boolean = false> extends BaseService<C> {
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'namespaces', options);
|
||||
return RequestHelper.get<NamespaceSchema[]>()(this, 'namespaces', options);
|
||||
}
|
||||
|
||||
show(namespaceId: string | number, options?: { search?: string } & Sudo) {
|
||||
const nId = encodeURIComponent(namespaceId);
|
||||
|
||||
return RequestHelper.get(this, `namespaces/${nId}`, options);
|
||||
return RequestHelper.get<NamespaceSchema>()(this, `namespaces/${nId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, RequestHelper } from '../infrastructure';
|
||||
|
||||
type NotificationSettingLevel =
|
||||
// TODO: Add missing functions
|
||||
|
||||
export type NotificationSettingLevel =
|
||||
| 'disabled'
|
||||
| 'participating'
|
||||
| 'watch'
|
||||
@ -9,6 +11,11 @@ type NotificationSettingLevel =
|
||||
| 'mention'
|
||||
| 'custom';
|
||||
|
||||
export interface NotificationSettingSchema extends Record<string, unknown> {
|
||||
level: NotificationSettingLevel;
|
||||
notification_email: string;
|
||||
}
|
||||
|
||||
type ProjectOrGroup = { projectId?: string | number } | { groupId?: string | number };
|
||||
|
||||
function url({ projectId, groupId }) {
|
||||
@ -23,9 +30,13 @@ function url({ projectId, groupId }) {
|
||||
return `${uri}notification_settings`;
|
||||
}
|
||||
|
||||
export class NotificationSettings extends BaseService {
|
||||
export class NotificationSettings<C extends boolean = false> extends BaseService<C> {
|
||||
all({ projectId, groupId, ...options }: ProjectOrGroup & PaginatedRequestOptions = {}) {
|
||||
return RequestHelper.get(this, url({ groupId, projectId }), options);
|
||||
return RequestHelper.get<NotificationSettingSchema[]>()(
|
||||
this,
|
||||
url({ groupId, projectId }),
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
edit({
|
||||
@ -33,6 +44,10 @@ export class NotificationSettings extends BaseService {
|
||||
groupId,
|
||||
...options
|
||||
}: { level?: NotificationSettingLevel } & ProjectOrGroup & BaseRequestOptions = {}) {
|
||||
return RequestHelper.put(this, url({ groupId, projectId }), options);
|
||||
return RequestHelper.put<NotificationSettingSchema>()(
|
||||
this,
|
||||
url({ groupId, projectId }),
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,54 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { PipelineSchema } from './Pipelines';
|
||||
import { PaginatedRequestOptions, RequestHelper, Sudo } from '../infrastructure';
|
||||
|
||||
export class Packages extends BaseService {
|
||||
// TODO: Add group support
|
||||
|
||||
export interface PackageSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
version: string;
|
||||
package_type: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface PackageFileSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
package_id: number;
|
||||
created_at: string;
|
||||
file_name: string;
|
||||
size: number;
|
||||
file_md5: string;
|
||||
file_sha1: string;
|
||||
pipelines?: PipelineSchema[];
|
||||
}
|
||||
|
||||
export class Packages<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/packages`, options);
|
||||
return RequestHelper.get<PackageSchema[]>()(this, `projects/${pId}/packages`, options);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, packageId: number, options?: Sudo) {
|
||||
const [pId, pkId] = [projectId, packageId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/packages/${pkId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/packages/${pkId}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, packageId: number, options?: Sudo) {
|
||||
const [pId, pkId] = [projectId, packageId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/packages/${pkId}`, options);
|
||||
return RequestHelper.get<PackageSchema>()(this, `projects/${pId}/packages/${pkId}`, options);
|
||||
}
|
||||
|
||||
showFiles(projectId: string | number, packageId: number, options?: Sudo) {
|
||||
const [pId, pkId] = [projectId, packageId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/packages/${pkId}/package_files`, options);
|
||||
return RequestHelper.get<PackageFileSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/packages/${pkId}/package_files`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,34 +6,58 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class PagesDomains extends BaseService {
|
||||
export interface PagesDomainSchema extends Record<string, unknown> {
|
||||
domain: string;
|
||||
url: string;
|
||||
project_id: number;
|
||||
auto_ssl_enabled: boolean;
|
||||
certificate: {
|
||||
expired: boolean;
|
||||
expiration: string;
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Add missing functions
|
||||
|
||||
export class PagesDomains<C extends boolean = false> extends BaseService<C> {
|
||||
all({ projectId, ...options }: { projectId?: string | number } & PaginatedRequestOptions = {}) {
|
||||
const url = projectId ? `projects/${encodeURIComponent(projectId)}/` : '';
|
||||
|
||||
return RequestHelper.get(this, `${url}pages/domains`, options);
|
||||
return RequestHelper.get<PagesDomainSchema[]>()(this, `${url}pages/domains`, options);
|
||||
}
|
||||
|
||||
create(projectId: string | number, domain: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pages/domains`, { domain, ...options });
|
||||
return RequestHelper.post<PagesDomainSchema>()(this, `projects/${pId}/pages/domains`, {
|
||||
domain,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId: string | number, domain: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/pages/domains/${domain}`, options);
|
||||
return RequestHelper.put<PagesDomainSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pages/domains/${domain}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId: string | number, domain: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pages/domains/${domain}`, options);
|
||||
return RequestHelper.get<PagesDomainSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pages/domains/${domain}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, domain: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/pages/domains/${domain}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/pages/domains/${domain}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,22 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { PipelineVariableSchema } from './Pipelines';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, RequestHelper } from '../infrastructure';
|
||||
|
||||
export class PipelineScheduleVariables extends BaseService {
|
||||
export class PipelineScheduleVariables<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, pipelineScheduleId: number, options?: PaginatedRequestOptions) {
|
||||
const [pId, psId] = [projectId, pipelineScheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipeline_schedules/${psId}/variables`, options);
|
||||
return RequestHelper.get<PipelineVariableSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${psId}/variables`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
create(projectId: string | number, pipelineScheduleId: number, options?: BaseRequestOptions) {
|
||||
const [pId, psId] = [projectId, pipelineScheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
return RequestHelper.post<PipelineVariableSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${psId}/variables`,
|
||||
options,
|
||||
@ -26,7 +31,7 @@ export class PipelineScheduleVariables extends BaseService {
|
||||
) {
|
||||
const [pId, psId, kId] = [projectId, pipelineScheduleId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(
|
||||
return RequestHelper.put<PipelineVariableSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${psId}/variables/${kId}`,
|
||||
options,
|
||||
@ -41,7 +46,7 @@ export class PipelineScheduleVariables extends BaseService {
|
||||
) {
|
||||
const [pId, psId, kId] = [projectId, pipelineScheduleId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(
|
||||
return RequestHelper.get<PipelineVariableSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${psId}/variables/${kId}`,
|
||||
options,
|
||||
@ -56,7 +61,7 @@ export class PipelineScheduleVariables extends BaseService {
|
||||
) {
|
||||
const [pId, psId, kId] = [projectId, pipelineScheduleId, keyId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(
|
||||
return RequestHelper.del<PipelineVariableSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${psId}/variables/${kId}`,
|
||||
options,
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { PipelineSchema, PipelineVariableSchema } from './Pipelines';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,11 +8,32 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class PipelineSchedules extends BaseService {
|
||||
export interface PipelineScheduleSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
description: string;
|
||||
ref: string;
|
||||
cron: string;
|
||||
cron_timezone: string;
|
||||
next_run_at: string;
|
||||
active: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
owner: Pick<UserSchema, 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url'>;
|
||||
}
|
||||
|
||||
export interface PipelineScheduleExtendedSchema extends PipelineScheduleSchema {
|
||||
last_pipeline: Pick<PipelineSchema, 'id' | 'sha' | 'ref' | 'status'>;
|
||||
}
|
||||
|
||||
export class PipelineSchedules<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipeline_schedules`, options);
|
||||
return RequestHelper.get<PipelineScheduleSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
create(
|
||||
@ -22,36 +45,52 @@ export class PipelineSchedules extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipeline_schedules`, {
|
||||
description,
|
||||
ref,
|
||||
cron,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<PipelineScheduleSchema & { variables?: PipelineVariableSchema[] }>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules`,
|
||||
{
|
||||
description,
|
||||
ref,
|
||||
cron,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, scheduleId: number, options?: BaseRequestOptions) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/pipeline_schedules/${sId}`, options);
|
||||
return RequestHelper.put<PipelineScheduleExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${sId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, scheduleId: number, options?: Sudo) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/pipeline_schedules/${sId}`, options);
|
||||
return RequestHelper.del<PipelineScheduleExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${sId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId: string | number, scheduleId: number, options?: Sudo) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipeline_schedules/${sId}`, options);
|
||||
return RequestHelper.get<PipelineScheduleExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${sId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
takeOwnership(projectId: string | number, scheduleId: number, options?: Sudo) {
|
||||
const [pId, sId] = [projectId, scheduleId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(
|
||||
return RequestHelper.post<PipelineScheduleExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipeline_schedules/${sId}/take_ownership`,
|
||||
options,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -19,68 +20,97 @@ export type PipelineStatus =
|
||||
| 'manual'
|
||||
| 'scheduled';
|
||||
|
||||
export interface PipelineBase {
|
||||
export interface PipelineSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
sha: string;
|
||||
ref: string;
|
||||
status: PipelineStatus;
|
||||
}
|
||||
|
||||
export interface PipelineSchemaDefault extends PipelineBase {
|
||||
created_at: Date;
|
||||
updated_at: Date;
|
||||
ref: string;
|
||||
sha: string;
|
||||
web_url: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
user: Pick<UserSchema, 'name' | 'avatar_url'>;
|
||||
}
|
||||
|
||||
export interface PipelineSchemaCamelized extends PipelineBase {
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
webUrl: string;
|
||||
export interface PipelineExtendedSchema extends PipelineSchema {
|
||||
project_id: number;
|
||||
before_sha: string;
|
||||
tag: boolean;
|
||||
yaml_errors?: string;
|
||||
user: Pick<UserSchema, 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url'>;
|
||||
started_at?: string;
|
||||
finished_at: string;
|
||||
committed_at?: string;
|
||||
duration?: string;
|
||||
coverage?: string;
|
||||
}
|
||||
|
||||
// As of GitLab v12.6.2
|
||||
export type PipelineSchema = PipelineSchemaDefault | PipelineSchemaCamelized;
|
||||
export interface PipelineVariableSchema extends Record<string, unknown> {
|
||||
key: string;
|
||||
variable_type?: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export class Pipelines extends BaseService {
|
||||
// TODO: Add missing function
|
||||
|
||||
export class Pipelines<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines`, options);
|
||||
return RequestHelper.get<PipelineSchema[]>()(this, `projects/${pId}/pipelines`, options);
|
||||
}
|
||||
|
||||
create(projectId: string | number, ref: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipeline`, { ref, ...options });
|
||||
return RequestHelper.post<PipelineSchema>()(this, `projects/${pId}/pipeline`, {
|
||||
ref,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
delete(projectId: string | number, pipelineId: number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/pipelines/${pipelineId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/pipelines/${pipelineId}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, pipelineId: number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines/${pipelineId}`, options);
|
||||
return RequestHelper.get<PipelineSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipelines/${pipelineId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
retry(projectId: string | number, pipelineId: number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipelines/${pipelineId}/retry`, options);
|
||||
return RequestHelper.post<PipelineExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipelines/${pipelineId}/retry`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
cancel(projectId: string | number, pipelineId: number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/pipelines/${pipelineId}/cancel`, options);
|
||||
return RequestHelper.post<PipelineExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/pipelines/${pipelineId}/cancel`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
allVariables(projectId: string | number, pipelineId: number, options?: PaginatedRequestOptions) {
|
||||
const [pId, pipeId] = [projectId, pipelineId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/pipelines/${pipeId}/variables`, options);
|
||||
return RequestHelper.get<PipelineVariableSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/pipelines/${pipeId}/variables`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,24 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceAccessRequests } from '../templates';
|
||||
import { ResourceAccessRequests, AccessRequestSchema, AccessLevel } from '../templates';
|
||||
import { Sudo, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export class ProjectAccessRequests extends ResourceAccessRequests {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export interface GroupAccessRequests<C extends boolean = false> extends ResourceAccessRequests<C> {
|
||||
all(projectId: string | number): Promise<CamelizedRecord<C, AccessRequestSchema>[]>;
|
||||
|
||||
request(projectId: string | number): Promise<CamelizedRecord<C, AccessRequestSchema>>;
|
||||
|
||||
approve(
|
||||
projectId: string | number,
|
||||
userId: number,
|
||||
options?: { accessLevel?: AccessLevel } & Sudo,
|
||||
): Promise<CamelizedRecord<C, AccessRequestSchema>>;
|
||||
|
||||
deny(projectId: string | number, userId: number): Promise<void>;
|
||||
}
|
||||
|
||||
export class ProjectAccessRequests<C extends boolean = false> extends ResourceAccessRequests<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,23 +1,52 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceBadges } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceBadges, BadgeSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface ProjectBadges extends ResourceBadges {
|
||||
add(projectId: string | number, options?: BaseRequestOptions);
|
||||
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions);
|
||||
|
||||
edit(projectId: string | number, badgeId: number, options?: BaseRequestOptions);
|
||||
|
||||
preview(projectId: string | number, linkUrl: string, imageUrl: string, options?: Sudo);
|
||||
|
||||
remove(projectId: string | number, badgeId: number, options?: Sudo);
|
||||
|
||||
show(projectId: string | number, badgeId: number, options?: Sudo);
|
||||
export interface ProjectBadgeSchema extends BadgeSchema {
|
||||
kind: 'project';
|
||||
}
|
||||
|
||||
export class ProjectBadges extends ResourceBadges {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
super('projects', options);
|
||||
export interface ProjectBadges<C extends boolean = false> extends ResourceBadges<C> {
|
||||
add(
|
||||
productId: string | number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ProjectBadgeSchema>>;
|
||||
|
||||
all(
|
||||
productId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ProjectBadgeSchema>[]>;
|
||||
|
||||
edit(
|
||||
productId: string | number,
|
||||
badgeId: number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ProjectBadgeSchema>>;
|
||||
|
||||
preview(
|
||||
productId: string | number,
|
||||
linkUrl: string,
|
||||
imageUrl: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, Omit<ProjectBadgeSchema, 'id' | 'name' | 'kind'>>>;
|
||||
|
||||
remove(productId: string | number, badgeId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
show(
|
||||
productId: string | number,
|
||||
badgeId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, ProjectBadgeSchema>>;
|
||||
}
|
||||
|
||||
export class ProjectBadges<C extends boolean = false> extends ResourceBadges<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('groups', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,33 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceCustomAttributes, CustomAttributeSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, CamelizedRecord, Sudo } from '../infrastructure';
|
||||
|
||||
export interface ProjectCustomAttributes extends ResourceCustomAttributes {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface ProjectCustomAttributes<C extends boolean = false>
|
||||
extends ResourceCustomAttributes<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>[]>;
|
||||
|
||||
set(projectId: string | number, customAttributeId: number, value: string, options?: Sudo);
|
||||
set(
|
||||
projectId: string | number,
|
||||
customAttributeId: number,
|
||||
value: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>>;
|
||||
|
||||
remove(projectId: string | number, customAttributeId: number, options?: Sudo);
|
||||
remove(projectId: string | number, customAttributeId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
show(projectId: string | number, customAttributeId: number, options?: Sudo);
|
||||
show(
|
||||
projectId: string | number,
|
||||
customAttributeId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>>;
|
||||
}
|
||||
|
||||
export class ProjectCustomAttributes extends ResourceCustomAttributes {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class ProjectCustomAttributes<C extends boolean> extends ResourceCustomAttributes<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,33 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceDeployTokens } from '../templates';
|
||||
import { ResourceDeployTokens, DeployTokenScope, DeployTokenSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
CamelizedRecord,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class ProjectDeployTokens extends ResourceDeployTokens {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export interface ProjectDeployTokens<C extends boolean = false> extends ResourceDeployTokens<C> {
|
||||
add(
|
||||
projectId: string | number,
|
||||
tokenName: string,
|
||||
tokenScopes: DeployTokenScope[],
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, DeployTokenSchema>>;
|
||||
|
||||
all({
|
||||
projectId,
|
||||
...options
|
||||
}: { projectId?: string | number } & PaginatedRequestOptions): Promise<
|
||||
CamelizedRecord<C, DeployTokenSchema>[]
|
||||
>;
|
||||
|
||||
remove(projectId: string | number, tokenId: number, options?: Sudo): Promise<void>;
|
||||
}
|
||||
|
||||
export class ProjectDeployTokens<C extends boolean = false> extends ResourceDeployTokens<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,34 +6,61 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class ProjectHooks extends BaseService {
|
||||
export interface ProjectHookSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
url: string;
|
||||
project_id: number;
|
||||
push_events: boolean;
|
||||
push_events_branch_filter: string;
|
||||
issues_events: boolean;
|
||||
confidential_issues_events: boolean;
|
||||
merge_requests_events: boolean;
|
||||
tag_push_events: boolean;
|
||||
note_events: boolean;
|
||||
confidential_note_events: boolean;
|
||||
job_events: boolean;
|
||||
pipeline_events: boolean;
|
||||
wiki_page_events: boolean;
|
||||
deployment_events: boolean;
|
||||
releases_events: boolean;
|
||||
enable_ssl_verification: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export class ProjectHooks<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks`, options);
|
||||
return RequestHelper.get<ProjectHookSchema[]>()(this, `projects/${pId}/hooks`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, hookId: number, options?: Sudo) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/hooks/${hId}`, options);
|
||||
return RequestHelper.get<ProjectHookSchema>()(this, `projects/${pId}/hooks/${hId}`, options);
|
||||
}
|
||||
|
||||
add(projectId: string | number, url: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/hooks`, { url, ...options });
|
||||
return RequestHelper.post<ProjectHookSchema>()(this, `projects/${pId}/hooks`, {
|
||||
url,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
edit(projectId: string | number, hookId: number, url: string, options?: BaseRequestOptions) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/hooks/${hId}`, { url, ...options });
|
||||
return RequestHelper.put<ProjectHookSchema>()(this, `projects/${pId}/hooks/${hId}`, {
|
||||
url,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
remove(projectId: string | number, hookId: number, options?: Sudo) {
|
||||
const [pId, hId] = [projectId, hookId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/hooks/${hId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/hooks/${hId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,43 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, Sudo, BaseRequestOptions } from '../infrastructure';
|
||||
|
||||
export interface ExportStatusSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
description: string;
|
||||
name: string;
|
||||
name_with_namespace: string;
|
||||
path: string;
|
||||
path_with_namespace: string;
|
||||
created_at: string;
|
||||
export_status: string;
|
||||
_links: {
|
||||
api_url: string;
|
||||
web_url: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface FailedRelationSchema {
|
||||
id: number;
|
||||
created_at: string;
|
||||
exception_class: string;
|
||||
exception_message: string;
|
||||
source: string;
|
||||
relation_name: string;
|
||||
}
|
||||
|
||||
export interface ImportStatusSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
description: string;
|
||||
name: string;
|
||||
name_with_namespace: string;
|
||||
path: string;
|
||||
path_with_namespace: string;
|
||||
created_at: string;
|
||||
import_status: string;
|
||||
correlation_id: string;
|
||||
failed_relations?: FailedRelationSchema[];
|
||||
}
|
||||
|
||||
export interface UploadMetadata {
|
||||
filename?: string;
|
||||
contentType?: string;
|
||||
@ -11,17 +48,17 @@ export const defaultMetadata = {
|
||||
contentType: 'application/octet-stream',
|
||||
};
|
||||
|
||||
export class ProjectImportExport extends BaseService {
|
||||
export class ProjectImportExport<C extends boolean = false> extends BaseService<C> {
|
||||
download(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/export/download`, options);
|
||||
return RequestHelper.get()(this, `projects/${pId}/export/download`, options);
|
||||
}
|
||||
|
||||
exportStatus(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/export`, options);
|
||||
return RequestHelper.get<ExportStatusSchema>()(this, `projects/${pId}/export`, options);
|
||||
}
|
||||
|
||||
import(
|
||||
@ -29,7 +66,7 @@ export class ProjectImportExport extends BaseService {
|
||||
path: string,
|
||||
{ metadata, ...options }: { metadata?: UploadMetadata } & BaseRequestOptions = {},
|
||||
) {
|
||||
return RequestHelper.post(this, 'projects/import', {
|
||||
return RequestHelper.post<ImportStatusSchema>()(this, 'projects/import', {
|
||||
isForm: true,
|
||||
...options,
|
||||
file: [content, { ...defaultMetadata, ...metadata }],
|
||||
@ -40,12 +77,12 @@ export class ProjectImportExport extends BaseService {
|
||||
importStatus(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/import`, options);
|
||||
return RequestHelper.get<ImportStatusSchema>()(this, `projects/${pId}/import`, options);
|
||||
}
|
||||
|
||||
schedule(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/export`, options);
|
||||
return RequestHelper.post<{ message: string }>()(this, `projects/${pId}/export`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,37 +1,91 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceIssueBoards } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ProjectSchema } from './Projects';
|
||||
import { ResourceIssueBoards, IssueBoardSchema, IssueBoardListSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface ProjectIssueBoards extends ResourceIssueBoards {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface ProjectIssueBoardSchema extends IssueBoardSchema {
|
||||
project: Pick<
|
||||
ProjectSchema,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'name_with_namespace'
|
||||
| 'path'
|
||||
| 'path_with_namespace'
|
||||
| 'http_url_to_repo'
|
||||
| 'web_url'
|
||||
>;
|
||||
}
|
||||
|
||||
create(projectId: string | number, name: string, options?: Sudo);
|
||||
export interface ProjectIssueBoards<C extends boolean = false> extends ResourceIssueBoards<C> {
|
||||
all(
|
||||
groupId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ProjectIssueBoardSchema>[]>;
|
||||
|
||||
createList(projectId: string | number, boardId: number, labelId: number, options?: Sudo);
|
||||
create(
|
||||
groupId: string | number,
|
||||
name: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, ProjectIssueBoardSchema>>;
|
||||
|
||||
edit(projectId: string | number, boardId: number, options?: BaseRequestOptions);
|
||||
createList(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
labelId: number | string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>>;
|
||||
|
||||
edit(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ProjectIssueBoardSchema>>;
|
||||
|
||||
editList(
|
||||
projectId: string | number,
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
listId: number,
|
||||
position: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>>;
|
||||
|
||||
lists(projectId: string | number, boardId: number, options?: Sudo);
|
||||
lists(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>[]>;
|
||||
|
||||
remove(projectId: string | number, boardId: number, options?: Sudo);
|
||||
remove(groupId: string | number, boardId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
removeList(projectId: string | number, boardId: number, listId: number, options?: Sudo);
|
||||
removeList(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
listId: number,
|
||||
options?: Sudo,
|
||||
): Promise<void>;
|
||||
|
||||
show(projectId: string | number, boardId: number, options?: Sudo);
|
||||
show(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, ProjectIssueBoardSchema>>;
|
||||
|
||||
showList(projectId: string | number, boardId: number, listId: number, options?: Sudo);
|
||||
showList(
|
||||
groupId: string | number,
|
||||
boardId: number,
|
||||
listId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueBoardListSchema>>;
|
||||
}
|
||||
|
||||
export class ProjectIssueBoards extends ResourceIssueBoards {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class ProjectIssueBoards<C extends boolean = false> extends ResourceIssueBoards<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,44 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceMembers } from '../templates';
|
||||
import { ResourceMembers, MembersSchema, IncludeInherited, AccessLevel } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
CamelizedRecord,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class ProjectMembers extends ResourceMembers {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export interface GroupMembers<C extends boolean = false> extends ResourceMembers<C> {
|
||||
add(
|
||||
projectId: string | number,
|
||||
userId: number,
|
||||
accessLevel: AccessLevel,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>>;
|
||||
|
||||
all(
|
||||
projectId: string | number,
|
||||
options?: IncludeInherited & PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>[]>;
|
||||
|
||||
edit(
|
||||
projectId: string | number,
|
||||
userId: number,
|
||||
accessLevel: AccessLevel,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
userId: number,
|
||||
options?: IncludeInherited & Sudo,
|
||||
): Promise<CamelizedRecord<C, MembersSchema>>;
|
||||
|
||||
remove(projectId: string | number, userId: number, options?: Sudo): Promise<void>;
|
||||
}
|
||||
|
||||
export class ProjectMembers<C extends boolean = false> extends ResourceMembers<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,23 +1,54 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceMilestones } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
import type { IssueSchema } from './Issues';
|
||||
import type { MergeRequestSchema } from './MergeRequests';
|
||||
import { ResourceMilestones, MilestoneSchema } from '../templates';
|
||||
import {
|
||||
PaginatedRequestOptions,
|
||||
BaseRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface ProjectMilestones extends ResourceMilestones {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface ProjectMilestones<C extends boolean = false> extends ResourceMilestones<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>[]>;
|
||||
|
||||
create(projectId: string | number, title: string, options?: BaseRequestOptions);
|
||||
create(
|
||||
projectId: string | number,
|
||||
title: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>>;
|
||||
|
||||
edit(projectId: string | number, milestoneId: number, options?: BaseRequestOptions);
|
||||
edit(
|
||||
projectId: string | number,
|
||||
milestoneId: number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>>;
|
||||
|
||||
issues(projectId: string | number, milestoneId: number, options?: Sudo);
|
||||
issues(
|
||||
projectId: string | number,
|
||||
milestoneId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, IssueSchema>[]>;
|
||||
|
||||
mergeRequests(projectId: string | number, milestoneId: number, options?: Sudo);
|
||||
mergeRequests(
|
||||
projectId: string | number,
|
||||
milestoneId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, MergeRequestSchema>[]>;
|
||||
|
||||
show(projectId: string | number, milestoneId: number, options?: Sudo);
|
||||
show(
|
||||
projectId: string | number,
|
||||
milestoneId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, MilestoneSchema>>;
|
||||
}
|
||||
|
||||
export class ProjectMilestones extends ResourceMilestones {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class ProjectMilestones<C extends boolean = false> extends ResourceMilestones<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +1,40 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceAwardEmojis } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceAwardEmojis, AwardEmojiSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export interface ProjectSnippetAwardEmojis extends ResourceAwardEmojis {
|
||||
export interface ProjectSnippetAwardEmojis<C extends boolean = false>
|
||||
extends ResourceAwardEmojis<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
noteId: number,
|
||||
snippetIId: number,
|
||||
options?: PaginatedRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>[]>;
|
||||
|
||||
award(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
noteId: number,
|
||||
snippetIId: number,
|
||||
name: string,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
|
||||
remove(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
snippetIId: number,
|
||||
awardId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<void>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
snippetIId: number,
|
||||
awardId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, AwardEmojiSchema>>;
|
||||
}
|
||||
|
||||
export class ProjectSnippetAwardEmojis extends ResourceAwardEmojis {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
super('issues', options);
|
||||
export class ProjectSnippetAwardEmojis<C extends boolean = false> extends ResourceAwardEmojis<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('snippets', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,39 +1,49 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceDiscussions } from '../templates';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceDiscussions, DiscussionSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface ProjectSnippetDiscussions extends ResourceDiscussions {
|
||||
export interface ProjectSnippetDiscussions<C extends boolean = false>
|
||||
extends ResourceDiscussions<C> {
|
||||
addNote(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
discussionId: string | number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
all(projectId: string | number, snippetId: string | number, options?: PaginatedRequestOptions);
|
||||
all(
|
||||
projectId: string | number,
|
||||
issueId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
editNote(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
discussionId: string | number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
content: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
|
||||
removeNote(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
discussionId: string | number,
|
||||
discussionId: number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
@ -41,13 +51,14 @@ export interface ProjectSnippetDiscussions extends ResourceDiscussions {
|
||||
show(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
discussionId: string | number,
|
||||
discussionId: number,
|
||||
options?: Sudo,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, DiscussionSchema>>;
|
||||
}
|
||||
|
||||
export class ProjectSnippetDiscussions extends ResourceDiscussions {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class ProjectSnippetDiscussions<C extends boolean = false> extends ResourceDiscussions<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', 'snippets', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,30 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceNotes } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceNotes, NoteSchema } from '../templates';
|
||||
import {
|
||||
PaginatedRequestOptions,
|
||||
BaseRequestOptions,
|
||||
Sudo,
|
||||
CamelizedRecord,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface ProjectSnippetNotes extends ResourceNotes {
|
||||
all(projectId: string | number, snippetId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface SnippetNoteSchema extends NoteSchema {
|
||||
file_name: string;
|
||||
expires_at: string;
|
||||
}
|
||||
|
||||
export interface ProjectSnippetNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, SnippetNoteSchema>[]>;
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, SnippetNoteSchema>>;
|
||||
|
||||
edit(
|
||||
projectId: string | number,
|
||||
@ -18,15 +32,21 @@ export interface ProjectSnippetNotes extends ResourceNotes {
|
||||
noteId: number,
|
||||
body: string,
|
||||
options?: BaseRequestOptions,
|
||||
);
|
||||
): Promise<CamelizedRecord<C, SnippetNoteSchema>>;
|
||||
|
||||
remove(projectId: string | number, snippetId: string | number, noteId: number, options?: Sudo);
|
||||
|
||||
show(projectId: string | number, snippetId: string | number, noteId: number, options?: Sudo);
|
||||
show(
|
||||
projectId: string | number,
|
||||
snippetId: string | number,
|
||||
noteId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, SnippetNoteSchema>>;
|
||||
}
|
||||
|
||||
export class ProjectSnippetNotes extends ResourceNotes {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class ProjectSnippetNotes<C extends boolean = false> extends ResourceNotes<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', 'snippets', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,20 +5,33 @@ import {
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
import { SnippetVisibility } from './Snippets';
|
||||
import { UserSchema } from './Users';
|
||||
|
||||
export class ProjectSnippets extends BaseService {
|
||||
export interface ProjectSnippetSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
title: string;
|
||||
file_name: string;
|
||||
description: string;
|
||||
author: Pick<UserSchema, 'id' | 'username' | 'name' | 'state' | 'created_at'>;
|
||||
updated_at: string;
|
||||
created_at: string;
|
||||
project_id: number;
|
||||
web_url: string;
|
||||
raw_url: string;
|
||||
}
|
||||
|
||||
export class ProjectSnippets<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets`, options);
|
||||
return RequestHelper.get<ProjectSnippetSchema[]>()(this, `projects/${pId}/snippets`, options);
|
||||
}
|
||||
|
||||
content(projectId: string | number, snippetId: number, options?: Sudo) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets/${sId}/raw`, options);
|
||||
return RequestHelper.get()(this, `projects/${pId}/snippets/${sId}/raw`, options);
|
||||
}
|
||||
|
||||
create(
|
||||
@ -31,7 +44,7 @@ export class ProjectSnippets extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/snippets`, {
|
||||
return RequestHelper.post<ProjectSnippetSchema>()(this, `projects/${pId}/snippets`, {
|
||||
title,
|
||||
fileName,
|
||||
code,
|
||||
@ -43,24 +56,36 @@ export class ProjectSnippets extends BaseService {
|
||||
edit(projectId: string | number, snippetId: number, options?: BaseRequestOptions) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/snippets/${sId}`, options);
|
||||
return RequestHelper.put<ProjectSnippetSchema>()(
|
||||
this,
|
||||
`projects/${pId}/snippets/${sId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, snippetId: number, options?: Sudo) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/snippets/${sId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/snippets/${sId}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, snippetId: number, options?: Sudo) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets/${sId}`, options);
|
||||
return RequestHelper.get<ProjectSnippetSchema>()(
|
||||
this,
|
||||
`projects/${pId}/snippets/${sId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
userAgentDetails(projectId: string | number, snippetId: number, options?: Sudo) {
|
||||
const [pId, sId] = [projectId, snippetId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/snippets/${sId}/user_agent_detail`, options);
|
||||
return RequestHelper.get<{
|
||||
user_agent: string;
|
||||
ip_address: string;
|
||||
akismet_submitted: boolean;
|
||||
}>()(this, `projects/${pId}/snippets/${sId}/user_agent_detail`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,40 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceVariables, ResourceVariableSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, BaseRequestOptions } from '../infrastructure';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, CamelizedRecord } from '../infrastructure';
|
||||
|
||||
export interface ProjectVariables extends ResourceVariables {
|
||||
export interface ProjectVariables<C extends boolean = false> extends ResourceVariables<C> {
|
||||
all(
|
||||
projectId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<ResourceVariableSchema[]>;
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>[]>;
|
||||
|
||||
create(projectId: string | number, options?: BaseRequestOptions);
|
||||
create(
|
||||
projectId: string | number,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>>;
|
||||
|
||||
edit(projectId: string | number, keyId: string, options?: BaseRequestOptions);
|
||||
edit(
|
||||
projectId: string | number,
|
||||
keyId: string,
|
||||
options?: BaseRequestOptions,
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>>;
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
keyId: string,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<ResourceVariableSchema>;
|
||||
): Promise<CamelizedRecord<C, ResourceVariableSchema>>;
|
||||
|
||||
remove(projectId: string | number, keyId: string, options?: PaginatedRequestOptions);
|
||||
remove(
|
||||
projectId: string | number,
|
||||
keyId: string,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<void>;
|
||||
}
|
||||
|
||||
export class ProjectVariables extends ResourceVariables {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class ProjectVariables<C extends boolean = false> extends ResourceVariables<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('projects', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,64 +1,160 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { LicenseTemplateSchema } from './LicenseTemplates';
|
||||
import { UploadMetadata, defaultMetadata } from './ProjectImportExport';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
RequestHelper,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
import { EventOptions } from './Events';
|
||||
import { UploadMetadata, defaultMetadata } from './ProjectImportExport';
|
||||
import { AccessLevel } from '../templates';
|
||||
|
||||
export interface NamespaceInfoSchemaDefault {
|
||||
// TODO add missing functions
|
||||
export interface ProjectSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
description?: string;
|
||||
default_branch: string;
|
||||
ssh_url_to_repo: string;
|
||||
http_url_to_repo: string;
|
||||
web_url: string;
|
||||
readme_url: string;
|
||||
tag_list?: string[];
|
||||
name: string;
|
||||
name_with_namespace: string;
|
||||
path: string;
|
||||
path_with_namespace: string;
|
||||
created_at: string;
|
||||
last_activity_at: string;
|
||||
forks_count: number;
|
||||
avatar_url: string;
|
||||
star_count: number;
|
||||
}
|
||||
|
||||
export interface NamespaceInfoSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
kind: string;
|
||||
full_path: string;
|
||||
avatar_url: string;
|
||||
web_url: string;
|
||||
}
|
||||
|
||||
export interface NamespaceInfoSchemaCamelize {
|
||||
id: number;
|
||||
name: string;
|
||||
path: string;
|
||||
kind: string;
|
||||
fullPath: string;
|
||||
export interface AccessSchema {
|
||||
access_level: AccessLevel;
|
||||
notification_level: number;
|
||||
}
|
||||
|
||||
export interface ProjectSchemaDefault {
|
||||
id: number;
|
||||
name: string;
|
||||
name_with_namespace: string;
|
||||
path: string;
|
||||
path_with_namespace: string;
|
||||
namespace: NamespaceInfoSchemaDefault;
|
||||
ssh_url_to_repo: string;
|
||||
http_url_to_repo: string;
|
||||
export interface SharedWithGroupSchema {
|
||||
group_id: number;
|
||||
group_name: string;
|
||||
group_full_path: string;
|
||||
group_access_level: number;
|
||||
}
|
||||
|
||||
export interface ProjectExtendedSchema extends ProjectSchema {
|
||||
visibility: string;
|
||||
owner: Pick<UserSchema, 'id' | 'name' | 'created_at'>;
|
||||
issues_enabled: boolean;
|
||||
open_issues_count: number;
|
||||
merge_requests_enabled: boolean;
|
||||
jobs_enabled: boolean;
|
||||
wiki_enabled: boolean;
|
||||
snippets_enabled: boolean;
|
||||
can_create_merge_request_in: boolean;
|
||||
resolve_outdated_diff_discussions: boolean;
|
||||
container_registry_enabled: boolean;
|
||||
container_expiration_policy: {
|
||||
cadence: string;
|
||||
enabled: boolean;
|
||||
keep_n?: number;
|
||||
older_than?: string;
|
||||
name_regex_delete?: string;
|
||||
name_regex_keep?: string;
|
||||
next_run_at: string;
|
||||
};
|
||||
creator_id: number;
|
||||
namespace: NamespaceInfoSchema;
|
||||
import_status: string;
|
||||
import_error?: string;
|
||||
permissions: {
|
||||
project_access: AccessSchema;
|
||||
group_access: AccessSchema;
|
||||
};
|
||||
archived: boolean;
|
||||
license_url: string;
|
||||
license: Pick<LicenseTemplateSchema, 'key' | 'name' | 'nickname' | 'html_url' | 'source_url'>;
|
||||
shared_runners_enabled: boolean;
|
||||
runners_token: string;
|
||||
ci_default_git_depth: number;
|
||||
ci_forward_deployment_enabled: boolean;
|
||||
public_jobs: boolean;
|
||||
shared_with_groups?: SharedWithGroupSchema[];
|
||||
repository_storage: string;
|
||||
only_allow_merge_if_pipeline_succeeds: boolean;
|
||||
allow_merge_on_skipped_pipeline: boolean;
|
||||
restrict_user_defined_variables: boolean;
|
||||
only_allow_merge_if_all_discussions_are_resolved: boolean;
|
||||
remove_source_branch_after_merge: boolean;
|
||||
printing_merge_requests_link_enabled: boolean;
|
||||
request_access_enabled: boolean;
|
||||
merge_method: string;
|
||||
auto_devops_enabled: boolean;
|
||||
auto_devops_deploy_strategy: string;
|
||||
approvals_before_merge: number;
|
||||
mirror: boolean;
|
||||
mirror_user_id: number;
|
||||
mirror_trigger_builds: boolean;
|
||||
only_mirror_protected_branches: boolean;
|
||||
mirror_overwrites_diverged_branches: boolean;
|
||||
external_authorization_classification_label?: string;
|
||||
packages_enabled: boolean;
|
||||
service_desk_enabled: boolean;
|
||||
service_desk_address?: string;
|
||||
autoclose_referenced_issues: boolean;
|
||||
suggestion_commit_message?: string;
|
||||
marked_for_deletion_at: string;
|
||||
marked_for_deletion_on: string;
|
||||
compliance_frameworks?: string[];
|
||||
statistics: {
|
||||
commit_count: number;
|
||||
storage_size: number;
|
||||
repository_size: number;
|
||||
wiki_size: number;
|
||||
lfs_objects_size: number;
|
||||
job_artifacts_size: number;
|
||||
packages_size: number;
|
||||
snippets_size: number;
|
||||
};
|
||||
container_registry_image_prefix: string;
|
||||
_links: {
|
||||
self: string;
|
||||
issues: string;
|
||||
merge_requests: string;
|
||||
repo_branches: string;
|
||||
labels: string;
|
||||
events: string;
|
||||
members: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ProjectSchemaCamelized {
|
||||
id: number;
|
||||
name: string;
|
||||
nameWithNamespace: string;
|
||||
path: string;
|
||||
pathWithNamespace: string;
|
||||
namespace: NamespaceInfoSchemaCamelize;
|
||||
sshUrlToRepo: string;
|
||||
httpUrlToRepo: string;
|
||||
archived: boolean;
|
||||
export interface ProjectFileUploadSchema extends Record<string, unknown> {
|
||||
alt: string;
|
||||
url: string;
|
||||
full_path: string;
|
||||
markdown: string;
|
||||
}
|
||||
|
||||
export type ProjectSchema = ProjectSchemaDefault | ProjectSchemaCamelized;
|
||||
|
||||
export class Projects extends BaseService {
|
||||
export class Projects<C extends boolean = false> extends BaseService<C> {
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'projects', options) as Promise<ProjectSchema[]>;
|
||||
return RequestHelper.get<ProjectSchema[]>()(this, 'projects', options);
|
||||
}
|
||||
|
||||
archive(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/archive`, options);
|
||||
return RequestHelper.post<ProjectExtendedSchema>()(this, `projects/${pId}/archive`, options);
|
||||
}
|
||||
|
||||
create({
|
||||
@ -67,19 +163,13 @@ export class Projects extends BaseService {
|
||||
}: ({ name: string } | { path: string }) & { userId?: number } & BaseRequestOptions) {
|
||||
const url = userId ? `projects/user/${encodeURIComponent(userId)}` : 'projects';
|
||||
|
||||
return RequestHelper.post(this, url, options);
|
||||
return RequestHelper.post<ProjectExtendedSchema>()(this, url, options);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
events(projectId: string | number, options?: BaseRequestOptions & EventOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/events`, options);
|
||||
return RequestHelper.put<ProjectExtendedSchema>()(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
fork(
|
||||
@ -91,43 +181,48 @@ export class Projects extends BaseService {
|
||||
|
||||
if (forkedFromId) url += `/${encodeURIComponent(forkedFromId)}`;
|
||||
|
||||
return RequestHelper.post(this, url, options);
|
||||
return RequestHelper.post<ProjectExtendedSchema>()(this, url, options);
|
||||
}
|
||||
|
||||
forks(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/forks`, options);
|
||||
return RequestHelper.get<ProjectExtendedSchema[]>()(this, `projects/${pId}/forks`, options);
|
||||
}
|
||||
|
||||
languages(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/languages`, options);
|
||||
return RequestHelper.get<{ [name: string]: number }>()(
|
||||
this,
|
||||
`projects/${pId}/languages`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
mirrorPull(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/mirror/pull`, options);
|
||||
return RequestHelper.post()(this, `projects/${pId}/mirror/pull`, options);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
removeFork(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/fork`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/fork`, options);
|
||||
}
|
||||
|
||||
search(projectName: string, options?: BaseRequestOptions) {
|
||||
return RequestHelper.get(this, 'projects', { search: projectName, ...options }) as Promise<
|
||||
ProjectSchema[]
|
||||
>;
|
||||
return RequestHelper.get<ProjectSchema[]>()(this, 'projects', {
|
||||
search: projectName,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
share(
|
||||
@ -138,58 +233,58 @@ export class Projects extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/share`, { groupId, groupAccess, ...options });
|
||||
return RequestHelper.post()(this, `projects/${pId}/share`, {
|
||||
groupId,
|
||||
groupAccess,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
show(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}`, options);
|
||||
return RequestHelper.get<ProjectExtendedSchema>()(this, `projects/${pId}`, options);
|
||||
}
|
||||
|
||||
star(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/star`, options);
|
||||
}
|
||||
|
||||
statuses(projectId: string | number, sha: string, state: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/statuses/${sha}`, { state, ...options });
|
||||
return RequestHelper.post<ProjectExtendedSchema>()(this, `projects/${pId}/star`, options);
|
||||
}
|
||||
|
||||
transfer(projectId: string | number, namespaceId: string | number) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
return RequestHelper.put(this, `projects/${pId}/transfer`, { namespace: namespaceId });
|
||||
return RequestHelper.put<ProjectExtendedSchema>()(this, `projects/${pId}/transfer`, {
|
||||
namespace: namespaceId,
|
||||
});
|
||||
}
|
||||
|
||||
unarchive(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/unarchive`, options);
|
||||
return RequestHelper.post<ProjectExtendedSchema>()(this, `projects/${pId}/unarchive`, options);
|
||||
}
|
||||
|
||||
unshare(projectId: string | number, groupId: string | number, options?: Sudo) {
|
||||
const [pId, gId] = [projectId, groupId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/share/${gId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/share/${gId}`, options);
|
||||
}
|
||||
|
||||
unstar(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/unstar`, options);
|
||||
return RequestHelper.post<ProjectExtendedSchema>()(this, `projects/${pId}/unstar`, options);
|
||||
}
|
||||
|
||||
upload(
|
||||
projectId,
|
||||
content,
|
||||
projectId: string | number,
|
||||
content: string,
|
||||
{ metadata, ...options }: { metadata?: UploadMetadata } & BaseRequestOptions = {},
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/uploads`, {
|
||||
return RequestHelper.post<ProjectFileUploadSchema>()(this, `projects/${pId}/uploads`, {
|
||||
isForm: true,
|
||||
file: [content, { ...defaultMetadata, ...metadata }],
|
||||
...options,
|
||||
|
||||
@ -6,17 +6,37 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class ProtectedBranches extends BaseService {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
export interface ProtectedBranchAccessLevelSchema {
|
||||
access_level: 0 | 30 | 40 | 60;
|
||||
access_level_description: string;
|
||||
user_id?: number;
|
||||
group_id?: number;
|
||||
}
|
||||
|
||||
export interface ProtectedBranchSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
push_access_levels?: ProtectedBranchAccessLevelSchema[];
|
||||
merge_access_levels?: ProtectedBranchAccessLevelSchema[];
|
||||
allow_force_push: boolean;
|
||||
code_owner_approval_required: boolean;
|
||||
}
|
||||
|
||||
export class ProtectedBranches<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options: { search?: string } & PaginatedRequestOptions = {}) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_branches`, options);
|
||||
return RequestHelper.get<ProtectedBranchSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/protected_branches`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
protect(projectId: string | number, branchName: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/protected_branches`, {
|
||||
return RequestHelper.post<ProtectedBranchSchema>()(this, `projects/${pId}/protected_branches`, {
|
||||
name: branchName,
|
||||
...options,
|
||||
});
|
||||
@ -25,12 +45,16 @@ export class ProtectedBranches extends BaseService {
|
||||
show(projectId: string | number, branchName: string, options?: Sudo) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_branches/${bName}`, options);
|
||||
return RequestHelper.get<ProtectedBranchSchema>()(
|
||||
this,
|
||||
`projects/${pId}/protected_branches/${bName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
unprotect(projectId: string | number, branchName: string, options?: Sudo) {
|
||||
const [pId, bName] = [projectId, branchName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/protected_branches/${bName}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/protected_branches/${bName}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,17 +6,31 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class ProtectedTags extends BaseService {
|
||||
export interface ProtectedTagAccessLevelSchema {
|
||||
access_level: 0 | 30 | 40 | 60;
|
||||
access_level_description: string;
|
||||
}
|
||||
|
||||
export interface ProtectedTagSchema extends Record<string, unknown> {
|
||||
name: string;
|
||||
create_access_levels?: ProtectedTagAccessLevelSchema[];
|
||||
}
|
||||
|
||||
export class ProtectedTags<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_tags`, options);
|
||||
return RequestHelper.get<ProtectedTagSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/protected_tags`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
protect(projectId: string | number, tagName: string, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/protected_tags`, {
|
||||
return RequestHelper.post<ProtectedTagSchema>()(this, `projects/${pId}/protected_tags`, {
|
||||
name: tagName,
|
||||
...options,
|
||||
});
|
||||
@ -25,12 +39,16 @@ export class ProtectedTags extends BaseService {
|
||||
show(projectId: string | number, tagName: string, options?: Sudo) {
|
||||
const [pId, tName] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/protected_tags/${tName}`, options);
|
||||
return RequestHelper.get<ProtectedTagSchema>()(
|
||||
this,
|
||||
`projects/${pId}/protected_tags/${tName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
unprotect(projectId: string | number, tagName: string, options?: Sudo) {
|
||||
const [pId, tName] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/protected_tags/${tName}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/protected_tags/${tName}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,45 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
|
||||
export class PushRules extends BaseService {
|
||||
export interface PushRulesSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
project_id: number;
|
||||
commit_message_regex: string;
|
||||
commit_message_negative_regex: string;
|
||||
branch_name_regex: string;
|
||||
deny_delete_tag: boolean;
|
||||
created_at: string;
|
||||
member_check: boolean;
|
||||
prevent_secrets: boolean;
|
||||
author_email_regex: string;
|
||||
file_name_regex: string;
|
||||
max_file_size: number;
|
||||
commit_committer_check?: boolean;
|
||||
reject_unsigned_commits?: boolean;
|
||||
}
|
||||
|
||||
export class PushRules<C extends boolean = false> extends BaseService<C> {
|
||||
create(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/push_rule`, options);
|
||||
return RequestHelper.post<PushRulesSchema>()(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/push_rule`, options);
|
||||
return RequestHelper.put<PushRulesSchema>()(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/push_rule`, options);
|
||||
return RequestHelper.del<PushRulesSchema>()(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/push_rule`, options);
|
||||
return RequestHelper.get<PushRulesSchema>()(this, `projects/${pId}/push_rule`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,43 +1,77 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
|
||||
export class ReleaseLinks extends BaseService {
|
||||
export interface ReleaseLinkSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
external: boolean;
|
||||
link_type: string;
|
||||
}
|
||||
|
||||
export class ReleaseLinks<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, tagName: string, options?: PaginatedRequestOptions) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/releases/${tId}/assets/links`, options);
|
||||
return RequestHelper.get<ReleaseLinkSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/releases/${tId}/assets/links`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
create(projectId: string | number, tagName: string, name: string, url: string, options?: Sudo) {
|
||||
create(
|
||||
projectId: string | number,
|
||||
tagName: string,
|
||||
name: string,
|
||||
url: string,
|
||||
options?: Sudo & { filePath?: string; linkType?: string },
|
||||
) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/releases/${tId}/assets/links`, {
|
||||
name,
|
||||
url,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<ReleaseLinkSchema>()(
|
||||
this,
|
||||
`projects/${pId}/releases/${tId}/assets/links`,
|
||||
{
|
||||
name,
|
||||
url,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
edit(
|
||||
projectId: string | number,
|
||||
tagName: string,
|
||||
linkId: number,
|
||||
options?: Sudo & ({ name: string } | { url: string }),
|
||||
options?: Sudo & { name?: string; url?: string; filePath?: string; linkType?: string },
|
||||
) {
|
||||
const [pId, tId, lId] = [projectId, tagName, linkId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/releases/${tId}/assets/links/${lId}`, options);
|
||||
return RequestHelper.put<ReleaseLinkSchema>()(
|
||||
this,
|
||||
`projects/${pId}/releases/${tId}/assets/links/${lId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, tagName: string, linkId: number, options?: Sudo) {
|
||||
const [pId, tId, lId] = [projectId, tagName, linkId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/releases/${tId}/assets/links/${lId}`, options);
|
||||
return RequestHelper.del()(
|
||||
this,
|
||||
`projects/${pId}/releases/${tId}/assets/links/${lId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
show(projectId: string | number, tagName: string, linkId: number, options?: Sudo) {
|
||||
const [pId, tId, lId] = [projectId, tagName, linkId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/releases/${tId}/assets/links/${lId}`, options);
|
||||
return RequestHelper.get<ReleaseLinkSchema>()(
|
||||
this,
|
||||
`projects/${pId}/releases/${tId}/assets/links/${lId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { CommitSchema } from './Commits';
|
||||
import { MilestoneSchema } from '../templates';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,34 +9,75 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class Releases extends BaseService {
|
||||
export interface EvidenceSchema {
|
||||
sha: string;
|
||||
filepath: string;
|
||||
collected_at: string;
|
||||
}
|
||||
|
||||
export interface SourceSchema {
|
||||
format: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface LinkSchema {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
external: boolean;
|
||||
link_type: string;
|
||||
}
|
||||
|
||||
export interface ReleaseSchema extends Record<string, unknown> {
|
||||
tag_name: string;
|
||||
description: string;
|
||||
name: string;
|
||||
description_html: string;
|
||||
created_at: string;
|
||||
released_at: string;
|
||||
user: Pick<UserSchema, 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url'>;
|
||||
commit: CommitSchema;
|
||||
milestones?: MilestoneSchema[];
|
||||
commit_path: string;
|
||||
tag_path: string;
|
||||
assets: {
|
||||
count: number;
|
||||
sources?: SourceSchema[];
|
||||
links?: LinkSchema[];
|
||||
evidence_file_path: string;
|
||||
};
|
||||
evidences?: EvidenceSchema[];
|
||||
}
|
||||
|
||||
// TODO: Add missing functions
|
||||
export class Releases<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/releases`, options);
|
||||
return RequestHelper.get<ReleaseSchema[]>()(this, `projects/${pId}/releases`, options);
|
||||
}
|
||||
|
||||
create(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/releases`, options);
|
||||
return RequestHelper.post<ReleaseSchema>()(this, `projects/${pId}/releases`, options);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, tagName: string, options?: BaseRequestOptions) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/releases/${tId}`, options);
|
||||
return RequestHelper.put<ReleaseSchema>()(this, `projects/${pId}/releases/${tId}`, options);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, tagName: string, options?: Sudo) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/releases/${tId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/releases/${tId}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, tagName: string, options?: Sudo) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/releases/${tId}`, options);
|
||||
return RequestHelper.get<ReleaseSchema>()(this, `projects/${pId}/releases/${tId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,71 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { CommitSchema, CommitDiffSchema } from './Commits';
|
||||
import { RequestHelper, Sudo, BaseRequestOptions } from '../infrastructure';
|
||||
|
||||
type ArchiveType = 'tar.gz' | 'tar.bz2' | 'tbz' | 'tbz2' | 'tb2' | 'bz2' | 'tar' | 'zip';
|
||||
|
||||
export class Repositories extends BaseService {
|
||||
export interface RepositoryCompareSchema extends Record<string, unknown> {
|
||||
commit: Pick<
|
||||
CommitSchema,
|
||||
'id' | 'short_id' | 'title' | 'author_name' | 'author_email' | 'created_at'
|
||||
>;
|
||||
commits?: Pick<
|
||||
CommitSchema,
|
||||
'id' | 'short_id' | 'title' | 'author_name' | 'author_email' | 'created_at'
|
||||
>[];
|
||||
diffs?: CommitDiffSchema[];
|
||||
compare_timeout: boolean;
|
||||
compare_same_ref: boolean;
|
||||
}
|
||||
|
||||
export interface RepositoryContributorSchema extends Record<string, unknown> {
|
||||
name: string;
|
||||
email: string;
|
||||
commits: number;
|
||||
additions: number;
|
||||
deletions: number;
|
||||
}
|
||||
|
||||
export interface RepositoryTreeSchema extends Record<string, unknown> {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
path: string;
|
||||
mode: string;
|
||||
}
|
||||
|
||||
export class Repositories<C extends boolean = false> extends BaseService<C> {
|
||||
compare(projectId: string | number, from: string, to: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/compare`, {
|
||||
from,
|
||||
to,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.get<RepositoryCompareSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/compare`,
|
||||
{
|
||||
from,
|
||||
to,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
contributors(projectId: string | number, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/contributors`, options);
|
||||
return RequestHelper.get<RepositoryContributorSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/repository/contributors`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
mergeBase(projectId: string | number, refs: string[], options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/merge_base`, { refs, ...options });
|
||||
return RequestHelper.get<CommitSchema>()(this, `projects/${pId}/repository/merge_base`, {
|
||||
refs,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
showArchive(
|
||||
@ -32,24 +74,40 @@ export class Repositories extends BaseService {
|
||||
) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/archive.${fileType}`, options);
|
||||
return (RequestHelper.get()(
|
||||
this,
|
||||
`projects/${pId}/repository/archive.${fileType}`,
|
||||
options as Record<string, unknown>,
|
||||
) as unknown) as Promise<void>;
|
||||
}
|
||||
|
||||
showBlob(projectId: string | number, sha: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/blobs/${sha}`, options);
|
||||
return (RequestHelper.get()(
|
||||
this,
|
||||
`projects/${pId}/repository/blobs/${sha}`,
|
||||
options,
|
||||
) as unknown) as Promise<Blob>;
|
||||
}
|
||||
|
||||
showBlobRaw(projectId: string | number, sha: string, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/blobs/${sha}/raw`, options);
|
||||
return (RequestHelper.get()(
|
||||
this,
|
||||
`projects/${pId}/repository/blobs/${sha}/raw`,
|
||||
options,
|
||||
) as unknown) as Promise<Blob>;
|
||||
}
|
||||
|
||||
tree(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tree`, options);
|
||||
return RequestHelper.get<RepositoryTreeSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/repository/tree`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { CommitSchema } from './Commits';
|
||||
import { RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
|
||||
export interface RepositoryFileSchemaDefault {
|
||||
export interface RepositoryFileExtendedSchema extends Record<string, unknown> {
|
||||
file_name: string;
|
||||
file_path: string;
|
||||
size: number;
|
||||
@ -14,22 +15,17 @@ export interface RepositoryFileSchemaDefault {
|
||||
last_commit_id: string;
|
||||
}
|
||||
|
||||
export interface RepositoryFileSchemaCamelized {
|
||||
fileName: string;
|
||||
filePath: string;
|
||||
size: number;
|
||||
encoding: string;
|
||||
content: string;
|
||||
contentSha256: string;
|
||||
ref: string;
|
||||
blobId: string;
|
||||
commitId: string;
|
||||
lastCommitId: string;
|
||||
export interface RepositoryFileBlameSchema extends Record<string, unknown> {
|
||||
commit: CommitSchema;
|
||||
lines?: string[];
|
||||
}
|
||||
|
||||
export type RepositoryFileSchema = RepositoryFileSchemaDefault | RepositoryFileSchemaCamelized;
|
||||
export interface RepositoryFileSchema extends Record<string, unknown> {
|
||||
file_path: string;
|
||||
branch: string;
|
||||
}
|
||||
|
||||
export class RepositoryFiles extends BaseService {
|
||||
export class RepositoryFiles<C extends boolean = false> extends BaseService<C> {
|
||||
create(
|
||||
projectId: string | number,
|
||||
filePath: string,
|
||||
@ -40,12 +36,16 @@ export class RepositoryFiles extends BaseService {
|
||||
) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/files/${path}`, {
|
||||
branch,
|
||||
content,
|
||||
commitMessage,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<RepositoryFileSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}`,
|
||||
{
|
||||
branch,
|
||||
content,
|
||||
commitMessage,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
edit(
|
||||
@ -58,12 +58,16 @@ export class RepositoryFiles extends BaseService {
|
||||
) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/repository/files/${path}`, {
|
||||
branch,
|
||||
content,
|
||||
commitMessage,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.put<RepositoryFileSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}`,
|
||||
{
|
||||
branch,
|
||||
content,
|
||||
commitMessage,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
remove(
|
||||
@ -75,39 +79,42 @@ export class RepositoryFiles extends BaseService {
|
||||
) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/repository/files/${path}`, {
|
||||
return RequestHelper.del()(this, `projects/${pId}/repository/files/${path}`, {
|
||||
branch,
|
||||
commitMessage,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
show(
|
||||
projectId: string | number,
|
||||
filePath: string,
|
||||
ref: string,
|
||||
options?: Sudo,
|
||||
): Promise<RepositoryFileSchema> {
|
||||
show(projectId: string | number, filePath: string, ref: string, options?: Sudo) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/files/${path}`, {
|
||||
ref,
|
||||
...options,
|
||||
}) as Promise<RepositoryFileSchema>;
|
||||
return RequestHelper.get<RepositoryFileExtendedSchema>()(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}`,
|
||||
{
|
||||
ref,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
showBlame(projectId: string | number, filePath: string, options?: Sudo) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/files/${path}/blame`, options);
|
||||
return RequestHelper.get<RepositoryFileBlameSchema[]>()(
|
||||
this,
|
||||
`projects/${pId}/repository/files/${path}/blame`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
showRaw(projectId: string | number, filePath: string, ref: string, options?: Sudo) {
|
||||
const [pId, path] = [projectId, filePath].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/files/${path}/raw`, {
|
||||
return (RequestHelper.get()(this, `projects/${pId}/repository/files/${path}/raw`, {
|
||||
ref,
|
||||
...options,
|
||||
});
|
||||
}) as unknown) as Promise<Blob>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { ProjectSchema } from './Projects';
|
||||
import { JobSchema } from './Jobs';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,7 +8,7 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export interface RunnerSchemaDefault {
|
||||
export interface RunnerSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
description: string;
|
||||
ip_address: string;
|
||||
@ -14,67 +16,72 @@ export interface RunnerSchemaDefault {
|
||||
is_shared: boolean;
|
||||
name: string;
|
||||
online: boolean;
|
||||
status: string;
|
||||
status: 'running' | 'success' | 'failed' | 'canceled';
|
||||
}
|
||||
|
||||
export interface RunnerSchemaCamelized {
|
||||
id: number;
|
||||
export interface RunnerExtendedSchema extends RunnerSchema {
|
||||
architecture?: string;
|
||||
description: string;
|
||||
ipAddress: string;
|
||||
active: boolean;
|
||||
isShared: boolean;
|
||||
name: string;
|
||||
online: boolean;
|
||||
status: string;
|
||||
contacted_at: string;
|
||||
platform?: string;
|
||||
projects?: Pick<
|
||||
ProjectSchema,
|
||||
'id' | 'name' | 'name_with_namespace' | 'path' | 'path_with_namespace'
|
||||
>;
|
||||
revision?: string;
|
||||
tag_list?: string[];
|
||||
version?: string;
|
||||
access_level: string;
|
||||
maximum_timeout?: number;
|
||||
}
|
||||
|
||||
// As of GitLab v12.6.2
|
||||
export type RunnerSchema = RunnerSchemaDefault | RunnerSchemaCamelized;
|
||||
|
||||
export class Runners extends BaseService {
|
||||
export class Runners<C extends boolean = false> extends BaseService<C> {
|
||||
all({ projectId, ...options }: { projectId?: string | number } & PaginatedRequestOptions = {}) {
|
||||
const url = projectId ? `projects/${encodeURIComponent(projectId)}/runners` : 'runners/all';
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get<RunnerSchema[]>()(this, url, options);
|
||||
}
|
||||
|
||||
allOwned(options?: BaseRequestOptions) {
|
||||
return RequestHelper.get(this, 'runners', options);
|
||||
return RequestHelper.get<RunnerSchema[]>()(this, 'runners', options);
|
||||
}
|
||||
|
||||
edit(runnerId: number, options?: BaseRequestOptions) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.put(this, `runners/${rId}`, options);
|
||||
return RequestHelper.put<RunnerExtendedSchema>()(this, `runners/${rId}`, options);
|
||||
}
|
||||
|
||||
enable(projectId: string | number, runnerId: number, options?: Sudo) {
|
||||
const [pId, rId] = [projectId, runnerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/runners`, { runnerId: rId, ...options });
|
||||
return RequestHelper.post<RunnerSchema>()(this, `projects/${pId}/runners`, {
|
||||
runnerId: rId,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
disable(projectId: string | number, runnerId: number, options?: Sudo) {
|
||||
const [pId, rId] = [projectId, runnerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/runners/${rId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/runners/${rId}`, options);
|
||||
}
|
||||
|
||||
jobs(runnerId: number, options?: Sudo) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.get(this, `runners/${rId}/jobs`, options);
|
||||
return RequestHelper.get<JobSchema[]>()(this, `runners/${rId}/jobs`, options);
|
||||
}
|
||||
|
||||
remove(runnerId: number, options?: Sudo) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.del(this, `runners/${rId}`, options);
|
||||
return RequestHelper.del()(this, `runners/${rId}`, options);
|
||||
}
|
||||
|
||||
show(runnerId: number, options?: Sudo) {
|
||||
const rId = encodeURIComponent(runnerId);
|
||||
|
||||
return RequestHelper.get(this, `runners/${rId}`, options);
|
||||
return RequestHelper.get<RunnerExtendedSchema>()(this, `runners/${rId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,26 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, BaseRequestOptions } from '../infrastructure';
|
||||
|
||||
export class Search extends BaseService {
|
||||
export interface SearchResultSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
description: string;
|
||||
name: string;
|
||||
name_with_namespace: string;
|
||||
path: string;
|
||||
path_with_namespace: string;
|
||||
created_at: string;
|
||||
default_branch: string;
|
||||
tag_list?: string[];
|
||||
ssh_url_to_repo: string;
|
||||
http_url_to_repo: string;
|
||||
web_url: string;
|
||||
avatar_url?: string;
|
||||
star_count: number;
|
||||
forks_count: number;
|
||||
last_activity_at: string;
|
||||
}
|
||||
|
||||
export class Search<C extends boolean = false> extends BaseService<C> {
|
||||
all(
|
||||
scope: string,
|
||||
search: string,
|
||||
@ -19,6 +38,10 @@ export class Search extends BaseService {
|
||||
url += `groups/${encodeURIComponent(groupId)}/`;
|
||||
}
|
||||
|
||||
return RequestHelper.get(this, `${url}search`, { scope, search, ...options });
|
||||
return RequestHelper.get<SearchResultSchema[]>()(this, `${url}search`, {
|
||||
scope,
|
||||
search,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
|
||||
import {
|
||||
RequestHelper,
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export type SupportedService =
|
||||
| 'asana'
|
||||
@ -35,22 +40,57 @@ export type SupportedService =
|
||||
| 'mock-ci'
|
||||
| 'youtrack';
|
||||
|
||||
export class Services extends BaseService {
|
||||
export interface ServiceSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
title: string;
|
||||
slug: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
active: boolean;
|
||||
commit_events: boolean;
|
||||
push_events: boolean;
|
||||
issues_events: boolean;
|
||||
confidential_issues_events: boolean;
|
||||
merge_requests_events: boolean;
|
||||
tag_push_events: boolean;
|
||||
note_events: boolean;
|
||||
confidential_note_events: boolean;
|
||||
pipeline_events: boolean;
|
||||
wiki_page_events: boolean;
|
||||
job_events: boolean;
|
||||
comment_on_event_enabled: boolean;
|
||||
}
|
||||
|
||||
export class Services<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get<ServiceSchema[]>()(this, `projects/${pId}/services`, options);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, serviceName: SupportedService, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/services/${serviceName}`, options);
|
||||
return RequestHelper.put<ServiceSchema>()(
|
||||
this,
|
||||
`projects/${pId}/services/${serviceName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, serviceName: SupportedService, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/services/${serviceName}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/services/${serviceName}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, serviceName: SupportedService, options?: Sudo) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/services/${serviceName}`, options);
|
||||
return RequestHelper.get<ServiceSchema>()(
|
||||
this,
|
||||
`projects/${pId}/services/${serviceName}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,58 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper } from '../infrastructure';
|
||||
|
||||
export class SidekiqMetrics extends BaseService {
|
||||
export interface ProcessMetricSchema {
|
||||
hostname: string;
|
||||
pid: number;
|
||||
tag: string;
|
||||
started_at: string;
|
||||
queues?: string[];
|
||||
labels?: string[];
|
||||
concurrency: number;
|
||||
busy: number;
|
||||
}
|
||||
|
||||
export interface SidekickProcessMetricsSchema extends Record<string, unknown> {
|
||||
processes?: ProcessMetricSchema[];
|
||||
}
|
||||
|
||||
export interface SidekickQueueMetricsSchema extends Record<string, unknown> {
|
||||
queues: {
|
||||
default: {
|
||||
backlog: number;
|
||||
latency: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface SidekickJobStatsSchema extends Record<string, unknown> {
|
||||
jobs: {
|
||||
processed: number;
|
||||
failed: number;
|
||||
enqueued: number;
|
||||
dead: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SidekickCompoundMetricsSchema
|
||||
extends SidekickJobStatsSchema,
|
||||
SidekickQueueMetricsSchema,
|
||||
SidekickProcessMetricsSchema {}
|
||||
|
||||
export class SidekiqMetrics<C extends boolean = false> extends BaseService<C> {
|
||||
queueMetrics() {
|
||||
return RequestHelper.get(this, 'sidekiq/queue_metrics');
|
||||
return RequestHelper.get<SidekickQueueMetricsSchema>()(this, 'sidekiq/queue_metrics');
|
||||
}
|
||||
|
||||
processMetrics() {
|
||||
return RequestHelper.get(this, 'sidekiq/process_metrics');
|
||||
return RequestHelper.get<SidekickProcessMetricsSchema>()(this, 'sidekiq/process_metrics');
|
||||
}
|
||||
|
||||
jobStats() {
|
||||
return RequestHelper.get(this, 'sidekiq/job_stats');
|
||||
return RequestHelper.get<SidekickJobStatsSchema>()(this, 'sidekiq/job_stats');
|
||||
}
|
||||
|
||||
compoundMetrics() {
|
||||
return RequestHelper.get(this, 'sidekiq/compound_metrics');
|
||||
return RequestHelper.get<SidekickCompoundMetricsSchema>()(this, 'sidekiq/compound_metrics');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -8,17 +9,49 @@ import {
|
||||
|
||||
export type SnippetVisibility = 'private' | 'public' | 'internal';
|
||||
|
||||
export class Snippets extends BaseService {
|
||||
export interface SnippetSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
title: string;
|
||||
file_name: string;
|
||||
description?: string;
|
||||
visibility: string;
|
||||
author: Pick<UserSchema, 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url'>;
|
||||
updated_at: string;
|
||||
created_at: string;
|
||||
project_id?: string | number;
|
||||
web_url: string;
|
||||
raw_url: string;
|
||||
}
|
||||
|
||||
export interface FileSchema {
|
||||
path: string;
|
||||
raw_url: string;
|
||||
}
|
||||
|
||||
export interface SnippetExtendedSchema extends SnippetSchema {
|
||||
expires_at?: string;
|
||||
ssh_url_to_repo: string;
|
||||
http_url_to_repo: string;
|
||||
files?: FileSchema[];
|
||||
}
|
||||
|
||||
export interface UserAgentDetailSchema extends Record<string, unknown> {
|
||||
user_agent: string;
|
||||
ip_address: string;
|
||||
akismet_submitted: boolean;
|
||||
}
|
||||
|
||||
export class Snippets<C extends boolean = false> extends BaseService<C> {
|
||||
all({ public: p, ...options }: { public?: boolean } & PaginatedRequestOptions = {}) {
|
||||
const url = p ? 'snippets/public' : 'snippets';
|
||||
|
||||
return RequestHelper.get(this, url, options);
|
||||
return RequestHelper.get<SnippetSchema[]>()(this, url, options);
|
||||
}
|
||||
|
||||
content(snippetId: number, options?: Sudo) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.get(this, `snippets/${sId}/raw`, options);
|
||||
return RequestHelper.get()(this, `snippets/${sId}/raw`, options);
|
||||
}
|
||||
|
||||
create(
|
||||
@ -28,7 +61,7 @@ export class Snippets extends BaseService {
|
||||
visibility: SnippetVisibility,
|
||||
options?: BaseRequestOptions,
|
||||
) {
|
||||
return RequestHelper.post(this, 'snippets', {
|
||||
return RequestHelper.post<SnippetExtendedSchema>()(this, 'snippets', {
|
||||
title,
|
||||
fileName,
|
||||
content,
|
||||
@ -40,24 +73,28 @@ export class Snippets extends BaseService {
|
||||
edit(snippetId: number, options?: BaseRequestOptions) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.put(this, `snippets/${sId}`, options);
|
||||
return RequestHelper.put<SnippetExtendedSchema>()(this, `snippets/${sId}`, options);
|
||||
}
|
||||
|
||||
remove(snippetId: number, options?: Sudo) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.del(this, `snippets/${sId}`, options);
|
||||
return RequestHelper.del()(this, `snippets/${sId}`, options);
|
||||
}
|
||||
|
||||
show(snippetId: number, options?: Sudo) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.get(this, `snippets/${sId}`, options);
|
||||
return RequestHelper.get<SnippetSchema>()(this, `snippets/${sId}`, options);
|
||||
}
|
||||
|
||||
userAgentDetails(snippetId: number, options?: Sudo) {
|
||||
const sId = encodeURIComponent(snippetId);
|
||||
|
||||
return RequestHelper.get(this, `snippets/${sId}/user_agent_detail`, options);
|
||||
return RequestHelper.get<UserAgentDetailSchema>()(
|
||||
this,
|
||||
`snippets/${sId}/user_agent_detail`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,24 +6,35 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class SystemHooks extends BaseService {
|
||||
export interface SystemHookSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
url: string;
|
||||
created_at: string;
|
||||
push_events: boolean;
|
||||
tag_push_events: boolean;
|
||||
merge_requests_events: boolean;
|
||||
repository_update_events: boolean;
|
||||
enable_ssl_verification: boolean;
|
||||
}
|
||||
|
||||
export class SystemHooks<C extends boolean = false> extends BaseService<C> {
|
||||
add(url: string, options?: BaseRequestOptions) {
|
||||
return RequestHelper.post(this, 'hooks', { url, ...options });
|
||||
return RequestHelper.post<SystemHookSchema>()(this, 'hooks', { url, ...options });
|
||||
}
|
||||
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'hooks', options);
|
||||
return RequestHelper.get<SystemHookSchema[]>()(this, 'hooks', options);
|
||||
}
|
||||
|
||||
edit(hookId: number, url: string, options?: BaseRequestOptions) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.put(this, `hooks/${hId}`, { url, ...options });
|
||||
return RequestHelper.put<SystemHookSchema>()(this, `hooks/${hId}`, { url, ...options });
|
||||
}
|
||||
|
||||
remove(hookId: number, options?: Sudo) {
|
||||
const hId = encodeURIComponent(hookId);
|
||||
|
||||
return RequestHelper.del(this, `hooks/${hId}`, options);
|
||||
return RequestHelper.del()(this, `hooks/${hId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { CommitSchema } from './Commits';
|
||||
import { ReleaseSchema } from './Releases';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,28 +8,37 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class Tags extends BaseService {
|
||||
export interface TagSchema extends Record<string, unknown> {
|
||||
commit: CommitSchema;
|
||||
release: Pick<ReleaseSchema, 'tag_name' | 'description'>;
|
||||
name: string;
|
||||
target: string;
|
||||
message?: string;
|
||||
protected: boolean;
|
||||
}
|
||||
|
||||
export class Tags<C extends boolean = false> extends BaseService<C> {
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tags`, options);
|
||||
return RequestHelper.get<TagSchema[]>()(this, `projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
create(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/repository/tags`, options);
|
||||
return RequestHelper.post<TagSchema>()(this, `projects/${pId}/repository/tags`, options);
|
||||
}
|
||||
|
||||
remove(projectId: string | number, tagName: string, options?: Sudo) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/repository/tags/${tId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/repository/tags/${tId}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, tagName: string, options?: Sudo) {
|
||||
const [pId, tId] = [projectId, tagName].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/repository/tags/${tId}`, options);
|
||||
return RequestHelper.get<TagSchema>()(this, `projects/${pId}/repository/tags/${tId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,35 +1,84 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import { ProjectSchema } from './Projects';
|
||||
import { MilestoneSchema } from '../templates';
|
||||
import { RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
|
||||
interface CreateTodoOptions extends Sudo {
|
||||
resourceName?: 'mergerequest' | 'issue';
|
||||
export interface TodoSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
project: Pick<
|
||||
ProjectSchema,
|
||||
'id' | 'name' | 'name_with_namespace' | 'path' | 'path_with_namespace'
|
||||
>;
|
||||
author: Pick<UserSchema, 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url'>;
|
||||
action_name: string;
|
||||
target_type: string;
|
||||
target: {
|
||||
id: number;
|
||||
iid: number;
|
||||
project_id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
state: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
target_branch: string;
|
||||
source_branch: string;
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
author: Pick<UserSchema, 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url'>;
|
||||
assignee: Pick<UserSchema, 'name' | 'username' | 'id' | 'state' | 'avatar_url' | 'web_url'>;
|
||||
source_project_id: number;
|
||||
target_project_id: number;
|
||||
labels?: string[];
|
||||
work_in_progress: boolean;
|
||||
milestone: Omit<MilestoneSchema, 'start_date' | 'expired' | 'web_url'>;
|
||||
merge_when_pipeline_succeeds: boolean;
|
||||
merge_status: string;
|
||||
user_notes_count: number;
|
||||
};
|
||||
target_url: string;
|
||||
body: string;
|
||||
state: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export class Todos extends BaseService {
|
||||
export class Todos<C extends boolean = false> extends BaseService<C> {
|
||||
all(options?: PaginatedRequestOptions) {
|
||||
return RequestHelper.get(this, 'todos', options);
|
||||
return RequestHelper.get<TodoSchema[]>()(this, 'todos', options);
|
||||
}
|
||||
|
||||
create(
|
||||
projectId: string | number,
|
||||
resourceId: number,
|
||||
{ resourceName, ...options }: CreateTodoOptions = {},
|
||||
resourceName: 'mergerequest' | 'issue',
|
||||
options?: Sudo,
|
||||
) {
|
||||
if (resourceName === 'issue') {
|
||||
return RequestHelper.post(this, `projects/${projectId}/issues/${resourceId}/todo`, options);
|
||||
}
|
||||
return RequestHelper.post(
|
||||
const resourceAPI = resourceName === 'issue' ? 'issues' : 'merge_requests';
|
||||
|
||||
return RequestHelper.post<TodoSchema>()(
|
||||
this,
|
||||
`projects/${projectId}/merge_requests/${resourceId}/todo`,
|
||||
`projects/${projectId}/${resourceAPI}/${resourceId}/todo`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
done({ todoId, ...options }: { todoId?: number } & Sudo) {
|
||||
let url = 'mark_as_done';
|
||||
done({ todoId, ...options }: { todoId?: number } & Sudo = {}) {
|
||||
const url = ['todos'];
|
||||
|
||||
if (todoId) url = `${todoId}/${url}`;
|
||||
if (todoId) url.push(todoId.toString());
|
||||
|
||||
return RequestHelper.post(this, `todos/${url}`, options);
|
||||
url.push('mark_as_done');
|
||||
|
||||
// Fixme: Rewrite this to make better use of proper typing
|
||||
if (todoId) {
|
||||
return RequestHelper.post<TodoSchema>()(
|
||||
this,
|
||||
url.join('/'),
|
||||
options as Record<string, unknown>,
|
||||
);
|
||||
}
|
||||
return RequestHelper.post<void>()(this, url.join('/'), options as Record<string, unknown>);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { UserSchema } from './Users';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
PaginatedRequestOptions,
|
||||
@ -6,23 +7,38 @@ import {
|
||||
Sudo,
|
||||
} from '../infrastructure';
|
||||
|
||||
export class Triggers extends BaseService {
|
||||
export interface PipelineTriggerSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
description: string;
|
||||
created_at: string;
|
||||
last_used?: string;
|
||||
token: string;
|
||||
updated_at: string;
|
||||
owner: Pick<UserSchema, 'id' | 'name' | 'created_at'>;
|
||||
}
|
||||
|
||||
// TODO: Rename PipelineTriggers
|
||||
export class Triggers<C extends boolean = false> extends BaseService<C> {
|
||||
add(projectId: string | number, options?: BaseRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/triggers`, options);
|
||||
return RequestHelper.post<PipelineTriggerSchema>()(this, `projects/${pId}/triggers`, options);
|
||||
}
|
||||
|
||||
all(projectId: string | number, options?: PaginatedRequestOptions) {
|
||||
const pId = encodeURIComponent(projectId);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/triggers`, options);
|
||||
return RequestHelper.get<PipelineTriggerSchema[]>()(this, `projects/${pId}/triggers`, options);
|
||||
}
|
||||
|
||||
edit(projectId: string | number, triggerId: number, options?: BaseRequestOptions) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.put(this, `projects/${pId}/triggers/${tId}`, options);
|
||||
return RequestHelper.put<PipelineTriggerSchema>()(
|
||||
this,
|
||||
`projects/${pId}/triggers/${tId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
pipeline(
|
||||
@ -40,7 +56,7 @@ export class Triggers extends BaseService {
|
||||
});
|
||||
}
|
||||
|
||||
return RequestHelper.post(this, `projects/${pId}/trigger/pipeline`, {
|
||||
return RequestHelper.post()(this, `projects/${pId}/trigger/pipeline`, {
|
||||
isForm: true,
|
||||
ref,
|
||||
token,
|
||||
@ -51,12 +67,16 @@ export class Triggers extends BaseService {
|
||||
remove(projectId: string | number, triggerId: number, options?: Sudo) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `projects/${pId}/triggers/${tId}`, options);
|
||||
return RequestHelper.del()(this, `projects/${pId}/triggers/${tId}`, options);
|
||||
}
|
||||
|
||||
show(projectId: string | number, triggerId: number, options?: Sudo) {
|
||||
const [pId, tId] = [projectId, triggerId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `projects/${pId}/triggers/${tId}`, options);
|
||||
return RequestHelper.get<PipelineTriggerSchema>()(
|
||||
this,
|
||||
`projects/${pId}/triggers/${tId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,33 @@
|
||||
import { BaseServiceOptions } from '@gitbeaker/requester-utils';
|
||||
import { ResourceCustomAttributes } from '../templates';
|
||||
import { PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
import { ResourceCustomAttributes, CustomAttributeSchema } from '../templates';
|
||||
import { PaginatedRequestOptions, CamelizedRecord, Sudo } from '../infrastructure';
|
||||
|
||||
export interface UserCustomAttributes extends ResourceCustomAttributes {
|
||||
all(userId: string | number, options?: PaginatedRequestOptions);
|
||||
export interface UserCustomAttributes<C extends boolean = false>
|
||||
extends ResourceCustomAttributes<C> {
|
||||
all(
|
||||
userId: string | number,
|
||||
options?: PaginatedRequestOptions,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>[]>;
|
||||
|
||||
set(userId: string | number, customAttributeId: number, value: string, options?: Sudo);
|
||||
set(
|
||||
userId: string | number,
|
||||
customAttributeId: number,
|
||||
value: string,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>>;
|
||||
|
||||
remove(userId: string | number, customAttributeId: number, options?: Sudo);
|
||||
remove(userId: string | number, customAttributeId: number, options?: Sudo): Promise<void>;
|
||||
|
||||
show(userId: string | number, customAttributeId: number, options?: Sudo);
|
||||
show(
|
||||
userId: string | number,
|
||||
customAttributeId: number,
|
||||
options?: Sudo,
|
||||
): Promise<CamelizedRecord<C, CustomAttributeSchema>>;
|
||||
}
|
||||
|
||||
export class UserCustomAttributes extends ResourceCustomAttributes {
|
||||
constructor(options: BaseServiceOptions = {}) {
|
||||
export class UserCustomAttributes<C extends boolean = false> extends ResourceCustomAttributes<C> {
|
||||
constructor(options: BaseServiceOptions<C>) {
|
||||
/* istanbul ignore next */
|
||||
super('users', options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,36 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, RequestHelper } from '../infrastructure';
|
||||
|
||||
const url = (userId) => (userId ? `users/${encodeURIComponent(userId)}/emails` : 'user/emails');
|
||||
export interface UserEmailSchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
email: string;
|
||||
confirmed_at: string;
|
||||
}
|
||||
|
||||
export class UserEmails extends BaseService {
|
||||
const url = (userId?: number) =>
|
||||
userId ? `users/${encodeURIComponent(userId)}/emails` : 'user/emails';
|
||||
|
||||
export class UserEmails<C extends boolean = false> extends BaseService<C> {
|
||||
all({ userId, ...options }: { userId?: number } & PaginatedRequestOptions = {}) {
|
||||
return RequestHelper.get(this, url(userId), options);
|
||||
return RequestHelper.get<UserEmailSchema[]>()(this, url(userId), options);
|
||||
}
|
||||
|
||||
add(email, { userId, ...options }: { userId?: number } & BaseRequestOptions = {}) {
|
||||
return RequestHelper.post(this, url(userId), {
|
||||
add(email: string, { userId, ...options }: { userId?: number } & BaseRequestOptions = {}) {
|
||||
return RequestHelper.post<UserEmailSchema>()(this, url(userId), {
|
||||
email,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
show(emailId, options?: BaseRequestOptions) {
|
||||
show(emailId: number, options?: BaseRequestOptions) {
|
||||
const eId = encodeURIComponent(emailId);
|
||||
|
||||
return RequestHelper.get(this, `user/emails/${eId}`, options);
|
||||
return RequestHelper.get<UserEmailSchema>()(this, `user/emails/${eId}`, options);
|
||||
}
|
||||
|
||||
remove(emailId, { userId, ...options }: { userId?: number } & BaseRequestOptions = {}) {
|
||||
remove(emailId: number, { userId, ...options }: { userId?: number } & BaseRequestOptions = {}) {
|
||||
const eId = encodeURIComponent(emailId);
|
||||
|
||||
return RequestHelper.del(this, `${url(userId)}/${eId}`, options);
|
||||
return RequestHelper.del()(this, `${url(userId)}/${eId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,22 @@
|
||||
import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { BaseRequestOptions, PaginatedRequestOptions, RequestHelper } from '../infrastructure';
|
||||
|
||||
const url = (userId) =>
|
||||
userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys';
|
||||
export interface UserGPGKeySchema extends Record<string, unknown> {
|
||||
id: number;
|
||||
key: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export class UserGPGKeys extends BaseService {
|
||||
const url = (userId?: number) =>
|
||||
userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'user/gpg_keys';
|
||||
|
||||
export class UserGPGKeys<C extends boolean = false> extends BaseService<C> {
|
||||
all({ userId, ...options }: { userId?: number } & PaginatedRequestOptions = {}) {
|
||||
return RequestHelper.get(this, url(userId), options);
|
||||
return RequestHelper.get<UserGPGKeySchema[]>()(this, url(userId), options);
|
||||
}
|
||||
|
||||
add(key: string, { userId, ...options }: { userId?: number } & BaseRequestOptions = {}) {
|
||||
return RequestHelper.post(this, url(userId), {
|
||||
return RequestHelper.post<UserGPGKeySchema>()(this, url(userId), {
|
||||
key,
|
||||
...options,
|
||||
});
|
||||
@ -19,12 +25,12 @@ export class UserGPGKeys extends BaseService {
|
||||
show(keyId: number, { userId, ...options }: { userId?: number } & BaseRequestOptions = {}) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.get(this, `${url(userId)}/${kId}`, options);
|
||||
return RequestHelper.get<UserGPGKeySchema>()(this, `${url(userId)}/${kId}`, options);
|
||||
}
|
||||
|
||||
remove(keyId: number, { userId, ...options }: { userId?: number } & BaseRequestOptions = {}) {
|
||||
const kId = encodeURIComponent(keyId);
|
||||
|
||||
return RequestHelper.del(this, `${url(userId)}/${kId}`, options);
|
||||
return RequestHelper.del()(this, `${url(userId)}/${kId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,14 +2,32 @@ import { BaseService } from '@gitbeaker/requester-utils';
|
||||
import { RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
|
||||
|
||||
type ImpersonationTokenScope = 'api' | 'read_user';
|
||||
type ImpersonationTokenState = 'all' | 'active' | 'inactive';
|
||||
|
||||
export class UserImpersonationTokens extends BaseService {
|
||||
all(userId: number, options?: PaginatedRequestOptions) {
|
||||
export interface UserImpersonationTokenSchema extends Record<string, unknown> {
|
||||
active: boolean;
|
||||
user_id: number;
|
||||
scopes?: string[];
|
||||
revoked: boolean;
|
||||
name: string;
|
||||
id: number;
|
||||
created_at: string;
|
||||
impersonation: boolean;
|
||||
expires_at: string;
|
||||
}
|
||||
|
||||
export class UserImpersonationTokens<C extends boolean = false> extends BaseService<C> {
|
||||
all(userId: number, options?: { state?: ImpersonationTokenState } & PaginatedRequestOptions) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/impersonation_tokens`, options);
|
||||
return RequestHelper.get<UserImpersonationTokenSchema[]>()(
|
||||
this,
|
||||
`users/${uId}/impersonation_tokens`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: change required params
|
||||
add(
|
||||
userId: number,
|
||||
name: string,
|
||||
@ -19,23 +37,31 @@ export class UserImpersonationTokens extends BaseService {
|
||||
) {
|
||||
const uId = encodeURIComponent(userId);
|
||||
|
||||
return RequestHelper.post(this, `users/${uId}/impersonation_tokens`, {
|
||||
name,
|
||||
expiresAt,
|
||||
scopes,
|
||||
...options,
|
||||
});
|
||||
return RequestHelper.post<UserImpersonationTokenSchema>()(
|
||||
this,
|
||||
`users/${uId}/impersonation_tokens`,
|
||||
{
|
||||
name,
|
||||
expiresAt,
|
||||
scopes,
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
show(userId: number, tokenId: number, options?: Sudo) {
|
||||
const [uId, tId] = [userId, tokenId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.get(this, `users/${uId}/impersonation_tokens/${tId}`, options);
|
||||
return RequestHelper.get<UserImpersonationTokenSchema>()(
|
||||
this,
|
||||
`users/${uId}/impersonation_tokens/${tId}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
revoke(userId: number, tokenId: number, options?: Sudo) {
|
||||
const [uId, tId] = [userId, tokenId].map(encodeURIComponent);
|
||||
|
||||
return RequestHelper.del(this, `users/${uId}/impersonation_tokens/${tId}`, options);
|
||||
return RequestHelper.del()(this, `users/${uId}/impersonation_tokens/${tId}`, options);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user