using System.Runtime.CompilerServices;
using Umbraco.Cms.Core.Composing;
namespace Umbraco.Cms.Core.Deploy;
///
/// Connects to an Umbraco service.
///
public interface IServiceConnector : IDiscoverable
{
///
/// Gets an artifact.
///
/// The entity identifier of the artifact.
/// The context cache.
///
/// The corresponding artifact or null.
///
[Obsolete("Use GetArtifactAsync() instead. This method will be removed in a future version.")]
IArtifact? GetArtifact(Udi udi, IContextCache contextCache);
///
/// Gets an artifact.
///
/// The entity identifier of the artifact.
/// The context cache.
/// The cancellation token.
///
/// A task that represents the asynchronous operation. The task result contains the corresponding artifact or null.
///
Task GetArtifactAsync(Udi udi, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetArtifact(udi, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
///
/// Gets an artifact.
///
/// The entity.
/// The context cache.
///
/// The corresponding artifact.
///
[Obsolete("Use GetArtifactAsync() instead. This method will be removed in a future version.")]
IArtifact GetArtifact(object entity, IContextCache contextCache);
///
/// Gets an artifact.
///
/// The entity.
/// The context cache.
/// The cancellation token.
///
/// A task that represents the asynchronous operation. The task result contains the corresponding artifact.
///
Task GetArtifactAsync(object entity, IContextCache contextCache, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetArtifact(entity, contextCache)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
///
/// Initializes processing for an artifact.
///
/// The artifact.
/// The deploy context.
///
/// The state of an artifact being deployed.
///
[Obsolete("Use ProcessInitAsync() instead. This method will be removed in a future version.")]
ArtifactDeployState ProcessInit(IArtifact art, IDeployContext context);
///
/// Initializes processing for an artifact.
///
/// The artifact.
/// The deploy context.
/// The cancellation token.
///
/// A task that represents the asynchronous operation. The task result contains the state of an artifact being deployed.
///
Task ProcessInitAsync(IArtifact artifact, IDeployContext context, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(ProcessInit(artifact, context)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
///
/// Processes an artifact.
///
/// The state of the artifact being deployed.
/// The deploy context.
/// The processing pass number.
[Obsolete("Use ProcessAsync() instead. This method will be removed in a future version.")]
void Process(ArtifactDeployState dart, IDeployContext context, int pass);
///
/// Processes an artifact.
///
/// The state of the artifact being deployed.
/// The deploy context.
/// The processing pass number.
/// The cancellation token.
///
/// A task that represents the asynchronous operation.
///
Task ProcessAsync(ArtifactDeployState state, IDeployContext context, int pass, CancellationToken cancellationToken = default)
{
// TODO: Remove default implementation in v15
#pragma warning disable CS0618 // Type or member is obsolete
Process(state, context, pass);
#pragma warning restore CS0618 // Type or member is obsolete
return Task.CompletedTask;
}
///
/// Explodes/expands an UDI range into UDIs.
///
/// The UDI range.
/// The list of UDIs where to add the exploded/expanded UDIs.
[Obsolete("Use ExpandRangeAsync() instead. This method will be removed in a future version.")]
void Explode(UdiRange range, List udis);
///
/// Expands an UDI range into UDIs.
///
/// The UDI range.
/// The cancellation token.
///
/// Returns an which when enumerated will asynchronously expand the UDI range into UDIs.
///
async IAsyncEnumerable ExpandRangeAsync(UdiRange range, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
// TODO: Remove default implementation in v15
var udis = new List();
#pragma warning disable CS0618 // Type or member is obsolete
Explode(range, udis);
#pragma warning restore CS0618 // Type or member is obsolete
foreach (Udi udi in udis)
{
yield return await ValueTask.FromResult(udi);
}
}
///
/// Gets a named range for a specified UDI and selector.
///
/// The UDI.
/// The selector.
///
/// The named range for the specified UDI and selector.
///
[Obsolete("Use GetRangeAsync() instead. This method will be removed in a future version.")]
NamedUdiRange GetRange(Udi udi, string selector);
///
/// Gets a named range for a specified UDI and selector.
///
/// The UDI.
/// The selector.
/// The cancellation token.
///
/// A task that represents the asynchronous operation. The task result contains the named range for the specified UDI and selector.
///
Task GetRangeAsync(Udi udi, string selector, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetRange(udi, selector)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
///
/// Gets a named range for specified entity type, identifier and selector.
///
/// The entity type.
/// The identifier.
/// The selector.
///
/// The named range for the specified entity type, identifier and selector.
///
///
/// This is temporary. At least we thought it would be, in sept. 2016. What day is it now?
///
/// At the moment our UI has a hard time returning proper UDIs, mainly because Core's tree do
/// not manage GUIDs but only integers... so we have to provide a way to support it. The string id here
/// can be either a real string (for string UDIs) or an "integer as a string", using the value "-1" to
/// indicate the "root" i.e. an open UDI.
///
///
[Obsolete("Use GetRangeAsync() instead. This method will be removed in a future version.")]
NamedUdiRange GetRange(string entityType, string sid, string selector);
///
/// Gets a named range for specified entity type, identifier and selector.
///
/// The entity type.
/// The identifier.
/// The selector.
/// The cancellation token.
///
/// A task that represents the asynchronous operation. The task result contains the named range for the specified entity type, identifier and selector.
///
///
/// This is temporary. At least we thought it would be, in sept. 2016. What day is it now?
///
/// At the moment our UI has a hard time returning proper UDIs, mainly because Core's tree do
/// not manage GUIDs but only integers... so we have to provide a way to support it. The string id here
/// can be either a real string (for string UDIs) or an "integer as a string", using the value "-1" to
/// indicate the "root" i.e. an open UDI.
///
///
Task GetRangeAsync(string entityType, string sid, string selector, CancellationToken cancellationToken = default)
#pragma warning disable CS0618 // Type or member is obsolete
=> Task.FromResult(GetRange(entityType, sid, selector)); // TODO: Remove default implementation in v15
#pragma warning restore CS0618 // Type or member is obsolete
///
/// Compares two artifacts.
///
/// The first artifact.
/// The second artifact.
/// A collection of differences to append to, if not null.
///
/// A boolean value indicating whether the artifacts are identical.
///
bool Compare(IArtifact? art1, IArtifact? art2, ICollection? differences = null);
}