rename to mixtape

This commit is contained in:
2026-05-05 11:34:32 +02:00
parent 56a51c9ad0
commit 34cc74dbf7
271 changed files with 1022 additions and 1025 deletions
@@ -1,21 +0,0 @@
using System.Threading.Tasks;
using Finch.Communication;
using Finch.Models;
namespace Finch.Sqlite;
public interface IEntityModifiedHandler : IHandler
{
Task Saved<T>(T model, bool update) where T : FinchIdEntity, new() => update ? Updated(model) : Created(model);
Task Created<T>(T model) where T : FinchIdEntity, new();
Task Updated<T>(T model) where T : FinchIdEntity, new();
Task Deleted<T>(T model) where T : FinchIdEntity, new();
}
public class EmptyEntityModifiedHandler : IEntityModifiedHandler
{
public Task Created<T>(T model) where T : FinchIdEntity, new() => Task.CompletedTask;
public Task Updated<T>(T model) where T : FinchIdEntity, new() => Task.CompletedTask;
public Task Deleted<T>(T model) where T : FinchIdEntity, new() => Task.CompletedTask;
}
-26
View File
@@ -1,26 +0,0 @@
using System;
using Finch.Communication;
using Finch.Configuration;
using Finch.Context;
namespace Finch.Sqlite;
public class StoreContext
{
public IFinchContext Context { get; private set; }
public IFinchOptions Options { get; private set; }
public IServiceProvider Services { get; private set; }
public IMessageAggregator Messages { get; private set; }
public StoreContext(IFinchContext context, IServiceProvider serviceProvider, IMessageAggregator messages)
{
Options = context.Options;
Context = context;
Services = serviceProvider;
Messages = messages;
}
}
@@ -1,16 +0,0 @@
using Microsoft.Extensions.DependencyModel;
namespace Finch.Assemblies;
public class FinchAssemblyDiscoveryRule : IAssemblyDiscoveryRule
{
const string FinchPrefix = "Finch.";
/// <inheritdoc />
public bool IsValid(RuntimeLibrary library, AssemblyDiscoveryContext context)
{
StringComparison casing = StringComparison.OrdinalIgnoreCase;
// TODO we need to auto-add assemblies and discover their types which have implementations of IFinchPlugin
return library.Name.StartsWith(FinchPrefix, casing) || (context.HasEntryAssembly && library.Name.Contains(context.EntryAssemblyName, casing));
}
}
-5
View File
@@ -1,5 +0,0 @@
namespace Finch.Communication;
public interface IHandler
{
}
@@ -1,6 +0,0 @@
namespace Finch.Configuration;
public interface IFinchCollectionOptions
{
}
-13
View File
@@ -1,13 +0,0 @@
using Microsoft.AspNetCore.Http;
namespace Finch.Context
{
public class FinchContextMiddleware(RequestDelegate next)
{
public async Task Invoke(HttpContext httpContext, IFinchContext finchContext)
{
await finchContext.Resolve(httpContext);
await next(httpContext);
}
}
}
-6
View File
@@ -1,6 +0,0 @@
namespace Finch.FileStorage;
public class FileSystemOptions
{
public string FinchAssetsPath { get; set; }
}
-30
View File
@@ -1,30 +0,0 @@
namespace Finch.Models;
public class FinchReference
{
public FinchReference() { }
public FinchReference(FinchEntity entity)
{
Id = entity.Id;
Name = entity.Name;
}
public static FinchReference From(FinchEntity entity)
{
return entity == null ? null : new FinchReference(entity);
}
public static FinchReference From<T>(T entity, Func<T, string> transform) where T : FinchEntity
{
return entity == null ? null : new FinchReference()
{
Id = entity.Id,
Name = transform(entity)
};
}
public string Id { get; set; }
public string Name { get; set; }
}
-11
View File
@@ -1,11 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace Finch.Mvc;
[ApiController]
public abstract class FinchApiController : ControllerBase
{
IFinchContext _context;
public IFinchContext Context => _context ?? (_context = HttpContext?.RequestServices?.GetService<IFinchContext>());
}
-10
View File
@@ -1,10 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace Finch.Mvc;
public abstract class FinchController : Controller
{
IFinchContext _context;
public IFinchContext Context => _context ?? (_context = HttpContext?.RequestServices?.GetService<IFinchContext>());
}
-17
View File
@@ -1,17 +0,0 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Finch;
public static class ServiceCollectionExtensions
{
public static FinchBuilder AddFinch(this IServiceCollection services, IConfiguration configuration)
{
return new FinchBuilder(services, configuration, null);
}
public static FinchBuilder AddFinch(this IServiceCollection services, IConfiguration configuration, Action<IFinchStartupOptions> setupAction)
{
return new FinchBuilder(services, configuration, setupAction);
}
}
-22
View File
@@ -1,22 +0,0 @@
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;
//global using Finch.Persistence;
global using Finch.Utils;
global using Finch.Configuration;
global using Finch.Extensions;
global using Finch.FileStorage;
global using Finch.Models;
global using Finch.Modules;
global using Finch.Media;
global using Finch.Rendering;
global using Finch.Validation;
global using Finch.Localization;
global using Finch.Context;
global using Finch.Communication;
global using Finch.Assemblies;
@@ -1,9 +1,9 @@
using System.Linq.Expressions;
using Finch.Identity;
using Mixtape.Identity;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class RavenIdentityStoreDbProvider : IFinchIdentityStoreDbProvider
public class RavenIdentityStoreDbProvider : IMixtapeIdentityStoreDbProvider
{
protected IRavenOperations Ops { get; set; }
@@ -14,27 +14,27 @@ public class RavenIdentityStoreDbProvider : IFinchIdentityStoreDbProvider
}
public Task<T> Load<T>(string id, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<T> Load<T>(string id, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Load<T>(id);
public Task<T> Find<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default) where T : FinchEntity =>
public Task<T> Find<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default) where T : MixtapeEntity =>
Ops.Session.Query<T>().FirstOrDefaultAsync(expression, ct);
public async Task<IList<T>> FindAll<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default)
where T : FinchEntity =>
where T : MixtapeEntity =>
await Ops.Session.Query<T>().Where(expression).ToListAsync(ct);
public Task<Result<T>> Create<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Create<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Create(model);
public Task<Result<T>> Update<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Update<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Update(model);
public Task<Result<T>> Delete<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Delete<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Delete(model);
}
@@ -1,9 +1,9 @@
using System.Linq.Expressions;
using Finch.Media;
using Mixtape.Media;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class RavenMediaStoreDbProvider : IFinchMediaStoreDbProvider
public class RavenMediaStoreDbProvider : IMixtapeMediaStoreDbProvider
{
protected IRavenOperations Ops { get; set; }
@@ -14,23 +14,23 @@ public class RavenMediaStoreDbProvider : IFinchMediaStoreDbProvider
}
public Task<T> Find<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default) where T : FinchEntity =>
public Task<T> Find<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default) where T : MixtapeEntity =>
Ops.Session.Query<T>().FirstOrDefaultAsync(expression, ct);
public async Task<IList<T>> FindAll<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default)
where T : FinchEntity =>
where T : MixtapeEntity =>
await Ops.Session.Query<T>().Where(expression).ToListAsync(ct);
public Task<Result<T>> Create<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Create<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Create(model);
public Task<Result<T>> Update<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Update<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Update(model);
public Task<Result<T>> Delete<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Delete<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Delete(model);
}
@@ -1,9 +1,9 @@
using System.Linq.Expressions;
using Finch.Numbers;
using Mixtape.Numbers;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class RavenNumberStoreDbProvider : IFinchNumberStoreDbProvider
public class RavenNumberStoreDbProvider : IMixtapeNumberStoreDbProvider
{
protected IRavenOperations Ops { get; set; }
@@ -14,27 +14,27 @@ public class RavenNumberStoreDbProvider : IFinchNumberStoreDbProvider
}
public Task<T> Load<T>(string id, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<T> Load<T>(string id, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Load<T>(id);
public Task<T> Find<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default) where T : FinchEntity =>
public Task<T> Find<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default) where T : MixtapeEntity =>
Ops.Session.Query<T>().FirstOrDefaultAsync(expression, ct);
public async Task<IList<T>> FindAll<T>(Expression<Func<T, bool>> expression, CancellationToken ct = default)
where T : FinchEntity =>
where T : MixtapeEntity =>
await Ops.Session.Query<T>().Where(expression).ToListAsync(ct);
public Task<Result<T>> Create<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Create<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Create(model);
public Task<Result<T>> Update<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Update<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Update(model);
public Task<Result<T>> Delete<T>(T model, CancellationToken ct = default) where T : FinchEntity, new() =>
public Task<Result<T>> Delete<T>(T model, CancellationToken ct = default) where T : MixtapeEntity, new() =>
Ops.Delete(model);
}
@@ -1,8 +1,8 @@
using Rv = Raven.Client;
namespace Finch.Raven;
namespace Mixtape.Raven;
public static class FinchDocumentSessionExtensions
public static class MixtapeDocumentSessionExtensions
{
public static void SetCollection<T>(this IAsyncDocumentSession session, T model, string collectionName)
{
@@ -1,7 +1,7 @@
using Raven.Client.Documents.Linq;
using System.Linq.Expressions;
namespace Finch.Raven;
namespace Mixtape.Raven;
public static class RavenQueryableExtensions
{
@@ -1,6 +1,6 @@
using FluentValidation;
namespace Finch.Raven;
namespace Mixtape.Raven;
public static class ValidatorExtensions
{
@@ -8,12 +8,12 @@ public static class ValidatorExtensions
/// Check if this value is unique within a collection
/// </summary>
public static IRuleBuilderOptions<T, TProperty> Unique<T, TProperty>(this IRuleBuilder<T, TProperty> ruleBuilder, IRavenOperations ops)
where T : FinchIdEntity
where T : MixtapeIdEntity
{
return ruleBuilder.MustAsync(async (entity, value, context, cancellation) =>
{
bool any = await ops.Session.Advanced.AsyncDocumentQuery<T>()
.WhereNotEquals(nameof(FinchIdEntity.Id), entity.Id)
.WhereNotEquals(nameof(MixtapeIdEntity.Id), entity.Id)
.WhereEquals(context.PropertyPath.ToPascalCaseId(), value)
.AnyAsync(cancellation);
@@ -42,12 +42,12 @@ public static class ValidatorExtensions
/// Check if this value is at least set once to the expected value within a collection
/// </summary>
public static IRuleBuilderOptions<T, TProperty> ExpectAnyUnique<T, TProperty>(this IRuleBuilder<T, TProperty> ruleBuilder, IRavenOperations ops, TProperty expectedValue)
where T : FinchIdEntity
where T : MixtapeIdEntity
{
return ruleBuilder.MustAsync(async (entity, value, context, cancellation) =>
{
return await ops.Session.Advanced.AsyncDocumentQuery<T>()
.WhereNotEquals(nameof(FinchIdEntity.Id), entity.Id)
.WhereNotEquals(nameof(MixtapeIdEntity.Id), entity.Id)
.WhereEquals(context.PropertyPath.ToPascalCaseId(), expectedValue)
.AnyAsync(cancellation);
}).WithMessage("@errors.forms.not_unique_alone");
@@ -58,7 +58,7 @@ public static class ValidatorExtensions
/// Check if this reference exists and is an entity which can be referenced
/// </summary>
public static IRuleBuilderOptions<T, string> Exists<T>(this IRuleBuilder<T, string> ruleBuilder, IRavenOperations ops)
where T : FinchIdEntity
where T : MixtapeIdEntity
{
return ruleBuilder.Exists<T, T>(ops);
}
@@ -68,7 +68,7 @@ public static class ValidatorExtensions
/// Check if this reference exists and is an entity which can be referenced
/// </summary>
public static IRuleBuilderOptions<T, string> Exists<T, TCollection>(this IRuleBuilder<T, string> ruleBuilder, IRavenOperations ops)
where TCollection : FinchIdEntity
where TCollection : MixtapeIdEntity
{
return ruleBuilder.MustAsync(async (entity, id, context, cancellation) =>
{
@@ -3,15 +3,15 @@ using Raven.Client.Documents.Indexes.Spatial;
using Raven.Client.Documents.Operations.Attachments;
using System.Linq.Expressions;
namespace Finch.Raven;
namespace Mixtape.Raven;
public abstract class FinchJavascriptIndex : AbstractJavaScriptIndexCreationTask, IFinchIndexDefinition
public abstract class MixtapeJavascriptIndex : AbstractJavaScriptIndexCreationTask, IMixtapeIndexDefinition
{
public FinchJavascriptIndex() { Create(); }
public MixtapeJavascriptIndex() { Create(); }
protected virtual void Create() { }
public virtual void Setup(IFinchOptions options, IDocumentStore store) { }
public virtual void Setup(IMixtapeOptions options, IDocumentStore store) { }
public new string Reduce { get => base.Reduce; set => base.Reduce = value; }
public new string OutputReduceToCollection { get => base.OutputReduceToCollection; set => base.OutputReduceToCollection = value; }
@@ -43,12 +43,12 @@ public abstract class FinchJavascriptIndex : AbstractJavaScriptIndexCreationTask
public new T? TryConvert<T>(object value) where T : struct => base.TryConvert<T>(value);
}
public abstract class FinchMultiMapIndex : AbstractMultiMapIndexCreationTask<object>, IFinchIndexDefinition
public abstract class MixtapeMultiMapIndex : AbstractMultiMapIndexCreationTask<object>, IMixtapeIndexDefinition
{
public FinchMultiMapIndex() { Create(); }
public MixtapeMultiMapIndex() { Create(); }
protected virtual void Create() { }
public virtual void Setup(IFinchOptions options, IDocumentStore store) { }
public virtual void Setup(IMixtapeOptions options, IDocumentStore store) { }
// AbstractMultiMapIndexCreationTask<TReduceResult>
public new void AddMap<TSource>(Expression<Func<IEnumerable<TSource>, IEnumerable>> map) => base.AddMap(map);
@@ -110,12 +110,12 @@ public abstract class FinchMultiMapIndex : AbstractMultiMapIndexCreationTask<obj
}
public abstract class FinchMultiMapIndex<TReduceResult> : AbstractMultiMapIndexCreationTask<TReduceResult>, IFinchIndexDefinition
public abstract class MixtapeMultiMapIndex<TReduceResult> : AbstractMultiMapIndexCreationTask<TReduceResult>, IMixtapeIndexDefinition
{
public FinchMultiMapIndex() { Create(); }
public MixtapeMultiMapIndex() { Create(); }
protected virtual void Create() { }
public virtual void Setup(IFinchOptions options, IDocumentStore store) { }
public virtual void Setup(IMixtapeOptions options, IDocumentStore store) { }
// AbstractMultiMapIndexCreationTask<TReduceResult>
public new void AddMap<TSource>(Expression<Func<IEnumerable<TSource>, IEnumerable>> map) => base.AddMap(map);
@@ -177,12 +177,12 @@ public abstract class FinchMultiMapIndex<TReduceResult> : AbstractMultiMapIndexC
}
public abstract class FinchIndex<TDocument, TReduceResult> : AbstractIndexCreationTask<TDocument, TReduceResult>, IFinchIndexDefinition
public abstract class MixtapeIndex<TDocument, TReduceResult> : AbstractIndexCreationTask<TDocument, TReduceResult>, IMixtapeIndexDefinition
{
public FinchIndex() { Create(); }
public MixtapeIndex() { Create(); }
protected virtual void Create() { }
public virtual void Setup(IFinchOptions options, IDocumentStore store) { }
public virtual void Setup(IMixtapeOptions options, IDocumentStore store) { }
// AbstractIndexCreationTask<TDocument, TReduceResult>
public new Expression<Func<IEnumerable<TDocument>, IEnumerable>> Map { get => base.Map; set => base.Map = value; }
@@ -243,17 +243,17 @@ public abstract class FinchIndex<TDocument, TReduceResult> : AbstractIndexCreati
}
public abstract class FinchIndex<TDocument> : FinchIndex<TDocument, TDocument>
public abstract class MixtapeIndex<TDocument> : MixtapeIndex<TDocument, TDocument>
{
}
public abstract class FinchIndex : AbstractIndexCreationTask, IFinchIndexDefinition
public abstract class MixtapeIndex : AbstractIndexCreationTask, IMixtapeIndexDefinition
{
public FinchIndex() { Create(); }
public MixtapeIndex() { Create(); }
protected virtual void Create() { }
public virtual void Setup(IFinchOptions options, IDocumentStore store) { }
public virtual void Setup(IMixtapeOptions options, IDocumentStore store) { }
// AbstractIndexCreationTask
public new IJsonObject AsJson(object doc) => base.AsJson(doc);
@@ -281,7 +281,7 @@ public abstract class FinchIndex : AbstractIndexCreationTask, IFinchIndexDefinit
}
public interface IFinchIndexDefinition : IAbstractIndexCreationTask
public interface IMixtapeIndexDefinition : IAbstractIndexCreationTask
{
void Setup(IFinchOptions options, IDocumentStore store);
void Setup(IMixtapeOptions options, IDocumentStore store);
}
@@ -1,14 +1,14 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public static class FinchIndexExtensions
public static class MixtapeIndexExtensions
{
internal static void RunModifiers<T>(this T index, RavenOptions options) where T : IFinchIndexDefinition
internal static void RunModifiers<T>(this T index, RavenOptions options) where T : IMixtapeIndexDefinition
{
IEnumerable<RavenIndexModifiersOptions.Modifier> modifiers = options.Indexes.Modifiers.GetAllForType(index.GetType());
foreach (RavenIndexModifiersOptions.Modifier modifier in modifiers)
{
Action<IFinchIndexDefinition> action = modifier.Modify.Compile();
Action<IMixtapeIndexDefinition> action = modifier.Modify.Compile();
action.Invoke(index);
}
}
@@ -1,17 +1,17 @@
using Raven.Client.Documents.Indexes;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class FinchTreeHierarchyIndexResult : FinchIdEntity, ISupportsDbConventions
public class MixtapeTreeHierarchyIndexResult : MixtapeIdEntity, ISupportsDbConventions
{
public List<string> Path { get; set; } = new List<string>();
}
public abstract class FinchTreeHierarchyIndex<T> : FinchIndex<T, FinchTreeHierarchyIndexResult> where T : FinchIdEntity, ISupportsTrees
public abstract class MixtapeTreeHierarchyIndex<T> : MixtapeIndex<T, MixtapeTreeHierarchyIndexResult> where T : MixtapeIdEntity, ISupportsTrees
{
protected override void Create()
{
Map = items => items.Select(item => new FinchTreeHierarchyIndexResult
Map = items => items.Select(item => new MixtapeTreeHierarchyIndexResult
{
Id = item.Id,
Path = Recurse(item, x => LoadDocument<T>(x.ParentId))
@@ -1,6 +1,6 @@
using Raven.Client.Documents.Indexes;
namespace Finch.Raven;
namespace Mixtape.Raven;
public static class RavenIndexExtensions
{
@@ -1,7 +1,7 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public abstract partial class Interceptor<T> : Interceptor, IInterceptor<T> where T : FinchIdEntity
public abstract partial class Interceptor<T> : Interceptor, IInterceptor<T> where T : MixtapeIdEntity
{
/// <inheritdoc />
public Type ModelType { get; protected set; }
@@ -22,51 +22,51 @@ public abstract partial class Interceptor<T> : Interceptor, IInterceptor<T> wher
public virtual Task<InterceptorResult<T>> Creating(InterceptorParameters args, T model) => Task.FromResult<InterceptorResult<T>>(default);
/// <inheritdoc />
public sealed override async Task<InterceptorResult<FinchIdEntity>> Creating(InterceptorParameters args, FinchIdEntity model) => Convert(await Creating(args, model as T));
public sealed override async Task<InterceptorResult<MixtapeIdEntity>> Creating(InterceptorParameters args, MixtapeIdEntity model) => Convert(await Creating(args, model as T));
/// <inheritdoc />
public virtual Task<InterceptorResult<T>> Updating(InterceptorParameters args, T model) => Task.FromResult<InterceptorResult<T>>(default);
/// <inheritdoc />
public sealed override async Task<InterceptorResult<FinchIdEntity>> Updating(InterceptorParameters args, FinchIdEntity model) => Convert(await Updating(args, model as T));
public sealed override async Task<InterceptorResult<MixtapeIdEntity>> Updating(InterceptorParameters args, MixtapeIdEntity model) => Convert(await Updating(args, model as T));
/// <inheritdoc />
public virtual Task<InterceptorResult<T>> Deleting(InterceptorParameters args, T model) => Task.FromResult<InterceptorResult<T>>(default);
/// <inheritdoc />
public sealed override async Task<InterceptorResult<FinchIdEntity>> Deleting(InterceptorParameters args, FinchIdEntity model) => Convert(await Deleting(args, model as T));
public sealed override async Task<InterceptorResult<MixtapeIdEntity>> Deleting(InterceptorParameters args, MixtapeIdEntity model) => Convert(await Deleting(args, model as T));
/// <inheritdoc />
public virtual Task Created(InterceptorParameters args, T model) => Task.CompletedTask;
/// <inheritdoc />
public sealed override Task Created(InterceptorParameters args, FinchIdEntity model) => Created(args, model as T);
public sealed override Task Created(InterceptorParameters args, MixtapeIdEntity model) => Created(args, model as T);
/// <inheritdoc />
public virtual Task Updated(InterceptorParameters args, T model) => Task.CompletedTask;
/// <inheritdoc />
public sealed override Task Updated(InterceptorParameters args, FinchIdEntity model) => Updated(args, model as T);
public sealed override Task Updated(InterceptorParameters args, MixtapeIdEntity model) => Updated(args, model as T);
/// <inheritdoc />
public virtual Task Deleted(InterceptorParameters args, T model) => Task.CompletedTask;
/// <inheritdoc />
public sealed override Task Deleted(InterceptorParameters args, FinchIdEntity model) => Deleted(args, model as T);
public sealed override Task Deleted(InterceptorParameters args, MixtapeIdEntity model) => Deleted(args, model as T);
InterceptorResult<FinchIdEntity> Convert(InterceptorResult<T> result)
InterceptorResult<MixtapeIdEntity> Convert(InterceptorResult<T> result)
{
if (result == default)
{
return default;
}
return new InterceptorResult<FinchIdEntity>()
return new InterceptorResult<MixtapeIdEntity>()
{
Continue = result.Continue,
InterceptorHash = result.InterceptorHash,
Result = result.Result != null ? result.Result.ConvertTo<FinchIdEntity>(result.Result.Model) : null
Result = result.Result != null ? result.Result.ConvertTo<MixtapeIdEntity>(result.Result.Model) : null
};
}
}
@@ -95,26 +95,26 @@ public abstract partial class Interceptor : IInterceptor
public virtual bool CanHandle(InterceptorParameters args, Type modelType) => true;
/// <inheritdoc />
public virtual Task<InterceptorResult<FinchIdEntity>> Creating(InterceptorParameters args, FinchIdEntity model) => Task.FromResult<InterceptorResult<FinchIdEntity>>(default);
public virtual Task<InterceptorResult<MixtapeIdEntity>> Creating(InterceptorParameters args, MixtapeIdEntity model) => Task.FromResult<InterceptorResult<MixtapeIdEntity>>(default);
/// <inheritdoc />
public virtual Task<InterceptorResult<FinchIdEntity>> Updating(InterceptorParameters args, FinchIdEntity model) => Task.FromResult<InterceptorResult<FinchIdEntity>>(default);
public virtual Task<InterceptorResult<MixtapeIdEntity>> Updating(InterceptorParameters args, MixtapeIdEntity model) => Task.FromResult<InterceptorResult<MixtapeIdEntity>>(default);
/// <inheritdoc />
public virtual Task<InterceptorResult<FinchIdEntity>> Deleting(InterceptorParameters args, FinchIdEntity model) => Task.FromResult<InterceptorResult<FinchIdEntity>>(default);
public virtual Task<InterceptorResult<MixtapeIdEntity>> Deleting(InterceptorParameters args, MixtapeIdEntity model) => Task.FromResult<InterceptorResult<MixtapeIdEntity>>(default);
/// <inheritdoc />
public virtual Task Created(InterceptorParameters args, FinchIdEntity model) => Task.CompletedTask;
public virtual Task Created(InterceptorParameters args, MixtapeIdEntity model) => Task.CompletedTask;
/// <inheritdoc />
public virtual Task Updated(InterceptorParameters args, FinchIdEntity model) => Task.CompletedTask;
public virtual Task Updated(InterceptorParameters args, MixtapeIdEntity model) => Task.CompletedTask;
/// <inheritdoc />
public virtual Task Deleted(InterceptorParameters args, FinchIdEntity model) => Task.CompletedTask;
public virtual Task Deleted(InterceptorParameters args, MixtapeIdEntity model) => Task.CompletedTask;
}
public interface IInterceptor<T> : IInterceptor where T : FinchIdEntity
public interface IInterceptor<T> : IInterceptor where T : MixtapeIdEntity
{
/// <summary>
/// Type of the associated model
@@ -178,30 +178,30 @@ public interface IInterceptor
/// <summary>
/// Called after an entity has been stored but before the session has saved its changes
/// </summary>
Task Created(InterceptorParameters args, FinchIdEntity model);
Task Created(InterceptorParameters args, MixtapeIdEntity model);
/// <summary>
/// Called before an entity is stored and validated
/// </summary>
Task<InterceptorResult<FinchIdEntity>> Creating(InterceptorParameters args, FinchIdEntity model);
Task<InterceptorResult<MixtapeIdEntity>> Creating(InterceptorParameters args, MixtapeIdEntity model);
/// <summary>
/// Called after an entity has been deleted but before the session has saved its changes
/// </summary>
Task Deleted(InterceptorParameters args, FinchIdEntity model);
Task Deleted(InterceptorParameters args, MixtapeIdEntity model);
/// <summary>
/// Called before an entity is deleted
/// </summary>
Task<InterceptorResult<FinchIdEntity>> Deleting(InterceptorParameters args, FinchIdEntity model);
Task<InterceptorResult<MixtapeIdEntity>> Deleting(InterceptorParameters args, MixtapeIdEntity model);
/// <summary>
/// Called after an entity has been updated but before the session has saved its changes
/// </summary>
Task Updated(InterceptorParameters args, FinchIdEntity model);
Task Updated(InterceptorParameters args, MixtapeIdEntity model);
/// <summary>
/// Called before an entity is stored and validated
/// </summary>
Task<InterceptorResult<FinchIdEntity>> Updating(InterceptorParameters args, FinchIdEntity model);
Task<InterceptorResult<MixtapeIdEntity>> Updating(InterceptorParameters args, MixtapeIdEntity model);
}
@@ -1,8 +1,8 @@
using Microsoft.Extensions.Logging;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class InterceptorInstruction<T> where T : FinchIdEntity, new()
public class InterceptorInstruction<T> where T : MixtapeIdEntity, new()
{
public Guid Guid { get; private set; }
@@ -16,9 +16,9 @@ public class InterceptorInstruction<T> where T : FinchIdEntity, new()
public Result<T> Result { get; private set; }
protected IFinchContext Context { get; }
protected IMixtapeContext Context { get; }
protected IFinchStore Store { get; }
protected IMixtapeStore Store { get; }
protected Lazy<IEnumerable<IInterceptor>> Interceptors { get; }
@@ -31,7 +31,7 @@ public class InterceptorInstruction<T> where T : FinchIdEntity, new()
protected Func<IInterceptor, bool> InterceptorFilter { get; private set; } = x => true;
internal InterceptorInstruction(IInterceptors interceptors, IFinchStore store, IFinchContext context, Lazy<IEnumerable<IInterceptor>> registrations, ILogger<IInterceptor> logger, InterceptorRunType runtype, T model, T previousModel = null)
internal InterceptorInstruction(IInterceptors interceptors, IMixtapeStore store, IMixtapeContext context, Lazy<IEnumerable<IInterceptor>> registrations, ILogger<IInterceptor> logger, InterceptorRunType runtype, T model, T previousModel = null)
{
InterceptorHandler = interceptors;
Store = store;
@@ -83,7 +83,7 @@ public class InterceptorInstruction<T> where T : FinchIdEntity, new()
Logger.LogDebug("Run interceptor {interceptor} for {type}:{operation}", interceptor.Name, ModelType, Runtype);
InterceptorResult<FinchIdEntity> result = (await HandleBefore(interceptor, parameters)) ?? new();
InterceptorResult<MixtapeIdEntity> result = (await HandleBefore(interceptor, parameters)) ?? new();
result.InterceptorHash = IdGenerator.Create(32);
InterceptorCache.Add(interceptor, parameters);
@@ -129,7 +129,7 @@ public class InterceptorInstruction<T> where T : FinchIdEntity, new()
/// <summary>
/// Proxy for handling methods on an interceptor
/// </summary>
protected Task<InterceptorResult<FinchIdEntity>> HandleBefore(IInterceptor interceptor, InterceptorParameters parameters) => Runtype switch
protected Task<InterceptorResult<MixtapeIdEntity>> HandleBefore(IInterceptor interceptor, InterceptorParameters parameters) => Runtype switch
{
InterceptorRunType.Create => interceptor.Creating(parameters, Model),
InterceptorRunType.Update => interceptor.Updating(parameters, Model),
@@ -1,16 +1,16 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public class InterceptorParameters
{
/// <summary>
/// The current finch context
/// The current mixtape context
/// </summary>
public IFinchContext Context { get; set; }
public IMixtapeContext Context { get; set; }
/// <summary>
/// Raven document store
/// </summary>
public IFinchStore Store { get; set; }
public IMixtapeStore Store { get; set; }
/// <summary>
/// Access to other interceptor methods
@@ -1,4 +1,4 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public class InterceptorResult<T>
{
@@ -1,4 +1,4 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public enum InterceptorRunType
{
@@ -1,19 +1,19 @@
using Microsoft.Extensions.Logging;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class Interceptors : IInterceptors
{
protected IFinchContext Context { get; set; }
protected IMixtapeContext Context { get; set; }
protected IFinchStore Store { get; set; }
protected IMixtapeStore Store { get; set; }
protected Lazy<IEnumerable<IInterceptor>> Registrations { get; set; }
protected ILogger<IInterceptor> Logger { get; set; }
public Interceptors(IFinchContext context, IFinchStore store, Lazy<IEnumerable<IInterceptor>> registrations, ILogger<IInterceptor> logger)
public Interceptors(IMixtapeContext context, IMixtapeStore store, Lazy<IEnumerable<IInterceptor>> registrations, ILogger<IInterceptor> logger)
{
Context = context;
Store = store;
@@ -23,13 +23,13 @@ public class Interceptors : IInterceptors
/// <inheritdoc />
public InterceptorInstruction<T> ForCreate<T>(T model) where T : FinchIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Create, model);
public InterceptorInstruction<T> ForCreate<T>(T model) where T : MixtapeIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Create, model);
/// <inheritdoc />
public InterceptorInstruction<T> ForUpdate<T>(T model, T previousModel = null) where T : FinchIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Update, model, previousModel);
public InterceptorInstruction<T> ForUpdate<T>(T model, T previousModel = null) where T : MixtapeIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Update, model, previousModel);
/// <inheritdoc />
public InterceptorInstruction<T> ForDelete<T>(T model) where T : FinchIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Delete, model);
public InterceptorInstruction<T> ForDelete<T>(T model) where T : MixtapeIdEntity, new() => new(this, Store, Context, Registrations, Logger, InterceptorRunType.Delete, model);
}
@@ -38,15 +38,15 @@ public interface IInterceptors
/// <summary>
/// Instruction which can run interceptors before and after a creating an entity
/// </summary>
InterceptorInstruction<T> ForCreate<T>(T model) where T : FinchIdEntity, new();
InterceptorInstruction<T> ForCreate<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Instruction which can run interceptors before and after updating an entity
/// </summary>
InterceptorInstruction<T> ForUpdate<T>(T model, T previousModel = null) where T : FinchIdEntity, new();
InterceptorInstruction<T> ForUpdate<T>(T model, T previousModel = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Instruction which can run interceptors before and after deleting an entity
/// </summary>
InterceptorInstruction<T> ForDelete<T>(T model) where T : FinchIdEntity, new();
InterceptorInstruction<T> ForDelete<T>(T model) where T : MixtapeIdEntity, new();
}
@@ -2,39 +2,39 @@
using Microsoft.Extensions.DependencyInjection;
using Raven.Client.Documents.Indexes;
using Raven.Client.Http;
using Finch.Identity;
using Finch.Media;
using Finch.Numbers;
using Mixtape.Identity;
using Mixtape.Media;
using Mixtape.Numbers;
namespace Finch.Raven;
namespace Mixtape.Raven;
public static class FinchBuilderExtensions
public static class MixtapeBuilderExtensions
{
public static FinchBuilder AddRavenDb(this FinchBuilder builder)
public static MixtapeBuilder AddRavenDb(this MixtapeBuilder builder)
{
builder.AddModule<FinchRavenModule>();
builder.AddModule<MixtapeRavenModule>();
return builder;
}
}
internal class FinchRavenModule : FinchModule
internal class MixtapeRavenModule : MixtapeModule
{
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton<IRavenDocumentConventionsBuilder, RavenDocumentConventionsBuilder>();
services.AddSingleton<IDocumentStore>(CreateRavenStore);
services.AddScoped<IFinchStore, FinchStore>();
services.AddScoped<IFinchTokenProvider, FinchTokenProvider>();
services.AddScoped<IMixtapeStore, MixtapeStore>();
services.AddScoped<IMixtapeTokenProvider, MixtapeTokenProvider>();
services.AddScoped<StoreContext>();
services.AddTransient<IRavenOperations, RavenOperations>();
services.AddScoped<IInterceptors, Interceptors>();
services.Replace<IFinchIdentityStoreDbProvider, RavenIdentityStoreDbProvider>(ServiceLifetime.Scoped);
services.Replace<IFinchMediaStoreDbProvider, RavenMediaStoreDbProvider>(ServiceLifetime.Scoped);
services.Replace<IFinchNumberStoreDbProvider, RavenNumberStoreDbProvider>(ServiceLifetime.Scoped);
services.Replace<IMixtapeIdentityStoreDbProvider, RavenIdentityStoreDbProvider>(ServiceLifetime.Scoped);
services.Replace<IMixtapeMediaStoreDbProvider, RavenMediaStoreDbProvider>(ServiceLifetime.Scoped);
services.Replace<IMixtapeNumberStoreDbProvider, RavenNumberStoreDbProvider>(ServiceLifetime.Scoped);
services.AddOptions<FlavorOptions>();
services.AddOptions<RavenOptions>().Bind(configuration.GetSection("Finch:Raven"));
services.AddOptions<RavenOptions>().Bind(configuration.GetSection("Mixtape:Raven"));
services.ConfigureOptions<ConfigureFlavorJsonOptions>();
}
@@ -43,7 +43,7 @@ internal class FinchRavenModule : FinchModule
/// </summary>
protected IDocumentStore CreateRavenStore(IServiceProvider services)
{
IFinchOptions options = services.GetService<IFinchOptions>();
IMixtapeOptions options = services.GetService<IMixtapeOptions>();
RavenOptions ravenOptions = options.For<RavenOptions>();
IRavenDocumentConventionsBuilder conventionsBuilder = services.GetService<IRavenDocumentConventionsBuilder>();
@@ -66,7 +66,7 @@ internal class FinchRavenModule : FinchModule
IDocumentStore raven = store.Initialize();
// create all indexes
IEnumerable<IFinchIndexDefinition> indexes = ravenOptions.Indexes.BuildAll(options, store);
IEnumerable<IMixtapeIndexDefinition> indexes = ravenOptions.Indexes.BuildAll(options, store);
IndexCreation.CreateIndexes(indexes, store, database: ravenOptions.Database);
@@ -1,15 +1,15 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public class FinchStore : IFinchStore
public class MixtapeStore : IMixtapeStore
{
public FinchStore(IDocumentStore raven, IFinchOptions options) : base()
public MixtapeStore(IDocumentStore raven, IMixtapeOptions options) : base()
{
Options = options;
Raven = raven;
//Database = null;
}
protected IFinchOptions Options { get; set; }
protected IMixtapeOptions Options { get; set; }
protected Dictionary<string, IAsyncDocumentSession> ScopedSessions { get; set; } = new();
private const string NullDb = "__default__";
@@ -19,11 +19,11 @@ public class FinchStore : IFinchStore
/// <inheritdoc />
public IAsyncDocumentSession Session(FinchSessionResolution resolution = FinchSessionResolution.Reuse, SessionOptions options = null)
public IAsyncDocumentSession Session(MixtapeSessionResolution resolution = MixtapeSessionResolution.Reuse, SessionOptions options = null)
{
options ??= new SessionOptions();
if (resolution == FinchSessionResolution.Create)
if (resolution == MixtapeSessionResolution.Create)
{
return Raven.OpenAsyncSession(options);
}
@@ -69,14 +69,14 @@ public class FinchStore : IFinchStore
}
public enum FinchSessionResolution
public enum MixtapeSessionResolution
{
Reuse = 0,
Create = 1
}
public interface IFinchStore
public interface IMixtapeStore
{
/// <summary>
/// Get underlying raven document store
@@ -86,7 +86,7 @@ public interface IFinchStore
/// <summary>
/// Use a specific session
/// </summary>
IAsyncDocumentSession Session(FinchSessionResolution resolution = FinchSessionResolution.Reuse, SessionOptions options = null);
IAsyncDocumentSession Session(MixtapeSessionResolution resolution = MixtapeSessionResolution.Reuse, SessionOptions options = null);
/// <summary>
/// Purges a collection
@@ -1,14 +1,14 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public partial class RavenOperations : IRavenOperations
{
/// <inheritdoc />
public virtual Task<Result<T>> Delete<T>(T model) where T : FinchIdEntity, new()
public virtual Task<Result<T>> Delete<T>(T model) where T : MixtapeIdEntity, new()
=> Delete<T>(model.Id);
/// <inheritdoc />
public virtual async Task<Result<T>> Delete<T>(string id) where T : FinchIdEntity, new()
public virtual async Task<Result<T>> Delete<T>(string id) where T : MixtapeIdEntity, new()
{
T model = await Load<T>(id);
@@ -45,7 +45,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task Purge<T>(string querySuffix = null, Parameters parameters = null) where T : FinchIdEntity, new()
public virtual async Task Purge<T>(string querySuffix = null, Parameters parameters = null) where T : MixtapeIdEntity, new()
{
var collectionName = Store.Raven.Conventions.FindCollectionName(typeof(T));
var operationQuery = new DeleteByQueryOperation(new IndexQuery()
@@ -1,14 +1,14 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public partial class RavenOperations : IRavenOperations
{
/// <inheritdoc />
public virtual Task<T> Empty<T>(string flavorAlias = null) where T : FinchIdEntity, ISupportsFlavors, new() => Empty<T, T>(flavorAlias);
public virtual Task<T> Empty<T>(string flavorAlias = null) where T : MixtapeIdEntity, ISupportsFlavors, new() => Empty<T, T>(flavorAlias);
/// <inheritdoc />
public virtual Task<TFlavor> Empty<T, TFlavor>(string flavorAlias = null)
where T : FinchIdEntity, ISupportsFlavors, new()
where T : MixtapeIdEntity, ISupportsFlavors, new()
where TFlavor : T, new()
{
return Task.FromResult(Flavors.Construct<T, TFlavor>(flavorAlias));
@@ -2,12 +2,12 @@
using Raven.Client.Documents.Linq;
using System.Linq.Expressions;
namespace Finch.Raven;
namespace Mixtape.Raven;
public partial class RavenOperations : IRavenOperations
{
/// <inheritdoc />
public virtual async Task<T> Load<T>(string id, string changeVector = null) where T : FinchIdEntity, new()
public virtual async Task<T> Load<T>(string id, string changeVector = null) where T : MixtapeIdEntity, new()
{
if (id.IsNullOrWhiteSpace())
{
@@ -23,7 +23,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : FinchIdEntity, new()
public virtual async Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new()
{
ids = ids.Distinct().ToArray();
@@ -41,7 +41,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : FinchIdEntity, new()
public virtual async Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new()
{
ids = ids.Distinct().ToArray();
@@ -62,7 +62,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<bool> Any<T>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : FinchIdEntity, new()
public virtual async Task<bool> Any<T>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : MixtapeIdEntity, new()
{
querySelector ??= x => x;
return await querySelector(Session.Query<T>()).AnyAsync();
@@ -70,7 +70,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<Paged<T>> Load<T>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : FinchIdEntity, new()
public virtual async Task<Paged<T>> Load<T>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : MixtapeIdEntity, new()
{
IRavenQueryable<T> queryable = Session.Query<T>().Statistics(out QueryStatistics statistics);
querySelector ??= x => x;
@@ -82,7 +82,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<Paged<T>> Load<T, TIndex>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default)
where T : FinchIdEntity, new()
where T : MixtapeIdEntity, new()
where TIndex : AbstractCommonApiForIndexes, new()
{
IRavenQueryable<T> queryable = Session.Query<T, TIndex>().Statistics(out QueryStatistics statistics);
@@ -94,7 +94,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<List<T>> Load<T>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector) where T : FinchIdEntity, new()
public virtual async Task<List<T>> Load<T>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector) where T : MixtapeIdEntity, new()
{
IRavenQueryable<T> queryable = Session.Query<T>();
querySelector ??= x => x;
@@ -105,7 +105,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<List<T>> Load<T, TIndex>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector)
where T : FinchIdEntity, new()
where T : MixtapeIdEntity, new()
where TIndex : AbstractCommonApiForIndexes, new()
{
IRavenQueryable<T> queryable = Session.Query<T, TIndex>();
@@ -116,7 +116,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<List<T>> Load<T>(Expression<Func<T, bool>> predicate) where T : FinchIdEntity, new()
public virtual async Task<List<T>> Load<T>(Expression<Func<T, bool>> predicate) where T : MixtapeIdEntity, new()
{
return await Session.Query<T>().Where(predicate).ToListAsync();
}
@@ -124,7 +124,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<List<T>> Load<T, TIndex>(Expression<Func<T, bool>> predicate)
where T : FinchIdEntity, new()
where T : MixtapeIdEntity, new()
where TIndex : AbstractCommonApiForIndexes, new()
{
return await Session.Query<T, TIndex>().Where(predicate).ToListAsync();
@@ -133,8 +133,8 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<Paged<TProjection>> Load<T, TIndex, TProjection>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default)
where T : FinchIdEntity, new()
where TProjection : FinchIdEntity, new()
where T : MixtapeIdEntity, new()
where TProjection : MixtapeIdEntity, new()
where TIndex : AbstractCommonApiForIndexes, new()
{
IRavenQueryable<T> queryable = Session.Query<T, TIndex>().Statistics(out QueryStatistics statistics);
@@ -146,7 +146,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<List<T>> LoadAll<T>() where T : FinchIdEntity, new()
public virtual async Task<List<T>> LoadAll<T>() where T : MixtapeIdEntity, new()
{
List<T> items = new();
@@ -160,7 +160,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async IAsyncEnumerable<T> Stream<T>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : FinchIdEntity, new()
public virtual async IAsyncEnumerable<T> Stream<T>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : MixtapeIdEntity, new()
{
IRavenQueryable<T> query = Session.Query<T>();
IQueryable<T> queryable = query;
@@ -185,7 +185,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual string GetChangeToken<T>(T model) where T : FinchIdEntity, new()
public virtual string GetChangeToken<T>(T model) where T : MixtapeIdEntity, new()
{
string changeVector = Session.Advanced.GetChangeVectorFor(model);
return IdGenerator.HashString(changeVector);
@@ -1,12 +1,12 @@
using Raven.Client.Documents.Indexes;
using Raven.Client.Documents.Linq;
namespace Finch.Raven;
namespace Mixtape.Raven;
public partial class RavenOperations : IRavenOperations
{
/// <inheritdoc />
public virtual Task<bool> IsAllowedAsChild<T>(T model, string parentId) where T : FinchIdEntity, ISupportsTrees, new()
public virtual Task<bool> IsAllowedAsChild<T>(T model, string parentId) where T : MixtapeIdEntity, ISupportsTrees, new()
{
return Task.FromResult(true);
}
@@ -14,13 +14,13 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<T[]> GetHierarchy<T, TIndex>(string id)
where T : FinchIdEntity, ISupportsTrees, new()
where TIndex : FinchTreeHierarchyIndex<T>, new()
where T : MixtapeIdEntity, ISupportsTrees, new()
where TIndex : MixtapeTreeHierarchyIndex<T>, new()
{
FinchTreeHierarchyIndexResult result = await Session.Query<FinchTreeHierarchyIndexResult, TIndex>()
.ProjectInto<FinchTreeHierarchyIndexResult>()
.Include<FinchTreeHierarchyIndexResult, T>(x => x.Path)
.Include<FinchTreeHierarchyIndexResult, T>(x => x.Id)
MixtapeTreeHierarchyIndexResult result = await Session.Query<MixtapeTreeHierarchyIndexResult, TIndex>()
.ProjectInto<MixtapeTreeHierarchyIndexResult>()
.Include<MixtapeTreeHierarchyIndexResult, T>(x => x.Path)
.Include<MixtapeTreeHierarchyIndexResult, T>(x => x.Id)
.FirstOrDefaultAsync(x => x.Id == id);
if (result == null)
@@ -36,7 +36,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<Paged<T>> LoadChildren<T>(string parentId, int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : FinchIdEntity, ISupportsTrees, new()
public async Task<Paged<T>> LoadChildren<T>(string parentId, int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : MixtapeIdEntity, ISupportsTrees, new()
{
IRavenQueryable<T> queryable = Session.Query<T>().Where(x => x.ParentId == parentId).Statistics(out QueryStatistics statistics);
querySelector ??= x => x.OrderBy(x => x.Sort);
@@ -48,7 +48,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<Paged<T>> LoadChildren<T, TIndex>(string parentId, int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default)
where T : FinchIdEntity, ISupportsTrees, new()
where T : MixtapeIdEntity, ISupportsTrees, new()
where TIndex : AbstractCommonApiForIndexes, new()
{
IRavenQueryable<T> queryable = Session.Query<T, TIndex>().Where(x => x.ParentId == parentId).Statistics(out QueryStatistics statistics);
@@ -62,7 +62,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<Result<T>> Move<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new()
public async Task<Result<T>> Move<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : MixtapeIdEntity, ISupportsTrees, new()
{
T model = await Load<T>(id);
T parent = await Load<T>(newParentId);
@@ -84,17 +84,17 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public Task<Result<T>> Copy<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new() => Copy<T>(id, newParentId, false, isParentAllowed);
public Task<Result<T>> Copy<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : MixtapeIdEntity, ISupportsTrees, new() => Copy<T>(id, newParentId, false, isParentAllowed);
/// <inheritdoc />
public Task<Result<T>> CopyWithDescendants<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new() => Copy<T>(id, newParentId, true, isParentAllowed);
public Task<Result<T>> CopyWithDescendants<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : MixtapeIdEntity, ISupportsTrees, new() => Copy<T>(id, newParentId, true, isParentAllowed);
/// <summary>
/// Copies an entity (with optional descendants) to a new location
/// </summary>
protected async Task<Result<T>> Copy<T>(string id, string newParentId, bool includeDescendants, Func<T, string, Task<bool>> isParentAllowed = null, bool isDescendant = false) where T : FinchIdEntity, ISupportsTrees, new()
protected async Task<Result<T>> Copy<T>(string id, string newParentId, bool includeDescendants, Func<T, string, Task<bool>> isParentAllowed = null, bool isDescendant = false) where T : MixtapeIdEntity, ISupportsTrees, new()
{
T originalModel = await Load<T>(id);
T model = ObjectCopycat.Clone(originalModel);
@@ -112,11 +112,11 @@ public partial class RavenOperations : IRavenOperations
model.Id = null;
model.ParentId = parent?.Id;
if (model is FinchEntity finchEntity)
if (model is MixtapeEntity mixtapeEntity)
{
finchEntity.IsActive = !isDescendant ? false : (originalModel as FinchEntity).IsActive;
finchEntity.CreatedDate = DateTime.Now;
finchEntity.Hash = null;
mixtapeEntity.IsActive = !isDescendant ? false : (originalModel as MixtapeEntity).IsActive;
mixtapeEntity.CreatedDate = DateTime.Now;
mixtapeEntity.Hash = null;
}
// check if new parent is allowed
@@ -143,7 +143,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<Result<string[]>> DeleteWithDescendants<T>(T model) where T : FinchIdEntity, ISupportsTrees, new()
public async Task<Result<string[]>> DeleteWithDescendants<T>(T model) where T : MixtapeIdEntity, ISupportsTrees, new()
{
List<T> pages = await GetDescendantsAndSelf(model);
@@ -160,7 +160,7 @@ public partial class RavenOperations : IRavenOperations
/// <summary>
/// Get an entity with all its descendants
/// </summary>
async Task<List<T>> GetDescendantsAndSelf<T>(T model) where T : FinchIdEntity, ISupportsTrees, new()
async Task<List<T>> GetDescendantsAndSelf<T>(T model) where T : MixtapeIdEntity, ISupportsTrees, new()
{
List<T> items = new() { model };
@@ -1,18 +1,18 @@
using FluentValidation.Results;
using Rv = Raven.Client;
namespace Finch.Raven;
namespace Mixtape.Raven;
public partial class RavenOperations : IRavenOperations
{
/// <inheritdoc />
public virtual Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : FinchIdEntity, new() => Save(model, validate, onAfterStore);
public virtual Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : MixtapeIdEntity, new() => Save(model, validate, onAfterStore);
/// <inheritdoc />
public virtual Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : FinchIdEntity, new() => Save(model, validate, onAfterStore, true);
public virtual Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : MixtapeIdEntity, new() => Save(model, validate, onAfterStore, true);
/// <inheritdoc />
protected virtual async Task<Result<T>> Save<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null, bool update = false) where T : FinchIdEntity, new()
protected virtual async Task<Result<T>> Save<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null, bool update = false) where T : MixtapeIdEntity, new()
{
if (model == null)
{
@@ -91,7 +91,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<Result<IOrderedEnumerable<T>>> Sort<T>(string[] sortedIds) where T : FinchIdEntity, ISupportsSorting, new()
public async Task<Result<IOrderedEnumerable<T>>> Sort<T>(string[] sortedIds) where T : MixtapeIdEntity, ISupportsSorting, new()
{
Dictionary<string, T> items = await Load<T>(sortedIds);
uint index = 10;
@@ -114,7 +114,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual async Task<Result<IEnumerable<T>>> CreateAll<T>(IEnumerable<T> models) where T : FinchIdEntity, new()
public virtual async Task<Result<IEnumerable<T>>> CreateAll<T>(IEnumerable<T> models) where T : MixtapeIdEntity, new()
{
using var bulkInsert = Store.Raven.BulkInsert();
@@ -4,7 +4,7 @@ using Raven.Client.Documents.Indexes;
using Raven.Client.Documents.Linq;
using System.Linq.Expressions;
namespace Finch.Raven;
namespace Mixtape.Raven;
public partial class RavenOperations : IRavenOperations
{
@@ -13,7 +13,7 @@ public partial class RavenOperations : IRavenOperations
protected record OperationOptions(bool IncludeInactive);
protected IFinchContext Context { get; private set; }
protected IMixtapeContext Context { get; private set; }
protected IInterceptors Interceptors { get; }
@@ -21,7 +21,7 @@ public partial class RavenOperations : IRavenOperations
protected IServiceProvider Services { get; }
protected IFinchStore Store { get; }
protected IMixtapeStore Store { get; }
protected StoreInterceptorBlocker InterceptorBlocker { get; private set; }
@@ -37,7 +37,7 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<string> GenerateId<T>(T model) where T : FinchIdEntity
public async Task<string> GenerateId<T>(T model) where T : MixtapeIdEntity
{
IAsyncDocumentSession session = Session;
return await session.Advanced.DocumentStore.Conventions.GenerateDocumentIdAsync(session.Advanced.DocumentStore.Database, model);
@@ -52,33 +52,33 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public T PrepareForSave<T>(T model) where T : FinchIdEntity
public T PrepareForSave<T>(T model) where T : MixtapeIdEntity
{
// set IDs
AutoSetIds(model);
if (model is FinchEntity finchModel)
if (model is MixtapeEntity mixtapeModel)
{
// get current user
string userId = null;
//string userId = Context.BackofficeUser.FindFirstValue(Constants.Auth.Claims.UserId).Or(Constants.Auth.SystemUser);
// set default properties
if (finchModel.CreatedDate == default)
if (mixtapeModel.CreatedDate == default)
{
finchModel.CreatedDate = DateTimeOffset.Now;
mixtapeModel.CreatedDate = DateTimeOffset.Now;
}
if (finchModel.CreatedById.IsNullOrEmpty())
if (mixtapeModel.CreatedById.IsNullOrEmpty())
{
finchModel.CreatedById = userId;
mixtapeModel.CreatedById = userId;
}
// update name alias and last modified
finchModel.Alias = Safenames.Alias(finchModel.Name);
finchModel.LastModifiedById = userId;
finchModel.LastModifiedDate = DateTimeOffset.Now;
finchModel.CreatedById ??= userId;
finchModel.Hash ??= IdGenerator.Create();
mixtapeModel.Alias = Safenames.Alias(mixtapeModel.Name);
mixtapeModel.LastModifiedById = userId;
mixtapeModel.LastModifiedDate = DateTimeOffset.Now;
mixtapeModel.CreatedById ??= userId;
mixtapeModel.Hash ??= IdGenerator.Create();
}
return model;
@@ -86,9 +86,9 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public async Task<ValidationResult> Validate<T>(T model) where T : FinchIdEntity, new()
public async Task<ValidationResult> Validate<T>(T model) where T : MixtapeIdEntity, new()
{
IFinchMergedValidator<T> validator = Services.GetService<IFinchMergedValidator<T>>();
IMixtapeMergedValidator<T> validator = Services.GetService<IMixtapeMergedValidator<T>>();
if (validator == null)
{
@@ -107,10 +107,10 @@ public partial class RavenOperations : IRavenOperations
/// <inheritdoc />
public virtual T WhenActive<T>(T model) where T : FinchIdEntity, new()
public virtual T WhenActive<T>(T model) where T : MixtapeIdEntity, new()
{
return model; // TODO should we really use this? I tried to get data in a custom backend but couldn't because of this
//return model != null && (model is not FinchEntity || (model as FinchEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default;
//return model != null && (model is not MixtapeEntity || (model as MixtapeEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default;
}
}
@@ -141,20 +141,20 @@ public interface IRavenOperations
/// <summary>
/// Get new instance of an entity (with an optional flavor)
/// </summary>
Task<T> Empty<T>(string flavorAlias = null) where T : FinchIdEntity, ISupportsFlavors, new();
Task<T> Empty<T>(string flavorAlias = null) where T : MixtapeIdEntity, ISupportsFlavors, new();
/// <summary>
/// Get new instance of an entity with a specific flavor
/// </summary>
/// <param name="flavorAlias">Optional alias. If left out the default flavor is used (if configured)</param>
Task<TFlavor> Empty<T, TFlavor>(string flavorAlias = null)
where T : FinchIdEntity, ISupportsFlavors, new()
where T : MixtapeIdEntity, ISupportsFlavors, new()
where TFlavor : T, new();
/// <summary>
/// Generate model Id by using configured document store conventions
/// </summary>
Task<string> GenerateId<T>(T model) where T : FinchIdEntity;
Task<string> GenerateId<T>(T model) where T : MixtapeIdEntity;
/// <summary>
/// Generate values for all properties (incl. nested) which contain the [GenerateId] attribute
@@ -162,88 +162,88 @@ public interface IRavenOperations
T AutoSetIds<T>(T model);
/// <summary>
/// Automatically fill base properties of a FinchEntity
/// Automatically fill base properties of a MixtapeEntity
/// </summary>
T PrepareForSave<T>(T model) where T : FinchIdEntity;
T PrepareForSave<T>(T model) where T : MixtapeIdEntity;
/// <summary>
/// Check if any items exist in this collection (with optional query)
/// </summary>
Task<bool> Any<T>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : FinchIdEntity, new();
Task<bool> Any<T>(Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : MixtapeIdEntity, new();
/// <summary>
/// Get an entity by Id
/// </summary>
Task<T> Load<T>(string id, string changeVector = null) where T : FinchIdEntity, new();
Task<T> Load<T>(string id, string changeVector = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by ids
/// </summary>
Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : FinchIdEntity, new();
Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by ids
/// </summary>
Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : FinchIdEntity, new();
Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by query
/// </summary>
Task<Paged<T>> Load<T>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> expression = default) where T : FinchIdEntity, new();
Task<Paged<T>> Load<T>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> expression = default) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by query (by using the specified index)
/// </summary>
Task<Paged<T>> Load<T, TIndex>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> expression = default) where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new();
Task<Paged<T>> Load<T, TIndex>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> expression = default) where T : MixtapeIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new();
/// <summary>
/// Get entities by query
/// </summary>
Task<List<T>> Load<T>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : FinchIdEntity, new();
Task<List<T>> Load<T>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by query (by using the specified index)
/// </summary>
Task<List<T>> Load<T, TIndex>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new();
Task<List<T>> Load<T, TIndex>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : MixtapeIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new();
/// <summary>
/// Get entities by query
/// </summary>
Task<List<T>> Load<T>(Expression<Func<T, bool>> predicate) where T : FinchIdEntity, new();
Task<List<T>> Load<T>(Expression<Func<T, bool>> predicate) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by query (by using the specified index)
/// </summary>
Task<List<T>> Load<T, TIndex>(Expression<Func<T, bool>> predicate) where T : FinchIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new();
Task<List<T>> Load<T, TIndex>(Expression<Func<T, bool>> predicate) where T : MixtapeIdEntity, new() where TIndex : AbstractCommonApiForIndexes, new();
/// <summary>
/// Get entities by query (by using the specified index) and project into a result
/// </summary>
Task<Paged<TProjection>> Load<T, TIndex, TProjection>(int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default)
where T : FinchIdEntity, new()
where TProjection : FinchIdEntity, new()
where T : MixtapeIdEntity, new()
where TProjection : MixtapeIdEntity, new()
where TIndex : AbstractCommonApiForIndexes, new();
/// <summary>
/// Get all entities from this collection.
/// Warning: Don't use this method for large collections. Stream the results instead.
/// </summary>
Task<List<T>> LoadAll<T>() where T : FinchIdEntity, new();
Task<List<T>> LoadAll<T>() where T : MixtapeIdEntity, new();
/// <summary>
/// Stream the collection
/// </summary>
IAsyncEnumerable<T> Stream<T>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : FinchIdEntity, new();
IAsyncEnumerable<T> Stream<T>(Func<IRavenQueryable<T>, IQueryable<T>> expression) where T : MixtapeIdEntity, new();
/// <summary>
/// Get the change vector for a model
/// </summary>
string GetChangeToken<T>(T model) where T : FinchIdEntity, new();
string GetChangeToken<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Validates an entity
/// </summary>
Task<ValidationResult> Validate<T>(T model) where T : FinchIdEntity, new();
Task<ValidationResult> Validate<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Do not run interceptors for create/update/delete operations while this disposable is active
@@ -253,73 +253,73 @@ public interface IRavenOperations
/// <summary>
/// Do only return the model when it is set to active or inactive entities are included with IncludeInactive()
/// </summary>
T WhenActive<T>(T model) where T : FinchIdEntity, new();
T WhenActive<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Creates an entity with an optional validator
/// </summary>
Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : FinchIdEntity, new();
Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Updates an entity with an optional validator
/// </summary>
Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : FinchIdEntity, new();
Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null, Action<IAsyncDocumentSession> onAfterStore = null) where T : MixtapeIdEntity, new();
/// <inheritdoc />
Task<Result<IOrderedEnumerable<T>>> Sort<T>(string[] sortedIds) where T : FinchIdEntity, ISupportsSorting, new();
Task<Result<IOrderedEnumerable<T>>> Sort<T>(string[] sortedIds) where T : MixtapeIdEntity, ISupportsSorting, new();
/// <summary>
/// Batch create entities
/// </summary>
Task<Result<IEnumerable<T>>> CreateAll<T>(IEnumerable<T> models) where T : FinchIdEntity, new();
Task<Result<IEnumerable<T>>> CreateAll<T>(IEnumerable<T> models) where T : MixtapeIdEntity, new();
/// <summary>
/// Deletes an entity
/// </summary>
Task<Result<T>> Delete<T>(T model) where T : FinchIdEntity, new();
Task<Result<T>> Delete<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Deletes an entity
/// </summary>
Task<Result<T>> Delete<T>(string id) where T : FinchIdEntity, new();
Task<Result<T>> Delete<T>(string id) where T : MixtapeIdEntity, new();
/// <summary>
/// Deletes the whole collection
/// </summary>
Task Purge<T>(string querySuffix = null, Parameters parameters = null) where T : FinchIdEntity, new();
Task Purge<T>(string querySuffix = null, Parameters parameters = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Loads all children for an entity
/// </summary>
Task<Paged<T>> LoadChildren<T>(string parentId, int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : FinchIdEntity, ISupportsTrees, new();
Task<Paged<T>> LoadChildren<T>(string parentId, int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : MixtapeIdEntity, ISupportsTrees, new();
/// <summary>
/// Get descendants by query (by using the specified index)
/// </summary>
Task<Paged<T>> LoadChildren<T, TIndex>(string parentId, int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : FinchIdEntity, ISupportsTrees, new() where TIndex : AbstractCommonApiForIndexes, new();
Task<Paged<T>> LoadChildren<T, TIndex>(string parentId, int pageNumber, int pageSize, Func<IRavenQueryable<T>, IQueryable<T>> querySelector = default) where T : MixtapeIdEntity, ISupportsTrees, new() where TIndex : AbstractCommonApiForIndexes, new();
/// <summary>
/// Get tree hierarchy for an entity
/// </summary>
Task<T[]> GetHierarchy<T, TIndex>(string id) where T : FinchIdEntity, ISupportsTrees, new() where TIndex : FinchTreeHierarchyIndex<T>, new();
Task<T[]> GetHierarchy<T, TIndex>(string id) where T : MixtapeIdEntity, ISupportsTrees, new() where TIndex : MixtapeTreeHierarchyIndex<T>, new();
/// <summary>
/// Move an entity to a new parent
/// </summary>
Task<Result<T>> Move<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new();
Task<Result<T>> Move<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : MixtapeIdEntity, ISupportsTrees, new();
/// <summary>
/// Copies an entity to a new location
/// </summary>
Task<Result<T>> Copy<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new();
Task<Result<T>> Copy<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : MixtapeIdEntity, ISupportsTrees, new();
/// <summary>
/// Copies an entity with descendants to a new location
/// </summary>
Task<Result<T>> CopyWithDescendants<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : FinchIdEntity, ISupportsTrees, new();
Task<Result<T>> CopyWithDescendants<T>(string id, string newParentId, Func<T, string, Task<bool>> isParentAllowed = null) where T : MixtapeIdEntity, ISupportsTrees, new();
/// <summary>
/// Deletes an entity with all descendents
/// </summary>
Task<Result<string[]>> DeleteWithDescendants<T>(T model) where T : FinchIdEntity, ISupportsTrees, new();
Task<Result<string[]>> DeleteWithDescendants<T>(T model) where T : MixtapeIdEntity, ISupportsTrees, new();
}
@@ -1,35 +1,35 @@
using System.Linq.Expressions;
namespace Finch.Raven;
namespace Mixtape.Raven;
public static class RavenOperationsExtensions
{
/// <summary>
/// Stream the collection
/// </summary>
public static IAsyncEnumerable<T> Stream<T>(this IRavenOperations ops) where T : FinchIdEntity, new() => ops.Stream<T>(null);
public static IAsyncEnumerable<T> Stream<T>(this IRavenOperations ops) where T : MixtapeIdEntity, new() => ops.Stream<T>(null);
/// <summary>
/// Deletes an entity by Id
/// </summary>
public static async Task<Result<T>> Delete<T>(this IRavenOperations ops, string id) where T : FinchIdEntity, new() => await ops.Delete(await ops.Load<T>(id));
public static async Task<Result<T>> Delete<T>(this IRavenOperations ops, string id) where T : MixtapeIdEntity, new() => await ops.Delete(await ops.Load<T>(id));
/// <summary>
/// Deletes entities by selector
/// </summary>
public static async Task<int> Delete<T>(this IRavenOperations ops, Expression<Func<T, bool>> predicate) where T : FinchIdEntity, new() => await ops.Delete(await ops.Load<T>(predicate));
public static async Task<int> Delete<T>(this IRavenOperations ops, Expression<Func<T, bool>> predicate) where T : MixtapeIdEntity, new() => await ops.Delete(await ops.Load<T>(predicate));
/// <summary>
/// Deletes entities by Id
/// </summary>
public static async Task<int> Delete<T>(this IRavenOperations ops, IEnumerable<string> ids) where T : FinchIdEntity, new() => await ops.Delete((await ops.Load<T>(ids)).Select(x => x.Value));
public static async Task<int> Delete<T>(this IRavenOperations ops, IEnumerable<string> ids) where T : MixtapeIdEntity, new() => await ops.Delete((await ops.Load<T>(ids)).Select(x => x.Value));
/// <summary>
/// Deletes entities
/// </summary>
public static async Task<int> Delete<T>(this IRavenOperations ops, IEnumerable<T> models) where T : FinchIdEntity, new()
public static async Task<int> Delete<T>(this IRavenOperations ops, IEnumerable<T> models) where T : MixtapeIdEntity, new()
{
int successCount = 0;
@@ -45,5 +45,5 @@ public static class RavenOperationsExtensions
/// <summary>
/// Deletes an entity by Id with all descendents
/// </summary>
public static async Task<Result<string[]>> DeleteWithDescendants<T>(this IRavenOperations ops, string id) where T : FinchIdEntity, ISupportsTrees, new() => await ops.DeleteWithDescendants(await ops.Load<T>(id));
public static async Task<Result<string[]>> DeleteWithDescendants<T>(this IRavenOperations ops, string id) where T : MixtapeIdEntity, ISupportsTrees, new() => await ops.DeleteWithDescendants(await ops.Load<T>(id));
}
@@ -1,12 +1,12 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public class StoreContext
{
public IFinchStore Store { get; private set; }
public IMixtapeStore Store { get; private set; }
public IFinchContext Context { get; private set; }
public IMixtapeContext Context { get; private set; }
public IFinchOptions Options { get; private set; }
public IMixtapeOptions Options { get; private set; }
public IInterceptors Interceptors { get; private set; }
@@ -15,7 +15,7 @@ public class StoreContext
public IMessageAggregator Messages { get; private set; }
public StoreContext(IFinchContext context, IFinchStore store, IInterceptors interceptors, IServiceProvider serviceProvider, IMessageAggregator messages)
public StoreContext(IMixtapeContext context, IMixtapeStore store, IInterceptors interceptors, IServiceProvider serviceProvider, IMessageAggregator messages)
{
Store = store;
Options = context.Options;
@@ -1,4 +1,4 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
/// <summary>
/// This attribute will allow the usage of custom collection names for Raven collections
@@ -1,4 +1,4 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
public static partial class RavenConstants
{
@@ -4,22 +4,22 @@ using System.Reflection;
using System.Text;
using Rv = Raven.Client;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder
{
protected HashSet<Type> PolymorphTypes { get; } = new();
protected Type AcceptsFinchConventionsType { get; set; } = typeof(ISupportsDbConventions);
protected Type AcceptsMixtapeConventionsType { get; set; } = typeof(ISupportsDbConventions);
protected char IdentityPartsSeparator { get; set; } = '.';
protected IFinchOptions Options { get; }
protected IMixtapeOptions Options { get; }
protected static ConcurrentDictionary<Type, string> CachedTypeCollectionNameMap = new();
public RavenDocumentConventionsBuilder(IFinchOptions options)
public RavenDocumentConventionsBuilder(IMixtapeOptions options)
{
Options = options;
}
@@ -32,7 +32,7 @@ public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder
conventions.IdentityPartsSeparator = IdentityPartsSeparator;
conventions.TransformTypeCollectionNameToDocumentIdPrefix = TransformTypeCollectionNameToDocumentIdPrefix;
conventions.FindCollectionName = FindCollectionName;
conventions.RegisterAsyncIdConvention<FinchIdEntity>((_, entity) => GetDocumentId(conventions, entity));
conventions.RegisterAsyncIdConvention<MixtapeIdEntity>((_, entity) => GetDocumentId(conventions, entity));
}
@@ -80,7 +80,7 @@ public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder
}
// do not alter non-internal entities
if (!AcceptsFinchConventionsType.IsAssignableFrom(type))
if (!AcceptsMixtapeConventionsType.IsAssignableFrom(type))
{
return cache(DocumentConventions.DefaultGetCollectionName(type));
}
@@ -94,7 +94,7 @@ public class RavenDocumentConventionsBuilder : IRavenDocumentConventionsBuilder
}
// use base interface if available
Type interfaceBaseType = type.GetInterfaces().FirstOrDefault(x => x.IsInterface && AcceptsFinchConventionsType.IsAssignableFrom(x) && x.Name != AcceptsFinchConventionsType.Name);
Type interfaceBaseType = type.GetInterfaces().FirstOrDefault(x => x.IsInterface && AcceptsMixtapeConventionsType.IsAssignableFrom(x) && x.Name != AcceptsMixtapeConventionsType.Name);
if (interfaceBaseType != null)
{
@@ -1,6 +1,6 @@
using System.Linq.Expressions;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class RavenOptions
{
@@ -22,9 +22,9 @@ public class RavenIndexesOptions : List<RavenIndexesOptions.Map>
{
internal Type Type { get; set; }
internal Expression<Func<IFinchIndexDefinition>> CreateIndex { get; set; }
internal Expression<Func<IMixtapeIndexDefinition>> CreateIndex { get; set; }
internal Map(Type type, Expression<Func<IFinchIndexDefinition>> create)
internal Map(Type type, Expression<Func<IMixtapeIndexDefinition>> create)
{
Type = type;
CreateIndex = create;
@@ -34,17 +34,17 @@ public class RavenIndexesOptions : List<RavenIndexesOptions.Map>
public RavenIndexModifiersOptions Modifiers { get; private set; } = new();
public void Add<T>() where T : IFinchIndexDefinition, new()
public void Add<T>() where T : IMixtapeIndexDefinition, new()
{
base.Add(new Map(typeof(T), () => new T()));
}
public void Add(Type indexType)
{
base.Add(new Map(indexType, () => (IFinchIndexDefinition)Activator.CreateInstance(indexType)));
base.Add(new Map(indexType, () => (IMixtapeIndexDefinition)Activator.CreateInstance(indexType)));
}
public void Add<T>(T index) where T : IFinchIndexDefinition
public void Add<T>(T index) where T : IMixtapeIndexDefinition
{
base.Add(new Map(typeof(T), () => index));
}
@@ -58,8 +58,8 @@ public class RavenIndexesOptions : List<RavenIndexesOptions.Map>
}
public void Replace<T, TReplaceWith>()
where T : IFinchIndexDefinition, new()
where TReplaceWith : IFinchIndexDefinition, new()
where T : IMixtapeIndexDefinition, new()
where TReplaceWith : IMixtapeIndexDefinition, new()
{
Replace(typeof(T), typeof(TReplaceWith));
}
@@ -74,13 +74,13 @@ public class RavenIndexesOptions : List<RavenIndexesOptions.Map>
Add(replaceWith);
}
public IEnumerable<IFinchIndexDefinition> BuildAll(IFinchOptions options, IDocumentStore store)
public IEnumerable<IMixtapeIndexDefinition> BuildAll(IMixtapeOptions options, IDocumentStore store)
{
RavenOptions ravenOptions = options.For<RavenOptions>();
foreach (Map map in this)
{
IFinchIndexDefinition index = map.CreateIndex.Compile().Invoke();
IMixtapeIndexDefinition index = map.CreateIndex.Compile().Invoke();
index.Setup(options, store);
index.RunModifiers(ravenOptions);
yield return index;
@@ -95,10 +95,10 @@ public class RavenIndexModifiersOptions : List<RavenIndexModifiersOptions.Modifi
{
public Type Type { get; set; }
public Expression<Action<IFinchIndexDefinition>> Modify { get; set; }
public Expression<Action<IMixtapeIndexDefinition>> Modify { get; set; }
}
public void Add<T>(Action<T> modify) where T : IFinchIndexDefinition, new()
public void Add<T>(Action<T> modify) where T : IMixtapeIndexDefinition, new()
{
Add(new()
{
@@ -108,7 +108,7 @@ public class RavenIndexModifiersOptions : List<RavenIndexModifiersOptions.Modifi
}
public IEnumerable<Modifier> GetAllForType<T>() where T : IFinchIndexDefinition, new() => GetAllForType(typeof(T));
public IEnumerable<Modifier> GetAllForType<T>() where T : IMixtapeIndexDefinition, new() => GetAllForType(typeof(T));
public IEnumerable<Modifier> GetAllForType(Type type)
@@ -2,18 +2,18 @@
using System.Security.Cryptography;
using System.Text;
namespace Finch.Raven;
namespace Mixtape.Raven;
public class FinchTokenProvider : IFinchTokenProvider
public class MixtapeTokenProvider : IMixtapeTokenProvider
{
readonly char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-".ToCharArray();
readonly RandomNumberGenerator randonNumberGenerator;
protected IFinchStore Store { get; }
protected IMixtapeStore Store { get; }
public FinchTokenProvider(IFinchStore store)
public MixtapeTokenProvider(IMixtapeStore store)
{
Store = store;
randonNumberGenerator = RandomNumberGenerator.Create();
@@ -245,7 +245,7 @@ public class FinchTokenProvider : IFinchTokenProvider
}
public interface IFinchTokenProvider
public interface IMixtapeTokenProvider
{
/// <summary>
/// Generates a token for a <paramref name="key"/> with a specified <paramref name="expires"/> lifespan.
@@ -3,7 +3,7 @@ using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace Finch.Raven;
namespace Mixtape.Raven;
/// <summary>
/// Replicates the Rfc6238AuthenticationService from ASP.NET Core internals as it isn't part of the public API
@@ -1,4 +1,4 @@
namespace Finch.Raven;
namespace Mixtape.Raven;
[RavenCollection("Tokens")]
public class SecurityToken : ISupportsDbConventions
@@ -6,17 +6,17 @@ global using System.Linq;
global using System.Threading;
global using System.Threading.Tasks;
global using Finch.Utils;
global using Finch.Configuration;
global using Finch.Extensions;
global using Finch.FileStorage;
global using Finch.Models;
global using Finch.Modules;
global using Finch.Rendering;
global using Finch.Validation;
global using Finch.Localization;
global using Finch.Context;
global using Finch.Communication;
global using Mixtape.Utils;
global using Mixtape.Configuration;
global using Mixtape.Extensions;
global using Mixtape.FileStorage;
global using Mixtape.Models;
global using Mixtape.Modules;
global using Mixtape.Rendering;
global using Mixtape.Validation;
global using Mixtape.Localization;
global using Mixtape.Context;
global using Mixtape.Communication;
global using Raven.Client.Documents;
global using Raven.Client.Documents.Operations;
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Finch.Raven</PackageId>
<PackageId>Mixtape.Raven</PackageId>
<Version>1.0.0</Version>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<RootNamespace>Finch.Raven</RootNamespace>
<RootNamespace>Mixtape.Raven</RootNamespace>
<DebugType>embedded</DebugType>
</PropertyGroup>
@@ -17,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Finch\Finch.csproj" />
<ProjectReference Include="..\Mixtape\Mixtape.csproj" />
</ItemGroup>
</Project>
@@ -1,9 +1,9 @@
using System;
using System.Linq.Expressions;
using ServiceStack.OrmLite;
using Finch.Extensions;
using Mixtape.Extensions;
namespace Finch.Sqlite;
namespace Mixtape.Sqlite;
public static class SqlExpressionExtensions
{
@@ -4,22 +4,22 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ServiceStack.Data;
using ServiceStack.OrmLite;
using Finch.Configuration;
using Finch.Models;
using Finch.Modules;
using Mixtape.Configuration;
using Mixtape.Models;
using Mixtape.Modules;
namespace Finch.Sqlite;
namespace Mixtape.Sqlite;
public static class FinchBuilderExtensions
public static class MixtapeBuilderExtensions
{
public static FinchBuilder AddSqlite(this FinchBuilder builder)
public static MixtapeBuilder AddSqlite(this MixtapeBuilder builder)
{
builder.AddModule<FinchSqliteModule>();
builder.AddModule<MixtapeSqliteModule>();
return builder;
}
}
internal class FinchSqliteModule : FinchModule
internal class MixtapeSqliteModule : MixtapeModule
{
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
@@ -29,14 +29,14 @@ internal class FinchSqliteModule : FinchModule
services.AddScoped<StoreContext>();
services.AddScoped<IEntityModifiedHandler, EmptyEntityModifiedHandler>();
services.AddOptions<FlavorOptions>();
services.AddOptions<SqliteOptions>().Bind(configuration.GetSection("Finch:Sqlite"));
services.AddOptions<SqliteOptions>().Bind(configuration.GetSection("Mixtape:Sqlite"));
services.ConfigureOptions<ConfigureFlavorJsonOptions>();
}
protected IDbConnectionFactory CreateDbConnectionFactory(IServiceProvider services)
{
IFinchOptions options = services.GetService<IFinchOptions>();
IMixtapeOptions options = services.GetService<IMixtapeOptions>();
SqliteOptions sqliteOptions = options.For<SqliteOptions>();
return new OrmLiteConnectionFactory(sqliteOptions.ConnectionString, SqliteDialect.Provider);
}
@@ -45,7 +45,7 @@ internal class FinchSqliteModule : FinchModule
protected IDbConnection CreateDbConnection(IServiceProvider services)
{
IDbConnectionFactory factory = services.GetService<IDbConnectionFactory>();
IFinchOptions options = services.GetService<IFinchOptions>();
IMixtapeOptions options = services.GetService<IMixtapeOptions>();
SqliteOptions sqliteOptions = options.For<SqliteOptions>();
IDbConnection db = factory.CreateDbConnection();
db.Open();
@@ -2,19 +2,19 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using ServiceStack.OrmLite;
using Finch.Models;
using Mixtape.Models;
namespace Finch.Sqlite;
namespace Mixtape.Sqlite;
public partial class DbOperations : IDbOperations
{
/// <inheritdoc />
public virtual Task<Result<T>> Delete<T>(T model) where T : FinchIdEntity, new()
public virtual Task<Result<T>> Delete<T>(T model) where T : MixtapeIdEntity, new()
=> Delete<T>(model.Id);
/// <inheritdoc />
public virtual async Task<Result<T>> Delete<T>(string id) where T : FinchIdEntity, new()
public virtual async Task<Result<T>> Delete<T>(string id) where T : MixtapeIdEntity, new()
{
T model = await Load<T>(id);
@@ -4,15 +4,15 @@ using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using ServiceStack.OrmLite;
using Finch.Extensions;
using Finch.Models;
using Mixtape.Extensions;
using Mixtape.Models;
namespace Finch.Sqlite;
namespace Mixtape.Sqlite;
public partial class DbOperations : IDbOperations
{
/// <inheritdoc />
public virtual async Task<T> Load<T>(string id, string changeVector = null) where T : FinchIdEntity, new()
public virtual async Task<T> Load<T>(string id, string changeVector = null) where T : MixtapeIdEntity, new()
{
if (id.IsNullOrWhiteSpace())
{
@@ -28,7 +28,7 @@ public partial class DbOperations : IDbOperations
/// <inheritdoc />
public virtual async Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : FinchIdEntity, new()
public virtual async Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new()
{
ids = ids.Distinct().ToArray();
@@ -46,7 +46,7 @@ public partial class DbOperations : IDbOperations
/// <inheritdoc />
public virtual async Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : FinchIdEntity, new()
public virtual async Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new()
{
ids = ids.Distinct().ToArray();
@@ -67,35 +67,35 @@ public partial class DbOperations : IDbOperations
/// <inheritdoc />
public virtual async Task<bool> Any<T>(Expression<Func<T, bool>> querySelector = null) where T : FinchIdEntity, new()
public virtual async Task<bool> Any<T>(Expression<Func<T, bool>> querySelector = null) where T : MixtapeIdEntity, new()
{
return await Db.ExistsAsync(querySelector ?? (x => true));
}
/// <inheritdoc />
public virtual async Task<List<T>> Load<T>(Expression<Func<T, bool>> querySelector) where T : FinchIdEntity, new()
public virtual async Task<List<T>> Load<T>(Expression<Func<T, bool>> querySelector) where T : MixtapeIdEntity, new()
{
return await Db.SelectAsync(querySelector ?? (x => true));
}
/// <inheritdoc />
public virtual async Task<T> Find<T>(Expression<Func<T, bool>> querySelector) where T : FinchIdEntity, new()
public virtual async Task<T> Find<T>(Expression<Func<T, bool>> querySelector) where T : MixtapeIdEntity, new()
{
return await Db.SingleAsync(querySelector);
}
/// <inheritdoc />
public virtual async Task<List<T>> LoadBySql<T>(Func<SqlExpression<T>, SqlExpression<T>> querySelector) where T : FinchIdEntity, new()
public virtual async Task<List<T>> LoadBySql<T>(Func<SqlExpression<T>, SqlExpression<T>> querySelector) where T : MixtapeIdEntity, new()
{
return await Db.SelectAsync(querySelector(Db.From<T>()));
}
/// <inheritdoc />
public virtual async Task<List<T>> LoadAll<T>() where T : FinchIdEntity, new()
public virtual async Task<List<T>> LoadAll<T>() where T : MixtapeIdEntity, new()
{
return await Db.SelectAsync<T>(x => true);
}
@@ -5,28 +5,28 @@ using System.Threading.Tasks;
using FluentValidation.Results;
using Microsoft.Extensions.Logging;
using ServiceStack.OrmLite;
using Finch.Models;
using Finch.Extensions;
using Mixtape.Models;
using Mixtape.Extensions;
namespace Finch.Sqlite;
namespace Mixtape.Sqlite;
public partial class DbOperations : IDbOperations
{
/// <inheritdoc />
public virtual Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : FinchIdEntity, new() => Save(model, validate);
public virtual Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : MixtapeIdEntity, new() => Save(model, validate);
/// <inheritdoc />
public virtual Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : FinchIdEntity, new() => Save(model, validate, true);
public virtual Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : MixtapeIdEntity, new() => Save(model, validate, true);
/// <inheritdoc />
public virtual async Task<Result<T>> CreateOrUpdate<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : FinchIdEntity, new()
public virtual async Task<Result<T>> CreateOrUpdate<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : MixtapeIdEntity, new()
{
bool update = !model.Id.IsNullOrEmpty() && await Any<T>(x => x.Id == model.Id);
return await Save(model, validate, update);
}
/// <inheritdoc />
protected virtual async Task<Result<T>> Save<T>(T model, Func<T, Task<ValidationResult>> validate = null, bool update = false) where T : FinchIdEntity, new()
protected virtual async Task<Result<T>> Save<T>(T model, Func<T, Task<ValidationResult>> validate = null, bool update = false) where T : MixtapeIdEntity, new()
{
if (model == null)
{
@@ -84,9 +84,9 @@ public partial class DbOperations : IDbOperations
await Db.SaveAsync(model);
string action = update ? "Updated" : "Created";
if (model is FinchEntity finchEntity)
if (model is MixtapeEntity mixtapeEntity)
{
Logger.LogInformation(action + " {id} with name {name}", model.Id, finchEntity.Name);
Logger.LogInformation(action + " {id} with name {name}", model.Id, mixtapeEntity.Name);
}
else
{
@@ -100,7 +100,7 @@ public partial class DbOperations : IDbOperations
/// <inheritdoc />
public virtual async Task Sort<T>(IEnumerable<string> ids) where T : FinchEntity, new()
public virtual async Task Sort<T>(IEnumerable<string> ids) where T : MixtapeEntity, new()
{
List<T> items = await LoadAll<T>();
@@ -7,17 +7,17 @@ using System.Linq.Expressions;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using ServiceStack.OrmLite;
using Finch.Communication;
using Finch.Context;
using Finch.Models;
using Finch.Utils;
using Finch.Validation;
using Mixtape.Communication;
using Mixtape.Context;
using Mixtape.Models;
using Mixtape.Utils;
using Mixtape.Validation;
namespace Finch.Sqlite;
namespace Mixtape.Sqlite;
public partial class DbOperations : IDbOperations
{
protected IFinchContext Context { get; private set; }
protected IMixtapeContext Context { get; private set; }
protected FlavorOptions Flavors { get; }
@@ -42,14 +42,14 @@ public partial class DbOperations : IDbOperations
/// <inheritdoc />
public bool EnsureTableExists<T>() where T : FinchIdEntity
public bool EnsureTableExists<T>() where T : MixtapeIdEntity
{
return Db.CreateTableIfNotExists<T>();
}
/// <inheritdoc />
public Task<string> GenerateId<T>(T model) where T : FinchIdEntity
public Task<string> GenerateId<T>(T model) where T : MixtapeIdEntity
{
return Task.FromResult(IdGenerator.Create(12));
}
@@ -63,35 +63,35 @@ public partial class DbOperations : IDbOperations
/// <inheritdoc />
public T PrepareForSave<T>(T model) where T : FinchIdEntity
public T PrepareForSave<T>(T model) where T : MixtapeIdEntity
{
// set IDs
AutoSetIds(model);
if (model is not FinchEntity finchModel)
if (model is not MixtapeEntity mixtapeModel)
{
return model;
}
// set default properties
if (finchModel.CreatedDate == default)
if (mixtapeModel.CreatedDate == default)
{
finchModel.CreatedDate = DateTimeOffset.Now;
mixtapeModel.CreatedDate = DateTimeOffset.Now;
}
// update name alias and last modified
finchModel.Alias = Safenames.Alias(finchModel.Name);
finchModel.LastModifiedDate = DateTimeOffset.Now;
finchModel.Hash ??= IdGenerator.Create();
mixtapeModel.Alias = Safenames.Alias(mixtapeModel.Name);
mixtapeModel.LastModifiedDate = DateTimeOffset.Now;
mixtapeModel.Hash ??= IdGenerator.Create();
return model;
}
/// <inheritdoc />
public async Task<ValidationResult> Validate<T>(T model) where T : FinchIdEntity, new()
public async Task<ValidationResult> Validate<T>(T model) where T : MixtapeIdEntity, new()
{
IFinchMergedValidator<T> validator = Services.GetService<IFinchMergedValidator<T>>();
IMixtapeMergedValidator<T> validator = Services.GetService<IMixtapeMergedValidator<T>>();
if (validator == null)
{
@@ -103,10 +103,10 @@ public partial class DbOperations : IDbOperations
/// <inheritdoc />
public virtual T WhenActive<T>(T model) where T : FinchIdEntity, new()
public virtual T WhenActive<T>(T model) where T : MixtapeIdEntity, new()
{
return model; // TODO should we really use this? I tried to get data in a custom backend but couldn't because of this
//return model != null && (model is not FinchEntity || (model as FinchEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default;
//return model != null && (model is not MixtapeEntity || (model as MixtapeEntity).IsActive) && (model is not ISupportsSoftDelete || !(model as ISupportsSoftDelete).IsDeleted) ? model : default;
}
}
@@ -116,22 +116,22 @@ public interface IDbOperations
/// <summary>
/// Create a table if not existing
/// </summary>
bool EnsureTableExists<T>() where T : FinchIdEntity;
bool EnsureTableExists<T>() where T : MixtapeIdEntity;
/// <summary>
/// Generate model Id by using configured document store conventions
/// </summary>
Task<string> GenerateId<T>(T model) where T : FinchIdEntity;
Task<string> GenerateId<T>(T model) where T : MixtapeIdEntity;
/// <summary>
/// Do only return the model when it is set to active or inactive entities are included with IncludeInactive()
/// </summary>
T WhenActive<T>(T model) where T : FinchIdEntity, new();
T WhenActive<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Validates an entity
/// </summary>
Task<ValidationResult> Validate<T>(T model) where T : FinchIdEntity, new();
Task<ValidationResult> Validate<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Generate values for all properties (incl. nested) which contain the [GenerateId] attribute
@@ -139,78 +139,78 @@ public interface IDbOperations
T AutoSetIds<T>(T model);
/// <summary>
/// Automatically fill base properties of a FinchEntity
/// Automatically fill base properties of a MixtapeEntity
/// </summary>
T PrepareForSave<T>(T model) where T : FinchIdEntity;
T PrepareForSave<T>(T model) where T : MixtapeIdEntity;
/// <summary>
/// Get an entity by Id
/// </summary>
Task<T> Load<T>(string id, string changeVector = null) where T : FinchIdEntity, new();
Task<T> Load<T>(string id, string changeVector = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by ids
/// </summary>
Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : FinchIdEntity, new();
Task<Dictionary<string, T>> Load<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by ids
/// </summary>
Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : FinchIdEntity, new();
Task<List<T>> LoadAsList<T>(IEnumerable<string> ids) where T : MixtapeIdEntity, new();
/// <summary>
/// Check if any items exist in this collection (with optional query)
/// </summary>
Task<bool> Any<T>(Expression<Func<T, bool>> querySelector = null) where T : FinchIdEntity, new();
Task<bool> Any<T>(Expression<Func<T, bool>> querySelector = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by query
/// </summary>
Task<List<T>> Load<T>(Expression<Func<T, bool>> querySelector) where T : FinchIdEntity, new();
Task<List<T>> Load<T>(Expression<Func<T, bool>> querySelector) where T : MixtapeIdEntity, new();
/// <summary>
/// Find entity by query
/// </summary>
Task<T> Find<T>(Expression<Func<T, bool>> querySelector) where T : FinchIdEntity, new();
Task<T> Find<T>(Expression<Func<T, bool>> querySelector) where T : MixtapeIdEntity, new();
/// <summary>
/// Get entities by sql query
/// </summary>
Task<List<T>> LoadBySql<T>(Func<SqlExpression<T>, SqlExpression<T>> querySelector) where T : FinchIdEntity, new();
Task<List<T>> LoadBySql<T>(Func<SqlExpression<T>, SqlExpression<T>> querySelector) where T : MixtapeIdEntity, new();
/// <summary>
/// Get all entities from this collection.
/// Warning: Don't use this method for large collections. Stream the results instead.
/// </summary>
Task<List<T>> LoadAll<T>() where T : FinchIdEntity, new();
Task<List<T>> LoadAll<T>() where T : MixtapeIdEntity, new();
/// <summary>
/// Creates an entity with an optional validator
/// </summary>
Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : FinchIdEntity, new();
Task<Result<T>> Create<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Updates an entity with an optional validator
/// </summary>
Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : FinchIdEntity, new();
Task<Result<T>> Update<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Checks if an entity exists (via ID) and creates or updates it afterwards accordingly
/// </summary>
Task<Result<T>> CreateOrUpdate<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : FinchIdEntity, new();
Task<Result<T>> CreateOrUpdate<T>(T model, Func<T, Task<ValidationResult>> validate = null) where T : MixtapeIdEntity, new();
/// <summary>
/// Updates sorting of all items in a collection based on the given enumerable
/// </summary>
Task Sort<T>(IEnumerable<string> ids) where T : FinchEntity, new();
Task Sort<T>(IEnumerable<string> ids) where T : MixtapeEntity, new();
/// <summary>
/// Deletes an entity
/// </summary>
Task<Result<T>> Delete<T>(T model) where T : FinchIdEntity, new();
Task<Result<T>> Delete<T>(T model) where T : MixtapeIdEntity, new();
/// <summary>
/// Deletes an entity
/// </summary>
Task<Result<T>> Delete<T>(string id) where T : FinchIdEntity, new();
Task<Result<T>> Delete<T>(string id) where T : MixtapeIdEntity, new();
}
@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using Mixtape.Communication;
using Mixtape.Models;
namespace Mixtape.Sqlite;
public interface IEntityModifiedHandler : IHandler
{
Task Saved<T>(T model, bool update) where T : MixtapeIdEntity, new() => update ? Updated(model) : Created(model);
Task Created<T>(T model) where T : MixtapeIdEntity, new();
Task Updated<T>(T model) where T : MixtapeIdEntity, new();
Task Deleted<T>(T model) where T : MixtapeIdEntity, new();
}
public class EmptyEntityModifiedHandler : IEntityModifiedHandler
{
public Task Created<T>(T model) where T : MixtapeIdEntity, new() => Task.CompletedTask;
public Task Updated<T>(T model) where T : MixtapeIdEntity, new() => Task.CompletedTask;
public Task Deleted<T>(T model) where T : MixtapeIdEntity, new() => Task.CompletedTask;
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using Mixtape.Communication;
using Mixtape.Configuration;
using Mixtape.Context;
namespace Mixtape.Sqlite;
public class StoreContext
{
public IMixtapeContext Context { get; private set; }
public IMixtapeOptions Options { get; private set; }
public IServiceProvider Services { get; private set; }
public IMessageAggregator Messages { get; private set; }
public StoreContext(IMixtapeContext context, IServiceProvider serviceProvider, IMessageAggregator messages)
{
Options = context.Options;
Context = context;
Services = serviceProvider;
Messages = messages;
}
}
@@ -1,7 +1,7 @@
using System;
using System.Data;
namespace Finch.Sqlite;
namespace Mixtape.Sqlite;
public class SqliteOptions
{
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Finch.Sqlite</PackageId>
<PackageId>Mixtape.Sqlite</PackageId>
<Version>1.0.0</Version>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<RootNamespace>Finch.Sqlite</RootNamespace>
<RootNamespace>Mixtape.Sqlite</RootNamespace>
<DebugType>embedded</DebugType>
</PropertyGroup>
@@ -15,7 +15,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Finch\Finch.csproj" />
<ProjectReference Include="..\Mixtape\Mixtape.csproj" />
</ItemGroup>
</Project>
+3 -3
View File
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Finch", "Finch\Finch.csproj", "{33CD6E46-CD81-42C3-9019-C0EAD557EE99}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mixtape", "mixtape\mixtape.csproj", "{33CD6E46-CD81-42C3-9019-C0EAD557EE99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Finch.Raven", "Finch.Raven\Finch.Raven.csproj", "{DC79D7EA-FAA1-4701-9C36-8295CD1C45D0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mixtape.Raven", "mixtape.Raven\mixtape.Raven.csproj", "{DC79D7EA-FAA1-4701-9C36-8295CD1C45D0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Finch.Sqlite", "Finch.Sqlite\Finch.Sqlite.csproj", "{A57D88BC-952F-4311-B474-26FBF0FA957E}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mixtape.Sqlite", "mixtape.Sqlite\mixtape.Sqlite.csproj", "{A57D88BC-952F-4311-B474-26FBF0FA957E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -3,13 +3,13 @@ using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Finch;
namespace Mixtape;
public static class ApplicationBuilderExtensions
{
public static IApplicationBuilder UseFinch(this IApplicationBuilder app)
public static IApplicationBuilder UseMixtape(this IApplicationBuilder app)
{
app.UseMiddleware<FinchContextMiddleware>();
app.UseMiddleware<MixtapeContextMiddleware>();
app.UseResponseCaching();
IHostEnvironment env = app.ApplicationServices.GetRequiredService<IHostEnvironment>();
@@ -24,7 +24,7 @@ public static class ApplicationBuilderExtensions
webApplication.MapControllers();
}
FinchBuilder.Modules.Configure(app, app as IEndpointRouteBuilder, app.ApplicationServices);
MixtapeBuilder.Modules.Configure(app, app as IEndpointRouteBuilder, app.ApplicationServices);
return app;
}
}
@@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyModel;
using System.Reflection;
namespace Finch.Assemblies;
namespace Mixtape.Assemblies;
public class AssemblyDiscovery : IAssemblyDiscovery
{
@@ -1,6 +1,6 @@
using System.Reflection;
namespace Finch.Assemblies;
namespace Mixtape.Assemblies;
public class AssemblyDiscoveryContext
{
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyModel;
namespace Finch.Assemblies;
namespace Mixtape.Assemblies;
public interface IAssemblyDiscoveryRule
{
@@ -0,0 +1,16 @@
using Microsoft.Extensions.DependencyModel;
namespace Mixtape.Assemblies;
public class MixtapeAssemblyDiscoveryRule : IAssemblyDiscoveryRule
{
const string MixtapePrefix = "Mixtape.";
/// <inheritdoc />
public bool IsValid(RuntimeLibrary library, AssemblyDiscoveryContext context)
{
StringComparison casing = StringComparison.OrdinalIgnoreCase;
// TODO we need to auto-add assemblies and discover their types which have implementations of IMixtapePlugin
return library.Name.StartsWith(MixtapePrefix, casing) || (context.HasEntryAssembly && library.Name.Contains(context.EntryAssemblyName, casing));
}
}
@@ -0,0 +1,5 @@
namespace Mixtape.Communication;
public interface IHandler
{
}
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
namespace Finch.Communication;
namespace Mixtape.Communication;
public class HandlerHolder : IHandlerHolder
{
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
namespace Finch.Communication;
namespace Mixtape.Communication;
public class LazilyResolved<T> : Lazy<T>
{
@@ -1,5 +1,5 @@

namespace Finch.Communication;
namespace Mixtape.Communication;
public interface IMessage
{
@@ -1,4 +1,4 @@
namespace Finch.Communication;
namespace Mixtape.Communication;
/// <summary>
/// Indicates a handler that can perform an action when a message of
@@ -1,7 +1,7 @@
using System.Collections.Concurrent;
using System.Linq.Expressions;
namespace Finch.Communication;
namespace Mixtape.Communication;
public class MessageAggregator : IMessageAggregator
{
@@ -2,7 +2,7 @@
using System.Linq.Expressions;
using System.Reflection;
namespace Finch.Communication;
namespace Mixtape.Communication;
internal class MessageSubscription<TMessage, TMessageHandler> : IMessageSubscription
where TMessage : class, IMessage
@@ -1,9 +1,9 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Finch.Communication;
namespace Mixtape.Communication;
internal class FinchCommunicationModule : FinchModule
internal class MixtapeCommunicationModule : MixtapeModule
{
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
@@ -0,0 +1,6 @@
namespace Mixtape.Configuration;
public interface IMixtapeCollectionOptions
{
}
@@ -2,22 +2,22 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace Finch.Configuration;
namespace Mixtape.Configuration;
internal class FinchConfigurationModule : FinchModule
internal class MixtapeConfigurationModule : MixtapeModule
{
public override int Order => -1000;
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddOptions<FinchOptions>().Configure<IServiceProvider>((opts, svc) =>
services.AddOptions<MixtapeOptions>().Configure<IServiceProvider>((opts, svc) =>
{
opts.ServiceProvider = svc;
opts.Version = "1.0.0-alpha.1";
opts.TokenExpiration = TimeSpan.FromHours(3);
opts.DataProtectionStoragePath = "../cache/dpkeys";
}).Bind(configuration.GetSection("Finch"));
}).Bind(configuration.GetSection("Mixtape"));
services.AddTransient<IFinchOptions, FinchOptions>(factory => factory.GetService<IOptions<FinchOptions>>().Value);
services.AddTransient<IMixtapeOptions, MixtapeOptions>(factory => factory.GetService<IOptions<MixtapeOptions>>().Value);
}
}
@@ -2,9 +2,9 @@
using Microsoft.Extensions.Options;
using System.Collections.Concurrent;
namespace Finch.Configuration;
namespace Mixtape.Configuration;
public class FinchOptions : IFinchOptions
public class MixtapeOptions : IMixtapeOptions
{
/// <inheritdoc />
public string Version { get; set; }
@@ -44,7 +44,7 @@ public class FinchOptions : IFinchOptions
}
public interface IFinchOptions
public interface IMixtapeOptions
{
/// <summary>
/// The currently active version
@@ -1,15 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
namespace Finch.Configuration;
namespace Mixtape.Configuration;
public class FinchStartupOptions(IMvcBuilder mvc) : IFinchStartupOptions
public class MixtapeStartupOptions(IMvcBuilder mvc) : IMixtapeStartupOptions
{
public IList<IAssemblyDiscoveryRule> AssemblyDiscoveryRules { get; } = new List<IAssemblyDiscoveryRule>();
public IMvcBuilder Mvc { get; } = mvc;
}
public interface IFinchStartupOptions
public interface IMixtapeStartupOptions
{
IList<IAssemblyDiscoveryRule> AssemblyDiscoveryRules { get; }
@@ -1,6 +1,6 @@
using FluentValidation;
namespace Finch.Configuration;
namespace Mixtape.Configuration;
public abstract class OptionsType
{
@@ -1,15 +1,15 @@
using Microsoft.AspNetCore.Http;
namespace Finch.Context;
namespace Mixtape.Context;
public class FinchContext(
IFinchOptions options,
public class MixtapeContext(
IMixtapeOptions options,
ICultureResolver cultureResolver,
IServiceProvider services)
: IFinchContext
: IMixtapeContext
{
/// <inheritdoc />
public IFinchOptions Options { get; } = options;
public IMixtapeOptions Options { get; } = options;
/// <inheritdoc />
public IServiceProvider Services { get; } = services;
@@ -35,12 +35,12 @@ public class FinchContext(
public interface IFinchContext
public interface IMixtapeContext
{
/// <summary>
/// Global finch options
/// Global mixtape options
/// </summary>
IFinchOptions Options { get; }
IMixtapeOptions Options { get; }
/// <summary>
/// Service container
@@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Http;
namespace Mixtape.Context
{
public class MixtapeContextMiddleware(RequestDelegate next)
{
public async Task Invoke(HttpContext httpContext, IMixtapeContext mixtapeContext)
{
await mixtapeContext.Resolve(httpContext);
await next(httpContext);
}
}
}
@@ -1,13 +1,13 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Finch.Context;
namespace Mixtape.Context;
internal class FinchContextModule : FinchModule
internal class MixtapeContextModule : MixtapeModule
{
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IFinchContext, FinchContext>();
services.AddScoped<IMixtapeContext, MixtapeContext>();
services.AddHttpContextAccessor();
}
}
@@ -1,4 +1,4 @@
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class CharExtensions
{
@@ -1,6 +1,6 @@
using System.Drawing;
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class ColorExtensions
{
@@ -1,4 +1,4 @@
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class DictionaryExtensions
{
@@ -1,4 +1,4 @@
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class EnumerableExtensions
{
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using System.Text;
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class ExpressionExtensions
{
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http;
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class HttpContextExtensions
{
@@ -1,4 +1,4 @@
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class NumberExtensions
{
@@ -1,6 +1,6 @@
//using Newtonsoft.Json;
//namespace Finch.Extensions;
//namespace Mixtape.Extensions;
//[Obsolete("we don't want this for every object (use a Utils class instead)")]
//public static class ObjectExtensions
@@ -1,4 +1,4 @@
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class ResultExtensions
{
@@ -31,7 +31,7 @@ public static class ResultExtensions
public static Result AddError(this Result origin, string message)
{
origin.IsSuccess = false;
origin.Errors.Add(new("__finch_no_field", message));
origin.Errors.Add(new("__mixtape_no_field", message));
return origin;
}
@@ -2,7 +2,7 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using System.Reflection;
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class ServiceCollectionExtensions
{
@@ -19,7 +19,7 @@ public static class ServiceCollectionExtensions
{
if (AssemblyDiscovery.Current == null)
{
throw new Exception("services.AddAll() can only be run after mvcBuilder.AddFinch()");
throw new Exception("services.AddAll() can only be run after mvcBuilder.AddMixtape()");
}
// add implementations with generic service types
@@ -4,7 +4,7 @@ using System.Text;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Html;
namespace Finch.Extensions;
namespace Mixtape.Extensions;
public static class StringExtensions
{
@@ -1,4 +1,4 @@
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public class FileResult
{
@@ -1,4 +1,4 @@
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public enum FileSizeNotation
{
@@ -1,4 +1,4 @@
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public class FileSystemException : Exception
{
+6
View File
@@ -0,0 +1,6 @@
namespace Mixtape.FileStorage;
public class FileSystemOptions
{
public string MixtapeAssetsPath { get; set; }
}
@@ -2,17 +2,17 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
internal class FinchFileStorageModule : FinchModule
internal class MixtapeFileStorageModule : MixtapeModule
{
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IPaths>(factory => new Paths(factory.GetService<IWebHostEnvironment>()));
services.AddOptions<FileSystemOptions>().Bind(configuration.GetSection("Finch:FileSystem")).Configure(opts =>
services.AddOptions<FileSystemOptions>().Bind(configuration.GetSection("Mixtape:FileSystem")).Configure(opts =>
{
opts.FinchAssetsPath = "finch";
opts.MixtapeAssetsPath = "mixtape";
});
services.AddSingleton<IWebRootFileSystem, WebRootFileSystem>(svc =>
@@ -1,4 +1,4 @@
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public interface IFileMeta
{
@@ -1,6 +1,6 @@
using System.IO;
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public interface IFileSystem
{
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.StaticFiles;
using System.IO;
using System.Text;
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public class Paths : IPaths
{
@@ -1,6 +1,6 @@
using Microsoft.Extensions.FileProviders;
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public class PhysicalFileMeta : IFileMeta
{
@@ -1,7 +1,7 @@
using Microsoft.Extensions.FileProviders.Physical;
using System.IO;
namespace Finch.FileStorage;
namespace Mixtape.FileStorage;
public class PhysicalFileSystem : IFileSystem
{

Some files were not shown because too many files have changed in this diff Show More