Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #557 from manish-singh-bisht/gh
Browse files Browse the repository at this point in the history
feat: Github issues support
  • Loading branch information
Nabhag8848 authored Jul 31, 2024
2 parents d4cdc8c + a0c0855 commit 8bcad8e
Show file tree
Hide file tree
Showing 22 changed files with 711 additions and 21 deletions.
2 changes: 2 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ navigation:
path: ./docs/contents/guides/trello.mdx
- page: BitBucket
path: ./docs/contents/guides/bitbucket.mdx
- page: GitHub
path: ./docs/contents/guides/github.mdx
colors:
accentPrimary: '#89a3ff'
logo:
Expand Down
19 changes: 19 additions & 0 deletions fern/docs/contents/guides/github.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<img src="https://res.cloudinary.com/dwoiwg0t5/image/upload/f_auto,q_auto/lmmkmmgaoatdbzhgbymy" />

#### Obtaining GitHub Client ID and Secret

- Open a [GitHub account](https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F&source=header-home).
- Create a GitHub OAuth app, using the steps mentioned [here](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app)
- `NOTE:` You can skip this step and use the default revert GitHub app
- Set `https://app.revert.dev/oauth-callback/github` as the `redirect` url for your app
- **Get your client_id and client_secret**:
- Copy your client_id and client_secret after you created the oauth app.

#### Connect to GitHub via Revert

- Create an account on Revert if you don't already have one. (https://app.revert.dev/sign-up)
- Login to your revert dashboard (https://app.revert.dev/sign-in) and click on `Customize your apps` - `GitHub`

<img src="https://res.cloudinary.com/dfcnic8wq/image/upload/v1705652583/Revert/Docs/nwlrrom2sw5xj7dsgznv.png" />

- Enter the `client_id` and `client_secret` you copied in the previous step into the App credentials here and click `Submit`.
4 changes: 3 additions & 1 deletion packages/backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ OPEN_INT_API_KEY=
TWENTY_ACCOUNT_ID=
BITBUCKET_CLIENT_ID=
BITBUCKET_CLIENT_SECRET=
DEFAULT_RATE_LIMIT_DEVELOPER_PLAN=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
DEFAULT_RATE_LIMIT_DEVELOPER_PLAN=
4 changes: 4 additions & 0 deletions packages/backend/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const config = {
OPEN_INT_API_KEY: process.env.OPEN_INT_API_KEY,
OPEN_INT_BASE_API_URL: process.env.OPEN_INT_BASE_API_URL,
TWENTY_ACCOUNT_ID: process.env.TWENTY_ACCOUNT_ID,

GITHUB_CLIENT_ID: process.env.GITHUB_CLIENT_ID!,
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET!,

DEFAULT_RATE_LIMIT_DEVELOPER_PLAN: process.env.DEFAULT_RATE_LIMIT_DEVELOPER_PLAN,
};

Expand Down
12 changes: 11 additions & 1 deletion packages/backend/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Request, Response } from 'express';

export type CRM_TP_ID = 'zohocrm' | 'sfdc' | 'pipedrive' | 'hubspot' | 'closecrm' | 'ms_dynamics_365_sales';
export type CHAT_TP_ID = 'slack' | 'discord';
export type TICKET_TP_ID = 'linear' | 'clickup' | 'asana' | 'jira' | 'trello' | 'bitbucket';
export type TICKET_TP_ID = 'linear' | 'clickup' | 'asana' | 'jira' | 'trello' | 'bitbucket' | 'github';

