fix: Make package Typescript-conformant

Remove the typings directory.
Declare and use the types/interfaces in the various index.ts files.
This will produce a package that can be used by Typescript without
errors.

Remove the typings directory. Declare and use the types/interfaces in the various index.ts files.

This will produce a package that can be used by Typescript without errors.
This commit is contained in:
Daniel Rose 2019-06-12 13:28:22 +02:00
parent b811a0b917
commit da1a8f6a63
109 changed files with 698 additions and 329 deletions

View File

@ -24,8 +24,7 @@
"email": "justin.s.dalrymple@gmail.com"
},
"files": [
"dist",
"typings"
"dist"
],
"main": "dist/index.js",
"module": "dist/index.es.js",

View File

@ -1,4 +1,3 @@
/// <reference types="../typings" />
import { shim } from 'universal-url';
// Add URL shim

View File

@ -1,4 +1,5 @@
import { KyRequester } from './KyRequester';
import { Requester, BaseServiceOptions } from '.';
export class BaseService {
public readonly url: string;

View File

@ -2,6 +2,7 @@ import Ky from 'ky-universal';
import { decamelizeKeys } from 'humps';
import { stringify } from 'query-string';
import { skipAllCaps } from './Utils';
import { Requester } from '.';
const methods = ['get', 'post', 'put', 'delete', 'stream'];
const KyRequester = {} as Requester;

View File

@ -1,6 +1,15 @@
import Li from 'li';
import { camelizeKeys } from 'humps';
import { BaseService } from './BaseService';
import {
BaseRequestOptions,
DelResponse,
GetResponse,
PaginatedRequestOptions,
PaginationResponse,
PostResponse,
PutResponse,
} from '.';
export async function get(
service: BaseService,

View File

@ -1,3 +1,5 @@
import { Constructor, Bundle } from ".";
export function bundler<T extends { [name: string]: Constructor }, P extends keyof T>(services: T) {
return (function Bundle(options?: any) {
Object.entries(services || {}).forEach(([name, ser]) => {

View File

@ -4,3 +4,74 @@ export { BaseService } from './BaseService';
export { bundler } from './Utils';
export { KyRequester } from './KyRequester';
export { RequestHelper };
// Bundler
export interface Constructor {
new (...args: any): any;
}
export type Mapper<T extends { [name: string]: Constructor }, P extends keyof T> = {
[name in P]: InstanceType<T[name]>
};
export interface Bundle<T extends { [name: string]: Constructor }, P extends keyof T> {
new (options?: any): Mapper<T, P>;
}
// Base Service
export interface Sudo {
sudo?: string | number;
}
export interface Requester {
get: Function;
post: Function;
put: Function;
delete: Function;
stream?: Function;
}
export interface BaseServiceOptions extends Sudo {
oauthToken?: string;
token?: string;
jobToken?: string;
host?: string;
url?: string;
version?: string;
rejectUnauthorized?: boolean;
camelize?: boolean;
requester?: Requester;
requestTimeout?: number;
}
// RequestHelper
export interface PaginationOptions {
total: number;
next: number | null;
current: number;
previous: number | null;
perPage: number;
totalPages: number;
}
export interface DefaultRequestOptions extends Sudo {
body?: object | FormData;
query?: object;
}
export interface BaseRequestOptions extends Sudo {
[key: string]: any;
}
export interface PaginatedRequestOptions extends BaseRequestOptions {
showPagination?: boolean;
maxPages?: number;
page?: number;
perPage?: number;
}
export type PaginationResponse = { data: object[], pagination: PaginationOptions }
export type GetResponse = PaginationResponse | object | object[];
export type PostResponse = object;
export type PutResponse = object;
export type DelResponse = object;

View File

@ -1,4 +1,4 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo, BaseRequestOptions } from '../infrastructure';
class ApplicationSettings extends BaseService {
all(options?: Sudo) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId } from '.';
class Branches extends BaseService {
all(projectId: ProjectId, options?: { search?: string } & PaginatedRequestOptions) {

View File

@ -1,4 +1,10 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
import { BroadcastMessageId } from '.';
class BroadcastMessages extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceDiscussions } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class CommitDiscussions extends ResourceDiscussions {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, CommitAction } from '.';
class Commits extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
import { ProjectId } from '.';
class ContainerRegistry extends BaseService {
repositories(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo, PaginatedRequestOptions } from '../infrastructure';
import { ProjectId, KeyId } from '.';
class DeployKeys extends BaseService {
add(projectId: ProjectId, options?: Sudo) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
import { ProjectId, DeploymentId } from '.';
class Deployments extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, EnvironmentId } from '.';
class Environments extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceDiscussions } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class EpicDiscussions extends ResourceDiscussions {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { GroupId, EpicId, IssueId } from '.';
class EpicIssues extends BaseService {
all(groupId: GroupId, epicId: EpicId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceNotes } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class EpicNotes extends ResourceNotes {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { GroupId, EpicId } from '.';
class Epics extends BaseService {
all(groupId: GroupId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, PaginatedRequestOptions } from '../infrastructure';
import { EventOptions } from '.';
class Events extends BaseService {
all(options?: PaginatedRequestOptions & EventOptions) {

View File

@ -1,4 +1,9 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
class FeatureFlags extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { GeonodeId } from '.';
class GeoNodes extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceTemplates } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GitLabCIYMLTemplates extends ResourceTemplates {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceTemplates } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GitignoreTemplates extends ResourceTemplates {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceAccessRequests } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GroupAccessRequests extends ResourceAccessRequests {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceBadges } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GroupBadges extends ResourceBadges {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceCustomAttributes } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GroupCustomAttributes extends ResourceCustomAttributes {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceIssueBoards } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GroupIssueBoards extends ResourceIssueBoards {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceMembers } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GroupMembers extends ResourceMembers {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceMilestones } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GroupMilestones extends ResourceMilestones {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,10 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
import { GroupProjectId, ProjectId } from '.';
class GroupProjects extends BaseService {
all(groupId: GroupProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceVariables } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class GroupVariables extends ResourceVariables {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { GroupId } from '.';
class Groups extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceAwardEmojis } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class IssueAwardEmojis extends ResourceAwardEmojis {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceDiscussions } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class IssueDiscussions extends ResourceDiscussions {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceNotes } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class IssueNotes extends ResourceNotes {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, IssueId } from '.';
class Issues extends BaseService {
addSpentTime(projectId: ProjectId, issueId: IssueId, duration: string, options?: Sudo) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, JobId, PipelineId, JobScope } from '.';
class Jobs extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo } from '../infrastructure';
import { KeyId } from '.';
class Keys extends BaseService {
show(keyId: KeyId, options?: Sudo) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, LabelId } from '.';
class Labels extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,4 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo } from '../infrastructure';
class Licence extends BaseService {
all(options?: Sudo) {

View File

@ -1,4 +1,5 @@
import { ResourceTemplates } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class LicenceTemplates extends ResourceTemplates {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,4 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo } from '../infrastructure';
class Lint extends BaseService {
lint(content: string, options?: Sudo) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo } from '../infrastructure';
import { ProjectId } from '.';
class Markdown extends BaseService {
render(text: string, options: { gfm?: string; project?: ProjectId } & Sudo) {

View File

@ -1,4 +1,5 @@
import { ResourceAwardEmojis } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class MergeRequestAwardEmojis extends ResourceAwardEmojis {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceDiscussions } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class MergeRequestDiscussions extends ResourceDiscussions {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceNotes } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class MergeRequestNotes extends ResourceNotes {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,20 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import {
AcceptMergeRequestOptions,
CreateMergeRequestOptions,
GroupId,
MergeRequestId,
ProjectId,
ShowMergeRequestOptions,
UpdateMergeRequestOptions,
UserId,
} from '.';
class MergeRequests extends BaseService {
accept(

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
import { NamespaceId } from '.';
class Namespaces extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,10 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
import { ProjectId, GroupId, NotificationSettingLevel } from '.';
class NotificationSettings extends BaseService {
all({

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId } from '.';
class PagesDomains extends BaseService {
all({ projectId, ...options }: { projectId?: ProjectId } & PaginatedRequestOptions = {}) {

View File

@ -1,4 +1,10 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
import { ProjectId, PipelineScheduleId, KeyId } from '.';
class PipelineScheduleVariables extends BaseService {
all(

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, PipelineScheduleId } from '.';
class PipelineSchedules extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, PipelineId, JobScope } from '.';
class Pipelines extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceAccessRequests } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectAccessRequests extends ResourceAccessRequests {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceBadges } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectBadges extends ResourceBadges {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceCustomAttributes } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectCustomAttributes extends ResourceCustomAttributes {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, HookId } from '.';
class ProjectHooks extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,5 +1,6 @@
import FormData from 'form-data';
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo, BaseRequestOptions } from '../infrastructure';
import { ProjectId } from '.';
class ProjectImportExport extends BaseService {
download(projectId: ProjectId, options?: Sudo) {

View File

@ -1,4 +1,5 @@
import { ResourceIssueBoards } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectIssueBoards extends ResourceIssueBoards {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceMembers } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectMembers extends ResourceMembers {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceMilestones } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectMilestones extends ResourceMilestones {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceAwardEmojis } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectSnippetAwardEmojis extends ResourceAwardEmojis {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceDiscussions } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectSnippetDiscussions extends ResourceDiscussions {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceNotes } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectSnippetNotes extends ResourceNotes {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, SnippetId, SnippetVisibility } from '.';
class ProjectSnippets extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceVariables } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class ProjectVariables extends ResourceVariables {
constructor(options: BaseServiceOptions) {

View File

@ -1,6 +1,13 @@
import FormData from 'form-data';
import randomstring from 'randomstring';
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, UserId, EventOptions, GroupId, NamespaceId, ProjectUploadMetadata } from '.';
class Projects extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId } from '.';
class ProtectedBranches extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId } from '.';
class ProtectedTags extends BaseService {
all(projectId: ProjectId, options: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
import { ProjectId } from '.';
class PushRule extends BaseService {
create(projectId: ProjectId, options?: BaseRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
import { ProjectId } from '.';
class ReleaseLinks extends BaseService {
all(projectId: ProjectId, tagName: string, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId } from '.';
class Releases extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo, BaseRequestOptions } from '../infrastructure';
import { ProjectId } from '.';
class Repositories extends BaseService {
compare(projectId: ProjectId, from: string, to: string, options?: Sudo) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
import { ProjectId } from '.';
class RepositoryFiles extends BaseService {
create(

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, RunnerId } from '.';
class Runners extends BaseService {
all({ projectId, ...options }: { projectId: ProjectId } & PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, BaseRequestOptions } from '../infrastructure';
import { ProjectId, GroupId } from '.';
class Search extends BaseService {
all(

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, BaseRequestOptions, Sudo } from '../infrastructure';
import { ProjectId, SupportedService } from '.';
class Services extends BaseService {
edit(projectId: ProjectId, serviceName: SupportedService, options?: BaseRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { SnippetId, SnippetVisibility } from '.';
class Snippets extends BaseService {
all({ public: p, ...options }: { public: boolean } & PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { HookId } from '.';
class SystemHooks extends BaseService {
add(url: string, options?: BaseRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId } from '.';
class Tags extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
import { ProjectId, MergeRequestId, TodoId } from '.';
class Todos extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, TriggerId } from '.';
class Triggers extends BaseService {
add(projectId: ProjectId, options?: BaseRequestOptions) {

View File

@ -1,4 +1,5 @@
import { ResourceCustomAttributes } from '../templates';
import { BaseServiceOptions } from '../infrastructure';
class UserCustomAttributes extends ResourceCustomAttributes {
constructor(options: BaseServiceOptions) {

View File

@ -1,4 +1,10 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
import { UserId } from '.';
const url = userId => (userId ? `users/${encodeURIComponent(userId)}/emails` : 'user/emails');

View File

@ -1,4 +1,10 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
import { UserId } from '.';
const url = userId => (userId ? `users/${encodeURIComponent(userId)}/gpg_keys` : 'users/gpg_keys');

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, PaginatedRequestOptions, Sudo } from '../infrastructure';
import { UserId, ImpersonationTokenScope, ImpersonationTokenId } from '.';
class UserImpersonationTokens extends BaseService {
all(userId: UserId, options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,10 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
} from '../infrastructure';
import { UserId } from '.';
const url = userId => (userId ? `users/${encodeURIComponent(userId)}/keys` : 'user/keys');

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { UserId, EventOptions } from '.';
class Users extends BaseService {
all(options?: PaginatedRequestOptions) {

View File

@ -1,4 +1,4 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, Sudo } from '../infrastructure';
class Version extends BaseService {
show(options?: Sudo) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId } from '.';
class Wikis extends BaseService {
all(projectId: ProjectId, options?: PaginatedRequestOptions) {

View File

@ -91,3 +91,182 @@ export { default as Snippets } from './Snippets';
export { default as SystemHooks } from './SystemHooks';
export { default as Version } from './Version';
export { default as Wikis } from './Wikis';
export type AwardId = number;
export type BroadcastMessageId = number;
export type BadgeId = number;
export type BoardId = number;
export type CustomAttributeId = number;
export type DeploymentId = number;
export type DiscussionId = number;
export type EnvironmentId = number;
export type EpicId = number;
export type GeonodeId = number;
export type GroupId = string | number;
export type GroupProjectId = string | number;
export type HookId = number;
export type ImpersonationTokenId = number;
export type IssueId = number;
export type JobId = number;
export type LabelId = number;
export type KeyId = string;
export type NamespaceId = string | number;
export type MergeRequestId = number;
export type MilestoneId = number;
export type NoteId = number;
export type PipelineId = number;
export type PipelineScheduleId = number;
export type ProjectId = string | number;
export type RunnerId = number;
export type ResourceId = string | number;
export type SnippetId = number;
export type TodoId = number;
export type TriggerId = number;
export type VersionId = number;
export type UserId = number;
// Access Requests
export type AccessLevel = 10 | 20 | 30 | 40 | 50;
// Commits
export interface CommitAction {
/** The action to perform */
action: 'create' | 'delete' | 'move' | 'update';
/** Full path to the file. Ex. lib/class.rb */
filePath: string;
/** Original full path to the file being moved.Ex.lib / class1.rb */
previousPath?: string;
/** File content, required for all except delete. Optional for move */
content?: string;
/** text or base64. text is default. */
encoding?: string;
/** Last known file commit id. Will be only considered in update, move and delete actions. */
lastCommitId?: string;
}
// Events
export interface EventOptions {
action?:
| 'created'
| 'updated'
| 'closed'
| 'reopened'
| 'pushed'
| 'commented'
| 'merged'
| 'joined'
| 'left'
| 'destroyed'
| 'expired';
targetType?: 'issue' | 'milestone' | 'merge_request' | 'note' | 'project' | 'snippet' | 'user';
}
// Jobs
export type JobScope =
| 'created'
| 'pending'
| 'running'
| 'failed'
| 'success'
| 'canceled'
| 'skipped'
| 'manual';
// Merge Requests
export interface AcceptMergeRequestOptions {
merge_commit_message?: string;
squash_commit_message?: string;
squash?: boolean;
should_remove_source_branch?: boolean;
merge_when_pipeline_succeeds?: boolean;
sha?: string;
}
export interface ShowMergeRequestOptions {
render_html?: boolean;
include_diverged_commits_count?: true;
include_rebase_in_progress?: boolean;
}
export interface CreateMergeRequestOptions {
assignee_id?: number;
description?: string;
target_project_id?: number;
labels?: string;
milestone_id?: number;
remove_source_branch?: boolean;
allow_collaboration?: boolean;
allow_maintainer_to_push?: boolean;
squash?: boolean;
}
export interface UpdateMergeRequestOptions {
target_branch?: number;
title?: string;
assignee_id?: number;
milestone_id?: number;
labels?: string;
description?: string;
state_event?: string;
remove_source_branch?: boolean;
squash?: boolean;
discussion_locked?: boolean;
allow_collaboration?: boolean;
allow_maintainer_to_push?: boolean;
}
// Notification Settings Levels
export type NotificationSettingLevel =
| 'disabled'
| 'participating'
| 'watch'
| 'global'
| 'mention'
| 'custom';
// Services
export type SupportedService =
| 'asana'
| 'assembla'
| 'bamboo'
| 'bugzilla'
| 'buildkite'
| 'campfire'
| 'custom-issue-tracker'
| 'drone-ci'
| 'emails-on-push'
| 'external-wiki'
| 'flowdock'
| 'hangouts_chat'
| 'hipchat'
| 'irker'
| 'jira'
| 'kubernetes'
| 'slack-slash-commands'
| 'slack'
| 'mattermost-slash-commands'
| 'packagist'
| 'pipelines-email'
| 'pivotaltracker'
| 'prometheus'
| 'pushover'
| 'redmine'
| 'microsoft-teams'
| 'mattermost'
| 'mattermost-slash-commands'
| 'teamcity'
| 'jenkins'
| 'jenkins-deprecated'
| 'mock-ci';
// Snippets
export type SnippetVisibility = 'private' | 'public' | 'internal';
// User Impersonation Tokens
export type ImpersonationTokenScope = 'api' | 'read_user';
// Project upload metadata
export interface ProjectUploadMetadata {
filename?: string;
contentType?: string;
}

View File

@ -1,4 +1,5 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { BaseService, RequestHelper, BaseServiceOptions, Sudo } from '../infrastructure';
import { ResourceId, UserId, AccessLevel } from '..';
class ResourceAccessRequests extends BaseService {
constructor(resourceType: string, options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseService,
BaseServiceOptions,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ProjectId, ResourceId, NoteId, AwardId } from '..';
function url(projectId, resourceType, resourceId, awardId, noteId) {
const [pId, rId] = [projectId, resourceId].map(encodeURIComponent);

View File

@ -1,4 +1,12 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
BaseServiceOptions,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ResourceId, BadgeId } from '..';
class ResourceBadges extends BaseService {
constructor(resourceType: string, options: BaseServiceOptions) {

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseService,
BaseServiceOptions,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ResourceId, CustomAttributeId } from '..';
class ResourceCustomAttributes extends BaseService {
constructor(resourceType: string, options: BaseServiceOptions) {

View File

@ -1,4 +1,12 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
BaseServiceOptions,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ResourceId, DiscussionId, NoteId } from '..';
class ResourceDiscussions extends BaseService {
protected resource2Type: string;

View File

@ -1,4 +1,11 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ResourceId, LabelId } from '..';
class ResourceIssueBoards extends BaseService {
constructor(resourceType: string, options) {

View File

@ -1,4 +1,12 @@
import { BaseService, RequestHelper } from '../infrastructure';
import {
BaseRequestOptions,
BaseService,
BaseServiceOptions,
PaginatedRequestOptions,
RequestHelper,
Sudo,
} from '../infrastructure';
import { ResourceId, UserId, AccessLevel } from '..';
class ResourceMembers extends BaseService {
constructor(resourceType: string, options: BaseServiceOptions) {

Some files were not shown because too many files have changed in this diff Show More