-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Issue 3: Feature: Add JSON Output Format
-
Title:
Feature: Add JSON Output Format for Analysis Results -
Labels:
enhancement,feature,help wanted -
Body:
Currently, UserPravah generates output in.dot(Graphviz) and.pngformats. To allow for easier integration with other tools and for programmatic access to the analyzed flow data, we should add a JSON output format.Requirements:
- Define JSON Schema: Determine a clear and comprehensive JSON structure to represent the routes, navigation flows, and any other relevant metadata.
- The existing internal interfaces
RouteandNavigationFlowingraphgeneratorts/src/angular-flow-analyzer.tscan serve as a good starting point. - Consider including:
- A list of all discovered routes/nodes (with properties like
id,fullPath,displayName,componentName,isRoot,guards,data). - A list of all navigation flows/edges (with properties like
fromNodeId,toNodeId,type: \'programmatic\' | \'template\' | \'redirect\',conditionsorguardInfo). - Project metadata (e.g., framework analyzed, analysis timestamp).
- A list of all discovered routes/nodes (with properties like
- The existing internal interfaces
- Implement JSON Generation:
- In
graphgeneratorts/src/angular-flow-analyzer.ts, modify or add to thegenerateGraphmethod (or create a newgenerateJsonOutputmethod). - This new logic should take the processed
this.routesandthis.flows(or the more structuredrouteNodesandflowEdgesfromgenerateGraph) and serialize them into the defined JSON schema.
- In
- CLI Option: Add a CLI flag (e.g.,
--output-format jsonor--json) to specify JSON output.- The output filename could be
user-flows.jsonby default.
- The output filename could be
Proposed JSON Structure (Draft):
```json
{
"metadata": {
"framework": "Angular", // or "React", etc.
"analyzedAt": "YYYY-MM-DDTHH:mm:ssZ",
"projectPath": "/path/to/project"
},
"nodes": [
{
"id": "cleaned_route_path_for_id", // e.g., "slash_admin_slash_users"
"fullPath": "/admin/users/:id",
"displayName": "Admin Users Detail",
"component": "UserDetailComponent",
"isRoot": false,
"guards": ["AuthGuard"],
"data": { "title": "User Details" }
// ... other relevant node properties
}
],
"edges": [
{
"fromNodeId": "cleaned_source_node_id",
"toNodeId": "cleaned_target_node_id",
"type": "dynamic", // "static", "redirect", "hierarchy"
"label": "AuthGuard, RoleGuard" // Optional label, e.g., for guards on dynamic nav
}
]
}
```Tasks:
- Finalize the JSON schema.
- Implement the JSON output generation logic within
AngularFlowAnalyzer. - Add a CLI option to trigger JSON output.
- Update documentation (
README.md) to reflect the new output option.
Files to look at:
graphgeneratorts/src/angular-flow-analyzer.ts(especiallygenerateGraph,RouteandNavigationFlowinterfaces).graphgeneratorts/README.md.
- Define JSON Schema: Determine a clear and comprehensive JSON structure to represent the routes, navigation flows, and any other relevant metadata.