mirror of
https://github.com/johndoe6345789/postgres.git
synced 2026-04-26 23:05:00 +00:00
refactor: Address code review feedback
- Replace 'as any' with proper FeaturesConfig type definition - Improve CHECK constraint SQL injection validation with comprehensive patterns - Move isValidIdentifier to shared validation module - Add comprehensive unit tests for identifier validation (12 tests) - Fix all linting issues - All 52 unit tests passing Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -40,31 +40,41 @@ export type ConstraintType = {
|
||||
requiresExpression: boolean;
|
||||
};
|
||||
|
||||
// Type definition for the features config structure
|
||||
type FeaturesConfig = {
|
||||
features: Feature[];
|
||||
dataTypes: DataType[];
|
||||
constraintTypes?: ConstraintType[];
|
||||
navItems: NavItem[];
|
||||
};
|
||||
|
||||
const config = featuresConfig as FeaturesConfig;
|
||||
|
||||
export function getFeatures(): Feature[] {
|
||||
return featuresConfig.features.filter(f => f.enabled);
|
||||
return config.features.filter(f => f.enabled);
|
||||
}
|
||||
|
||||
export function getFeatureById(id: string): Feature | undefined {
|
||||
return featuresConfig.features.find(f => f.id === id && f.enabled);
|
||||
return config.features.find(f => f.id === id && f.enabled);
|
||||
}
|
||||
|
||||
export function getDataTypes(): DataType[] {
|
||||
return featuresConfig.dataTypes;
|
||||
return config.dataTypes;
|
||||
}
|
||||
|
||||
export function getConstraintTypes(): ConstraintType[] {
|
||||
return (featuresConfig as any).constraintTypes || [];
|
||||
return config.constraintTypes || [];
|
||||
}
|
||||
|
||||
export function getNavItems(): NavItem[] {
|
||||
return featuresConfig.navItems.filter((item) => {
|
||||
return config.navItems.filter((item) => {
|
||||
const feature = getFeatureById(item.featureId);
|
||||
return feature && feature.enabled;
|
||||
});
|
||||
}
|
||||
|
||||
export function getEnabledFeaturesByPriority(priority: string): Feature[] {
|
||||
return featuresConfig.features.filter(
|
||||
return config.features.filter(
|
||||
f => f.enabled && f.priority === priority,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user