UNPKG

n8n

Version:

n8n Workflow Automation Tool

98 lines 4.74 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AgentSlackIntegrationsController = void 0; const api_types_1 = require("@n8n/api-types"); const decorators_1 = require("@n8n/decorators"); const slack_manual_setup_service_1 = require("./integrations/platforms/slack/slack-manual-setup.service"); let AgentSlackIntegrationsController = class AgentSlackIntegrationsController { constructor(manualSetup) { this.manualSetup = manualSetup; } async createSlackApp(req, _res, agentId, payload) { return await this.manualSetup.createApp({ projectId: req.params.projectId, agentId, appConfigurationToken: payload.appConfigurationToken, user: req.user, }); } async getSlackAppManifest(req, _res, agentId) { return await this.manualSetup.getManifest({ projectId: req.params.projectId, agentId, }); } async handleSlackAppOAuthCallback(req, res, agentId) { const { code, state, error, error_description: errorDescription } = req.query; if (error) { return res.render('oauth-error-callback', { error: { message: error, ...(errorDescription ? { reason: errorDescription } : {}), }, }); } if (!code || !state) { return res.render('oauth-error-callback', { error: { message: 'Insufficient parameters for Slack app setup callback.' }, }); } try { await this.manualSetup.completeInstall({ projectId: req.params.projectId, agentId, code, state, }); return res.render('oauth-callback'); } catch (callbackError) { const message = callbackError instanceof Error ? callbackError.message : 'Slack app setup failed'; return res.render('oauth-error-callback', { error: { message }, }); } } }; exports.AgentSlackIntegrationsController = AgentSlackIntegrationsController; __decorate([ (0, decorators_1.Post)('/:agentId/integrations/slack/app'), (0, decorators_1.ProjectScope)('agent:update'), __param(2, (0, decorators_1.Param)('agentId')), __param(3, decorators_1.Body), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, String, api_types_1.CreateSlackAgentAppDto]), __metadata("design:returntype", Promise) ], AgentSlackIntegrationsController.prototype, "createSlackApp", null); __decorate([ (0, decorators_1.Get)('/:agentId/integrations/slack/manifest'), (0, decorators_1.ProjectScope)('agent:read'), __param(2, (0, decorators_1.Param)('agentId')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, String]), __metadata("design:returntype", Promise) ], AgentSlackIntegrationsController.prototype, "getSlackAppManifest", null); __decorate([ (0, decorators_1.Get)('/:agentId/integrations/slack/oauth/callback', { skipAuth: true, usesTemplates: true }), __param(2, (0, decorators_1.Param)('agentId')), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, String]), __metadata("design:returntype", Promise) ], AgentSlackIntegrationsController.prototype, "handleSlackAppOAuthCallback", null); exports.AgentSlackIntegrationsController = AgentSlackIntegrationsController = __decorate([ (0, decorators_1.RestController)('/projects/:projectId/agents/v2'), __metadata("design:paramtypes", [slack_manual_setup_service_1.SlackManualSetupService]) ], AgentSlackIntegrationsController); //# sourceMappingURL=agent-slack-integrations.controller.js.map