1
0
Fork 0

feat(remote): sketch out interface, stub github/gitlab remotes

This commit is contained in:
ssube 2020-08-11 19:37:00 -05:00
parent fe160fa53e
commit 7af3f35baf
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
3 changed files with 159 additions and 0 deletions

44
src/remote/github.ts Normal file
View File

@ -0,0 +1,44 @@
import { NotImplementedError } from '@apextoaster/js-utils';
import { IssueUpdate, LabelUpdate, Remote } from '.';
/**
* Github/Octokit API implementation of the `Remote` contract.
*/
export class GithubRemote implements Remote {
public async createComment() {
throw new NotImplementedError();
}
public async createLabel(): Promise<LabelUpdate> {
throw new NotImplementedError();
}
public async deleteLabel(): Promise<LabelUpdate> {
throw new NotImplementedError();
}
public async getIssue(): Promise<Array<IssueUpdate>> {
throw new NotImplementedError();
}
public async getLabel(): Promise<Array<LabelUpdate>> {
throw new NotImplementedError();
}
public async listIssues(): Promise<Array<IssueUpdate>> {
throw new NotImplementedError();
}
public async listLabels(): Promise<Array<LabelUpdate>> {
throw new NotImplementedError();
}
public async updateIssue(): Promise<IssueUpdate> {
throw new NotImplementedError();
}
public async updateLabel(): Promise<LabelUpdate> {
throw new NotImplementedError();
}
}

45
src/remote/gitlab.ts Normal file
View File

@ -0,0 +1,45 @@
import { NotImplementedError } from '@apextoaster/js-utils';
import { IssueUpdate, LabelUpdate, Remote } from '.';
/**
* Gitlab API implementation of the `Remote` contract.
*/
export class GitlabRemote implements Remote {
public async createComment() {
throw new NotImplementedError();
}
public async createLabel(): Promise<LabelUpdate> {
throw new NotImplementedError();
}
public async deleteLabel(): Promise<LabelUpdate> {
throw new NotImplementedError();
}
public async getIssue(): Promise<Array<IssueUpdate>> {
throw new NotImplementedError();
}
public async getLabel(): Promise<Array<LabelUpdate>> {
throw new NotImplementedError();
}
public async listIssues(): Promise<Array<IssueUpdate>> {
throw new NotImplementedError();
}
public async listLabels(): Promise<Array<LabelUpdate>> {
throw new NotImplementedError();
}
public async updateIssue(): Promise<IssueUpdate> {
throw new NotImplementedError();
}
public async updateLabel(): Promise<LabelUpdate> {
throw new NotImplementedError();
}
}

70
src/remote/index.ts Normal file
View File

@ -0,0 +1,70 @@
export interface LabelQuery {
project: string;
name: string;
}
export interface IssueQuery {
project: string;
issue: string;
}
export interface CommentUpdate extends IssueQuery {
comment: string;
}
export interface IssueUpdate extends IssueQuery {
labels: Array<string>;
name: string;
}
export interface LabelUpdate extends LabelQuery {
color: string;
desc: string;
}
/**
* Basic functions which every remote API must provide.
*/
export interface Remote {
/**
* Add a comment to an issue (for attribution and auditing).
*/
createComment(options: CommentUpdate): Promise<unknown>;
/**
* Create a new label.
*/
createLabel(options: LabelQuery): Promise<LabelUpdate>;
/**
* Delete an existing label.
*/
deleteLabel(options: LabelQuery): Promise<LabelUpdate>;
/**
* Get details of a single issue.
*/
getIssue(options: IssueQuery): Promise<Array<IssueUpdate>>;
/**
* Get details of a single label.
*/
getLabel(options: LabelQuery): Promise<Array<LabelUpdate>>;
/**
* List all issues.
*/
listIssues(): Promise<Array<IssueUpdate>>;
/**
* List all labels.
*/
listLabels(): Promise<Array<LabelUpdate>>;
/**
* Set labels on an issue.
*/
updateIssue(options: IssueUpdate): Promise<IssueUpdate>;
updateLabel(options: LabelUpdate): Promise<LabelUpdate>;
}