Skip to main content

Module templates

Module templates 

Source
Expand description

Flow templates - versionable, named flow graphs persisted to disk, grouped into collections by SQLite metadata.

Filesystem layout is intentionally flat: one JSON file per template at <dir>/<slug>.flow.json (plus an optional sibling <slug>.flow text projection). Collections do not affect filesystem layout - they’re held in the template_collections / template_membership tables on flow_storage::Store. A template with no template_membership row is in the system-managed Default collection.

Structs§

TemplateRecord
TemplateSource
Source provenance for a template installed from the Template Hub. Plain struct rather than an enum: there is exactly one source today; widen later if another lands.

Enums§

TemplateError

Constants§

DEFAULT_COLLECTION_NAME
Display name of the Default collection, used by ensure_default.
DEFAULT_COLLECTION_SLUG
Slug of the system-managed Default collection. Every template whose template_membership row is absent is reported as belonging here.

Functions§

delete
File-first deletion: removes the canonical JSON, then the sibling DSL, then the membership row. Membership cleanup is best-effort and logs on failure - the file is the source of truth.
ensure_default
Idempotently insert the Default collection row at boot. Called by FlowApp::new. Safe to call repeatedly: the upsert never downgrades is_system once set.
list
List every template on disk, annotated with its collection + source from the membership index. Files without a membership row report DEFAULT_COLLECTION_SLUG and source: None.
list_in
List templates in one collection only. Files in other collections are skipped. Files with no membership row count as Default.
load
save
Save a template into collection_slug. Membership is written only when the placement is non-default OR a hub source is supplied - keeps the SQLite skinny: in-default user-authored templates have no row.
save_with_slug
Lower-level save that takes an explicit slug instead of deriving one. Used by the Hub install path, where the catalog slug must stay stable across versions even when the display name changes. slug is validated against the same [a-z0-9-]+ rule as the renderer-facing routes.