mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:31:12 -05:00
1.1 KiB
1.1 KiB
API Reference
Complete API documentation for versioning functions and hooks
Database Functions
create_relational_version()
Trigger function - automatically creates versions on entity INSERT/UPDATE.
get_version_diff(entity_type, from_version_id, to_version_id)
Returns JSONB diff between two versions.
cleanup_old_versions(entity_type, keep_versions)
Deletes old versions, keeping N most recent per entity.
rollback_to_version(entity_type, entity_id, target_version_id, changed_by, reason)
Restores entity to previous version, creates new version with change_type='restored'.
React Hooks
useEntityVersions(entityType, entityId)
Returns: { versions, currentVersion, loading, rollbackToVersion, ... }
useVersionComparison(entityType, fromVersionId, toVersionId)
Returns: { diff, loading, error }
Components
<VersionIndicator />- Version badge<EntityVersionHistory />- Full timeline<VersionComparisonDialog />- Side-by-side diff<RollbackDialog />- Restore confirmation
See FRONTEND.md for detailed usage.