Modular, feature-flagged Rust types for Salesforce metadata, automatically generated from @salesforce/types.
This is a fully codegen-built crateβno manual type definitions. All Rust types are automatically generated from Salesforce metadata definitions via the @salesforce/types npm package.
π Explore the interactive type dependency graph β
This repository contains:
- Generated types in
crates/sf-types/src/metadata/(derived from Salesforce metadata) - Codegen tooling in
sf-typegen/(Rust tool that performs the generation)
Every version of this crate corresponds to a version of @salesforce/types. The crate version is aligned with the npm package version:
@salesforce/types@1.0.0β crate1.0.0@salesforce/types@1.1.0β crate1.1.0@salesforce/types@1.1.0(codegen fix) β crate1.1.1
See ATTRIBUTION.md for licensing and attribution requirements.
The generated nature of this crate is explicit and reproducible:
# To regenerate from scratch:
npm install # Fetches @salesforce/types
bash scripts/generate.sh
# Output in crates/sf-types/src/ will exactly match what's committedThis workspace consists of two main crates:
busbar-sf-types: The library crate containing auto-generated Rust structs and enumssf-typegen: The codegen toolchain that parses@salesforce/typesand produces modular Rust code
The core library provides Rust types generated from Salesforce's @salesforce/types metadata definitions.
Types are organized by domain, allowing you to include only what you need to keep compile times fast.
| Feature | Description | ~Types |
|---|---|---|
common |
Core enums used across types (default) | 45 |
settings |
Org settings for scratch org definitions | 261 |
full |
All types (enables everything) | 2680+ |
| Feature | Description |
|---|---|
objects |
Custom objects, fields, schema types |
permissions |
Permission sets, profiles, sharing rules |
flows |
Flow definitions and process automation |
apex |
Apex classes, triggers, components |
lwc |
Lightning Web Components and Aura |
ai |
AI/ML, Einstein, Prompt Templates |
datacloud |
Data Cloud, CDP, Data Sources |
servicecloud |
Service Cloud, Cases, Knowledge |
(See crates/sf-types/Cargo.toml for the full list of 80+ supported categories)
Add to your Cargo.toml:
[dependencies]
# For org settings only (minimal footprint, ~5s compile)
sf-generated-types = { git = "https://github.com/kantext-dev/busbar-sf-types", features = ["settings"] }
# For deployment operations (~20s compile)
sf-generated-types = { git = "https://github.com/kantext-dev/busbar-sf-types", features = ["deployments"] }
# For JSON Schema support
sf-generated-types = { git = "https://github.com/kantext-dev/busbar-sf-types", features = ["full", "schemars"] }use sf_generated_types::{ApexSettings, SecuritySettings, FieldType};
use sf_generated_types::metadata::ai::Prompt;
fn main() {
let settings = ApexSettings {
enable_compile_on_deploy: Some(true),
enable_debug_logs_during_deployment: Some(true),
..Default::default()
};
// Core enum
let field_type = FieldType::Text;
// Domain-specific type
let prompt = Prompt {
master_label: "My Prompt".to_string(),
..Default::default()
};
}This crate supports generating JSON Schemas for Salesforce metadata types via the schemars feature.
You can run the included schema generator to produce JSON schema files for types like CustomObject, PermissionSet, etc.:
cargo run -p sf-generated-types --bin schema-gen --features "full schemars" -- schemas/This will output files like schemas/CustomObject.json and schemas/SecuritySettings.json.
The types are generated using the sf-typegen crate included in this repository.
- Rust toolchain (1.91.0 or later)
- Node.js and npm (for
@salesforce/types)
bash scripts/generate.shThis command will:
- Fetch the latest
metadata.tsfrom@salesforce/typesnpm package - Parse the TypeScript AST using oxc parser
- Build a type dependency graph to analyze relationships between types
- Perform graph-based categorization to automatically assign types to modules
- Apply manual documentation overlays (descriptions for key types)
- Apply categorization rules defined in
sf-typegen/src/categories.rs - Generate modular Rust files in
crates/sf-types/src/metadata/ - Export type graph to
assets/type-graph.jsonandassets/type-graph.dot - Copy type graph to
docs/type-graph.jsonfor GitHub Pages deployment
The generator now includes a sophisticated type dependency graph that:
- Analyzes TypeScript AST to build a directed graph of type relationships
- Categorizes types automatically based on their dependencies
- Detects shared types used by multiple categories (assigned to "common" module)
- Exports to JSON and DOT formats for analysis and visualization
The graph contains:
- 2682 nodes (types from Salesforce metadata)
- 4906 edges (dependency relationships)
- 267 shared types automatically identified and moved to common module
See assets/README.md for detailed information on using the type graph.
Explore the type dependency graph interactively in your browser:
π Launch Salesforce Types Explorer
The interactive explorer is built with React, reagraph (WebGL graph visualization), and reablocks and provides:
- π Search - Find types by name across 2600+ types with real-time results
- π Category Browsing - Browse types organized into 80+ categories
- π― Interactive Graph - Click nodes in the WebGL-rendered dependency graph to navigate
- Overview mode - Shows top 20 categories by type count
- Type-specific mode - Displays dependencies for the selected type
- π¨ Relationship Types - Filter and visualize different edge types:
- Contains - Type A has a field of Type B
- Extends - Type A extends/inherits from Type B
- Generic - Type A is a generic instantiation of Type B
- π Tabbed Interface - Switch between type Details and JSON Schema views
- π Statistics - View graph metrics and category distributions
- π¨ Color-coded - Types colored by category for easy identification
Developing the Site:
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run buildSee SITE_README.md for detailed information about the site architecture.
Testing the Graph Viewer:
The graph viewer includes comprehensive Playwright tests to ensure reliability:
# Run tests
npm test
# Run tests in UI mode (interactive)
npm run test:ui
# Debug tests
npm run test:debugTests cover:
- Initial page load and overview graph display
- Type selection and dependency visualization
- Search functionality
- Category browsing
- Relationship filtering (Contains/Extends/Generic)
- Navigation between related types
To visualize the graph locally with Graphviz:
dot -Tpng assets/type-graph.dot -o type-graph.pngNote: Building with --all-features requires >8GB of memory and may fail in memory-constrained environments (CI runners, devcontainers). This is due to the large number of feature flags (80+).
For development and CI, we recommend:
- Use specific feature subsets:
cargo build --features "objects,flows,apex" - Or use default features:
cargo build(includes common types only) - Full feature compilation works on machines with 16GB+ RAM
Since the source @salesforce/types definitions do not include comments, we support a manual overlay system to inject documentation into the generated Rust code (and resulting JSON schemas).
These are defined in sf-typegen/src/bin/generate_from_typescript.rs in the apply_overlays() function.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.