feat: Implement versioning documentation

This commit is contained in:
gpt-engineer-app[bot]
2025-10-15 17:54:53 +00:00
parent 96a5d235e9
commit ea78aff4a7
9 changed files with 2183 additions and 0 deletions

34
docs/versioning/API.md Normal file
View File

@@ -0,0 +1,34 @@
# 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](./FRONTEND.md) for detailed usage.