45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// DocumentVersion represents a snapshot of a document at a point in time
|
|
type DocumentVersion struct {
|
|
ID uuid.UUID `json:"id"`
|
|
DocumentID uuid.UUID `json:"document_id"`
|
|
YjsSnapshot []byte `json:"-"` // Omit from JSON (binary)
|
|
TextPreview *string `json:"text_preview"` // Full plain text
|
|
VersionNumber int `json:"version_number"`
|
|
CreatedBy *uuid.UUID `json:"created_by"`
|
|
VersionLabel *string `json:"version_label"`
|
|
IsAutoGenerated bool `json:"is_auto_generated"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// DocumentVersionWithAuthor includes author information
|
|
type DocumentVersionWithAuthor struct {
|
|
DocumentVersion
|
|
Author *User `json:"author,omitempty"` // Nullable if user deleted
|
|
}
|
|
|
|
// CreateVersionRequest is the API request for manual snapshots
|
|
type CreateVersionRequest struct {
|
|
VersionLabel *string `json:"version_label"` // Optional user label
|
|
TextPreview *string `json:"text_preview"` // Frontend-generated full text
|
|
// YjsSnapshot sent as multipart file, not JSON
|
|
}
|
|
|
|
// RestoreVersionRequest specifies which version to restore
|
|
type RestoreVersionRequest struct {
|
|
VersionID uuid.UUID `json:"version_id" binding:"required"`
|
|
}
|
|
|
|
// VersionListResponse for listing versions
|
|
type VersionListResponse struct {
|
|
Versions []DocumentVersionWithAuthor `json:"versions"`
|
|
Total int `json:"total"`
|
|
}
|