bananareporter
Version:
Easily generate a report from multiple sources
123 lines (122 loc) • 3.83 kB
TypeScript
import { CommonBananaReporterObj, IntegrationBase } from './base';
import { BananaConfig } from '../core';
import { z } from 'zod';
type GitlabRawEventData = {
'id': 123;
'project_id': 4;
'action_name': 'pushed to';
'target_id': null;
'target_iid': null;
'target_type': null;
'author_id': 333;
'target_title': null;
'created_at': '2022-01-03T16:29:13.384Z';
'author': {
'id': 333;
'username': 'testusername';
'name': 'Test';
'state': 'active';
'avatar_url': 'https://gitlab.com/uploads/-/system/user/avatar/333/avatar.png';
'web_url': 'https://gitlab.com/testusername';
};
'push_data': {
'commit_count': 2;
'action': 'pushed';
'ref_type': 'branch';
'commit_from': '314d57ea6ece959ffe94a5186abc67db0372dae2';
'commit_to': '7fec56814c69d22296c3e3e240763a0c759d3927';
'ref': 'branchname';
'commit_title': 'chore: commit msg';
'ref_count': null;
};
'author_username': 'testusername';
};
export type GitlabConfig = z.infer<typeof GitlabConfig>;
export declare const GitlabConfig: z.ZodObject<{
committerUsername: z.ZodString;
userId: z.ZodOptional<z.ZodNumber>;
token: z.ZodString;
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
on: z.ZodString;
regex: z.ZodString;
}, "strip", z.ZodTypeAny, {
on: string;
regex: string;
}, {
on: string;
regex: string;
}>, "atleastone">>;
domain: z.ZodDefault<z.ZodOptional<z.ZodString>>;
apiVersion: z.ZodDefault<z.ZodOptional<z.ZodString>>;
protocol: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"http">, z.ZodLiteral<"https">]>>>;
apiBasePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
from: z.ZodOptional<z.ZodString>;
to: z.ZodOptional<z.ZodString>;
delay: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
protocol: "http" | "https";
committerUsername: string;
token: string;
domain: string;
apiVersion: string;
apiBasePath: string;
userId?: number | undefined;
filters?: [{
on: string;
regex: string;
}, ...{
on: string;
regex: string;
}[]] | undefined;
from?: string | undefined;
to?: string | undefined;
delay?: number | undefined;
}, {
committerUsername: string;
token: string;
userId?: number | undefined;
filters?: [{
on: string;
regex: string;
}, ...{
on: string;
regex: string;
}[]] | undefined;
domain?: string | undefined;
apiVersion?: string | undefined;
protocol?: "http" | "https" | undefined;
apiBasePath?: string | undefined;
from?: string | undefined;
to?: string | undefined;
delay?: number | undefined;
}>;
export declare class GitlabIntegration extends IntegrationBase {
static type: "gitlab";
private projectIdToDetails;
private httpClient;
private config;
private delayToUse;
private dateRange;
private bananaReporterConfig;
constructor(_rawConfig: unknown, bananaReporterConfig: BananaConfig);
private setup;
private httpRequest;
/**
* events API needs the user id, retrieve it
* from the username provided
* @returns GitLab user id
*/
private getUserId;
fetchData(): Promise<CommonBananaReporterObj[]>;
/**
* GitLab doesn't return project information in the events call,
* need to fetch all projects to enrich the events data
* @param userId identifier of gitlab user
* @param projectIds set of project ids found in events call
* @returns list of projects found
*/
private getProjects;
private getUserEvents;
toBananaReporterObj(rawData: GitlabRawEventData): CommonBananaReporterObj;
}
export {};