bananareporter
Version:
Easily generate a report from multiple sources
216 lines (215 loc) • 10.9 kB
TypeScript
import { CommonBananaReporterObj, IntegrationBase } from './base';
import { BananaConfig } from '../core';
import { z } from 'zod';
type GithubCommitItemData = {
'url': 'https://api.github.com/repos/username/reponame/commits/dd0de5e530c625e188ec7211816898deee6b36ec';
'sha': 'dd0de5e230c625e188ec7211816898deee6b36ec';
'node_id': 'MDY1Q29tbWl0NTQ3OTE5NDExOmRkMGRlNWU1MzBjNjI1ZTE4OGVjNzIxMTgxNjg5OGRlZWU2YjM2ZWM=';
'html_url': 'https://github.com/username/reponame/commit/dd0de5e530c625e188ec7211816898deee6b36ec';
'comments_url': 'https://api.github.com/repos/username/reponame/commits/dd0de5e530c625e188ec7211816898deee6b36ec/comments';
'commit': {
'url': 'https://api.github.com/repos/username/reponame/git/commits/dd0de5e530c625e188ec7211816898deee6b36ec';
'author': {
'date': '2022-10-08T20:16:43.000+02:00';
'name': 'username';
'email': 'usernamegit@example.com';
};
'committer': {
'date': '2022-10-08T20:16:43.000+02:00';
'name': 'username';
'email': 'usernamegit@example.com';
};
'message': 'refactor: moved custom badge to components folder';
'tree': {
'url': 'https://api.github.com/repos/username/reponame/git/trees/535dc8a05b4bb6f97bda80f3722e85f9af06bd7f';
'sha': '535dc8a05b4bb6f97bda80f3722e85f9af06bd7f';
};
'comment_count': 0;
};
'author': {
'login': 'username';
'id': 1;
'node_id': 'MDQ2VXNlcjE2NjM2NzQz';
'avatar_url': 'https://avatars.githubusercontent.com/u/1?v=4';
'gravatar_id': '';
'url': 'https://api.github.com/users/username';
'html_url': 'https://github.com/username';
'followers_url': 'https://api.github.com/users/username/followers';
'following_url': 'https://api.github.com/users/username/following{/other_user}';
'gists_url': 'https://api.github.com/users/username/gists{/gist_id}';
'starred_url': 'https://api.github.com/users/username/starred{/owner}{/repo}';
'subscriptions_url': 'https://api.github.com/users/username/subscriptions';
'organizations_url': 'https://api.github.com/users/username/orgs';
'repos_url': 'https://api.github.com/users/username/repos';
'events_url': 'https://api.github.com/users/username/events{/privacy}';
'received_events_url': 'https://api.github.com/users/username/received_events';
'type': 'User';
'site_admin': false;
};
'committer': {
'login': 'username';
'id': 1;
'node_id': 'MDQ4VXNlcjE2NjM2NzQz';
'avatar_url': 'https://avatars.githubusercontent.com/u/1?v=4';
'gravatar_id': '';
'url': 'https://api.github.com/users/username';
'html_url': 'https://github.com/username';
'followers_url': 'https://api.github.com/users/username/followers';
'following_url': 'https://api.github.com/users/username/following{/other_user}';
'gists_url': 'https://api.github.com/users/username/gists{/gist_id}';
'starred_url': 'https://api.github.com/users/username/starred{/owner}{/repo}';
'subscriptions_url': 'https://api.github.com/users/username/subscriptions';
'organizations_url': 'https://api.github.com/users/username/orgs';
'repos_url': 'https://api.github.com/users/username/repos';
'events_url': 'https://api.github.com/users/username/events{/privacy}';
'received_events_url': 'https://api.github.com/users/username/received_events';
'type': 'User';
'site_admin': false;
};
'parents': [
{
'url': 'https://api.github.com/repos/username/reponame/commits/99cf5912aa946c952d848b04a38d98f3379b98ec';
'html_url': 'https://github.com/username/reponame/commit/99cf5912aa946c952d848b04a38d98f3379b98ec';
'sha': '99cf5912aa946c942d848b04a38d98f3379b98ec';
}
];
'repository': {
'id': 547919410;
'node_id': 'R_kgDOAKiWMw';
'name': 'reponame';
'full_name': 'username/reponame';
'private': false;
'owner': {
'login': 'username';
'id': 1;
'node_id': 'MDQ3VXNlcjE2NjM2NzQz';
'avatar_url': 'https://avatars.githubusercontent.com/u/1?v=4';
'gravatar_id': '';
'url': 'https://api.github.com/users/username';
'html_url': 'https://github.com/username';
'followers_url': 'https://api.github.com/users/username/followers';
'following_url': 'https://api.github.com/users/username/following{/other_user}';
'gists_url': 'https://api.github.com/users/username/gists{/gist_id}';
'starred_url': 'https://api.github.com/users/username/starred{/owner}{/repo}';
'subscriptions_url': 'https://api.github.com/users/username/subscriptions';
'organizations_url': 'https://api.github.com/users/username/orgs';
'repos_url': 'https://api.github.com/users/username/repos';
'events_url': 'https://api.github.com/users/username/events{/privacy}';
'received_events_url': 'https://api.github.com/users/username/received_events';
'type': 'User';
'site_admin': false;
};
'html_url': 'https://github.com/username/reponame';
'description': 'repository description';
'fork': false;
'url': 'https://api.github.com/repos/username/reponame';
'forks_url': 'https://api.github.com/repos/username/reponame/forks';
'keys_url': 'https://api.github.com/repos/username/reponame/keys{/key_id}';
'collaborators_url': 'https://api.github.com/repos/username/reponame/collaborators{/collaborator}';
'teams_url': 'https://api.github.com/repos/username/reponame/teams';
'hooks_url': 'https://api.github.com/repos/username/reponame/hooks';
'issue_events_url': 'https://api.github.com/repos/username/reponame/issues/events{/number}';
'events_url': 'https://api.github.com/repos/username/reponame/events';
'assignees_url': 'https://api.github.com/repos/username/reponame/assignees{/user}';
'branches_url': 'https://api.github.com/repos/username/reponame/branches{/branch}';
'tags_url': 'https://api.github.com/repos/username/reponame/tags';
'blobs_url': 'https://api.github.com/repos/username/reponame/git/blobs{/sha}';
'git_tags_url': 'https://api.github.com/repos/username/reponame/git/tags{/sha}';
'git_refs_url': 'https://api.github.com/repos/username/reponame/git/refs{/sha}';
'trees_url': 'https://api.github.com/repos/username/reponame/git/trees{/sha}';
'statuses_url': 'https://api.github.com/repos/username/reponame/statuses/{sha}';
'languages_url': 'https://api.github.com/repos/username/reponame/languages';
'stargazers_url': 'https://api.github.com/repos/username/reponame/stargazers';
'contributors_url': 'https://api.github.com/repos/username/reponame/contributors';
'subscribers_url': 'https://api.github.com/repos/username/reponame/subscribers';
'subscription_url': 'https://api.github.com/repos/username/reponame/subscription';
'commits_url': 'https://api.github.com/repos/username/reponame/commits{/sha}';
'git_commits_url': 'https://api.github.com/repos/username/reponame/git/commits{/sha}';
'comments_url': 'https://api.github.com/repos/username/reponame/comments{/number}';
'issue_comment_url': 'https://api.github.com/repos/username/reponame/issues/comments{/number}';
'contents_url': 'https://api.github.com/repos/username/reponame/contents/{+path}';
'compare_url': 'https://api.github.com/repos/username/reponame/compare/{base}...{head}';
'merges_url': 'https://api.github.com/repos/username/reponame/merges';
'archive_url': 'https://api.github.com/repos/username/reponame/{archive_format}{/ref}';
'downloads_url': 'https://api.github.com/repos/username/reponame/downloads';
'issues_url': 'https://api.github.com/repos/username/reponame/issues{/number}';
'pulls_url': 'https://api.github.com/repos/username/reponame/pulls{/number}';
'milestones_url': 'https://api.github.com/repos/username/reponame/milestones{/number}';
'notifications_url': 'https://api.github.com/repos/username/reponame/notifications{?since,all,participating}';
'labels_url': 'https://api.github.com/repos/username/reponame/labels{/name}';
'releases_url': 'https://api.github.com/repos/username/reponame/releases{/id}';
'deployments_url': 'https://api.github.com/repos/username/reponame/deployments';
};
'score': 1;
};
export type GithubConfig = z.infer<typeof GithubConfig>;
export declare const GithubConfig: z.ZodObject<{
committerUsername: z.ZodString;
/**
* needed only if you want to access commits
* made to private repositories
*/
token: z.ZodOptional<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">]>>>;
from: z.ZodOptional<z.ZodString>;
to: z.ZodOptional<z.ZodString>;
delay: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
protocol: "http" | "https";
committerUsername: string;
domain: string;
apiVersion: string;
token?: string | undefined;
filters?: [{
on: string;
regex: string;
}, ...{
on: string;
regex: string;
}[]] | undefined;
from?: string | undefined;
to?: string | undefined;
delay?: number | undefined;
}, {
committerUsername: string;
token?: string | undefined;
filters?: [{
on: string;
regex: string;
}, ...{
on: string;
regex: string;
}[]] | undefined;
domain?: string | undefined;
apiVersion?: string | undefined;
protocol?: "http" | "https" | undefined;
from?: string | undefined;
to?: string | undefined;
delay?: number | undefined;
}>;
export declare class GithubIntegration extends IntegrationBase {
static type: "github";
private httpClient;
private config;
private delayToUse;
private dateRange;
private bananaReporterConfig;
constructor(_rawConfig: unknown, bananaReporterConfig: BananaConfig);
private httpRequest;
fetchData(): Promise<CommonBananaReporterObj[]>;
private getUserCommits;
toBananaReporterObj(rawData: GithubCommitItemData): CommonBananaReporterObj;
}
export {};