WS Frappe Tree
A Visual Studio Code extension for analyzing and visualizing Frappe DocType dependencies and generating Custom DocPerms.
Features
- Analyze DocType Dependencies: Automatically scan all DocType JSON files in your Frappe workspace
- Visual Dependency Graph: Interactive force-directed graph showing relationships between DocTypes
- Dependency Tree View: Hierarchical tree visualization for specific DocTypes
- Export to JSON: Export all dependency information to a structured JSON file (flat or nested)
- Statistics: View detailed statistics about your DocType structure
- Generate Custom DocPerms: Automatically generate permission fixtures for DocTypes and their dependencies
Supported Field Types
The extension analyzes the following Frappe field types:
- Link: Direct reference to another DocType
- Dynamic Link: Dynamic reference based on another field
- Table: Child table (One-to-Many relationship)
- Table MultiSelect: Multiple selection from child table
Commands
Access these commands from the Command Palette (Cmd+Shift+P / Ctrl+Shift+P):
Frappe: Analyze DocType Dependencies - Scan all DocTypes in workspace
Frappe: Show Dependency Tree - Display interactive dependency graph
Frappe: Export Dependencies to JSON - Export analysis to JSON file (choose between all DocTypes flat or specific DocType nested)
Frappe: Analyze Current DocType - Analyze the currently open DocType file
Frappe: Export Current DocType to Nested JSON - Export the current DocType with nested dependencies
Frappe: Generate Custom DocPerms - Generate Custom DocPerm fixtures for a DocType and its dependencies
Usage
1. Analyze Single DocType
Right-click on any DocType JSON file and select:
Frappe: Analyze Current DocType
Or open a DocType file and run the command from the palette.
This will show:
- Direct dependencies (DocTypes this one references)
- Reverse dependencies (DocTypes that reference this one)
- Interactive tree visualization
- Field-level dependency information
2. Export Data
Right-click on a DocType JSON file:
Frappe: Export Current DocType to Nested JSON
This exports a single DocType with nested dependency tree:
{
"timestamp": "2025-10-26T...",
"workspace": "your-workspace",
"rootDocType": "Sales Order",
"maxDepth": 3,
"tree": {
"name": "Sales Order",
"module": "Selling",
"dependencies": [
{
"name": "Customer",
"module": "CRM",
"connectionInfo": {
"fieldName": "customer",
"fieldType": "Link"
},
"dependencies": [
{
"name": "Territory",
"module": "Setup",
"connectionInfo": {
"fieldName": "territory",
"fieldType": "Link"
},
"dependencies": []
}
]
}
]
}
}
The nested export respects the maxDepth configuration setting.
3. Generate Custom DocPerms
Generate permission fixtures automatically for a DocType and all its dependencies:
Frappe: Generate Custom DocPerms
This command will:
- Prompt for DocType: Select the main DocType to generate permissions for
- Prompt for Role: Enter the role name (e.g., "Sales User", "Manager")
- Prompt for App: Select or enter the app name where fixtures will be saved
- Generate Permission Tree: Build a tree of the DocType and its dependencies:
- Main DocType: Full permissions (read, write, create, delete, etc.)
- First-level dependencies (Link, Dynamic Link, Table MultiSelect): Select permission
- Table fields: Select permission for the table and its Link/Dynamic Link dependencies
- Create/Update Fixtures: Add permissions to
fixtures/custom_docperm.json in the selected app
Permission Logic
- Full Permissions (main DocType):
read, write, create, delete, submit (if submittable), cancel (if submittable), amend (if submittable), email, print, export, import, report, share, select
- Select Permission (dependencies): Only
select is enabled
- Base Permissions: Automatically copies existing permissions from DocType JSON files if no Custom DocPerms exist yet
- Smart Merging: Merges new permissions with existing ones (OR operation on permission flags)
Requirements
- Visual Studio Code 1.80.0 or higher
- Frappe workspace with DocType JSON files
Extension Settings
This extension contributes the following settings:
ws-frappe-tree.maxDepth: Maximum depth for dependency tree analysis (default: 3, range: 1-10). Higher values show deeper dependency chains but may affect performance. This setting applies to nested JSON exports and dependency tree visualizations.
Known Issues
- Large workspaces (1000+ DocTypes) may take some time to analyze
- Dynamic Link fields show the reference field name, not actual target DocTypes
Development
Building from Source
cd ws-frappe-tree
npm install
npm run compile
Release Notes
0.4.6
Latest release with enhanced features:
- DocType dependency analysis
- Interactive graph visualization
- Tree view for specific DocTypes
- JSON export functionality (flat and nested)
- Statistics and reports
- Custom DocPerm generation with smart merging
- Base permission copying from DocType files
- Fixtures directory management
- Multi-app support
- Permission tree visualization
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
MIT