feat: Add license helpers for insights (no-changelog) (#14180)

This commit is contained in:
Marc Littlemore
2025-04-07 09:18:46 +01:00
committed by GitHub
parent ce5a237d0d
commit 89d2eb7aa3
6 changed files with 55 additions and 0 deletions

View File

@@ -183,5 +183,7 @@ export interface FrontendSettings {
}; };
insights: { insights: {
enabled: boolean; enabled: boolean;
summary: boolean;
dashboard: boolean;
}; };
} }

View File

@@ -95,6 +95,9 @@ export const LICENSE_FEATURES = {
COMMUNITY_NODES_CUSTOM_REGISTRY: 'feat:communityNodes:customRegistry', COMMUNITY_NODES_CUSTOM_REGISTRY: 'feat:communityNodes:customRegistry',
AI_CREDITS: 'feat:aiCredits', AI_CREDITS: 'feat:aiCredits',
FOLDERS: 'feat:folders', FOLDERS: 'feat:folders',
INSIGHTS_VIEW_SUMMARY: 'feat:insights:viewSummary',
INSIGHTS_VIEW_DASHBOARD: 'feat:insights:viewDashboard',
INSIGHTS_VIEW_HOURLY_DATA: 'feat:insights:viewHourlyData',
} as const; } as const;
export const LICENSE_QUOTAS = { export const LICENSE_QUOTAS = {
@@ -104,6 +107,9 @@ export const LICENSE_QUOTAS = {
WORKFLOW_HISTORY_PRUNE_LIMIT: 'quota:workflowHistoryPrune', WORKFLOW_HISTORY_PRUNE_LIMIT: 'quota:workflowHistoryPrune',
TEAM_PROJECT_LIMIT: 'quota:maxTeamProjects', TEAM_PROJECT_LIMIT: 'quota:maxTeamProjects',
AI_CREDITS: 'quota:aiCredits', AI_CREDITS: 'quota:aiCredits',
INSIGHTS_MAX_HISTORY_DAYS: 'quota:insights:maxHistoryDays',
INSIGHTS_RETENTION_MAX_AGE_DAYS: 'quota:insights:retention:maxAgeDays',
INSIGHTS_RETENTION_PRUNE_INTERVAL_DAYS: 'quota:insights:retention:pruneIntervalDays',
} as const; } as const;
export const UNLIMITED_LICENSE_QUOTA = -1; export const UNLIMITED_LICENSE_QUOTA = -1;

View File

@@ -102,6 +102,9 @@ export class E2EController {
[LICENSE_FEATURES.ASK_AI]: false, [LICENSE_FEATURES.ASK_AI]: false,
[LICENSE_FEATURES.AI_CREDITS]: false, [LICENSE_FEATURES.AI_CREDITS]: false,
[LICENSE_FEATURES.FOLDERS]: false, [LICENSE_FEATURES.FOLDERS]: false,
[LICENSE_FEATURES.INSIGHTS_VIEW_SUMMARY]: false,
[LICENSE_FEATURES.INSIGHTS_VIEW_DASHBOARD]: false,
[LICENSE_FEATURES.INSIGHTS_VIEW_HOURLY_DATA]: false,
}; };
private static readonly numericFeaturesDefaults: Record<NumericLicenseFeature, number> = { private static readonly numericFeaturesDefaults: Record<NumericLicenseFeature, number> = {
@@ -111,6 +114,9 @@ export class E2EController {
[LICENSE_QUOTAS.WORKFLOW_HISTORY_PRUNE_LIMIT]: -1, [LICENSE_QUOTAS.WORKFLOW_HISTORY_PRUNE_LIMIT]: -1,
[LICENSE_QUOTAS.TEAM_PROJECT_LIMIT]: 0, [LICENSE_QUOTAS.TEAM_PROJECT_LIMIT]: 0,
[LICENSE_QUOTAS.AI_CREDITS]: 0, [LICENSE_QUOTAS.AI_CREDITS]: 0,
[LICENSE_QUOTAS.INSIGHTS_MAX_HISTORY_DAYS]: 7,
[LICENSE_QUOTAS.INSIGHTS_RETENTION_MAX_AGE_DAYS]: 30,
[LICENSE_QUOTAS.INSIGHTS_RETENTION_PRUNE_INTERVAL_DAYS]: 180,
}; };
private numericFeatures: Record<NumericLicenseFeature, number> = { private numericFeatures: Record<NumericLicenseFeature, number> = {
@@ -124,6 +130,13 @@ export class E2EController {
[LICENSE_QUOTAS.TEAM_PROJECT_LIMIT]: [LICENSE_QUOTAS.TEAM_PROJECT_LIMIT]:
E2EController.numericFeaturesDefaults[LICENSE_QUOTAS.TEAM_PROJECT_LIMIT], E2EController.numericFeaturesDefaults[LICENSE_QUOTAS.TEAM_PROJECT_LIMIT],
[LICENSE_QUOTAS.AI_CREDITS]: E2EController.numericFeaturesDefaults[LICENSE_QUOTAS.AI_CREDITS], [LICENSE_QUOTAS.AI_CREDITS]: E2EController.numericFeaturesDefaults[LICENSE_QUOTAS.AI_CREDITS],
[LICENSE_QUOTAS.INSIGHTS_MAX_HISTORY_DAYS]:
E2EController.numericFeaturesDefaults[LICENSE_QUOTAS.INSIGHTS_MAX_HISTORY_DAYS],
[LICENSE_QUOTAS.INSIGHTS_RETENTION_MAX_AGE_DAYS]:
E2EController.numericFeaturesDefaults[LICENSE_QUOTAS.INSIGHTS_RETENTION_MAX_AGE_DAYS],
[LICENSE_QUOTAS.INSIGHTS_RETENTION_PRUNE_INTERVAL_DAYS]:
E2EController.numericFeaturesDefaults[LICENSE_QUOTAS.INSIGHTS_RETENTION_PRUNE_INTERVAL_DAYS],
}; };
constructor( constructor(

View File

@@ -315,6 +315,18 @@ export class License {
return this.isFeatureEnabled(LICENSE_FEATURES.FOLDERS); return this.isFeatureEnabled(LICENSE_FEATURES.FOLDERS);
} }
isInsightsSummaryEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.INSIGHTS_VIEW_SUMMARY);
}
isInsightsDashboardEnabled() {
return this.isFeatureEnabled(LICENSE_FEATURES.INSIGHTS_VIEW_DASHBOARD);
}
isInsightsHourlyDataEnabled() {
return this.getFeatureValue(LICENSE_FEATURES.INSIGHTS_VIEW_HOURLY_DATA);
}
getCurrentEntitlements() { getCurrentEntitlements() {
return this.manager?.getCurrentEntitlements() ?? []; return this.manager?.getCurrentEntitlements() ?? [];
} }
@@ -377,6 +389,18 @@ export class License {
); );
} }
getInsightsMaxHistory() {
return this.getFeatureValue(LICENSE_QUOTAS.INSIGHTS_MAX_HISTORY_DAYS) ?? 7;
}
getInsightsRetentionMaxAge() {
return this.getFeatureValue(LICENSE_QUOTAS.INSIGHTS_RETENTION_MAX_AGE_DAYS) ?? 180;
}
getInsightsRetentionPruneInterval() {
return this.getFeatureValue(LICENSE_QUOTAS.INSIGHTS_RETENTION_PRUNE_INTERVAL_DAYS) ?? 24;
}
getTeamProjectLimit() { getTeamProjectLimit() {
return this.getFeatureValue(LICENSE_QUOTAS.TEAM_PROJECT_LIMIT) ?? 0; return this.getFeatureValue(LICENSE_QUOTAS.TEAM_PROJECT_LIMIT) ?? 0;
} }

View File

@@ -241,6 +241,8 @@ export class FrontendService {
}, },
insights: { insights: {
enabled: this.modulesConfig.modules.includes('insights'), enabled: this.modulesConfig.modules.includes('insights'),
summary: true,
dashboard: false,
}, },
}; };
} }
@@ -361,6 +363,12 @@ export class FrontendService {
this.settings.aiCredits.credits = this.license.getAiCredits(); this.settings.aiCredits.credits = this.license.getAiCredits();
} }
Object.assign(this.settings.insights, {
enabled: this.modulesConfig.modules.includes('insights'),
summary: this.license.isInsightsSummaryEnabled(),
dashboard: this.license.isInsightsDashboardEnabled(),
});
this.settings.mfa.enabled = config.get('mfa.enabled'); this.settings.mfa.enabled = config.get('mfa.enabled');
this.settings.executionMode = config.getEnv('executions.mode'); this.settings.executionMode = config.getEnv('executions.mode');

View File

@@ -143,5 +143,7 @@ export const defaultSettings: FrontendSettings = {
}, },
insights: { insights: {
enabled: false, enabled: false,
summary: true,
dashboard: false,
}, },
}; };