/home/techb158/balavpn.abdallabala.com/src/integrations/pm-clients
Edit: /home/techb158/balavpn.abdallabala.com/src/integrations/pm-clients/index.js (1892B)
const { TrelloClient } = require("./trello-client");
const { JiraClient } = require("./jira-client");
const { AsanaClient } = require("./asana-client");
const { PlannerClient } = require("./planner-client");
function envCredentials(provider) {
if (provider === "TRELLO") {
return { apiKey: process.env.TRELLO_API_KEY, token: process.env.TRELLO_TOKEN, listId: process.env.TRELLO_LIST_ID };
}
if (provider === "JIRA") {
return {
accessToken: process.env.JIRA_ACCESS_TOKEN,
cloudId: process.env.JIRA_CLOUD_ID,
apiEmail: process.env.JIRA_API_EMAIL,
apiToken: process.env.JIRA_API_TOKEN,
baseUrl: process.env.JIRA_BASE_URL,
projectKey: process.env.JIRA_PROJECT_KEY
};
}
if (provider === "ASANA") {
return { accessToken: process.env.ASANA_ACCESS_TOKEN, projectGid: process.env.ASANA_PROJECT_GID };
}
if (provider === "MICROSOFT_PLANNER") {
return { accessToken: process.env.MICROSOFT_GRAPH_ACCESS_TOKEN, planId: process.env.PLANNER_PLAN_ID, bucketId: process.env.PLANNER_BUCKET_ID };
}
return {};
}
function createPmClient(provider, credentials = {}, options = {}) {
const merged = Object.assign({}, envCredentials(provider), credentials, options);
if (provider === "TRELLO") return new TrelloClient(merged);
if (provider === "JIRA") return new JiraClient(merged);
if (provider === "ASANA") return new AsanaClient(merged);
if (provider === "MICROSOFT_PLANNER") return new PlannerClient(merged);
throw new Error(`Unsupported live integration provider: ${provider}`);
}
async function discoverIntegrationResources(provider, credentials = {}, options = {}) {
const client = createPmClient(provider, credentials, options);
if (typeof client.discoverResources !== "function") return [];
return client.discoverResources();
}
module.exports = { createPmClient, envCredentials, discoverIntegrationResources };