n8n
Version:
n8n Workflow Automation Tool
44 lines • 2.31 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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InsightsSettings = void 0;
const backend_common_1 = require("@n8n/backend-common");
const di_1 = require("@n8n/di");
const insights_constants_1 = require("./insights.constants");
let InsightsSettings = class InsightsSettings {
constructor(licenseState) {
this.licenseState = licenseState;
}
settings() {
return {
summary: this.licenseState.isInsightsSummaryLicensed(),
dashboard: this.licenseState.isInsightsDashboardLicensed(),
dateRanges: this.getAvailableDateRanges(),
};
}
getAvailableDateRanges() {
const maxHistoryInDays = this.licenseState.getInsightsMaxHistory() === -1
? Number.MAX_SAFE_INTEGER
: this.licenseState.getInsightsMaxHistory();
const isHourlyDateLicensed = this.licenseState.isInsightsHourlyDataLicensed();
return insights_constants_1.INSIGHTS_DATE_RANGE_KEYS.map((key) => ({
key,
licensed: key === 'day' ? (isHourlyDateLicensed ?? false) : maxHistoryInDays >= insights_constants_1.keyRangeToDays[key],
granularity: key === 'day' ? 'hour' : insights_constants_1.keyRangeToDays[key] <= 30 ? 'day' : 'week',
}));
}
};
exports.InsightsSettings = InsightsSettings;
exports.InsightsSettings = InsightsSettings = __decorate([
(0, di_1.Service)(),
__metadata("design:paramtypes", [backend_common_1.LicenseState])
], InsightsSettings);
//# sourceMappingURL=insights.settings.js.map