using System.Xml.Linq; using Umbraco.Cms.Core.Models.Packaging; using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.Services.OperationStatus; using Umbraco.Extensions; using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Core.Services; public interface IPackagingService : IService { /// /// Returns a result from an umbraco package file (zip) /// /// /// CompiledPackage GetCompiledPackageInfo(XDocument packageXml); /// /// Installs the data, entities, objects contained in an umbraco package file (zip) /// /// /// InstallationSummary InstallCompiledPackageData(FileInfo packageXmlFile, int userId = Constants.Security.SuperUserId); InstallationSummary InstallCompiledPackageData(XDocument? packageXml, int userId = Constants.Security.SuperUserId); /// /// Returns the advertised installed packages /// /// [Obsolete("Use GetAllInstalledPackagesAsync instead. Scheduled for removal in Umbraco 15.")] IEnumerable GetAllInstalledPackages(); /// /// Returns the advertised installed packages /// /// Task> GetAllInstalledPackagesAsync() #pragma warning disable CS0618 // Type or member is obsolete => Task.FromResult(GetAllInstalledPackages()); #pragma warning restore CS0618 // Type or member is obsolete /// /// Returns installed packages collected from the package migration plans. /// Task> GetInstalledPackagesFromMigrationPlansAsync(int skip, int take); InstalledPackage? GetInstalledPackageByName(string packageName); [Obsolete("Use GetCreatedPackagesAsync instead. Scheduled for removal in Umbraco 15.")] IEnumerable GetAllCreatedPackages(); /// /// Returns the created packages as a paged model. /// /// The amount of items to skip. /// The amount of items to take. Task> GetCreatedPackagesAsync(int skip, int take) { PackageDefinition[] packages = GetAllCreatedPackages().WhereNotNull().ToArray(); var pagedModel = new PagedModel(packages.Length, packages.Skip(skip).Take(take)); return Task.FromResult(pagedModel); } /// /// Returns a created package by id /// /// /// PackageDefinition? GetCreatedPackageById(int id); /// /// Returns a created package by key. /// /// The key of the package. /// The package or null if the package was not found. Task GetCreatedPackageByKeyAsync(Guid key); [Obsolete("Use DeleteCreatedPackageAsync instead. Scheduled for removal in Umbraco 15.")] void DeleteCreatedPackage(int id, int userId = Constants.Security.SuperUserId); /// /// Deletes a created package by key. /// /// The key of the package. /// Key of the user deleting the package. Task> DeleteCreatedPackageAsync(Guid key, Guid userKey); /// /// Persists a package definition to storage /// /// [Obsolete("Use CreateCreatedPackageAsync or UpdateCreatedPackageAsync instead. Scheduled for removal in Umbraco 15.")] bool SaveCreatedPackage(PackageDefinition definition); /// /// Creates a new package. /// /// model for the package to create. /// Key of the user performing the create. Task> CreateCreatedPackageAsync(PackageDefinition package, Guid userKey); /// /// Updates a created package. /// /// model for the package to update. /// Key of the user performing the update. Task> UpdateCreatedPackageAsync(PackageDefinition package, Guid userKey); /// /// Creates the package file and returns it's physical path /// /// string ExportCreatedPackage(PackageDefinition definition); /// /// Gets the package file stream. /// /// Stream? GetPackageFileStream(PackageDefinition definition) => null; }