Skip to content

Feature: Add JSON Output Format #5

@ksrpraneeth

Description

@ksrpraneeth

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 .png formats. 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:

    1. 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 Route and NavigationFlow in graphgeneratorts/src/angular-flow-analyzer.ts can 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\', conditions or guardInfo).
        • Project metadata (e.g., framework analyzed, analysis timestamp).
    2. Implement JSON Generation:
      • In graphgeneratorts/src/angular-flow-analyzer.ts, modify or add to the generateGraph method (or create a new generateJsonOutput method).
      • This new logic should take the processed this.routes and this.flows (or the more structured routeNodes and flowEdges from generateGraph) and serialize them into the defined JSON schema.
    3. CLI Option: Add a CLI flag (e.g., --output-format json or --json) to specify JSON output.
      • The output filename could be user-flows.json by default.

    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 (especially generateGraph, Route and NavigationFlow interfaces).
    • graphgeneratorts/README.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions