diff --git a/src/Umbraco.Core/Services/IContentVersionOperationService.cs b/src/Umbraco.Core/Services/IContentVersionOperationService.cs new file mode 100644 index 0000000000..81b54af338 --- /dev/null +++ b/src/Umbraco.Core/Services/IContentVersionOperationService.cs @@ -0,0 +1,133 @@ +// src/Umbraco.Core/Services/IContentVersionOperationService.cs +using Umbraco.Cms.Core.Models; + +namespace Umbraco.Cms.Core.Services; + +/// +/// Service for content version operations (retrieving versions, rollback, deleting versions). +/// +/// +/// +/// Implementation Note: Do not implement this interface directly. +/// Instead, inherit from which provides required +/// infrastructure (scoping, repository access, auditing). Direct implementation +/// without this base class will result in missing functionality. +/// +/// +/// This interface is part of the ContentService refactoring initiative (Phase 3). +/// It extracts version operations into a focused, testable service. +/// +/// +/// Note: This interface provides synchronous version operations +/// extracted from . For async API-layer version operations, +/// see which orchestrates via this service. +/// +/// +/// Versioning Policy: This interface follows additive-only changes. +/// New methods may be added with default implementations. Existing methods will not +/// be removed or have signatures changed without a 2 major version deprecation period. +/// +/// +/// Version History: +/// +/// v1.0 (Phase 3): Initial interface with GetVersion, GetVersions, Rollback, DeleteVersions operations +/// +/// +/// +/// 1.0 +public interface IContentVersionOperationService : IService +{ + #region Version Retrieval + + /// + /// Gets a specific version of content by version id. + /// + /// The version id to retrieve. + /// The content version, or null if not found. + IContent? GetVersion(int versionId); + + /// + /// Gets all versions of a content item. + /// + /// The content id. + /// All versions of the content, ordered by version date descending. + IEnumerable GetVersions(int id); + + /// + /// Gets a paged subset of versions for a content item. + /// + /// The content id. + /// Number of versions to skip. + /// Number of versions to take. + /// Paged versions of the content, ordered by version date descending. + IEnumerable GetVersionsSlim(int id, int skip, int take); + + /// + /// Gets version ids for a content item, ordered with latest first. + /// + /// The content id. + /// Maximum number of version ids to return. Must be positive. + /// Version ids ordered with latest first. Empty if content not found. + /// Thrown if maxRows is less than or equal to zero. + /// + /// This method acquires a read lock on the content tree for consistency with other + /// version retrieval methods. If content with the specified id does not exist, + /// an empty enumerable is returned rather than throwing an exception. + /// + IEnumerable GetVersionIds(int id, int maxRows); + + #endregion + + #region Rollback + + /// + /// Rolls back content to a previous version. + /// + /// The content id to rollback. + /// The version id to rollback to. + /// The culture to rollback, or "*" for all cultures. + /// The user performing the rollback. + /// The operation result indicating success or failure. + /// + /// Fires (cancellable) before rollback + /// and after successful rollback. + /// The rollback copies property values from the target version to the current content + /// and saves it, creating a new version. + /// + OperationResult Rollback(int id, int versionId, string culture = "*", int userId = Constants.Security.SuperUserId); + + #endregion + + #region Version Deletion + + /// + /// Permanently deletes versions of content prior to a specific date. + /// + /// The content id. + /// Delete versions older than this date. + /// The user performing the deletion. + /// + /// This method will never delete the latest version of a content item. + /// Fires (cancellable) before deletion + /// and after deletion. + /// + void DeleteVersions(int id, DateTime versionDate, int userId = Constants.Security.SuperUserId); + + /// + /// Permanently deletes a specific version of content. + /// + /// The content id. + /// The version id to delete. + /// If true, also deletes all versions prior to the specified version. + /// The user performing the deletion. + /// + /// This method will never delete the current version or published version of a content item. + /// Fires (cancellable) before deletion + /// and after deletion. + /// If deletePriorVersions is true, it first deletes all versions prior to the specified version's date, + /// then deletes the specified version. + /// + void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = Constants.Security.SuperUserId); + + #endregion +}