/home/techb158/cosmic.abdallabala.com/src/integrations
NameSizeModeActions
pmClients/-0777rm
livePmClientFactory.js19150666editdlrm
oauthProviderConfig.js82260666editdlrm
Edit: /home/techb158/cosmic.abdallabala.com/src/integrations/livePmClientFactory.js (1915B)
const { TrelloClient } = require("./pmClients/trelloClient.js"); const { JiraClient } = require("./pmClients/jiraClient.js"); const { AsanaClient } = require("./pmClients/asanaClient.js"); const { PlannerClient } = require("./pmClients/plannerClient.js"); function parseLiveConfig(integration) { if (!integration || !integration.live_config_json) return {}; try { return JSON.parse(integration.live_config_json); } catch (_error) { return {}; } } function createLivePmClient(provider, integration, oauthService, options = {}) { const env = options.env || process.env; const fetchImpl = options.fetchImpl || global.fetch; const accessToken = oauthService && oauthService.getAccessToken(provider, integration && integration.id); const liveConfig = parseLiveConfig(integration); if (provider === "Trello") { return new TrelloClient({ apiKey: env.TRELLO_API_KEY, token: env.TRELLO_TOKEN || accessToken, listId: env.TRELLO_LIST_ID, fetchImpl }); } if (provider === "Jira") { return new JiraClient({ accessToken: env.JIRA_ACCESS_TOKEN || accessToken, apiEmail: env.JIRA_API_EMAIL, apiToken: env.JIRA_API_TOKEN, baseUrl: env.JIRA_BASE_URL || integration.base_url, cloudId: env.JIRA_CLOUD_ID || liveConfig.cloudId, projectKey: env.JIRA_PROJECT_KEY, fetchImpl }); } if (provider === "Asana") { return new AsanaClient({ accessToken: env.ASANA_ACCESS_TOKEN || accessToken, projectGid: env.ASANA_PROJECT_GID, fetchImpl }); } if (provider === "Microsoft Planner") { return new PlannerClient({ accessToken: env.MICROSOFT_GRAPH_ACCESS_TOKEN || accessToken, planId: env.PLANNER_PLAN_ID, bucketId: env.PLANNER_BUCKET_ID, fetchImpl }); } throw new Error(`Unsupported live PM provider: ${provider}`); } module.exports = { createLivePmClient, parseLiveConfig };