Each generator in the pipeline returns a plain Rust struct. These intermediate representations (IRs) carry typed metadata from one stage to the next. There’s no magic here — just data that downstream generators use to make smarter decisions.
When you pass Some(&seaorm) to gen_store, it uses the structured metadata for exact table names, column names, and junction table references instead of guessing from naming conventions. For example:
JunctionMeta.table_name tells it the exact junction table to sync for many-to-many updates.
JunctionMeta.source_fk and target_fk give exact column names for the sync_junction() calls.
EntityTableMeta.module_path drives the correct use statements in generated store code.
When you pass None, the store generator derives all of this from snake_case transformations of entity and field names. This works if your naming is conventional, but the structured metadata is more reliable.
Every method and function in the IR carries a Source discriminator that records whether it was generated from an EntityDef or scanned from a hand-written source file.
Produced by a codegen layer from an EntityDef. The module_path is the Rust path to the generated module (e.g., "crate::api::v1::generated::workout").
Scanned
module_path, file_path
Parsed from a hand-written source file. file_path points to the original .rs file on disk.
Downstream generators use Source to emit correct use statements. A Generated function is imported from the generated module path. A Scanned function is imported from its original location.
Classifies what kind of operation an API function represents. This drives HTTP verb selection, route structure, and parameter handling in transport generators. Defined in ontogen_core::ir::OpKind and re-exported as ontogen::OpKind.
pubenum OpKind {
List,
GetById,
Create,
Update,
Delete,
JunctionList { child_segment: String },
JunctionAdd { child_segment: String },
JunctionRemove { child_segment: String },
CustomGet,
CustomPost,
EventStream,
}
Variant
HTTP Method
Route Pattern
Description
List
GET
/entities
Returns all entities.
GetById
GET
/entities/:id
Returns one entity by ID.
Create
POST
/entities
Creates a new entity.
Update
PUT
/entities/:id
Updates an existing entity.
Delete
DELETE
/entities/:id
Deletes an entity.
JunctionList { child_segment }
GET
/parents/:parent_id/{child_segment}
List child entities of a parent through a junction.
JunctionAdd { child_segment }
POST
/parents/:parent_id/{child_segment}
Add a child to a parent through a junction.
JunctionRemove { child_segment }
DELETE
/parents/:parent_id/{child_segment}/:child_id
Remove a child from a parent through a junction.
CustomGet
GET
/entities/:action
Custom read operation with non-standard parameters.
CustomPost
POST
/entities/:action
Custom write operation with non-standard parameters.
EventStream
GET (SSE)
/events/:name
Server-Sent Events stream.
OpKind is assigned automatically during API scanning based on function name patterns and parameter shapes. For generated CRUD functions, the mapping is direct. Junction operations are recognized by name prefixes like list_*/add_*/remove_* paired with parent+child id parameters. For other scanned custom functions, the classifier looks at the function name prefix (get_* becomes CustomGet, others become CustomPost) and whether the return type looks like a stream.