Skip to content

Commit

Permalink
fix(remote): remove fake typeguard around gitlab responses
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Aug 5, 2021
1 parent 4e6c007 commit f2475c7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/remote/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import { BaseOptions } from 'noicejs';
import { CommentUpdate, IssueUpdate, LabelUpdate, ProjectQuery, Remote, RemoteOptions } from '.';
import { BaseRemote } from './base';

export function unwrapResponse<T>(resp: unknown): T {
return resp as T;
}

// TODO: find this type without instantiating a client
const client = new Gitlab({});

Expand Down Expand Up @@ -73,11 +69,13 @@ export class GitlabRemote extends BaseRemote<typeof client, RemoteOptions> imple

public async listIssues(options: ProjectQuery): Promise<Array<IssueUpdate>> {
const project = await this.resolvePath(options.project);
const data = unwrapResponse<Array<GitlabIssue>>(await mustExist(this.client).Issues.all({
...project,
}));
const data = await mustExist(this.client).Issues.all(project);

// TODO: the compiler has trouble with the types of data items and shows them as empty
// when they should be something based on Array<Types.IssueSchema>

return data.map((issue) => ({
/* eslint-disable-next-line */
return data.map((issue: any) => ({
issue: issue.iid.toString(),
labels: issue.labels,
name: issue.title,
Expand All @@ -87,7 +85,7 @@ export class GitlabRemote extends BaseRemote<typeof client, RemoteOptions> imple

public async listLabels(options: ProjectQuery): Promise<Array<LabelUpdate>> {
const project = await this.resolvePath(options.project);
const data = unwrapResponse<Array<GitlabLabel>>(await mustExist(this.client).Labels.all(project.projectId));
const data = await mustExist(this.client).Labels.all(project.projectId);

return data.map((label) => ({
color: label.color.replace(/^#/, ''),
Expand Down Expand Up @@ -126,7 +124,7 @@ export class GitlabRemote extends BaseRemote<typeof client, RemoteOptions> imple
groupId: number;
projectId: number;
}> {
const project = unwrapResponse<GitlabProject>(await mustExist(this.client).Projects.show(path));
const project = await mustExist(this.client).Projects.show(path);

return {
groupId: project.namespace.id,
Expand Down

0 comments on commit f2475c7

Please sign in to comment.