Skip to content

Commit

Permalink
Merge pull request #29 from bemijonathan/integration/trello
Browse files Browse the repository at this point in the history
Integration/trello
  • Loading branch information
bemijonathan authored May 11, 2024
2 parents 65a1e98 + ddc6155 commit 7b721c4
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 63 deletions.
195 changes: 177 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"ignore": "^5.2.4",
"jira.js": "^3.0.2",
"langchain": "^0.1.3",
"node-fetch": "^3.3.2",
"openai": "^4.24.7"
},
"devDependencies": {
Expand Down
40 changes: 40 additions & 0 deletions src/clients/base-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Logger } from '../utils'
import { TrelloClient } from './trello'
import { JiraClient } from './jira'

export class BaseClient {
static get client(): TrelloClient | JiraClient | null {
const trelloCredentials = {
trelloPublicKey: process.env.TRELLO_PUBLIC_KEY,
trelloPrivateKey: process.env.TRELLO_PRIVATE_KEY
}

if (this.validateCredentials(trelloCredentials)) {
return new TrelloClient()
}

const jiraCredentials: Record<string, unknown> = {
jiraApiKey: process.env.JIRA_API_KEY,
jiraEmail: process.env.JIRA_EMAIL,
jiraHost: process.env.JIRA_HOST
}

if (this.validateCredentials(jiraCredentials)) {
return new JiraClient()
}

return null
}

static validateCredentials(credential: Record<string, unknown>) {
if (Object.values(credential).filter(e => Boolean(e)).length > 0) {
Object.keys(credential).forEach(e => {
if (!credential[e]) {
Logger.error(`${e} configuration is missing`)
return false
}
})
return true
}
}
}
1 change: 1 addition & 0 deletions src/clients/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './jira.js'
export * from './github.js'
export * from './base-client.js'
Loading

0 comments on commit 7b721c4

Please sign in to comment.