UNPKG

n8n

Version:

n8n Workflow Automation Tool

18 lines 973 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.assertProjectScope = assertProjectScope; const db_1 = require("@n8n/db"); const di_1 = require("@n8n/di"); const forbidden_error_1 = require("../../../../errors/response-errors/forbidden.error"); const not_found_error_1 = require("../../../../errors/response-errors/not-found.error"); const project_service_ee_1 = require("../../../../services/project.service.ee"); async function assertProjectScope(user, projectId, scopes) { const exists = await di_1.Container.get(db_1.ProjectRepository).findOneBy({ id: projectId }); if (!exists) { throw new not_found_error_1.NotFoundError(`Project with ID "${projectId}" not found`); } const project = await di_1.Container.get(project_service_ee_1.ProjectService).getProjectWithScope(user, projectId, scopes); if (!project) throw new forbidden_error_1.ForbiddenError(); } //# sourceMappingURL=utils.service.js.map