diff --git a/old/zero.Core/Api/Safenames.cs b/old/zero.Core/Api/Safenames.cs
deleted file mode 100644
index 1da0deea..00000000
--- a/old/zero.Core/Api/Safenames.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using System;
-using System.IO;
-using System.Text;
-using zero.Core.Extensions;
-
-namespace zero.Core.Api
-{
- public class Safenames
- {
- public enum Scope
- {
- Url,
- File
- }
-
- const char HYPHEN = '-';
-
- const char DOT = '.';
-
- const char PLUS = '+';
-
- const char AMPERSAND = '&';
-
-
- ///
- /// Converts an untrusted to a safe filename
- ///
- public static string File(string value)
- {
- return Generate(Path.GetFileName(value), Scope.File);
- }
-
-
- ///
- /// Converts a term to a safe alias (suitable for URLs)
- ///
- public static string Alias(string value)
- {
- return Generate(value, Scope.Url);
- }
-
-
- ///
- /// Converts a term to a safe alias (suitable for URLs)
- ///
- public static string Alias(object value)
- {
- return Generate(value?.ToString(), Scope.Url);
- }
-
-
- ///
- ///
- ///
- static string Generate(string value, Scope scope)
- {
- if (String.IsNullOrWhiteSpace(value))
- {
- return String.Empty;
- }
-
- char previous = default;
- StringBuilder output = new StringBuilder();
-
- for (int i = 0; i < value.Length; i++)
- {
- // get character in lower case
- char character = char.ToLower(value[i]);
- char target;
-
- // do not handle surrogates
- if (char.IsSurrogate(character))
- {
- continue;
- }
-
- // special replacements accents + umlauts
- if (character.TryReplaceAccent(out char[] replacement))
- {
- if (replacement.Length > 1)
- {
- output.Append(replacement);
- output.Remove(output.Length - 1, 1);
- }
- target = replacement[replacement.Length - 1];
- }
- // append character a-z, 0-9
- else if (character.IsAZor09())
- {
- target = character;
- }
- // + sign for + and &
- else if (character == PLUS || character == AMPERSAND)
- {
- target = PLUS;
- }
- else if (scope == Scope.File && character == DOT)
- {
- target = DOT;
- }
- // add hyphen for all other characters
- else
- {
- target = HYPHEN;
- }
-
- // add default characters
- if (target != HYPHEN && target != PLUS)
- {
- output.Append(target);
- }
- // add hyphen if it isn't first and previous char is not + or -
- else if (target == HYPHEN && previous != default && previous != PLUS && previous != HYPHEN)
- {
- output.Append(target);
- }
- // add plus. do remove hyphen it is the previous character
- else if (target == PLUS)
- {
- if (previous == HYPHEN)
- {
- output.Remove(output.Length - 1, 1);
- }
- output.Append(target);
- }
-
- if (output.Length > 0)
- {
- previous = output[output.Length - 1];
- }
- }
-
- if (output.Length > 0 && !output[output.Length - 1].IsAZor09())
- {
- output.Remove(output.Length - 1, 1);
- }
-
- if (output.Length == 0)
- {
- output.Append(HYPHEN);
- }
-
- return output.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Api/Token.cs b/old/zero.Core/Api/Token.cs
deleted file mode 100644
index 5b8797b3..00000000
--- a/old/zero.Core/Api/Token.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-//using Raven.Client.Documents;
-//using Raven.Client.Documents.Session;
-//using System;
-//using System.Linq;
-//using System.Threading.Tasks;
-//using zero.Core.Database;
-//using zero.Core.Entities;
-//using zero.Core.Extensions;
-//using zero.Core.Options;
-
-//namespace zero.Core.Api
-//{
-// public class Token : IToken
-// {
-// protected IZeroStore Store { get; private set; }
-
-// protected IZeroOptions Options { get; private set; }
-
-// private const string PREFIX = "changeTokens";
-
-
-// public Token(IZeroStore store, IZeroOptions options)
-// {
-// Store = store;
-// Options = options;
-// }
-
-
-// ///
-// public bool Verify(ZeroIdEntity entity, string token)
-// {
-// return Verify(entity?.Id, token);
-// }
-
-
-// ///
-// public bool Verify(string entityId, string token)
-// {
-// if (token.IsNullOrWhiteSpace() && entityId.IsNullOrEmpty())
-// {
-// return true;
-// }
-
-// if (token.IsNullOrWhiteSpace() || entityId.IsNullOrEmpty())
-// {
-// return false;
-// }
-
-// using (IDocumentSession session = Store.OpenSession())
-// {
-// return session.Query().Any(x => x.Id == token && x.ReferenceId == entityId);
-// }
-// }
-
-
-// ///
-// public string Get(ZeroIdEntity entity)
-// {
-// return Get(entity?.Id);
-// }
-
-
-// ///
-// public string Get(string entityId)
-// {
-// if (entityId.IsNullOrEmpty())
-// {
-// return null;
-// }
-
-// ChangeToken token = new ChangeToken()
-// {
-// Id = Options.Raven.CollectionPrefix.EnsureEndsWith(Store.Raven.Conventions.IdentityPartsSeparator) + PREFIX.EnsureEndsWith(Store.Raven.Conventions.IdentityPartsSeparator) + Guid.NewGuid(),
-// ReferenceId = entityId
-// };
-
-// using (IDocumentSession session = Store.OpenSession())
-// {
-// session.Store(token);
-// session.Advanced.GetMetadataFor(token)[Constants.Database.Expires] = DateTime.UtcNow.AddMinutes(Options.TokenExpiration);
-// session.SaveChanges();
-// }
-
-// return token.Id;
-// }
-// }
-
-
-// public interface IToken
-// {
-// ///
-// /// Verifies if the change token is valid for the entity
-// ///
-// bool Verify(ZeroIdEntity entity, string token);
-
-// ///
-// /// Verifies if the change token is valid for the entity
-// ///
-// bool Verify(string entityId, string token);
-
-// ///
-// /// Get a new change token for the entity
-// ///
-// string Get(ZeroIdEntity entity);
-
-// ///
-// /// Get a new change token for the entity
-// ///
-// string Get(string entityId);
-// }
-//}
diff --git a/old/zero.Core/ApplicationResolver.cs b/old/zero.Core/ApplicationResolver.cs
deleted file mode 100644
index a0c17e4d..00000000
--- a/old/zero.Core/ApplicationResolver.cs
+++ /dev/null
@@ -1,240 +0,0 @@
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Http.Extensions;
-using Microsoft.Extensions.Logging;
-using Raven.Client.Documents;
-using Raven.Client.Documents.Session;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Claims;
-using System.Threading.Tasks;
-using zero.Core.Database;
-using zero.Core.Entities;
-using zero.Core.Extensions;
-using zero.Core.Handlers;
-using zero.Core.Identity;
-using zero.Core.Options;
-
-namespace zero.Core
-{
- public class ApplicationResolver : IApplicationResolver
- {
- protected IZeroStore Store { get; private set; }
-
- protected IZeroOptions Options { get; private set; }
-
- protected ILogger Logger { get; private set; }
-
- protected IHandlerHolder Handler { get; private set; }
-
- private IList Apps { get; set; }
-
-
-
- public ApplicationResolver(IZeroStore store, IZeroOptions options, ILogger logger, IHandlerHolder handler = null)
- {
- Store = store;
- Options = options;
- Logger = logger;
- Handler = handler;
- }
-
-
- ///
- public async Task Resolve(HttpContext context, ClaimsPrincipal user)
- {
- if (context?.Request == null)
- {
- Logger.LogWarning("Could not resolve application as HTTP request is null");
- return null;
- }
-
- Application app;
-
- if (context.IsBackofficeRequest(Options.BackofficePath))
- {
- app = await ResolveFromUser(user);
- }
- else
- {
- app = await ResolveFromRequest(context);
- }
-
- if (app == null)
- {
- //Logger.LogWarning("Could not resolve application for host {host}", context.Request.Host);
- IList apps = await GetApplications();
- app = apps.FirstOrDefault();
- }
-
- return app;
- }
-
-
- ///
- public async Task ResolveFromUser(ClaimsPrincipal user)
- {
- BackofficeUser userEntity = await GetBackofficeUser(user);
- return await ResolveFromUser(userEntity);
- }
-
-
- ///
- public async Task ResolveFromUser(BackofficeUser user)
- {
- if (user == null)
- {
- return null;
- }
-
- string appId;
- string[] allowedAppIds = user.GetAllowedAppIds();
-
- if (!user.CurrentAppId.IsNullOrEmpty())
- {
- if (user.IsSuper || allowedAppIds.Contains(user.CurrentAppId, StringComparer.InvariantCultureIgnoreCase))
- {
- appId = user.CurrentAppId;
- }
- else
- {
- appId = user.AppId;
- }
- }
- else
- {
- appId = user.AppId;
- }
-
- if (appId.IsNullOrEmpty())
- {
- throw new Exception($"User entity ${user.Id} needs a valid AppId");
- }
-
- IAsyncDocumentSession session = Store.Session(global: true);
- return await session.LoadAsync(appId);
- }
-
-
- ///
- public async Task ResolveFromRequest(HttpContext context)
- {
- IApplicationResolverHandler handler = Handler.Get();
- Application app = handler?.Resolve(context.Request, await GetApplications());
-
- if (app == null)
- {
- app = await ResolveFromUri(context.Request.GetEncodedUrl());
- }
-
- return app;
- }
-
-
- ///
- public async Task ResolveFromUri(string uriString)
- {
- return ResolveFromUriInternal(new Uri(uriString, UriKind.Absolute), await GetApplications());
- }
-
-
- ///
- public async Task ResolveFromUri(Uri uri)
- {
- return ResolveFromUriInternal(uri, await GetApplications());
- }
-
-
- ///
- /// Get matching application from an URI
- ///
- Application ResolveFromUriInternal(Uri uri, IList apps)
- {
- foreach (Application app in apps)
- {
- if (app.Domains?.Length < 1)
- {
- Logger.LogWarning("No domains specified for app {app}", app.Id);
- continue;
- }
-
- foreach (Uri domain in app.Domains)
- {
- int compareResult = Uri.Compare(uri, domain, UriComponents.HostAndPort, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);
- if (compareResult == 0)
- {
- return app;
- }
- }
- }
-
- return null;
- }
-
-
- ///
- /// Get all applications to choose from
- ///
- async Task> GetApplications()
- {
- if (Apps != null)
- {
- return Apps;
- }
-
- IAsyncDocumentSession session = Store.Session(global: true);
- Apps = await session.Query().ToListAsync();
- return Apps;
- }
-
-
- ///
- /// Get backoffice user from claims principal
- ///
- async Task GetBackofficeUser(ClaimsPrincipal user)
- {
- string userId = user.FindFirstValue(Constants.Auth.Claims.UserId);
-
- IAsyncDocumentSession session = Store.Session(global: true);
- return await session.LoadAsync(userId);
- }
- }
-
-
- public interface IApplicationResolver
- {
- ///
- /// Resolves the current application from either the backoffice user (in case it is backoffice request)
- /// or the domain (in case it is frontend request).
- ///
- Task Resolve(HttpContext context, ClaimsPrincipal user);
-
- ///
- /// Resolves the current application from the request path
- ///
- Task ResolveFromRequest(HttpContext context);
-
- ///
- /// Get matching application from an URI string
- ///
- Task ResolveFromUri(string uriString);
-
- ///
- /// Get matching application from an URI
- ///
- Task ResolveFromUri(Uri uri);
-
- ///
- /// Resolves the current application from the logged-in backoffice user.
- /// This method won't return apps the user has no access to.
- ///
- Task ResolveFromUser(ClaimsPrincipal user);
-
- ///
- /// Resolves the current application from a user.
- /// This method won't return apps the user has no access to.
- ///
- Task ResolveFromUser(BackofficeUser user);
- }
-}
diff --git a/old/zero.Core/Attributes/GenerateIdAttribute.cs b/old/zero.Core/Attributes/GenerateIdAttribute.cs
deleted file mode 100644
index 1f771ff5..00000000
--- a/old/zero.Core/Attributes/GenerateIdAttribute.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-
-namespace zero.Core.Attributes
-{
- ///
- /// Automatically generate ID with the specified length and insert it into this property on entity save
- ///
- [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
- public class GenerateIdAttribute : Attribute
- {
- public int? Length = null;
-
- public GenerateIdAttribute(int length)
- {
- Length = length;
- }
-
- public GenerateIdAttribute() { }
- }
-}
diff --git a/old/zero.Core/Attributes/LocalizeAttribute.cs b/old/zero.Core/Attributes/LocalizeAttribute.cs
deleted file mode 100644
index 494bddbc..00000000
--- a/old/zero.Core/Attributes/LocalizeAttribute.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace zero.Core.Attributes
-{
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Field, AllowMultiple = false)]
- public class LocalizeAttribute : Attribute
- {
- public string Key;
-
- public LocalizeAttribute(string key)
- {
- Key = key;
- }
- }
-}
diff --git a/old/zero.Core/Attributes/OperationCancelledExceptionFilterAttribute.cs b/old/zero.Core/Attributes/OperationCancelledExceptionFilterAttribute.cs
deleted file mode 100644
index 202e6d31..00000000
--- a/old/zero.Core/Attributes/OperationCancelledExceptionFilterAttribute.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Filters;
-using Microsoft.Extensions.Logging;
-using System;
-
-namespace zero.Core.Attributes
-{
- public class OperationCancelledExceptionFilterAttribute : ExceptionFilterAttribute
- {
- private readonly ILogger _logger;
-
-
- public OperationCancelledExceptionFilterAttribute(ILoggerFactory loggerFactory)
- {
- _logger = loggerFactory.CreateLogger();
- }
-
-
- public override void OnException(ExceptionContext context)
- {
- if (context.Exception is OperationCanceledException)
- {
- _logger.LogInformation("Request was cancelled");
- context.ExceptionHandled = true;
- context.Result = new StatusCodeResult(400);
- }
- }
- }
-}
diff --git a/old/zero.Core/Blueprints/Blueprint.cs b/old/zero.Core/Blueprints/Blueprint.cs
deleted file mode 100644
index 4a448556..00000000
--- a/old/zero.Core/Blueprints/Blueprint.cs
+++ /dev/null
@@ -1,205 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using zero.Core.Entities;
-using zero.Core.Extensions;
-using zero.Core.Utils;
-
-namespace zero.Core.Blueprints
-{
- ///
- ///
- ///
- public class Blueprint : Blueprint where T : ZeroEntity, new()
- {
- public List> UnlockedFields { get; private set; } = new();
-
- ///
- /// These fields are not copied by the ObjectCloner
- /// as they are either locked or copied manually by ApplyDefaults()
- ///
- protected static string[] DefaultUncopyFields { get; set; } = new[] { "id", "url", "name", "alias", "key", "sort", "isActive", "hash", "languageId", "createdById", "createdDate", "lastModifiedById", "lastModifiedDate", "blueprint" };
-
-
- public Blueprint() : base(typeof(T)) { }
-
-
- ///
- /// Merges blueprint data into a model based on the configuration
- ///
- public virtual T Apply(T blueprint, T model)
- {
- // reset blueprint options for model in case no blueprint was found
- if (blueprint == null || model.Blueprint == null)
- {
- model.Blueprint = null;
- return model;
- }
-
- // copy all properties which are synced from the blueprint to the model
- ApplyDefaults(blueprint, model);
- ObjectCloner.CopyProperties(blueprint, model, DefaultUncopyFields.Union(model.Blueprint.Desync).ToArray());
-
- return model;
- }
-
-
- ///
- public override ZeroEntity Apply(ZeroEntity blueprint, ZeroEntity model) => Apply(blueprint as T, model as T);
-
-
- ///
- /// Update default entity data
- ///
- protected virtual void ApplyDefaults(T blueprint, T model)
- {
- if (!model.Blueprint.Desync.Contains(nameof(ZeroEntity.Name), StringComparer))
- {
- model.Name = blueprint.Name;
- model.Alias = blueprint.Alias;
- }
- if (!model.Blueprint.Desync.Contains(nameof(ZeroEntity.Key), StringComparer))
- {
- model.Key = blueprint.Key;
- }
- if (!model.Blueprint.Desync.Contains(nameof(ZeroEntity.Sort), StringComparer))
- {
- model.Sort = blueprint.Sort;
- }
- if (!model.Blueprint.Desync.Contains(nameof(ZeroEntity.IsActive), StringComparer))
- {
- model.IsActive = blueprint.IsActive;
- }
-
- // these values can't be overridden
- model.Hash = blueprint.Hash;
- model.LanguageId = blueprint.LanguageId;
- model.CreatedById = blueprint.CreatedById;
- model.CreatedDate = blueprint.CreatedDate;
- model.LastModifiedById = blueprint.LastModifiedById;
- model.LastModifiedDate = blueprint.LastModifiedDate;
- }
-
-
- ///
- /// Lock a field so it always get synchronized no and cannot be changed
- ///
- public void LockAll()
- {
- UnlockedFields = new();
- }
-
-
- ///
- /// Lock a field so it always get synchronized no and cannot be changed
- ///
- public void Lock(Expression> selector)
- {
- RemoveField(selector);
- }
-
-
- public void Unlock(Expression> selector)
- {
- AddField(selector);
- }
-
-
- public void UnlockDefaults()
- {
- AddField(x => x.Name);
- AddField(x => x.Alias);
- AddField(x => x.Sort);
- AddField(x => x.Key);
- AddField(x => x.IsActive);
- }
-
-
- ///
- public override IEnumerable GetUnlockedFieldNames()
- {
- foreach (BlueprintField field in UnlockedFields)
- {
- yield return field.FieldName.ToCamelCaseId();
- }
- }
-
-
- ///
- /// Get existing field or create a new one
- ///
- protected BlueprintField AddField(Expression> selector)
- {
- BlueprintField tempField = new(selector);
- BlueprintField storedField = UnlockedFields.FirstOrDefault(x => x.FieldName.Equals(tempField.FieldName, StringComparison.InvariantCultureIgnoreCase));
-
- if (storedField != null)
- {
- return storedField;
- }
-
- UnlockedFields.Add(tempField);
- return tempField;
- }
-
-
- ///
- /// Removes a field
- ///
- protected void RemoveField(Expression> selector)
- {
- BlueprintField tempField = new(selector);
-
- if (tempField != null)
- {
- UnlockedFields.RemoveAll(x => x.FieldName.Equals(tempField.FieldName, StringComparison.InvariantCultureIgnoreCase));
- }
- }
- }
-
-
- ///
- ///
- ///
- public abstract class Blueprint
- {
- ///
- /// Type of the associated entity
- ///
- public Type ContentType { get; private set; }
-
- public string Alias { get; private set; }
-
- ///
- /// String comparer for property name comparison
- ///
- protected readonly StringComparer StringComparer = StringComparer.InvariantCultureIgnoreCase;
-
-
- public Blueprint(Type type)
- {
- ContentType = type;
- Alias = type.Name.ToCamelCaseId();
- }
-
- ///
- /// Merges blueprint data into a model based on the configuration
- ///
- public abstract ZeroEntity Apply(ZeroEntity blueprint, ZeroEntity model);
-
- ///
- /// Get all fields which have been unlocked
- ///
- public abstract IEnumerable GetUnlockedFieldNames();
- }
-
-
- public class DefaultBlueprint : Blueprint where T : ZeroEntity, new()
- {
- public DefaultBlueprint(Action> expression = null) : base()
- {
- expression?.Invoke(this);
- }
- }
-}
diff --git a/old/zero.Core/Blueprints/BlueprintChildInterceptor.cs b/old/zero.Core/Blueprints/BlueprintChildInterceptor.cs
deleted file mode 100644
index 29e95118..00000000
--- a/old/zero.Core/Blueprints/BlueprintChildInterceptor.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Microsoft.Extensions.Logging;
-using System.Threading.Tasks;
-using zero.Core.Collections;
-using zero.Core.Database;
-using zero.Core.Entities;
-
-namespace zero.Core.Blueprints
-{
- public class BlueprintChildInterceptor : CollectionInterceptor
- {
- protected IZeroContext Context { get; set; }
-
- protected IZeroStore Store { get; set; }
-
- protected ILogger Logger { get; set; }
-
- protected IBlueprintService BlueprintService { get; set; }
-
-
- public BlueprintChildInterceptor(IZeroContext context, IZeroStore store, ILogger logger, IBlueprintService blueprintService)
- {
- Context = context;
- Store = store;
- Logger = logger;
- BlueprintService = blueprintService;
- }
-
- ///
- public override bool CanRun(InterceptorParameters args, ZeroIdEntity model)
- {
- // this interceptor does only work for child entities
- return args.Context.Store.ResolvedDatabase != Context.Options.Raven.Database;
- }
-
-
- ///
- public override Task> Deleting(InterceptorParameters args, ZeroIdEntity model)
- {
- if (model is not ZeroEntity || (model as ZeroEntity).Blueprint != null)
- {
- InterceptorResult result = new();
- result.Result = EntityResult.Fail("@blueprint.errors.cannotDeleteChild");
- return Task.FromResult(result);
- }
-
- return base.Deleting(args, model);
- }
- }
-}
diff --git a/old/zero.Core/Blueprints/BlueprintField.cs b/old/zero.Core/Blueprints/BlueprintField.cs
deleted file mode 100644
index d2ea2b01..00000000
--- a/old/zero.Core/Blueprints/BlueprintField.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.Text;
-using zero.Core.Entities;
-using zero.Core.Extensions;
-
-namespace zero.Core.Blueprints
-{
- public class BlueprintField where T : ZeroEntity
- {
- public Expression> Expression { get; private set; }
-
- public PropertyInfo PropertyInfo { get; private set; }
-
- public string FieldName { get; private set; }
-
- Action _applyHook { get; set; }
-
- Func _selectorFunc = null;
-
-
- internal BlueprintField(Expression> selector)
- {
- Expression = selector;
- FieldName = selector.GetPropertyPath(out MemberExpression member);
- PropertyInfo = member?.Member as PropertyInfo;
-
- if (PropertyInfo == null)
- {
- throw new ArgumentException("selector parameter has to be a property selector");
- }
-
- if (FieldName.IsNullOrEmpty())
- {
- throw new Exception("Could not find a matching field name");
- }
- }
-
-
- public virtual void Apply(T blueprint, T model)
- {
- if (_applyHook != null)
- {
- _applyHook(blueprint, model);
- return;
- }
-
- _selectorFunc ??= Expression.Compile();
- PropertyInfo.SetValue(model, _selectorFunc(blueprint));
- }
-
-
- public virtual void OnUpdate(Action onUpdate)
- {
- _applyHook = onUpdate;
- }
- }
-}
diff --git a/old/zero.Core/Blueprints/BlueprintInterceptor.cs b/old/zero.Core/Blueprints/BlueprintInterceptor.cs
deleted file mode 100644
index 43d883f3..00000000
--- a/old/zero.Core/Blueprints/BlueprintInterceptor.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using Microsoft.Extensions.Logging;
-using Raven.Client.Documents;
-using Raven.Client.Documents.Session;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using zero.Core.Collections;
-using zero.Core.Database;
-using zero.Core.Entities;
-using zero.Core.Extensions;
-
-namespace zero.Core.Blueprints
-{
- public class BlueprintInterceptor : CollectionInterceptor
- {
- protected IZeroContext Context { get; set; }
-
- protected IZeroStore Store { get; set; }
-
- protected ILogger Logger { get; set; }
-
- protected IBlueprintService BlueprintService { get; set; }
-
- IList Apps { get; set; }
-
-
- public BlueprintInterceptor(IZeroContext context, IZeroStore store, ILogger logger, IBlueprintService blueprintService)
- {
- Context = context;
- Store = store;
- Logger = logger;
- BlueprintService = blueprintService;
- }
-
- ///
- public override bool CanRun(InterceptorParameters args, ZeroIdEntity model)
- {
- // we do only update children if we operate on the shared database
- return args.Context.Store.ResolvedDatabase == Context.Options.Raven.Database;
- }
-
-
- ///
- public override async Task Saved(InterceptorParameters args, ZeroIdEntity model)
- {
- if (model is not ZeroEntity || !BlueprintService.TryGetBlueprint(model, out Blueprint blueprint))
- {
- return;
- }
-
- ZeroEntity entity = model as ZeroEntity;
- int count = 0;
-
- foreach (Application app in await GetApplications())
- {
- using ZeroContextScope scope = Context.CreateScope(app);
- IZeroDocumentSession session = scope.Store.Session(scope.Database);
-
- ZeroEntity child = await session.LoadAsync(model.Id);
-
- if (child == null)
- {
- child = entity.Clone();
- child.Blueprint = new() { Id = model.Id };
- }
- else
- {
- blueprint.Apply(entity, child);
- }
-
- count += 1;
-
- // now we have to store the child
- // but this will not work with the session as we need to run the scoped interceptors,
- // therefore we need access to the collection
-
- await session.StoreAsync(child);
- await session.SaveChangesAsync();
- }
-
- Logger.LogDebug("Blueprint: Synced {count} children for {name} ({id})", count, entity.Name, model.Id);
- }
-
-
- ///
- public override async Task Deleted(InterceptorParameters args, ZeroIdEntity model)
- {
- if (model is not ZeroEntity || !BlueprintService.TryGetBlueprint(model, out Blueprint blueprint))
- {
- return;
- }
-
- ZeroEntity entity = model as ZeroEntity;
- int count = 0;
-
- foreach (Application app in await GetApplications())
- {
- using ZeroContextScope scope = Context.CreateScope(app);
- IZeroDocumentSession session = scope.Store.Session(scope.Database);
-
- count += 1;
-
- // now we have to delete the child
- // but this will not work with the session as we need to run the scoped interceptors,
- // therefore we need access to the collection
- session.Delete(entity.Id);
- await session.SaveChangesAsync();
- }
-
- Logger.LogDebug("Blueprint: Deleted {count} children for {name} ({id})", count, entity.Name, entity.Id);
- }
-
-
- ///
- /// Get all applications to choose from
- ///
- async Task> GetApplications()
- {
- if (Apps != null)
- {
- return Apps;
- }
-
- IAsyncDocumentSession session = Store.Session(global: true);
- Apps = await session.Query().ToListAsync();
- return Apps;
- }
-
-
-
-
- ///
- //public override async Task Saved(SaveParameters args)
- //{
-
- // //Logger.LogInformation("Route updates completed (+{added}/~{updated}/-{removed}) for {model} (id: {id})", countRoutes - countUpdatedRoutes, countUpdatedRoutes, obsoleteRoutes.Count, args.Model.Name, args.Model.Id);
- //}
- }
-}
diff --git a/old/zero.Core/Blueprints/BlueprintService.cs b/old/zero.Core/Blueprints/BlueprintService.cs
deleted file mode 100644
index 58c241dd..00000000
--- a/old/zero.Core/Blueprints/BlueprintService.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Options;
-
-namespace zero.Core.Blueprints
-{
- public class BlueprintService : IBlueprintService
- {
- protected IZeroOptions Options { get; set; }
-
- protected IReadOnlyCollection Blueprints { get; set; }
-
-
- public BlueprintService(IZeroOptions options)
- {
- Options = options;
- Blueprints = Options.Blueprints.GetAllItems();
- }
-
-
- ///
- public bool IsEnabled(T model) => IsEnabled(model.GetType());
-
-
- ///
- public bool IsEnabled()=> IsEnabled(typeof(T));
-
-
- ///
- public bool IsEnabled(Type type) => Blueprints.Any(x => x.ContentType.IsAssignableFrom(type));
-
-
- ///
- public bool TryGetBlueprint(T model, out Blueprint blueprint) => TryGetBlueprint(model.GetType(), out blueprint);
-
-
- ///
- public bool TryGetBlueprint(out Blueprint blueprint) => TryGetBlueprint(typeof(T), out blueprint);
-
-
- ///
- public bool TryGetBlueprint(Type type, out Blueprint blueprint)
- {
- blueprint = Blueprints.FirstOrDefault(x => x.ContentType.IsAssignableFrom(type));
- return blueprint != null;
- }
- }
-
-
- public interface IBlueprintService
- {
- ///
- /// Check whether blueprinting functionality is enabled for a certain entity
- ///
- bool IsEnabled();
-
- ///
- /// Check whether blueprinting functionality is enabled for a certain entity
- ///
- bool IsEnabled(T model);
-
- bool IsEnabled(Type type);
-
- bool TryGetBlueprint(T model, out Blueprint blueprint);
-
- bool TryGetBlueprint(out Blueprint blueprint);
-
- bool TryGetBlueprint(Type type, out Blueprint blueprint);
- }
-}
diff --git a/old/zero.Core/Collections/Interceptors/CollectionInterceptor.cs b/old/zero.Core/Collections/Interceptors/CollectionInterceptor.cs
deleted file mode 100644
index c5d72504..00000000
--- a/old/zero.Core/Collections/Interceptors/CollectionInterceptor.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System.Threading.Tasks;
-using zero.Core.Entities;
-
-namespace zero.Core.Collections
-{
- public abstract partial class CollectionInterceptor : ICollectionInterceptor where T : ZeroIdEntity
- {
- ///
- public virtual bool CanRun(InterceptorParameters args, T model) => true;
-
- ///
- public virtual Task> Creating(InterceptorParameters args, T model) => Task.FromResult>(default);
-
- ///
- public virtual Task> Updating(InterceptorParameters args, T model) => Task.FromResult>(default);
-
- ///
- public virtual Task> Saving(InterceptorParameters args, T model) => Task.FromResult>(default);
-
- ///
- public virtual Task> Deleting(InterceptorParameters args, T model) => Task.FromResult>(default);
-
- ///
- public virtual Task Created(InterceptorParameters args, T model) => Task.CompletedTask;
-
- ///
- public virtual Task Updated(InterceptorParameters args, T model) => Task.CompletedTask;
-
- ///
- public virtual Task Saved(InterceptorParameters args, T model) => Task.CompletedTask;
-
- ///
- public virtual Task Deleted(InterceptorParameters args, T model) => Task.CompletedTask;
- }
-
-
- public abstract partial class CollectionInterceptor : CollectionInterceptor, ICollectionInterceptor
- {
- ///
- public override bool CanRun(InterceptorParameters args, ZeroIdEntity model) => base.CanRun(args, model);
- }
-
- public interface ICollectionInterceptor : ICollectionInterceptor { }
-
- public interface ICollectionInterceptor where T : ZeroIdEntity
- {
- ///
- /// Whether any of the interceptor methods is allowed to run based on the parameters
- ///
- bool CanRun(InterceptorParameters args, T model);
-
- ///
- /// Called after an entity has been stored but before the session has saved its changes
- ///
- Task Created(InterceptorParameters args, T model);
-
- ///
- /// Called before an entity is stored and validated
- ///
- Task> Creating(InterceptorParameters args, T model);
-
- ///
- /// Called after an entity has been deleted but before the session has saved its changes
- ///
- Task Deleted(InterceptorParameters args, T model);
-
- ///
- /// Called before an entity is deleted
- ///
- Task> Deleting(InterceptorParameters args, T model);
-
- ///
- /// Called after an entity has been updated but before the session has saved its changes
- ///
- Task Updated(InterceptorParameters args, T model);
-
- ///
- /// Called before an entity is stored and validated
- ///
- Task> Updating(InterceptorParameters args, T model);
-
- ///
- /// Called after an entity has been saved (created or updated) but before the session has saved its changes
- ///
- Task Saved(InterceptorParameters args, T model);
-
- ///
- /// Called before an entity is stored and validated
- ///
- Task> Saving(InterceptorParameters args, T model);
- }
-}
diff --git a/old/zero.Core/Collections/Interceptors/CollectionInterceptorShim.cs b/old/zero.Core/Collections/Interceptors/CollectionInterceptorShim.cs
deleted file mode 100644
index c244c429..00000000
--- a/old/zero.Core/Collections/Interceptors/CollectionInterceptorShim.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System.Threading.Tasks;
-using zero.Core.Entities;
-
-namespace zero.Core.Collections
-{
- public sealed class CollectionInterceptorShim : CollectionInterceptor where T : ZeroIdEntity
- {
- ICollectionInterceptor _base;
-
- public CollectionInterceptorShim(ICollectionInterceptor baseInterceptor)
- {
- _base = baseInterceptor;
- }
-
- InterceptorResult Result(InterceptorResult result)
- {
- return result == null ? null : new InterceptorResult()
- {
- InterceptorHash = result.InterceptorHash,
- Parameters = result.Parameters,
- Prevent = result.Prevent,
- Result = result.Result != null ? EntityResult.From(result.Result, result.Result.Model as T) : null
- };
- }
-
- ///
- public override bool CanRun(InterceptorParameters args, T model) => _base.CanRun(args, model);
-
- ///
- public override async Task> Creating(InterceptorParameters args, T model) => Result(await _base.Creating(args, model));
-
- ///
- public override async Task> Updating(InterceptorParameters args, T model) => Result(await _base.Updating(args, model));
-
- ///
- public override async Task> Saving(InterceptorParameters args, T model) => Result(await _base.Saving(args, model));
-
- ///
- public override async Task> Deleting(InterceptorParameters args, T model) => Result(await _base.Deleting(args, model));
-
- ///
- public override Task Created(InterceptorParameters args, T model) => _base.Created(args, model);
-
- ///
- public override Task Updated(InterceptorParameters args, T model) => _base.Updated(args, model);
-
- ///
- public override Task Saved(InterceptorParameters args, T model) => _base.Saved(args, model);
-
- ///
- public override Task Deleted(InterceptorParameters args, T model) => _base.Deleted(args, model);
- }
-}
diff --git a/old/zero.Core/Collections/Interceptors/InterceptorResult.cs b/old/zero.Core/Collections/Interceptors/InterceptorResult.cs
deleted file mode 100644
index 30023eaf..00000000
--- a/old/zero.Core/Collections/Interceptors/InterceptorResult.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System.Collections.Generic;
-using zero.Core.Entities;
-
-namespace zero.Core.Collections
-{
- public class InterceptorResult
- {
- ///
- /// Autoset. Hash used to match interceptors in order to correctly pass parameters
- ///
- internal string InterceptorHash { get; set; }
-
- ///
- /// Prevent further interceptors from running for this operation (only valid for the current interception type, e.g. Update/Created/Purge/...)
- ///
- public bool Prevent { get; set; }
-
- ///
- /// Set a result. This will prevent further execution of the operation and cancels all subsequent interceptors
- ///
- public EntityResult Result { get; set; }
-
- ///
- /// Additional parameters which can be passed to the interceptor after the operation was completed
- ///
- public Dictionary Parameters { get; set; } = new();
- }
-}
diff --git a/old/zero.Core/Constants.cs b/old/zero.Core/Constants.cs
deleted file mode 100644
index 21128a8b..00000000
--- a/old/zero.Core/Constants.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-namespace zero.Core
-{
- public static class Constants
- {
- public const string ErrorFieldNone = "__zero_no_field";
-
- public static class Tabs
- {
- public const string General = "general";
- }
-
- public static class Auth
- {
- public const string SystemUser = "system";
- public const string DefaultScheme = "zeroScheme";
- public const string BackofficeDisplayName = "Zero Bacckoffice";
- public const string BackofficeScheme = "zeroBackoffice";
- public const string BackofficeCookieName = "zero.be.session";
- public const string DefaultCookieName = "zero.session";
-
- public static class Claims
- {
- public const string IsZero = "zero.claim.iszero";
- public const string IsSuper = "zero.claim.issuper";
- public const string UserId = "zero.claim.userid";
- public const string UserName = "zero.claim.username";
- public const string Role = "zero.claim.rolealias";
- public const string SecurityStamp = "zero.claim.securitystamp";
- public const string Email = "zero.claim.email";
- public const string Permission = "zero.claim.permission";
- public const string DefaultAppId = "zero.claim.defaultAppId";
- public const string AppId = "zero.claim.appId";
- public const string TicketExpires = "zero.claim.ticketExpires";
- }
- }
-
- public static class Database
- {
- public const string ReservationPrefix = "zero.";
- public const string CoreIdPrefix = "core.";
- public const string Expires = Raven.Client.Constants.Documents.Metadata.Expires;
- }
-
- public static class Sections
- {
- public const string Dashboard = "dashboard";
- public const string Pages = "pages";
- public const string Spaces = "spaces";
- public const string Media = "media";
- public const string Settings = "settings";
- }
-
- public static class Settings
- {
- public const string Updates = "updates";
- public const string Applications = "applications";
- public const string Users = "users";
- public const string Languages = "languages";
- public const string Translations = "translations";
- public const string Countries = "countries";
- public const string Mails = "mailTemplates";
- public const string Integrations = "integrations";
- public const string Logging = "logs";
- public const string Plugins = "plugins";
- public const string CreatePlugin = "createplugin";
- }
-
- public static class PermissionCollections
- {
- public const string Sections = "permissionCollectionSections";
- public const string Spaces = "permissionCollectionSpaces";
- public const string Settings = "permisssionCollectionSettings";
- public const string Modules = "permissionCollectionModules";
- }
-
- public static class Pages
- {
- public const string FolderAlias = "zero.folder";
- public const string DefaultRootPageTypeAlias = "root";
- public const string PageRouteProviderAlias = "zero.pages";
- }
-
- public static class Routing
- {
- public const string InternalRoutePrefix = "/__zero/";
-
- public const string ErrorRoute = InternalRoutePrefix + "error";
- }
- }
-}
diff --git a/old/zero.Core/Cultures/CultureResolver.cs b/old/zero.Core/Cultures/CultureResolver.cs
deleted file mode 100644
index a0b7b9a9..00000000
--- a/old/zero.Core/Cultures/CultureResolver.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using FluentValidation;
-using Microsoft.Extensions.Logging;
-using Raven.Client.Documents;
-using Raven.Client.Documents.Session;
-using System;
-using System.Globalization;
-using System.Threading.Tasks;
-using zero.Core.Database;
-using zero.Core.Entities;
-using zero.Core.Extensions;
-
-namespace zero.Core.Cultures
-{
- public class CultureResolver : ICultureResolver
- {
- protected ILogger Logger { get; private set; }
-
-
- public CultureResolver(ILogger logger)
- {
- Logger = logger;
- }
-
-
- ///
- public async Task Resolve(IZeroContext context)
- {
- // TODO this is just fake, we need to correctly resolve culture here
-
- if (context.IsBackofficeRequest)
- {
-
- }
- else
- {
- var session = context.Store.Session();
- Language language = await session.Query().FirstOrDefaultAsync();
-
- if (language == null)
- {
- Logger.LogWarning("Could not set request culture as there is no available Language stored");
- return CultureInfo.CurrentCulture;
- }
-
- try
- {
- CultureInfo culture = CultureInfo.CreateSpecificCulture(language.Code);
-
- if (culture.ThreeLetterISOLanguageName.IsNullOrEmpty())
- {
- throw new Exception("ThreeLetterISOLanguageName is empty");
- }
-
- CultureInfo.CurrentCulture = culture;
- CultureInfo.CurrentUICulture = culture;
- ValidatorOptions.Global.LanguageManager.Culture = culture;
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Could not create culture from Language code {code}", language.Code);
- return CultureInfo.CurrentCulture;
- }
- }
-
- return CultureInfo.CurrentCulture;
- }
- }
-
-
- public interface ICultureResolver
- {
- ///
- /// Resolves the current application from either the backoffice user (in case it is backoffice request)
- /// or the domain (in case it is frontend request).
- ///
- Task Resolve(IZeroContext context);
- }
-}
diff --git a/old/zero.Core/Database/Indexes/Backoffice/zero_Countries.cs b/old/zero.Core/Database/Indexes/Backoffice/zero_Countries.cs
deleted file mode 100644
index ea6b043b..00000000
--- a/old/zero.Core/Database/Indexes/Backoffice/zero_Countries.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class zero_Countries : ZeroIndex
- {
- protected override void Create()
- {
- Map = items => items.Select(item => new
- {
- Name = item.Name,
- IsPreferred = item.IsPreferred
- });
-
- Index(x => x.Name, FieldIndexing.Search);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/MediaFolder_ByHierarchy.cs b/old/zero.Core/Database/Indexes/MediaFolder_ByHierarchy.cs
deleted file mode 100644
index 7146ba68..00000000
--- a/old/zero.Core/Database/Indexes/MediaFolder_ByHierarchy.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class MediaFolder_ByHierarchy : ZeroIndex
- {
- public class Result : ZeroIdEntity, IZeroDbConventions
- {
- public string Name { get; set; }
-
- public List Path { get; set; } = new List();
- }
-
-
- public class PathResult
- {
- public string Id { get; set; }
-
- public string Name { get; set; }
- }
-
-
- protected override void Create()
- {
- Map = items => items.Select(item => new Result
- {
- Id = item.Id,
- Name = item.Name,
- Path = Recurse(item, x => LoadDocument(x.ParentId))
- .Where(x => x != null && x.Id != null && x.Id != item.Id)
- .Reverse()
- .Select(current => new PathResult()
- {
- Id = current.Id,
- Name = current.Name
- })
- .ToList()
- });
-
- StoreAllFields(FieldStorage.Yes);
- //Index(x => x.ChannelId, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/MediaFolders_WithChildren.cs b/old/zero.Core/Database/Indexes/MediaFolders_WithChildren.cs
deleted file mode 100644
index 57997362..00000000
--- a/old/zero.Core/Database/Indexes/MediaFolders_WithChildren.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class MediaFolders_WithChildren : ZeroIndex
- {
- public class Result : ZeroIdEntity
- {
- public string ParentId { get; set; }
-
- public string Name { get; set; }
-
- public string[] ChildrenIds { get; set; }
- }
-
-
- protected override void Create()
- {
- Map = items => items.Where(x => x.ParentId != null).Select(item => new Result
- {
- Id = item.Id,
- ParentId = item.ParentId,
- Name = item.Name,
- ChildrenIds = new string[] { }
- });
-
- Reduce = results => results.GroupBy(x => new { x.ParentId }).Select(group => new Result()
- {
- Id = group.Key.ParentId,
- ParentId = group.Key.ParentId,
- Name = String.Empty,
- ChildrenIds = group.Select(x => x.Id).ToArray()
- });
-
- StoreAllFields(FieldStorage.Yes);
- //Index(x => x.ChannelId, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/Media_ByChildren.cs b/old/zero.Core/Database/Indexes/Media_ByChildren.cs
deleted file mode 100644
index c25d97bc..00000000
--- a/old/zero.Core/Database/Indexes/Media_ByChildren.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class Media_ByChildren : ZeroMultiMapIndex
- {
- public class Result : ZeroIdEntity, IZeroDbConventions
- {
- public string ParentId { get; set; }
-
- public int ChildrenCount { get; set; }
-
- public string[] ChildrenIds { get; set; }
- }
-
-
- protected override void Create()
- {
- AddMap(items => items.Select(item => new Result()
- {
- Id = item.Id,
- ParentId = item.FolderId,
- ChildrenCount = 1,
- ChildrenIds = new string[] { }
- }));
-
- AddMap(items => items.Select(item => new Result()
- {
- Id = item.Id,
- ParentId = item.ParentId,
- ChildrenCount = 1,
- ChildrenIds = new string[] { }
- }));
-
- Reduce = results => results.GroupBy(x => new { x.ParentId }).Select(group => new Result()
- {
- Id = null,
- ParentId = group.Key.ParentId,
- ChildrenCount = group.Sum(x => x.ChildrenCount),
- ChildrenIds = group.Select(x => x.Id).ToArray()
- });
-
- StoreAllFields(FieldStorage.Yes);
- Index(x => x.ParentId, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/Media_ByParent.cs b/old/zero.Core/Database/Indexes/Media_ByParent.cs
deleted file mode 100644
index fd137988..00000000
--- a/old/zero.Core/Database/Indexes/Media_ByParent.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class Media_ByParent : ZeroMultiMapIndex
- {
- protected override void Create()
- {
- AddMap(items => items.Select(item => new MediaListItem
- {
- Id = item.Id,
- ParentId = item.ParentId,
- CreatedDate = item.CreatedDate,
- IsFolder = true,
- Name = item.Name,
- Image = null,
- Children = 0,
- Size = 0,
- IsShared = item.Blueprint != null,
- AspectRatio = 0
- }));
-
- AddMap(items => items.Select(item => new MediaListItem
- {
- Id = item.Id,
- ParentId = item.FolderId,
- CreatedDate = item.CreatedDate,
- IsFolder = false,
- Name = item.Name,
- Image = item.PreviewSource,
- Children = 0,
- Size = item.Size,
- IsShared = item.Blueprint != null,
- AspectRatio = item.ImageMeta != null ? (float)item.ImageMeta.Width / item.ImageMeta.Height : 0
- }));
-
- StoreAllFields(FieldStorage.Yes);
- Index(x => x.ParentId, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/Pages_AsHistory.cs b/old/zero.Core/Database/Indexes/Pages_AsHistory.cs
deleted file mode 100644
index e4311f84..00000000
--- a/old/zero.Core/Database/Indexes/Pages_AsHistory.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class Pages_AsHistory : ZeroIndex
- {
- public class Result : ZeroIdEntity, IZeroDbConventions
- {
- public DateTimeOffset LastModified { get; set; }
- }
-
-
- protected override void Create()
- {
- Map = items => items
- .Select(x => new Result()
- {
- Id = x.Id,
- LastModified = x.LastModifiedDate
- });
-
- StoreAllFields(FieldStorage.Yes);
- //Index(x => x.ChannelId, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/Pages_ByHierarchy.cs b/old/zero.Core/Database/Indexes/Pages_ByHierarchy.cs
deleted file mode 100644
index 5481431d..00000000
--- a/old/zero.Core/Database/Indexes/Pages_ByHierarchy.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class Pages_ByHierarchy : ZeroIndex
- {
- public class Result : ZeroIdEntity, IZeroDbConventions
- {
- public string Name { get; set; }
-
- public List Path { get; set; } = new List();
-
- public string[] PathIds { get; set; } = Array.Empty();
- }
-
-
- public class PathResult
- {
- public string Id { get; set; }
-
- public string Name { get; set; }
- }
-
-
- protected override void Create()
- {
- Map = items => items
- .Select(item => new
- {
- Item = item,
- Path = Recurse(item, x => LoadDocument(x.ParentId)).Where(x => x != null && x.Id != null && x.Id != item.Id).Reverse()
- })
- .Select(item => new Result
- {
- Id = item.Item.Id,
- Name = item.Item.Name,
- Path = item.Path.Select(current => new PathResult() { Id = current.Id, Name = current.Name }).ToList(),
- PathIds = item.Path.Select(current => current.Id).ToArray()
- });
-
- StoreAllFields(FieldStorage.Yes);
- Index("PathIds", FieldIndexing.Exact);
- //Index(x => x.ChannelId, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/Pages_ByType.cs b/old/zero.Core/Database/Indexes/Pages_ByType.cs
deleted file mode 100644
index 3fc94dfa..00000000
--- a/old/zero.Core/Database/Indexes/Pages_ByType.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class Pages_ByType : ZeroIndex
- {
- protected override void Create()
- {
- Map = items => items.Select(item => new
- {
- PageTypeAlias = item.PageTypeAlias
- });
-
- Index(x => x.PageTypeAlias, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/Pages_WithChildren.cs b/old/zero.Core/Database/Indexes/Pages_WithChildren.cs
deleted file mode 100644
index 442e4138..00000000
--- a/old/zero.Core/Database/Indexes/Pages_WithChildren.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using Raven.Client.Documents.Indexes;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Database.Indexes
-{
- public class Pages_WithChildren : ZeroIndex
- {
- public class Result : ZeroIdEntity, IZeroDbConventions
- {
- public string ParentId { get; set; }
-
- public string Name { get; set; }
-
- public string[] ChildrenIds { get; set; }
- }
-
-
- protected override void Create()
- {
- Map = items => items.Where(x => x.ParentId != null).Select(item => new Result
- {
- Id = item.Id,
- ParentId = item.ParentId,
- Name = item.Name,
- ChildrenIds = new string[] { }
- });
-
- Reduce = results => results.GroupBy(x => new { x.ParentId }).Select(group => new Result()
- {
- Id = group.Key.ParentId,
- ParentId = group.Key.ParentId,
- Name = String.Empty,
- ChildrenIds = group.Select(x => x.Id).ToArray()
- });
-
- StoreAllFields(FieldStorage.Yes);
- //Index(x => x.ChannelId, FieldIndexing.Exact);
- }
- }
-}
diff --git a/old/zero.Core/Database/Indexes/RouteRedirects_ByUrl.cs b/old/zero.Core/Database/Indexes/RouteRedirects_ByUrl.cs
deleted file mode 100644
index ffb5e55a..00000000
--- a/old/zero.Core/Database/Indexes/RouteRedirects_ByUrl.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Linq;
-using zero.Core.Routing;
-
-namespace zero.Core.Database.Indexes
-{
- public class RouteRedirects_ByUrl : ZeroIndex
- {
- protected override void Create()
- {
- Map = items => items
- .Select(x => new
- {
- IsAutomated = x.IsAutomated,
- SourceUrl = x.SourceUrl,
- TargetUrl = x.TargetUrl
- });
- }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Database/Indexes/Routes_ByDependencies.cs b/old/zero.Core/Database/Indexes/Routes_ByDependencies.cs
deleted file mode 100644
index 6cf7e204..00000000
--- a/old/zero.Core/Database/Indexes/Routes_ByDependencies.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Linq;
-using zero.Core.Routing;
-
-namespace zero.Core.Database.Indexes
-{
- public class Routes_ByDependencies : ZeroIndex
- {
- protected override void Create()
- {
- Map = items => items
- .Select(x => new
- {
- Dependencies = x.Dependencies
- });
- }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Database/Indexes/Routes_ForResolver.cs b/old/zero.Core/Database/Indexes/Routes_ForResolver.cs
deleted file mode 100644
index 4a78352c..00000000
--- a/old/zero.Core/Database/Indexes/Routes_ForResolver.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Linq;
-using zero.Core.Routing;
-
-namespace zero.Core.Database.Indexes
-{
- public class Routes_ForResolver : ZeroIndex
- {
- protected override void Create()
- {
- Map = items => items
- .Select(x => new
- {
- Url = x.Url,
- AllowSuffix = x.AllowSuffix
- });
- }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Entities/Applications/Application.cs b/old/zero.Core/Entities/Applications/Application.cs
deleted file mode 100644
index 61e565ce..00000000
--- a/old/zero.Core/Entities/Applications/Application.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Collections.Generic;
-using zero.Core.Attributes;
-
-namespace zero.Core.Entities
-{
- ///
- /// An application is a website. zero can host multiple websites at once which share common assets
- ///
- [Collection("Applications")]
- public class Application : ZeroEntity
- {
- ///
- /// Raven database name for application data
- ///
- public string Database { get; set; }
-
- ///
- /// Full company or product name
- ///
- public string FullName { get; set; }
-
- ///
- /// Generic contact email. Can be used in various locations
- ///
- public string Email { get; set; }
-
- ///
- /// Image of the application
- ///
- public string ImageId { get; set; }
-
- ///
- /// Simple image of the application (can be used as favicon)
- ///
- public string IconId { get; set; }
-
- ///
- /// All assigned domains for this application
- ///
- public Uri[] Domains { get; set; } = Array.Empty();
-
- ///
- /// Features which are enabled for this application.
- /// Can be user-defined and affect both backoffice and frontend
- ///
- public List Features { get; set; } = new();
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Entities/Country.cs b/old/zero.Core/Entities/Country.cs
deleted file mode 100644
index d80547a4..00000000
--- a/old/zero.Core/Entities/Country.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace zero.Core.Entities
-{
- public class Country : ZeroEntity
- {
- ///
- /// Preferred countries are displayed on top in lists
- ///
- public bool IsPreferred { get; set; }
-
- ///
- /// Country code (ISO 3166-1)
- ///
- public string Code { get; set; }
- }
-}
diff --git a/old/zero.Core/Entities/Culture.cs b/old/zero.Core/Entities/Culture.cs
deleted file mode 100644
index df81cafb..00000000
--- a/old/zero.Core/Entities/Culture.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace zero.Core.Entities
-{
- public class Culture
- {
- public string Code { get; set; }
-
- public string Name { get; set; }
- }
-}
diff --git a/old/zero.Core/Entities/Language.cs b/old/zero.Core/Entities/Language.cs
deleted file mode 100644
index 63aa61ce..00000000
--- a/old/zero.Core/Entities/Language.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using zero.Core.Attributes;
-
-namespace zero.Core.Entities
-{
- [Collection("Languages")]
- public class Language : ZeroEntity
- {
- ///
- /// Language code (ISO 3166-1)
- ///
- public string Code { get; set; }
-
- ///
- /// Whether this is the default language
- ///
- public bool IsDefault { get; set; }
-
- ///
- /// Whether this language is optional and does not have to be filled out
- ///
- public bool IsOptional { get; set; }
-
- ///
- /// If this language is inherited it gets all missing properties from its parent
- ///
- public string InheritedLanguageId { get; set; }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Entities/MailTemplate.cs b/old/zero.Core/Entities/MailTemplate.cs
deleted file mode 100644
index 30aa4510..00000000
--- a/old/zero.Core/Entities/MailTemplate.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using zero.Core.Attributes;
-
-namespace zero.Core.Entities
-{
- [Collection("MailTemplates")]
- public class MailTemplate : ZeroEntity
- {
- ///
- /// Email address of the sender (overrides email from application)
- ///
- public string SenderEmail { get; set; }
-
- ///
- /// Name of the sender (overrides name from application)
- ///
- public string SenderName { get; set; }
-
- ///
- /// Email address of the recipient. This is only necessary for templates which do not have a dynamic recipient (e.g. reports).
- ///
- public string RecipientEmail { get; set; }
-
- ///
- /// Additional comma-separated emails to send a copy to
- ///
- public string Cc { get; set; }
-
- ///
- /// Additional comma-separated emails to send a hidden copy to
- ///
- public string Bcc { get; set; }
-
- ///
- /// Email subject (can contain placeholders)
- ///
- public string Subject { get; set; }
-
- ///
- /// Email body (can contain placeholders)
- ///
- public string Body { get; set; }
-
- ///
- /// Preheader which is displayed in the preview pane (can contain placeholders)
- ///
- public string Preheader { get; set; }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Entities/Media/Media.cs b/old/zero.Core/Entities/Media/Media.cs
deleted file mode 100644
index 722c39d4..00000000
--- a/old/zero.Core/Entities/Media/Media.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using zero.Core.Attributes;
-
-namespace zero.Core.Entities
-{
- ///
- /// A media file (can contain an image or other media like videos and documents)
- ///
- [Collection("Media")]
- public class Media : ZeroEntity
- {
- ///
- /// Id/name of the phyiscal folder which is stored on disk/cloud
- ///
- public string FileId { get; set; }
-
- ///
- /// Id of the media folder
- ///
- public string FolderId { get; set; }
-
- ///
- /// Alternative text which is used when the image can't be loaded
- ///
- public string AlternativeText { get; set; }
-
- ///
- /// Additional caption text
- ///
- public string Caption { get; set; }
-
- ///
- /// Path of the media item
- ///
- public string Source { get; set; }
-
- ///
- /// For images this is the source for a 100x100px thumbnail
- ///
- public string ThumbnailSource { get; set; }
-
- ///
- /// For images this is the source for a [proportional]x210px thumbnail
- ///
- public string PreviewSource { get; set; }
-
- ///
- /// Filesize in bytes
- ///
- public long Size { get; set; }
-
- ///
- /// Meta data for images
- ///
- public MediaImageMeta ImageMeta { get; set; }
-
- ///
- /// Optional focal point for an image
- ///
- public MediaFocalPoint FocalPoint { get; set; }
-
- ///
- /// Type of the media
- ///
- public MediaType Type { get; set; }
- }
-
-
- public enum MediaSourceSize
- {
- Original = 0,
- Preview = 1,
- Thumbnail = 2
- }
-}
diff --git a/old/zero.Core/Entities/Media/MediaFocalPoint.cs b/old/zero.Core/Entities/Media/MediaFocalPoint.cs
deleted file mode 100644
index 2142594f..00000000
--- a/old/zero.Core/Entities/Media/MediaFocalPoint.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace zero.Core.Entities
-{
- ///
- /// The focal point sets the point of interest in an image with x/y coordinates from 0-1
- ///
- public class MediaFocalPoint
- {
- public decimal Left { get; set; }
-
- public decimal Top { get; set; }
- }
-}
diff --git a/old/zero.Core/Entities/Media/MediaFolder.cs b/old/zero.Core/Entities/Media/MediaFolder.cs
deleted file mode 100644
index e92bda9f..00000000
--- a/old/zero.Core/Entities/Media/MediaFolder.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using zero.Core.Attributes;
-
-namespace zero.Core.Entities
-{
- ///
- /// A media folder contains media and other folders
- ///
- [Collection("MediaFolders")]
- public class MediaFolder : ZeroEntity
- {
- ///
- /// Parent folder id
- ///
- public string ParentId { get; set; }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Entities/Media/MediaImageMeta.cs b/old/zero.Core/Entities/Media/MediaImageMeta.cs
deleted file mode 100644
index e0558dcd..00000000
--- a/old/zero.Core/Entities/Media/MediaImageMeta.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-
-namespace zero.Core.Entities
-{
- ///
- /// Metadata for images
- ///
- public class MediaImageMeta
- {
- ///
- /// Width in pixels
- ///
- public int Width { get; set; }
-
- ///
- /// Height in pixels
- ///
- public int Height { get; set; }
-
- ///
- /// Resolution factor
- ///
- public double DPI { get; set; }
-
- ///
- /// Date the image was taken
- ///
- public DateTimeOffset? CreatedDate { get; set; }
-
- ///
- /// Original color space of the image
- ///
- public string ColorSpace { get; set; }
-
- ///
- /// Whether this image contains transparent pixels
- ///
- public bool HasTransparency { get; set; }
-
- ///
- /// How many frames contains this image (for animation)
- ///
- public int Frames { get; set; } = 1;
- }
-}
diff --git a/old/zero.Core/Entities/Media/MediaListItem.cs b/old/zero.Core/Entities/Media/MediaListItem.cs
deleted file mode 100644
index c812073d..00000000
--- a/old/zero.Core/Entities/Media/MediaListItem.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-namespace zero.Core.Entities
-{
- public class MediaListItem : ZeroIdEntity
- {
- public string ParentId { get; set; }
-
- public string Name { get; set; }
-
- public DateTimeOffset CreatedDate { get; set; }
-
- public bool IsFolder { get; set; }
-
- public string Image { get; set; }
-
- public long Size { get; set; }
-
- public int Children { get; set; }
-
- public bool HasTransparency { get; set; }
-
- public float AspectRatio { get; set; }
-
- public bool IsShared { get; set; }
- }
-}
diff --git a/old/zero.Core/Entities/Media/MediaListQuery.cs b/old/zero.Core/Entities/Media/MediaListQuery.cs
deleted file mode 100644
index c36f07f5..00000000
--- a/old/zero.Core/Entities/Media/MediaListQuery.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace zero.Core.Entities
-{
- public class MediaListQuery : ListQuery
- {
- public string FolderId { get; set; }
- }
-
-
- public class MediaListItemQuery : ListQuery
- {
- public string FolderId { get; set; }
-
- public bool SearchIsGlobal { get; set; }
- }
-}
diff --git a/old/zero.Core/Entities/Media/MediaType.cs b/old/zero.Core/Entities/Media/MediaType.cs
deleted file mode 100644
index b33ff27b..00000000
--- a/old/zero.Core/Entities/Media/MediaType.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace zero.Core.Entities
-{
- public enum MediaType
- {
- File = 0,
- Image = 1
- }
-}
diff --git a/old/zero.Core/Entities/Refs/MediaRef.cs b/old/zero.Core/Entities/Refs/MediaRef.cs
deleted file mode 100644
index b610e7fb..00000000
--- a/old/zero.Core/Entities/Refs/MediaRef.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-namespace zero.Core.Entities
-{
- public class MediaRef : Ref
- {
- public bool IsCore { get; set; }
-
- public MediaRef() : base() { }
- public MediaRef(string id, bool isCore) : base(id)
- {
- IsCore = isCore;
- }
-
- public static implicit operator string(MediaRef reference) => reference.Id;
-
- public static implicit operator MediaRef(string id) => new MediaRef(id, false);
- }
-}
diff --git a/old/zero.Core/Entities/Refs/Ref.cs b/old/zero.Core/Entities/Refs/Ref.cs
deleted file mode 100644
index 2934ad5f..00000000
--- a/old/zero.Core/Entities/Refs/Ref.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-namespace zero.Core.Entities
-{
- public class Ref : Ref where T : ZeroIdEntity
- {
- public Ref() : base() { }
- public Ref(string id) : base(id) { }
-
- public static implicit operator Ref(string id) => new Ref(id);
-
- public static implicit operator string(Ref reference) => reference.Id;
- }
-
-
- public class Ref
- {
- public Ref() { }
-
- public Ref(string id)
- {
- Id = id;
- }
-
- public string Id { get; set; }
-
-
- public override string ToString()
- {
- return Id;
- }
-
-
- public static implicit operator Ref(string id) => new Ref(id);
-
- public static implicit operator string(Ref reference) => reference.Id;
- }
-}
diff --git a/old/zero.Core/Entities/Refs/ValueRef.cs b/old/zero.Core/Entities/Refs/ValueRef.cs
deleted file mode 100644
index dec86607..00000000
--- a/old/zero.Core/Entities/Refs/ValueRef.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-namespace zero.Core.Entities
-{
- public class ValueRef : ValueRef where T : ZeroIdEntity
- {
- public ValueRef() : base() { }
- public ValueRef(string id, string value) : base(id, value) { }
-
- public static implicit operator string(ValueRef reference) => reference.Id;
- }
-
-
- public class ValueRef : Ref where TEntity : ZeroIdEntity
- {
- public ValueRef() : base() { }
- public ValueRef(string id, TValue value) : base(id)
- {
- Value = value;
- }
-
- public TValue Value { get; set; }
-
- public static implicit operator string(ValueRef reference) => reference.Id;
- }
-
- //public class ValueRef : Ref
- //{
- // public ValueRef() : base() { }
-
- // public ValueRef(string id, string value) : base(id)
- // {
- // Value = value;
- // }
-
- // public string Value { get; set; }
-
-
- // public override string ToString()
- // {
- // return (Id, Value).ToString();
- // }
- //}
-}
diff --git a/old/zero.Core/Entities/Setup/SetupModel.cs b/old/zero.Core/Entities/Setup/SetupModel.cs
deleted file mode 100644
index a4b7d2a9..00000000
--- a/old/zero.Core/Entities/Setup/SetupModel.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-namespace zero.Core.Entities.Setup
-{
- public sealed class SetupModel
- {
- public string AppName { get; set; }
-
- public SetupUserModel User { get; set; }
-
- public SetupDatabaseModel Database { get; set; }
-
- public string ContentRootPath { get; set; }
- }
-
-
- public sealed class SetupUserModel
- {
- public string Name { get; set; }
-
- public string Email { get; set; }
-
- public string Password { get; set; }
- }
-
- public sealed class SetupDatabaseModel
- {
- public string Url { get; set; }
-
- public string Name { get; set; }
- }
-}
diff --git a/old/zero.Core/Entities/Translation.cs b/old/zero.Core/Entities/Translation.cs
deleted file mode 100644
index 70421779..00000000
--- a/old/zero.Core/Entities/Translation.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-namespace zero.Core.Entities
-{
- public class Translation : ZeroEntity
- {
- public Translation()
- {
- IsActive = true;
- }
-
- ///
- /// Value of the translation
- ///
- public string Value { get; set; }
-
- ///
- /// Display + input type
- ///
- public TranslationDisplay Display { get; set; }
- }
-
-
- public enum TranslationDisplay
- {
- Text = 0,
- HTML = 1
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Entities/Video.cs b/old/zero.Core/Entities/Video.cs
deleted file mode 100644
index edbc9409..00000000
--- a/old/zero.Core/Entities/Video.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-namespace zero.Core.Entities
-{
- public class Video
- {
- public VideoProvider Provider { get; set; }
-
- public string VideoId { get; set; }
-
- public string VideoUrl { get; set; }
-
- public string VideoPreviewImageUrl { get; set; }
-
- public string Title { get; set; }
-
- public string PreviewImageId { get; set; }
- }
-
-
- public enum VideoProvider
- {
- Html,
- Youtube,
- Vimeo
- }
-}
diff --git a/old/zero.Core/Extensions/BackofficeUserExtensions.cs b/old/zero.Core/Extensions/BackofficeUserExtensions.cs
deleted file mode 100644
index ce3c4b34..00000000
--- a/old/zero.Core/Extensions/BackofficeUserExtensions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Entities;
-using zero.Core.Identity;
-
-namespace zero.Core.Extensions
-{
- public static class BackofficeUserExtensions
- {
- public static string[] GetAllowedAppIds(this BackofficeUser user)
- {
- if (user == null)
- {
- return new string[0] { };
- }
-
- IEnumerable permissions = user.Claims
- .Where(claim => claim.Type == Constants.Auth.Claims.Permission && claim.Value.StartsWith(Permissions.Applications))
- .Select(x => Permission.FromClaim(x.ToClaim(), Permissions.Applications));
-
- return permissions.Where(x => x.IsTrue).Select(x => x.NormalizedKey).ToArray();
- }
- }
-}
diff --git a/old/zero.Core/Extensions/CollectionExtensions.cs b/old/zero.Core/Extensions/CollectionExtensions.cs
deleted file mode 100644
index eddba42b..00000000
--- a/old/zero.Core/Extensions/CollectionExtensions.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using zero.Core.Collections;
-
-namespace zero.Core.Extensions
-{
- public static class CollectionExtensions
- {
- ///
- /// Shared scope for the current collection instance
- ///
- public static CollectionScope SharedScope(this T collection) where T : ICollectionBase
- {
- return new CollectionScope(collection, "shared");
- }
- }
-}
diff --git a/old/zero.Core/Extensions/ColorExtensions.cs b/old/zero.Core/Extensions/ColorExtensions.cs
deleted file mode 100644
index 056244da..00000000
--- a/old/zero.Core/Extensions/ColorExtensions.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System;
-using System.Drawing;
-using System.Linq;
-
-namespace zero.Core.Extensions
-{
- public static class ColorExtensions
- {
- ///
- /// Get color object from a hex string
- ///
- public static Color FromHex(this string color)
- {
- if (color.StartsWith("#"))
- {
- color = color[1..];
- }
-
- if (color.Length != 6)
- {
- throw new Exception("Hex color has to be in format #RRGGBB");
- }
-
- return Color.FromArgb(
- int.Parse(color.Substring(0, 2), System.Globalization.NumberStyles.HexNumber),
- int.Parse(color.Substring(2, 2), System.Globalization.NumberStyles.HexNumber),
- int.Parse(color.Substring(4, 2), System.Globalization.NumberStyles.HexNumber)
- );
- }
-
-
- ///
- /// Get contrast ratio between two color values
- ///
- ///
- public static double GetContrastRatio(this Color color1, Color color2)
- {
- double lum1 = color1.GetLuminance();
- double lum2 = color2.GetLuminance();
- double brightest = Math.Max(lum1, lum2);
- double darkest = Math.Min(lum1, lum2);
- return (brightest + 0.05) / (darkest + 0.05);
- }
-
-
- ///
- /// Get luminance value of a color based on WCAG-conform JS implementation
- ///
- ///
- public static double GetLuminance(this Color color)
- {
- double[] a = new double[3] { color.R, color.G, color.B }.Select(v =>
- {
- v /= 255;
- return v <= 0.03928 ? v / 12.92 : Math.Pow((v + 0.055) / 1.055, 2.4);
- }).ToArray();
-
- return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
- }
- }
-}
diff --git a/old/zero.Core/Extensions/EnumerableExtensions.cs b/old/zero.Core/Extensions/EnumerableExtensions.cs
deleted file mode 100644
index 9f384396..00000000
--- a/old/zero.Core/Extensions/EnumerableExtensions.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Extensions
-{
- public static class EnumerableExtensions
- {
- ///
- ///
- ///
- public static ListResult ToQueriedList(this IEnumerable items, ListQuery query) where T : ZeroEntity
- {
- //queryable = queryable.Statistics(out QueryStatistics stats);
-
- if (query != null)
- {
- if (!query.IncludeInactive)
- {
- items = items.Where(x => x.IsActive);
- }
-
- if (!query.Search.IsNullOrEmpty())
- {
- items = items.Where(x => x.Name.Contains(query.Search, StringComparison.InvariantCultureIgnoreCase));
- }
- //if (!query.Search.IsNullOrEmpty() && query.SearchSelector != null)
- //{
- // items = items.SearchIf(query.SearchSelector, query.Search, "*", "*", Raven.Client.Documents.Queries.SearchOperator.And);
- //}
- //if (!query.Search.IsNullOrEmpty() && query.SearchSelectors.Length > 0)
- //{
- // foreach (var selector in query.SearchSelectors)
- // {
- // items = items.SearchIf(selector, query.Search, "*", "*", Raven.Client.Documents.Queries.SearchOperator.And);
- // }
- //}
-
- //if (!query.OrderBy.IsNullOrEmpty())
- //{
- // items = items.OrderBy(query.OrderBy, query.OrderIsDescending);
- //}
-
- if (query.PageSize > 0)
- {
- items = items.Paging(query.Page, query.PageSize);
- }
- }
-
- List result = items.ToList();
-
- return new ListResult(result, result.Count, query.Page, query.PageSize);
- }
-
-
-
- public static IEnumerable Paging(this IEnumerable source, int pageNumber, int pageSize)
- {
- pageNumber = pageNumber.Limit(1, 10_000_000);
- pageSize = pageSize.Limit(1, 1_000);
-
- if (pageNumber <= 0 || pageSize <= 0)
- {
- throw new NotSupportedException("Both pageNumber and pageSize must be greater than zero");
- }
-
- return source.Skip((pageNumber - 1) * pageSize).Take(pageSize);
- }
-
-
- public static bool TryGet(this IEnumerable source, Func predicate, out T model)
- {
- model = source.FirstOrDefault(predicate);
- return model != null;
- }
-
-
- public static bool TryAdd(this IList source, T model) where T : class
- {
- if (model == default)
- {
- return false;
- }
-
- source.Add(model);
- return true;
- }
- }
-}
diff --git a/old/zero.Core/Extensions/HttpContextExtensions.cs b/old/zero.Core/Extensions/HttpContextExtensions.cs
deleted file mode 100644
index 2edc77de..00000000
--- a/old/zero.Core/Extensions/HttpContextExtensions.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using Microsoft.AspNetCore.Http;
-
-namespace zero.Core.Extensions
-{
- public static class HttpContextExtensions
- {
- ///
- /// Whether the current request is a backoffice request
- ///
- public static bool IsBackofficeRequest(this HttpContext context, string backofficePath)
- {
- string path = backofficePath.EnsureStartsWith('/').TrimEnd('/');
- return context.Request.Path.ToString().StartsWith(path);
- }
-
-
- ///
- /// Whether the current request is an AJAX request
- ///
- public static bool IsAjaxRequest(this HttpContext context)
- {
- if (context?.Request?.Headers == null)
- {
- return false;
- }
-
- return context.Request.Headers["X-Requested-With"] == "XMLHttpRequest";
- }
-
-
- ///
- /// Whether the current request only accepts application/json
- ///
- public static bool IsJsonRequest(this HttpContext context)
- {
- if (context?.Request?.Headers == null)
- {
- return false;
- }
-
- return context.Request.Headers["Accept"] == "application/json";
- }
-
-
- ///
- /// Get IP Address of the client
- ///
- public static string GetClientIpAddress(this HttpContext context)
- {
- return context.Connection.RemoteIpAddress?.ToString();
- //string ipAddress = context.GetServerVariable("HTTP_X_FORWARDED_FOR");
- //return !ipAddress.IsNullOrEmpty() ? ipAddress.Split(',')[0] : context.GetServerVariable("REMOTE_ADDR");
- }
- }
-}
diff --git a/old/zero.Core/Extensions/MailExtensions.cs b/old/zero.Core/Extensions/MailExtensions.cs
deleted file mode 100644
index 6cb97377..00000000
--- a/old/zero.Core/Extensions/MailExtensions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Mail;
-using zero.Core.Entities;
-
-namespace zero.Core.Extensions
-{
- public static class MailExtensions
- {
- //public static string Add(this AttachmentCollection attachments, byte[] content, )
- //{
- // if (input < min)
- // {
- // return min;
- // }
- // if (input > max)
- // {
- // return max;
- // }
- // return input;
- //}
- }
-}
diff --git a/old/zero.Core/Extensions/NumberExtensions.cs b/old/zero.Core/Extensions/NumberExtensions.cs
deleted file mode 100644
index 553de5e6..00000000
--- a/old/zero.Core/Extensions/NumberExtensions.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using zero.Core.Entities;
-
-namespace zero.Core.Extensions
-{
- public static class NumberExtensions
- {
- static Dictionary FileSizeUnits = new()
- {
- { FileSizeNotation.SI, new string[] { "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" } },
- { FileSizeNotation.IEC, new string[] { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" } },
- { FileSizeNotation.JEDEC, new string[] { "B", "KB", "MB", "GB" } }
- };
-
- public static int Limit(this int input, int min, int max)
- {
- if (input < min)
- {
- return min;
- }
- if (input > max)
- {
- return max;
- }
- return input;
- }
-
-
- public static string GetFileSize(this long sizeInBytes, FileSizeNotation notation = FileSizeNotation.JEDEC)
- {
- if (!FileSizeUnits.ContainsKey(notation))
- {
- throw new NotImplementedException($"The notation {notation} has no implementation for generating human-readable file sizes");
- }
-
- int power = notation == FileSizeNotation.SI ? 1000 : 1024;
-
- string[] units = FileSizeUnits[notation];
-
- int order = 0;
-
- while (sizeInBytes >= power && order + 1 < units.Length)
- {
- order++;
- sizeInBytes = sizeInBytes / power;
- }
-
- return String.Format("{0:0.##} {1}", sizeInBytes, units[order]);
- }
- }
-}
diff --git a/old/zero.Core/Extensions/ObjectExtensions.cs b/old/zero.Core/Extensions/ObjectExtensions.cs
deleted file mode 100644
index 6207080f..00000000
--- a/old/zero.Core/Extensions/ObjectExtensions.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using zero.Core.Attributes;
-using zero.Core.Utils;
-
-namespace zero.Core.Extensions
-{
- public static class ObjectExtensions
- {
- public static bool Is(this Type type)
- {
- return type.IsAssignableFrom(typeof(T));
- }
-
-
- public static bool Is(this object obj)
- {
- return obj.GetType().IsAssignableFrom(typeof(T));
- }
-
-
- public static T Clone(this T obj)
- {
- Type type = obj.GetType();
- return (T)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj, new RefJsonConverter()), type, new RefJsonConverter());
- }
-
- public static T CloneLax(this object obj)
- {
- return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj, new RefJsonConverter()), new RefJsonConverter());
- }
-
- public static T AutoSetIds(this T obj)
- {
- // find all Raven Ids
- List> ravenIds = ObjectTraverser.FindAttribute(obj);
-
- // set unset Raven Ids
- foreach (ObjectTraverser.Result item in ravenIds)
- {
- string id = item.Property.GetValue(item.Parent, null) as string;
- if (String.IsNullOrWhiteSpace(id))
- {
- item.Property.SetValue(item.Parent, item.Item.Length.HasValue ? IdGenerator.Create(item.Item.Length.Value) : IdGenerator.Create());
- }
- }
-
- return obj;
- }
- }
-}
diff --git a/old/zero.Core/Extensions/QueryableExtensions.cs b/old/zero.Core/Extensions/QueryableExtensions.cs
deleted file mode 100644
index 547cfc01..00000000
--- a/old/zero.Core/Extensions/QueryableExtensions.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using Raven.Client.Documents;
-using Raven.Client.Documents.Linq;
-using Raven.Client.Documents.Queries;
-using Raven.Client.Documents.Session;
-using System;
-using System.Linq;
-using System.Linq.Expressions;
-
-namespace zero.Core.Extensions
-{
- public static class QueryableExtensions
- {
- public static IOrderedQueryable OrderBy(this IQueryable source, string path, bool isDescending, OrderingType type = OrderingType.String)
- {
- if (!String.IsNullOrEmpty(path))
- {
- char[] a = path.ToCharArray();
- a[0] = char.ToUpper(a[0]);
- path = new string(a);
- }
-
- if (isDescending)
- {
- return source.OrderByDescending(path, type);
- }
- return source.OrderBy(path, type);
- }
-
-
- public static IOrderedQueryable ThenBy(this IOrderedQueryable source, string path, bool isDescending, OrderingType type = OrderingType.String)
- {
- if (!String.IsNullOrEmpty(path))
- {
- char[] a = path.ToCharArray();
- a[0] = char.ToUpper(a[0]);
- path = new string(a);
- }
-
- if (isDescending)
- {
- return source.ThenByDescending(path, type);
- }
- return source.ThenBy(path, type);
- }
-
-
- public static IQueryable Paging(this IQueryable source, int pageNumber, int pageSize)
- {
- pageNumber = pageNumber.Limit(1, 10_000_000);
- pageSize = pageSize.Limit(1, 1_000);
-
- if (pageNumber <= 0 || pageSize <= 0)
- {
- throw new NotSupportedException("Both pageNumber and pageSize must be greater than zero");
- }
-
- return source.Skip((pageNumber - 1) * pageSize).Take(pageSize);
- }
-
-
- public static IRavenQueryable WhereIf(this IRavenQueryable source, Expression> predicate, bool condition, Expression> elsePredicate = null)
- {
- if (!condition)
- {
- if (elsePredicate != null)
- {
- return source.Where(elsePredicate);
- }
- return source;
- }
-
- return source.Where(predicate);
- }
-
-
- public static IQueryable SearchIf(this IQueryable source, Expression> fieldSelector, string searchTerms, string suffix = null, string prefix = null, SearchOperator @operator = SearchOperator.Or)
- {
- if (String.IsNullOrWhiteSpace(searchTerms))
- {
- return source;
- }
-
- searchTerms = searchTerms.Trim();
-
- string[] searchParts = searchTerms.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x =>
- {
- if (suffix != null)
- {
- x += suffix;
- }
- if (prefix != null)
- {
- x = prefix + x;
- }
- return x;
- }).ToArray();
-
- if (searchTerms.StartsWith('"') && searchTerms.EndsWith('"'))
- {
- searchParts = new[] { searchTerms };
- }
-
- return source.Search(fieldSelector, searchParts, @operator: @operator);
- }
- }
-}
diff --git a/old/zero.Core/Extensions/ServiceCollectionExtensions.cs b/old/zero.Core/Extensions/ServiceCollectionExtensions.cs
deleted file mode 100644
index 6c93cc89..00000000
--- a/old/zero.Core/Extensions/ServiceCollectionExtensions.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.DependencyInjection.Extensions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using zero.Core.Assemblies;
-
-namespace zero.Core.Extensions
-{
- public static class ServiceCollectionExtensions
- {
- ///
- /// Adds all found implementations based on the service type and assembly discovery rules
- ///
- public static void AddAll(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient, bool asSelf = false) => services.AddAll(typeof(TService), lifetime, asSelf);
-
-
- ///
- /// Adds all found implementations based on the service type and assembly discovery rules
- ///
- public static void AddAll(this IServiceCollection services, Type serviceType, ServiceLifetime lifetime = ServiceLifetime.Transient, bool asSelf = false)
- {
- if (AssemblyDiscovery.Current == null)
- {
- throw new Exception("services.AddAll() can only be run after mvcBuilder.AddZero()");
- }
-
- // add implementations with generic service types
- if (serviceType.GetTypeInfo().IsGenericTypeDefinition)
- {
- IEnumerable<(Type, TypeInfo)> matches = AssemblyDiscovery.Current.GetAllClassTypes().SelectMany(type =>
- {
- var interfaces = type.GetInterfaces().Select(x => x.GetTypeInfo());
- IEnumerable genericTypes = interfaces.Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == serviceType);
- if (genericTypes.Any())
- {
- var genericTypeDefinitions = genericTypes.First();
- }
- return genericTypes.Select(x => (x, type));
- });
-
- foreach ((Type, Type) match in matches)
- {
- services.Add(new ServiceDescriptor(asSelf ? match.Item2 : match.Item1, match.Item2, lifetime));
- }
- }
- // add implementations with specific service types
- else
- {
- foreach (Type type in AssemblyDiscovery.Current.GetTypes(serviceType))
- {
- services.Add(new ServiceDescriptor(asSelf ? type : serviceType, type, lifetime));
- }
- }
- }
-
-
- ///
- /// Adds or overrides an implementation
- ///
- public static void Replace(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient)
- where TService : class
- where TImplementation : class, TService
- {
- services.RemoveAll();
- services.Add(new ServiceDescriptor(typeof(TService), typeof(TImplementation), lifetime));
- }
-
-
- ///
- /// Adds or overrides an implementation
- ///
- public static void Replace(this IServiceCollection services, Func implementationFactory, ServiceLifetime lifetime = ServiceLifetime.Transient)
- where TService : class
- where TImplementation : class, TService
- {
- services.RemoveAll();
- services.Add(new ServiceDescriptor(typeof(TService), implementationFactory, lifetime));
- }
- }
-}
diff --git a/old/zero.Core/Extensions/ValidatorExtensions.cs b/old/zero.Core/Extensions/ValidatorExtensions.cs
deleted file mode 100644
index 41608c50..00000000
--- a/old/zero.Core/Extensions/ValidatorExtensions.cs
+++ /dev/null
@@ -1,246 +0,0 @@
-using FluentValidation;
-using Raven.Client.Documents;
-using Raven.Client.Documents.Session;
-using System;
-using System.Globalization;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using zero.Core.Api;
-using zero.Core.Database;
-using zero.Core.Entities;
-
-namespace zero.Core.Extensions
-{
- public static class ValidatorExtensions
- {
- private const char DOT = '.';
-
- private const char KLAMMERAFFE = '@';
-
- private static string HEX_REGEX = "#[0-9a-fA-F]{3,8}";
-
- ///
- /// Validate a color input as HEX (#aabbccdd or #aabbcc or #abc)
- ///
- public static IRuleBuilderOptions Hex(this IRuleBuilder ruleBuilder)
- {
- return ruleBuilder.Matches(HEX_REGEX).WithMessage("@errors.forms.hex_format");
- }
-
-
- ///
- /// Validate an email
- ///
- public static IRuleBuilderOptions Url(this IRuleBuilder ruleBuilder)
- {
- return ruleBuilder.Must((root, value, context) =>
- {
- return value.IsNullOrWhiteSpace() || Uri.IsWellFormedUriString(value, UriKind.Absolute);
- }).WithMessage("@errors.forms.url_format");
- }
-
-
- ///
- /// Validate an email
- ///
- public static IRuleBuilderOptions Email(this IRuleBuilder ruleBuilder)
- {
- return ruleBuilder.Must((root, value, context) =>
- {
- if (value.IsNullOrWhiteSpace())
- {
- return true;
- }
-
- int index = value.IndexOf(KLAMMERAFFE);
-
- if (index < 0 || index == value.Length - 1 || index != value.LastIndexOf(KLAMMERAFFE))
- {
- return false;
- }
-
- return true;
- }).WithMessage("@errors.forms.email_invalid");
- }
-
-
- ///
- /// Validate one or multiple emails
- ///
- public static IRuleBuilderOptions Emails(this IRuleBuilder ruleBuilder)
- {
- return ruleBuilder.Must((root, value, context) =>
- {
- if (value.IsNullOrWhiteSpace())
- {
- return true;
- }
-
- string[] mails = value.Split(',', ';').Select(x => x.Trim()).Where(x => !x.IsNullOrWhiteSpace()).ToArray();
-
- if (!mails.Any())
- {
- return false;
- }
-
- foreach (string mail in mails)
- {
- int index = value.IndexOf(KLAMMERAFFE);
-
- if (index < 0 || index == value.Length - 1 || index != value.LastIndexOf(KLAMMERAFFE))
- {
- return false;
- }
- }
-
- return true;
- }).WithMessage("@errors.forms.emails_invalid");
- }
-
-
- ///
- /// Check if this value is unique within a collection
- ///
- public static IRuleBuilderOptions Unique(this IRuleBuilder ruleBuilder, IZeroStore store) where T : ZeroEntity
- {
- return ruleBuilder.MustAsync(async (entity, value, context, cancellation) =>
- {
- bool any = await store.Session().Advanced.AsyncDocumentQuery()
- .WhereNotEquals(nameof(ZeroIdEntity.Id), entity.Id)
- .WhereEquals(context.PropertyName.ToPascalCaseId(), value)
- .AnyAsync(cancellation);
-
- return !any;
- }).WithMessage("@errors.forms.not_unique");
- }
-
-
- ///
- /// Check if this value is at least set once to the expected value within a collection
- ///
- public static IRuleBuilderOptions ExpectAnyUnique(this IRuleBuilder ruleBuilder, IZeroStore store, TProperty expectedValue) where T : ZeroEntity
- {
- return ruleBuilder.MustAsync(async (entity, value, context, cancellation) =>
- {
- return await store.Session().Advanced.AsyncDocumentQuery()
- .WhereNotEquals(nameof(ZeroIdEntity.Id), entity.Id)
- .WhereEquals(context.PropertyName.ToPascalCaseId(), expectedValue)
- .AnyAsync(cancellation);
- }).WithMessage("@errors.forms.not_unique_alone");
- }
-
-
- ///
- /// Check if this reference exists and is an entity which can be referenced (appId = shared for shareable entities or appId = current)
- ///
- public static IRuleBuilderOptions Exists(this IRuleBuilder ruleBuilder, IZeroStore store) where T : ZeroEntity
- {
- return ruleBuilder.Exists(store);
- }
-
-
- ///
- /// Check if this reference exists and is an entity which can be referenced (appId = shared for shareable entities or appId = current)
- ///
- public static IRuleBuilderOptions Exists(this IRuleBuilder ruleBuilder, IZeroStore store) where T : ZeroEntity where TReference : ZeroEntity
- {
- return ruleBuilder.MustAsync(async (entity, id, context, cancellation) =>
- {
- if (id.IsNullOrWhiteSpace())
- {
- return true;
- }
-
- TReference model = await store.Session().LoadAsync(id);
- return model != null;
- }).WithMessage("@errors.forms.reference_notfound");
- }
-
-
- ///
- /// Validates a culture identifier
- ///
- public static IRuleBuilderOptions Culture(this IRuleBuilder ruleBuilder)
- {
- return ruleBuilder.Must((root, value, context) =>
- {
- if (value.IsNullOrWhiteSpace())
- {
- return true;
- }
-
- try
- {
- CultureInfo info = CultureInfo.GetCultureInfo(value);
- return info != null && !info.EnglishName.Equals(value, StringComparison.InvariantCultureIgnoreCase);
- }
- catch
- {
- return false;
- }
- }).WithMessage("@errors.forms.culture");
- }
-
-
-
-
- ///
- /// Check if this value is unique within a collection
- ///
- public static IRuleBuilderOptions Unique(this IRuleBuilder ruleBuilder, IZeroDocumentSession session) where T : ZeroEntity
- {
- return ruleBuilder.MustAsync(async (entity, value, context, cancellation) =>
- {
- bool any = await session.Advanced.AsyncDocumentQuery()
- .WhereNotEquals(nameof(ZeroIdEntity.Id), entity.Id)
- .WhereEquals(context.PropertyName.ToPascalCaseId(), value)
- .AnyAsync(cancellation);
-
- return !any;
- }).WithMessage("@errors.forms.not_unique");
- }
-
-
- ///
- /// Check if this value is at least set once to the expected value within a collection
- ///
- public static IRuleBuilderOptions ExpectAnyUnique(this IRuleBuilder ruleBuilder, IZeroDocumentSession session, TProperty expectedValue) where T : ZeroEntity
- {
- return ruleBuilder.MustAsync(async (entity, value, context, cancellation) =>
- {
- return await session.Advanced.AsyncDocumentQuery()
- .WhereNotEquals(nameof(ZeroIdEntity.Id), entity.Id)
- .WhereEquals(context.PropertyName.ToPascalCaseId(), expectedValue)
- .AnyAsync(cancellation);
- }).WithMessage("@errors.forms.not_unique_alone");
- }
-
-
- ///
- /// Check if this reference exists and is an entity which can be referenced (appId = shared for shareable entities or appId = current)
- ///
- public static IRuleBuilderOptions Exists(this IRuleBuilder ruleBuilder, IZeroDocumentSession session) where T : ZeroEntity
- {
- return ruleBuilder.Exists(session);
- }
-
-
- ///
- /// Check if this reference exists and is an entity which can be referenced (appId = shared for shareable entities or appId = current)
- ///
- public static IRuleBuilderOptions Exists(this IRuleBuilder ruleBuilder, IZeroDocumentSession session) where T : ZeroEntity where TReference : ZeroEntity
- {
- return ruleBuilder.MustAsync(async (entity, id, context, cancellation) =>
- {
- if (id.IsNullOrWhiteSpace())
- {
- return true;
- }
-
- TReference model = await session.LoadAsync(id);
- return model != null;
- }).WithMessage("@errors.forms.reference_notfound");
- }
- }
-}
diff --git a/old/zero.Core/Handlers/IApplicationResolverHandler.cs b/old/zero.Core/Handlers/IApplicationResolverHandler.cs
deleted file mode 100644
index 200328d1..00000000
--- a/old/zero.Core/Handlers/IApplicationResolverHandler.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using zero.Core.Entities;
-
-namespace zero.Core.Handlers
-{
- public interface IApplicationResolverHandler : IHandler
- {
- Application Resolve(HttpRequest request, IEnumerable applications);
- }
-}
diff --git a/old/zero.Core/Handlers/IHandler.cs b/old/zero.Core/Handlers/IHandler.cs
deleted file mode 100644
index c0c06e5a..00000000
--- a/old/zero.Core/Handlers/IHandler.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace zero.Core.Handlers
-{
- public interface IHandler
- {
- }
-}
diff --git a/old/zero.Core/Handlers/IHandlerHolder.cs b/old/zero.Core/Handlers/IHandlerHolder.cs
deleted file mode 100644
index f9ebdf0d..00000000
--- a/old/zero.Core/Handlers/IHandlerHolder.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using System;
-
-namespace zero.Core.Handlers
-{
- public class HandlerHolder : IHandlerHolder
- {
- IServiceProvider Services { get; }
-
- public HandlerHolder(IServiceProvider services)
- {
- Services = services;
- }
-
-
- public T Get() where T : IHandler
- {
- return Services.GetService();
- }
- }
-
-
- public interface IHandlerHolder
- {
- T Get() where T : IHandler;
- }
-}
diff --git a/old/zero.Core/Handlers/IModuleTypeHandler.cs b/old/zero.Core/Handlers/IModuleTypeHandler.cs
deleted file mode 100644
index 9c995b46..00000000
--- a/old/zero.Core/Handlers/IModuleTypeHandler.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-using zero.Core.Entities;
-
-namespace zero.Core.Handlers
-{
- public interface IModuleTypeHandler : IHandler
- {
- IEnumerable GetAllowedModuleTypes(Application application, IEnumerable registeredTypes, Page page = default, string[] tags = default);
- }
-}
diff --git a/old/zero.Core/Handlers/IPageTypeHandler.cs b/old/zero.Core/Handlers/IPageTypeHandler.cs
deleted file mode 100644
index 07f0bce5..00000000
--- a/old/zero.Core/Handlers/IPageTypeHandler.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Raven.Client.Documents.Session;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using zero.Core.Entities;
-
-namespace zero.Core.Handlers
-{
- public interface IPageTypeHandler : IHandler
- {
- Task> GetAllowedPageTypes(Application application, IEnumerable registeredTypes, IEnumerable parents);
- }
-}
diff --git a/old/zero.Core/Integrations/Integration.cs b/old/zero.Core/Integrations/Integration.cs
deleted file mode 100644
index df9b7e23..00000000
--- a/old/zero.Core/Integrations/Integration.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using zero.Core.Attributes;
-using zero.Core.Entities;
-
-namespace zero.Core.Integrations
-{
- ///
- /// An integration is an application part which has a public configuration per app.
- /// It's up to the user to provide functionality.
- ///
- [Collection("Integrations")]
- public class Integration : ZeroEntity
- {
- ///
- public string TypeAlias { get; set; }
- }
-}
\ No newline at end of file
diff --git a/old/zero.Core/Integrations/IntegrationService.cs b/old/zero.Core/Integrations/IntegrationService.cs
deleted file mode 100644
index a6c00f78..00000000
--- a/old/zero.Core/Integrations/IntegrationService.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using Microsoft.Extensions.Logging;
-using zero.Core.Collections;
-
-namespace zero.Core.Integrations
-{
- public class IntegrationService : IntegrationsCollection, IIntegrationService
- {
- public IntegrationService(ICollectionContext context, ILogger logger) : base(context, logger)
- {
- Options = new(false);
- }
- }
-
-
- public interface IIntegrationService : IIntegrationsCollection { }
-}
diff --git a/old/zero.Core/Integrations/IntegrationType.cs b/old/zero.Core/Integrations/IntegrationType.cs
deleted file mode 100644
index b4212925..00000000
--- a/old/zero.Core/Integrations/IntegrationType.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Collections.Generic;
-using zero.Core.Options;
-
-namespace zero.Core.Integrations
-{
- ///
- /// An integration is an application part which has a public configuration per app.
- /// It's up to the user to provide functionality.
- ///
- public class IntegrationType : IntegrationType where T : Integration, new()
- {
- public IntegrationType() : base(typeof(T)) { }
- }
-
- ///
- /// An integration is an application part which has a public configuration per app.
- /// It's up to the user to provide functionality.
- ///
- public class IntegrationType : OptionsType
- {
- ///
- /// Group integrations by tags
- ///
- public List Tags { get; set; } = new();
-
- ///
- /// Optional description
- ///
- public string Description { get; set; }
-
- ///
- /// Image of the integration
- ///
- public string ImagePath { get; set; }
-
-
- public IntegrationType(Type type)
- {
- ContentType = type;
- }
-
- public static IntegrationType Convert(IntegrationType model) where T : Integration, new()
- {
- return new(model.ContentType)
- {
- Alias = model.Alias,
- Name = model.Name,
- Description = model.Description,
- ImagePath = model.ImagePath,
- Tags = model.Tags,
- Validator = model.Validator
- };
- }
- }
-}
diff --git a/old/zero.Core/Integrations/IntegrationTypeWithStatus.cs b/old/zero.Core/Integrations/IntegrationTypeWithStatus.cs
deleted file mode 100644
index ebb6cc70..00000000
--- a/old/zero.Core/Integrations/IntegrationTypeWithStatus.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace zero.Core.Integrations
-{
- public class IntegrationTypeWithStatus
- {
- public IntegrationType Type { get; set; }
-
- public bool IsActive { get; set; }
-
- public bool IsConfigured { get; set; }
-
- public string Id { get; set; }
- }
-}
diff --git a/old/zero.Core/Mails/FileMailDispatcher.cs b/old/zero.Core/Mails/FileMailDispatcher.cs
deleted file mode 100644
index f1a78ab1..00000000
--- a/old/zero.Core/Mails/FileMailDispatcher.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using Microsoft.Extensions.Logging;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net.Mail;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using zero.Core.Api;
-
-namespace zero.Core.Mails
-{
- ///
- /// Default implementation of an IMailSender which sends the mail a flat file
- /// and therefore not using the SMTP channel.
- /// Implementing real mail sending is up to the consuming application.
- ///
- public class FileMailDispatcher : IMailDispatcher
- {
- protected Queue Queue { get; private set; } = new Queue();
-
- protected IPaths PathResolver { get; private set; }
-
- string MailDirectory;
-
-
- public FileMailDispatcher(IPaths pathResolver)
- {
- PathResolver = pathResolver;
- MailDirectory = "mails";
- }
-
-
- ///
- public void Enqueue(Mail message)
- {
- Queue.Enqueue(message);
- }
-
-
- ///
- public async Task Send(CancellationToken token = default)
- {
- if (Queue.Count < 1)
- {
- return;
- }
-
- string folder = PathResolver.Map(MailDirectory);
- PathResolver.Create(folder);
-
- while (Queue.Count > 0)
- {
- Mail message = Queue.Dequeue();
- string content = JsonConvert.SerializeObject(message, new JsonSerializerSettings()
- {
- Formatting = Formatting.Indented,
- TypeNameHandling = TypeNameHandling.None,
- ReferenceLoopHandling = ReferenceLoopHandling.Ignore
- });
-
- string filename = Safenames.File(DateTimeOffset.Now.ToString("yyyy-MM-dd-HH-mm-ss") + "_" + message.To[0].Address + ".txt");
- string path = PathResolver.Map(folder, filename);
-
- await File.WriteAllTextAsync(path, content, token);
- }
- }
-
-
- ///
- public void Dispose() { }
-
-
- ///
- /// Creats the file content from a mail message
- ///
- string CreateContent(Mail message)
- {
- StringBuilder text = new();
- text.AppendLine("To: " + message.To);
- text.AppendLine("CC: " + message.CC);
- text.AppendLine("Bcc: " + message.Bcc);
- text.AppendLine("From: " + message.From);
- text.AppendLine("Subject: " + message.Subject);
- text.Append("Date: " + DateTimeOffset.UtcNow.ToString());
-
- text.AppendLine();
- text.AppendLine("=============== BODY ===============");
- text.AppendLine();
-
- text.AppendLine(message.Body);
-
- return text.ToString();
- }
- }
-}
diff --git a/old/zero.Core/Mails/IMailDispatcher.cs b/old/zero.Core/Mails/IMailDispatcher.cs
deleted file mode 100644
index d9c7e6f1..00000000
--- a/old/zero.Core/Mails/IMailDispatcher.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Net.Mail;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace zero.Core.Mails
-{
- public interface IMailDispatcher : IDisposable
- {
- ///
- /// Adds a new mail message to the outgoing queue
- ///
- void Enqueue(Mail message);
-
- ///
- /// Sends all mails which have been added to the queue previously
- ///
- Task Send(CancellationToken token = default);
-
- ///
- /// Whether a certain sender signature is supported by this dispatcher
- ///
- Task IsSenderSupported(string email) => Task.FromResult(true);
- }
-}
diff --git a/old/zero.Core/Mails/LoggerMailDispatcher.cs b/old/zero.Core/Mails/LoggerMailDispatcher.cs
deleted file mode 100644
index 227ba3ec..00000000
--- a/old/zero.Core/Mails/LoggerMailDispatcher.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using Microsoft.Extensions.Logging;
-using System.Collections.Generic;
-using System.Net.Mail;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace zero.Core.Mails
-{
- ///