mirror of
https://github.com/johndoe6345789/postgres.git
synced 2026-04-25 14:25:06 +00:00
60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
import featuresConfig from '@/config/features.json';
|
|
|
|
export type Feature = {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
enabled: boolean;
|
|
priority: string;
|
|
endpoints: Array<{
|
|
path: string;
|
|
methods: string[];
|
|
description: string;
|
|
}>;
|
|
ui: {
|
|
showInNav: boolean;
|
|
icon: string;
|
|
actions: string[];
|
|
};
|
|
};
|
|
|
|
export type DataType = {
|
|
name: string;
|
|
category: string;
|
|
requiresLength: boolean;
|
|
defaultLength?: number;
|
|
autoIncrement?: boolean;
|
|
};
|
|
|
|
export type NavItem = {
|
|
id: string;
|
|
label: string;
|
|
icon: string;
|
|
featureId: string;
|
|
};
|
|
|
|
export function getFeatures(): Feature[] {
|
|
return featuresConfig.features.filter(f => f.enabled);
|
|
}
|
|
|
|
export function getFeatureById(id: string): Feature | undefined {
|
|
return featuresConfig.features.find(f => f.id === id && f.enabled);
|
|
}
|
|
|
|
export function getDataTypes(): DataType[] {
|
|
return featuresConfig.dataTypes;
|
|
}
|
|
|
|
export function getNavItems(): NavItem[] {
|
|
return featuresConfig.navItems.filter(item => {
|
|
const feature = getFeatureById(item.featureId);
|
|
return feature && feature.enabled;
|
|
});
|
|
}
|
|
|
|
export function getEnabledFeaturesByPriority(priority: string): Feature[] {
|
|
return featuresConfig.features.filter(
|
|
f => f.enabled && f.priority === priority,
|
|
);
|
|
}
|