n8n
Version:
n8n Workflow Automation Tool
76 lines • 3.7 kB
JavaScript
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.InsightsController = void 0;
const api_types_1 = require("@n8n/api-types");
const decorators_1 = require("../../decorators");
const pagination_1 = require("../../middlewares/list-query/pagination");
const sort_by_1 = require("../../middlewares/list-query/sort-by");
const insights_service_1 = require("./insights.service");
let InsightsController = class InsightsController {
constructor(insightsService) {
this.insightsService = insightsService;
this.maxAgeInDaysFilteredInsights = 7;
}
async getInsightsSummary() {
return await this.insightsService.getInsightsSummary({
periodLengthInDays: this.maxAgeInDaysFilteredInsights,
});
}
async getInsightsByWorkflow(_req, _res, payload) {
return await this.insightsService.getInsightsByWorkflow({
maxAgeInDays: this.maxAgeInDaysFilteredInsights,
skip: payload.skip,
take: payload.take,
sortBy: payload.sortBy,
});
}
async getInsightsByTime() {
return await this.insightsService.getInsightsByTime({
maxAgeInDays: this.maxAgeInDaysFilteredInsights,
periodUnit: 'day',
});
}
};
exports.InsightsController = InsightsController;
__decorate([
(0, decorators_1.Get)('/summary'),
(0, decorators_1.GlobalScope)('insights:list'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], InsightsController.prototype, "getInsightsSummary", null);
__decorate([
(0, decorators_1.Get)('/by-workflow', { middlewares: [pagination_1.paginationListQueryMiddleware, sort_by_1.sortByQueryMiddleware] }),
(0, decorators_1.GlobalScope)('insights:list'),
(0, decorators_1.Licensed)('feat:insights:viewDashboard'),
__param(2, decorators_1.Query),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Response,
api_types_1.ListInsightsWorkflowQueryDto]),
__metadata("design:returntype", Promise)
], InsightsController.prototype, "getInsightsByWorkflow", null);
__decorate([
(0, decorators_1.Get)('/by-time'),
(0, decorators_1.GlobalScope)('insights:list'),
(0, decorators_1.Licensed)('feat:insights:viewDashboard'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], InsightsController.prototype, "getInsightsByTime", null);
exports.InsightsController = InsightsController = __decorate([
(0, decorators_1.RestController)('/insights'),
__metadata("design:paramtypes", [insights_service_1.InsightsService])
], InsightsController);
//# sourceMappingURL=insights.controller.js.map
;