-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.json.js
More file actions
76 lines (63 loc) · 2.16 KB
/
index.json.js
File metadata and controls
76 lines (63 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// PatternFly Component Schemas - JSON Optimized
// Generated on: 2025-10-14T12:27:01.682Z
// Load metadata
const { default: index } = await import('./schemas/index.json', { with: { type: 'json' } });
// Cache for loaded schemas
let schemas = null;
// Export lightweight data
export { index };
export const componentNames = Object.keys(index.components);
export const componentCount = index.totalComponents;
export const schemaVersion = index.version;
// Get all schemas on-demand
export async function getAllSchemas() {
if (!schemas) {
const { default: loadedSchemas } = await import('./schemas/schemas.json', { with: { type: 'json' } });
schemas = loadedSchemas;
}
return schemas;
}
// Lazy-loaded schema access
export async function getComponentSchema(name) {
if (!index.components[name]) {
throw new Error(`Component '${name}' not found`);
}
const schemas = await getAllSchemas();
return schemas[name];
}
// Fast operations using in-memory metadata
export function getComponentNames(filter = 'all') {
const allComponents = Object.keys(index.components);
switch (filter) {
case 'complex':
return allComponents.filter(name => index.components[name].isComplex);
case 'withRequiredProps':
return allComponents.filter(name => index.components[name].hasRequiredProps);
default:
return allComponents;
}
}
export function searchComponents(query) {
const lowerQuery = query.toLowerCase();
return Object.values(index.components).filter(c =>
c.name.toLowerCase().includes(lowerQuery) ||
c.description.toLowerCase().includes(lowerQuery)
);
}
export function getComponentsWithRequiredProps() {
return Object.values(index.components).filter(c => c.hasRequiredProps);
}
export function getComplexComponents() {
return Object.values(index.components).filter(c => c.isComplex);
}
export function getComponentStats() {
return {
totalComponents: index.totalComponents,
totalProps: index.totalProps,
averagePropsPerComponent: index.averagePropsPerComponent,
componentsWithRequiredProps: index.componentsWithRequiredProps,
complexComponents: index.complexComponents
};
}
// Default export
export default index;