diff --git a/packages/github/package.json b/packages/github/package.json index bb3098b..e575b67 100644 --- a/packages/github/package.json +++ b/packages/github/package.json @@ -1,6 +1,6 @@ { "name": "@hawk.so/github-sdk", - "version": "1.0.3", + "version": "1.0.4", "description": "GitHub API client for Hawk (GitHub App, Issues, OAuth)", "author": "CodeX ", "license": "AGPL-3.0-only", diff --git a/packages/github/src/service.ts b/packages/github/src/service.ts index a9ea590..0850ae0 100644 --- a/packages/github/src/service.ts +++ b/packages/github/src/service.ts @@ -136,10 +136,15 @@ export class GitHubService { installation_id: parseInt(installationId, 10), }); + let accountId = 0; let accountLogin = ''; let accountType = ''; if (data.account) { + if ('id' in data.account) { + accountId = data.account.id; + } + if ('login' in data.account) { accountLogin = data.account.login; accountType = 'login' in data.account && 'type' in data.account ? data.account.type : 'User'; @@ -152,6 +157,7 @@ export class GitHubService { return { id: data.id, account: { + id: accountId, login: accountLogin, type: accountType, }, diff --git a/packages/github/src/types/index.ts b/packages/github/src/types/index.ts index 33f3187..749d5d3 100644 --- a/packages/github/src/types/index.ts +++ b/packages/github/src/types/index.ts @@ -47,6 +47,8 @@ export type Installation = { id: number; /** Account where the app is installed. */ account: { + /** GitHub account ID. */ + id: number; /** GitHub username or org login. */ login: string; /** Account type (e.g. "User", "Organization"). */ diff --git a/packages/github/tests/service.test.ts b/packages/github/tests/service.test.ts index 7390080..cde4175 100644 --- a/packages/github/tests/service.test.ts +++ b/packages/github/tests/service.test.ts @@ -160,6 +160,7 @@ describe('GitHubService', () => { expect(result).toEqual({ id: 12345, account: { + id: 1, login: 'octocat', type: 'User', }, @@ -203,6 +204,7 @@ describe('GitHubService', () => { expect(result).toEqual({ id: 12345, account: { + id: 1, login: 'my-org', type: 'Organization', },