export const DEFAULT_SCOPE = {
[TP_ID.hubspot]: [
Expand Down Expand Up @@ -49,6 +49,15 @@ export const DEFAULT_SCOPE = {
[TP_ID.jira]: ['read:jira-work', 'read:jira-user', 'write:jira-work', 'offline_access'],
[TP_ID.ms_dynamics_365_sales]: ['offline_access', 'User.Read'],
[TP_ID.bitbucket]: ['issue', 'issue:write', 'repository', 'account'],
[TP_ID.github]: [
'repo',
'issues:write',
'pull_requests:write',
'issues:read',
'pull_requests:read',
'metadata:read',
'repository_projects:read',
],
};

export const mapIntegrationIdToIntegrationName = {
Expand All @@ -66,6 +75,7 @@ export const mapIntegrationIdToIntegrationName = {
[TP_ID.jira]: 'Jira',
[TP_ID.ms_dynamics_365_sales]: 'Microsoft Dynamics 365 Sales',
[TP_ID.bitbucket]: 'Bitbucket',
[TP_ID.github]: 'GitHub',
};

export const rootSchemaMappingId = 'revertRootSchemaMapping';
Expand Down
13 changes: 13 additions & 0 deletions packages/backend/helpers/crm/transform/disunify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,18 @@ export async function disunifyTicketObject<T extends Record<string, any>>({
}
return processedObj;
}
case TP_ID.github: {
if (objType === 'ticketTask') {
return {
...transformedObj,
assignees:
obj.assignees && Array.isArray(obj.assignees) && obj.assignees.length > 0
? obj.assignees
: undefined,
};
}

return processedObj;
}
}
}
1 change: 1 addition & 0 deletions packages/backend/helpers/crm/transform/preprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export const postprocessDisUnifyTicketObject = <T extends Record<string, any>>({
[TP_ID.trello]: {},
[TP_ID.asana]: {},
[TP_ID.bitbucket]: {},
[TP_ID.github]: {},
};
const transformFn = (preprocessMap[tpId] || {})[objType];
return transformFn ? transformFn(obj) : obj;
Expand Down
29 changes: 29 additions & 0 deletions packages/backend/prisma/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'id',
[TP_ID.trello]: 'id',
[TP_ID.bitbucket]: 'id',
[TP_ID.github]: 'id',
},
target_field_name: 'id',
},
Expand All @@ -941,6 +942,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'id',
[TP_ID.trello]: 'id',
[TP_ID.bitbucket]: 'id',
[TP_ID.github]: 'id',
},
target_field_name: 'remoteId',
},
Expand All @@ -951,6 +953,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'summary',
[TP_ID.trello]: 'name',
[TP_ID.bitbucket]: 'title',
[TP_ID.github]: 'title',
},
target_field_name: 'name',
},
Expand All @@ -961,6 +964,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'assignee',
[TP_ID.trello]: 'idMembers',
[TP_ID.bitbucket]: 'assignee',
[TP_ID.github]: 'assignees',
},
target_field_name: 'assignees',
},
Expand All @@ -971,6 +975,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'description',
[TP_ID.trello]: 'desc',
[TP_ID.bitbucket]: 'content.raw',
[TP_ID.github]: 'body',
},
target_field_name: 'description',
},
Expand All @@ -981,6 +986,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'status.name',
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: 'state',
[TP_ID.github]: 'state',
},
target_field_name: 'status',
},
Expand All @@ -991,6 +997,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'priority.name',
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: 'priority',
[TP_ID.github]: undefined,
},
target_field_name: 'priority',
},
Expand All @@ -1001,6 +1008,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'creator.accountId',
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: 'reporter.account_id',
[TP_ID.github]: 'user.id',
},
target_field_name: 'creatorId',
},
Expand All @@ -1011,6 +1019,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'created',
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: 'created_on',
[TP_ID.github]: 'created_at',
},
target_field_name: 'createdTimeStamp',
},
Expand All @@ -1021,6 +1030,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'updated',
[TP_ID.trello]: 'dateLastActivity',
[TP_ID.bitbucket]: 'updated_on',
[TP_ID.github]: 'updated_at',
},
target_field_name: 'updatedTimeStamp',
},
Expand All @@ -1031,6 +1041,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'duedate',
[TP_ID.trello]: 'due',
[TP_ID.bitbucket]: undefined,
[TP_ID.github]: undefined,
},
target_field_name: 'dueDate',
},
Expand All @@ -1041,6 +1052,7 @@ export const ticketingFields = {
[TP_ID.jira]: undefined,
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: undefined,
[TP_ID.github]: 'closed_at',
},
target_field_name: 'completedDate',
},
Expand All @@ -1051,6 +1063,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'parent.id',
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: undefined,
[TP_ID.github]: undefined,
},
target_field_name: 'parentId',
},
Expand All @@ -1076,6 +1089,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'accountId',
[TP_ID.trello]: 'id',
[TP_ID.bitbucket]: 'account_id',
[TP_ID.github]: 'id',
},
target_field_name: 'id',
},
Expand All @@ -1086,6 +1100,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'accountId',
[TP_ID.trello]: 'id',
[TP_ID.bitbucket]: 'account_id',
[TP_ID.github]: 'id',
},
target_field_name: 'remoteId',
},
Expand All @@ -1096,6 +1111,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'emailAddress',
[TP_ID.trello]: 'email',
[TP_ID.bitbucket]: undefined,
[TP_ID.github]: 'email',
},
target_field_name: 'email',
},
Expand All @@ -1106,6 +1122,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'displayName',
[TP_ID.trello]: 'fullName',
[TP_ID.bitbucket]: 'display_name',
[TP_ID.github]: 'name',
},
target_field_name: 'name',
},
Expand All @@ -1116,6 +1133,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'active',
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: 'account_status',
[TP_ID.github]: undefined,
},
target_field_name: 'isActive',
},
Expand All @@ -1126,6 +1144,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'avatarUrls."48x48"',
[TP_ID.trello]: 'avatarUrl',
[TP_ID.bitbucket]: 'links.avatar',
[TP_ID.github]: 'avatar_url',
},
target_field_name: 'avatar',
},
Expand All @@ -1136,6 +1155,7 @@ export const ticketingFields = {
[TP_ID.jira]: undefined,
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: 'created_on',
[TP_ID.github]: 'created_at',
},
target_field_name: 'createdTimeStamp',
},
Expand All @@ -1146,6 +1166,7 @@ export const ticketingFields = {
[TP_ID.jira]: undefined,
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: undefined,
[TP_ID.github]: 'updated_at',
},
target_field_name: 'updatedTimeStamp',
},
Expand All @@ -1156,6 +1177,7 @@ export const ticketingFields = {
[TP_ID.jira]: undefined,
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: 'is_staff',
[TP_ID.github]: 'site_admin',
},
target_field_name: 'isAdmin',
},
Expand All @@ -1168,6 +1190,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'id',
[TP_ID.trello]: 'id',
[TP_ID.bitbucket]: 'id',
[TP_ID.github]: 'id',
},
target_field_name: 'id',
},
Expand All @@ -1178,6 +1201,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'id',
[TP_ID.trello]: 'id',
[TP_ID.bitbucket]: 'id',
[TP_ID.github]: 'id',
},
target_field_name: 'remoteId',
},
Expand All @@ -1188,6 +1212,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'body',
[TP_ID.trello]: 'data.text',
[TP_ID.bitbucket]: 'content.raw',
[TP_ID.github]: 'body',
},
target_field_name: 'body',
},
Expand All @@ -1198,6 +1223,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'author.accountId',
[TP_ID.trello]: 'idMemberCreator',
[TP_ID.bitbucket]: 'user.account_id',
[TP_ID.github]: 'user.id',
},
target_field_name: 'createdBy',
},
Expand All @@ -1208,6 +1234,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'created',
[TP_ID.trello]: 'date',
[TP_ID.bitbucket]: 'created_on',
[TP_ID.github]: 'created_at',
},
target_field_name: 'createdTimestamp',
},
Expand All @@ -1218,6 +1245,7 @@ export const ticketingFields = {
[TP_ID.jira]: 'updated',
[TP_ID.trello]: 'data.dateLastEdited',
[TP_ID.bitbucket]: 'updated_on',
[TP_ID.github]: 'updated_at',
},
target_field_name: 'updatedTimeStamp',
},
Expand All @@ -1228,6 +1256,7 @@ export const ticketingFields = {
[TP_ID.jira]: undefined,
[TP_ID.trello]: undefined,
[TP_ID.bitbucket]: undefined,
[TP_ID.github]: undefined,
},
target_field_name: 'parentId',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "TP_ID" ADD VALUE 'github';
1 change: 1 addition & 0 deletions packages/backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum TP_ID {
trello
jira
bitbucket
github
}

enum ENV {
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ async function main() {
tpId === 'clickup' ||
tpId === 'jira' ||
tpId === 'trello' ||
tpId === 'bitbucket'
tpId === 'bitbucket' ||
tpId === 'github'
)
)
return;
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/routes/v1/ticket/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import clickup from './authHandlers/clickup';
import trello from './authHandlers/trello';
import bitbucket from './authHandlers/bitbucket';
import jira from './authHandlers/jira';
import github from './authHandlers/github';

const authRouter = express.Router();

Expand Down Expand Up @@ -71,6 +72,8 @@ authRouter.get('/oauth-callback', async (req, res) => {
return jira.handleOAuth(authProps);
case TP_ID.bitbucket:
return bitbucket.handleOAuth(authProps);
case TP_ID.github:
return github.handleOAuth(authProps);

default:
return processOAuthResult({
Expand Down
Loading

0 comments on commit 8bcad8e

Please sign in to comment.