Browse Source

Separator folders/namespaces for domain objects.

pull/613/head
Sebastian 5 years ago
parent
commit
99752173e1
  1. 4
      backend/src/Migrations/Migrations/ClearRules.cs
  2. 4
      backend/src/Migrations/Migrations/ClearSchemas.cs
  3. 6
      backend/src/Migrations/Migrations/CreateAssetSlugs.cs
  4. 27
      backend/src/Migrations/RebuilderExtensions.cs
  5. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleEventFormatter.cs
  6. 16
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository_SnapshotStore.cs
  7. 1
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository.cs
  8. 16
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository_SnapshotStore.cs
  9. 22
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs
  10. 1
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByQuery.cs
  11. 1
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Rules/MongoRuleEventRepository.cs
  12. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppCommandMiddleware.cs
  13. 231
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObject.State.cs
  14. 7
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObject.cs
  15. 5
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObjectGrain.cs
  16. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardApp.cs
  17. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppClients.cs
  18. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppContributors.cs
  19. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppLanguages.cs
  20. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppPatterns.cs
  21. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppRoles.cs
  22. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppWorkflows.cs
  23. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/IAppGrain.cs
  24. 1
      backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs
  25. 228
      backend/src/Squidex.Domain.Apps.Entities/Apps/State/AppState.cs
  26. 6
      backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs
  27. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetCommandMiddleware.cs
  28. 178
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs
  29. 7
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.cs
  30. 5
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObjectGrain.cs
  31. 72
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderDomainObject.State.cs
  32. 7
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderDomainObject.cs
  33. 5
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderDomainObjectGrain.cs
  34. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/GuardAsset.cs
  35. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/GuardAssetFolder.cs
  36. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/IAssetFolderGrain.cs
  37. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/IAssetGrain.cs
  38. 1
      backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetLoader.cs
  39. 69
      backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetFolderState.cs
  40. 175
      backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetState.cs
  41. 1
      backend/src/Squidex.Domain.Apps.Entities/Comments/CommentsLoader.cs
  42. 2
      backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsCommandMiddleware.cs
  43. 4
      backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsGrain.cs
  44. 2
      backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/Guards/GuardComments.cs
  45. 2
      backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/ICommentsGrain.cs
  46. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs
  47. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/BulkUpdateCommandMiddleware.cs
  48. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentCommandMiddleware.cs
  49. 159
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.State.cs
  50. 9
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs
  51. 5
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObjectGrain.cs
  52. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentOperationContext.cs
  53. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentVersion.cs
  54. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/GuardContent.cs
  55. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/IContentGrain.cs
  56. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/IContentQueryService.cs
  57. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentLoader.cs
  58. 156
      backend/src/Squidex.Domain.Apps.Entities/Contents/State/ContentState.cs
  59. 2
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/GuardRule.cs
  60. 2
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/RuleTriggerValidator.cs
  61. 2
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/IRuleGrain.cs
  62. 96
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs
  63. 7
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.cs
  64. 5
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObjectGrain.cs
  65. 1
      backend/src/Squidex.Domain.Apps.Entities/Rules/Indexes/RulesIndex.cs
  66. 1
      backend/src/Squidex.Domain.Apps.Entities/Rules/RuleCommandMiddleware.cs
  67. 93
      backend/src/Squidex.Domain.Apps.Entities/Rules/State/RuleState.cs
  68. 2
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/FieldPropertiesValidator.cs
  69. 2
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardHelper.cs
  70. 2
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchema.cs
  71. 2
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchemaField.cs
  72. 2
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/ISchemaGrain.cs
  73. 210
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/SchemaDomainObject.State.cs
  74. 7
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/SchemaDomainObject.cs
  75. 5
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/SchemaDomainObjectGrain.cs
  76. 1
      backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs
  77. 207
      backend/src/Squidex.Domain.Apps.Entities/Schemas/State/SchemaState.cs
  78. 1
      backend/src/Squidex/Config/Domain/AppsServices.cs
  79. 1
      backend/src/Squidex/Config/Domain/AssetServices.cs
  80. 9
      backend/src/Squidex/Config/Domain/CommandsServices.cs
  81. 2
      backend/src/Squidex/Config/Domain/ContentsServices.cs
  82. 1
      backend/src/Squidex/Config/Domain/RuleServices.cs
  83. 1
      backend/src/Squidex/Config/Domain/SchemasServices.cs
  84. 10
      backend/src/Squidex/Config/Domain/StoreServices.cs
  85. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs
  86. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs
  87. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppClientsTests.cs
  88. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppContributorsTests.cs
  89. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppLanguagesTests.cs
  90. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppPatternsTests.cs
  91. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppRolesTests.cs
  92. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppTests.cs
  93. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppWorkflowTests.cs
  94. 1
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs
  95. 6
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs
  96. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetCommandMiddlewareTests.cs
  97. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectGrainTests.cs
  98. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs
  99. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetFolderDomainObjectGrainTests.cs
  100. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetFolderDomainObjectTests.cs

4
backend/src/Migrations/Migrations/ClearRules.cs

@ -7,7 +7,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Rules.State; using Squidex.Domain.Apps.Entities.Rules.DomainObject;
using Squidex.Infrastructure.Migrations; using Squidex.Infrastructure.Migrations;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
@ -24,7 +24,7 @@ namespace Migrations.Migrations
public Task UpdateAsync() public Task UpdateAsync()
{ {
return store.ClearSnapshotsAsync<Guid, RuleState>(); return store.ClearSnapshotsAsync<Guid, RuleDomainObject.State>();
} }
} }
} }

4
backend/src/Migrations/Migrations/ClearSchemas.cs

@ -7,7 +7,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Schemas.State; using Squidex.Domain.Apps.Entities.Schemas.DomainObject;
using Squidex.Infrastructure.Migrations; using Squidex.Infrastructure.Migrations;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
@ -24,7 +24,7 @@ namespace Migrations.Migrations
public Task UpdateAsync() public Task UpdateAsync()
{ {
return store.ClearSnapshotsAsync<Guid, SchemaState>(); return store.ClearSnapshotsAsync<Guid, SchemaDomainObject.State>();
} }
} }
} }

6
backend/src/Migrations/Migrations/CreateAssetSlugs.cs

@ -7,7 +7,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Assets; using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Migrations; using Squidex.Infrastructure.Migrations;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
@ -16,9 +16,9 @@ namespace Migrations.Migrations
{ {
public sealed class CreateAssetSlugs : IMigration public sealed class CreateAssetSlugs : IMigration
{ {
private readonly ISnapshotStore<AssetState, string> stateForAssets; private readonly ISnapshotStore<AssetDomainObject.State, string> stateForAssets;
public CreateAssetSlugs(ISnapshotStore<AssetState, string> stateForAssets) public CreateAssetSlugs(ISnapshotStore<AssetDomainObject.State, string> stateForAssets)
{ {
this.stateForAssets = stateForAssets; this.stateForAssets = stateForAssets;
} }

27
backend/src/Migrations/RebuilderExtensions.cs

@ -7,16 +7,11 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps.DomainObject;
using Squidex.Domain.Apps.Entities.Apps.State; using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Domain.Apps.Entities.Assets; using Squidex.Domain.Apps.Entities.Contents.DomainObject;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Rules.DomainObject;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Schemas.DomainObject;
using Squidex.Domain.Apps.Entities.Contents.State;
using Squidex.Domain.Apps.Entities.Rules;
using Squidex.Domain.Apps.Entities.Rules.State;
using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Domain.Apps.Entities.Schemas.State;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
namespace Migrations namespace Migrations
@ -25,32 +20,32 @@ namespace Migrations
{ {
public static Task RebuildAppsAsync(this Rebuilder rebuilder, CancellationToken ct = default) public static Task RebuildAppsAsync(this Rebuilder rebuilder, CancellationToken ct = default)
{ {
return rebuilder.RebuildAsync<AppDomainObject, AppState>("^app\\-", ct); return rebuilder.RebuildAsync<AppDomainObject, AppDomainObject.State>("^app\\-", ct);
} }
public static Task RebuildSchemasAsync(this Rebuilder rebuilder, CancellationToken ct = default) public static Task RebuildSchemasAsync(this Rebuilder rebuilder, CancellationToken ct = default)
{ {
return rebuilder.RebuildAsync<SchemaDomainObject, SchemaState>("^schema\\-", ct); return rebuilder.RebuildAsync<SchemaDomainObject, SchemaDomainObject.State>("^schema\\-", ct);
} }
public static Task RebuildRulesAsync(this Rebuilder rebuilder, CancellationToken ct = default) public static Task RebuildRulesAsync(this Rebuilder rebuilder, CancellationToken ct = default)
{ {
return rebuilder.RebuildAsync<RuleDomainObject, RuleState>("^rule\\-", ct); return rebuilder.RebuildAsync<RuleDomainObject, RuleDomainObject.State>("^rule\\-", ct);
} }
public static Task RebuildAssetsAsync(this Rebuilder rebuilder, CancellationToken ct = default) public static Task RebuildAssetsAsync(this Rebuilder rebuilder, CancellationToken ct = default)
{ {
return rebuilder.RebuildAsync<AssetDomainObject, AssetState>("^asset\\-", ct); return rebuilder.RebuildAsync<AssetDomainObject, AssetDomainObject.State>("^asset\\-", ct);
} }
public static Task RebuildAssetFoldersAsync(this Rebuilder rebuilder, CancellationToken ct = default) public static Task RebuildAssetFoldersAsync(this Rebuilder rebuilder, CancellationToken ct = default)
{ {
return rebuilder.RebuildAsync<AssetFolderDomainObject, AssetFolderState>("^assetFolder\\-", ct); return rebuilder.RebuildAsync<AssetFolderDomainObject, AssetFolderDomainObject.State>("^assetFolder\\-", ct);
} }
public static Task RebuildContentAsync(this Rebuilder rebuilder, CancellationToken ct = default) public static Task RebuildContentAsync(this Rebuilder rebuilder, CancellationToken ct = default)
{ {
return rebuilder.RebuildAsync<ContentDomainObject, ContentState>("^content\\-", ct); return rebuilder.RebuildAsync<ContentDomainObject, ContentDomainObject.State>("^content\\-", ct);
} }
} }
} }

4
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleEventFormatter.cs

@ -348,7 +348,7 @@ namespace Squidex.Domain.Apps.Core.HandleRules
script = null!; script = null!;
var comparer = StringComparison.OrdinalIgnoreCase; const StringComparison comparer = StringComparison.OrdinalIgnoreCase;
if (text.StartsWith(ScriptPrefix, comparer) && text.EndsWith(ScriptSuffix, comparer)) if (text.StartsWith(ScriptPrefix, comparer) && text.EndsWith(ScriptSuffix, comparer))
{ {
@ -366,7 +366,7 @@ namespace Squidex.Domain.Apps.Core.HandleRules
script = null!; script = null!;
var comparer = StringComparison.OrdinalIgnoreCase; const StringComparison comparer = StringComparison.OrdinalIgnoreCase;
if (text.StartsWith(TemplatePrefix, comparer) && text.EndsWith(TemplateSuffix, comparer)) if (text.StartsWith(TemplatePrefix, comparer) && text.EndsWith(TemplateSuffix, comparer))
{ {

16
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository_SnapshotStore.cs

@ -10,7 +10,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Bson; using MongoDB.Bson;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
@ -19,9 +19,9 @@ using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.MongoDb.Assets namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
{ {
public sealed partial class MongoAssetFolderRepository : ISnapshotStore<AssetFolderState, DomainId> public sealed partial class MongoAssetFolderRepository : ISnapshotStore<AssetFolderDomainObject.State, DomainId>
{ {
async Task<(AssetFolderState Value, long Version)> ISnapshotStore<AssetFolderState, DomainId>.ReadAsync(DomainId key) async Task<(AssetFolderDomainObject.State Value, long Version)> ISnapshotStore<AssetFolderDomainObject.State, DomainId>.ReadAsync(DomainId key)
{ {
using (Profiler.TraceMethod<MongoAssetFolderRepository>()) using (Profiler.TraceMethod<MongoAssetFolderRepository>())
{ {
@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
async Task ISnapshotStore<AssetFolderState, DomainId>.WriteAsync(DomainId key, AssetFolderState value, long oldVersion, long newVersion) async Task ISnapshotStore<AssetFolderDomainObject.State, DomainId>.WriteAsync(DomainId key, AssetFolderDomainObject.State value, long oldVersion, long newVersion)
{ {
using (Profiler.TraceMethod<MongoAssetFolderRepository>()) using (Profiler.TraceMethod<MongoAssetFolderRepository>())
{ {
@ -50,7 +50,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
async Task ISnapshotStore<AssetFolderState, DomainId>.ReadAllAsync(Func<AssetFolderState, long, Task> callback, CancellationToken ct) async Task ISnapshotStore<AssetFolderDomainObject.State, DomainId>.ReadAllAsync(Func<AssetFolderDomainObject.State, long, Task> callback, CancellationToken ct)
{ {
using (Profiler.TraceMethod<MongoAssetFolderRepository>()) using (Profiler.TraceMethod<MongoAssetFolderRepository>())
{ {
@ -58,7 +58,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
async Task ISnapshotStore<AssetFolderState, DomainId>.RemoveAsync(DomainId key) async Task ISnapshotStore<AssetFolderDomainObject.State, DomainId>.RemoveAsync(DomainId key)
{ {
using (Profiler.TraceMethod<MongoAssetFolderRepository>()) using (Profiler.TraceMethod<MongoAssetFolderRepository>())
{ {
@ -66,9 +66,9 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
private static AssetFolderState Map(MongoAssetFolderEntity existing) private static AssetFolderDomainObject.State Map(MongoAssetFolderEntity existing)
{ {
return SimpleMapper.Map(existing, new AssetFolderState()); return SimpleMapper.Map(existing, new AssetFolderDomainObject.State());
} }
} }
} }

1
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository.cs

@ -16,7 +16,6 @@ using Squidex.Domain.Apps.Entities.MongoDb.Assets.Visitors;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.MongoDb.Queries; using Squidex.Infrastructure.MongoDb.Queries;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Log; using Squidex.Log;

16
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository_SnapshotStore.cs

@ -10,7 +10,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Bson; using MongoDB.Bson;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
@ -19,9 +19,9 @@ using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.MongoDb.Assets namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
{ {
public sealed partial class MongoAssetRepository : ISnapshotStore<AssetState, DomainId> public sealed partial class MongoAssetRepository : ISnapshotStore<AssetDomainObject.State, DomainId>
{ {
async Task<(AssetState Value, long Version)> ISnapshotStore<AssetState, DomainId>.ReadAsync(DomainId key) async Task<(AssetDomainObject.State Value, long Version)> ISnapshotStore<AssetDomainObject.State, DomainId>.ReadAsync(DomainId key)
{ {
using (Profiler.TraceMethod<MongoAssetRepository>()) using (Profiler.TraceMethod<MongoAssetRepository>())
{ {
@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
async Task ISnapshotStore<AssetState, DomainId>.WriteAsync(DomainId key, AssetState value, long oldVersion, long newVersion) async Task ISnapshotStore<AssetDomainObject.State, DomainId>.WriteAsync(DomainId key, AssetDomainObject.State value, long oldVersion, long newVersion)
{ {
using (Profiler.TraceMethod<MongoAssetRepository>()) using (Profiler.TraceMethod<MongoAssetRepository>())
{ {
@ -50,7 +50,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
async Task ISnapshotStore<AssetState, DomainId>.ReadAllAsync(Func<AssetState, long, Task> callback, CancellationToken ct) async Task ISnapshotStore<AssetDomainObject.State, DomainId>.ReadAllAsync(Func<AssetDomainObject.State, long, Task> callback, CancellationToken ct)
{ {
using (Profiler.TraceMethod<MongoAssetRepository>()) using (Profiler.TraceMethod<MongoAssetRepository>())
{ {
@ -58,7 +58,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
async Task ISnapshotStore<AssetState, DomainId>.RemoveAsync(DomainId key) async Task ISnapshotStore<AssetDomainObject.State, DomainId>.RemoveAsync(DomainId key)
{ {
using (Profiler.TraceMethod<MongoAssetRepository>()) using (Profiler.TraceMethod<MongoAssetRepository>())
{ {
@ -66,9 +66,9 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
private static AssetState Map(MongoAssetEntity existing) private static AssetDomainObject.State Map(MongoAssetEntity existing)
{ {
return SimpleMapper.Map(existing, new AssetState()); return SimpleMapper.Map(existing, new AssetDomainObject.State());
} }
} }
} }

22
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository_SnapshotStore.cs

@ -9,7 +9,7 @@ using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities.Contents.State; using Squidex.Domain.Apps.Entities.Contents.DomainObject;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
@ -18,14 +18,14 @@ using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.MongoDb.Contents namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
{ {
public partial class MongoContentRepository : ISnapshotStore<ContentState, DomainId> public partial class MongoContentRepository : ISnapshotStore<ContentDomainObject.State, DomainId>
{ {
Task ISnapshotStore<ContentState, DomainId>.ReadAllAsync(Func<ContentState, long, Task> callback, CancellationToken ct) Task ISnapshotStore<ContentDomainObject.State, DomainId>.ReadAllAsync(Func<ContentDomainObject.State, long, Task> callback, CancellationToken ct)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
async Task ISnapshotStore<ContentState, DomainId>.ClearAsync() async Task ISnapshotStore<ContentDomainObject.State, DomainId>.ClearAsync()
{ {
using (Profiler.TraceMethod<MongoContentRepository>()) using (Profiler.TraceMethod<MongoContentRepository>())
{ {
@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
} }
} }
async Task ISnapshotStore<ContentState, DomainId>.RemoveAsync(DomainId key) async Task ISnapshotStore<ContentDomainObject.State, DomainId>.RemoveAsync(DomainId key)
{ {
using (Profiler.TraceMethod<MongoContentRepository>()) using (Profiler.TraceMethod<MongoContentRepository>())
{ {
@ -43,7 +43,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
} }
} }
async Task<(ContentState Value, long Version)> ISnapshotStore<ContentState, DomainId>.ReadAsync(DomainId key) async Task<(ContentDomainObject.State Value, long Version)> ISnapshotStore<ContentDomainObject.State, DomainId>.ReadAsync(DomainId key)
{ {
using (Profiler.TraceMethod<MongoContentRepository>()) using (Profiler.TraceMethod<MongoContentRepository>())
{ {
@ -60,14 +60,14 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
contentEntity.ParseData(schema.SchemaDef, converter); contentEntity.ParseData(schema.SchemaDef, converter);
return (SimpleMapper.Map(contentEntity, new ContentState()), contentEntity.Version); return (SimpleMapper.Map(contentEntity, new ContentDomainObject.State()), contentEntity.Version);
} }
return (null!, EtagVersion.NotFound); return (null!, EtagVersion.NotFound);
} }
} }
async Task ISnapshotStore<ContentState, DomainId>.WriteAsync(DomainId key, ContentState value, long oldVersion, long newVersion) async Task ISnapshotStore<ContentDomainObject.State, DomainId>.WriteAsync(DomainId key, ContentDomainObject.State value, long oldVersion, long newVersion)
{ {
using (Profiler.TraceMethod<MongoContentRepository>()) using (Profiler.TraceMethod<MongoContentRepository>())
{ {
@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
} }
} }
private async Task UpsertOrDeletePublishedAsync(ContentState value, long oldVersion, long newVersion, ISchemaEntity schema) private async Task UpsertOrDeletePublishedAsync(ContentDomainObject.State value, long oldVersion, long newVersion, ISchemaEntity schema)
{ {
if (value.Status == Status.Published && !value.IsDeleted) if (value.Status == Status.Published && !value.IsDeleted)
{ {
@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
return collectionPublished.RemoveAsync(documentId); return collectionPublished.RemoveAsync(documentId);
} }
private async Task UpsertDraftContentAsync(ContentState value, long oldVersion, long newVersion, ISchemaEntity schema) private async Task UpsertDraftContentAsync(ContentDomainObject.State value, long oldVersion, long newVersion, ISchemaEntity schema)
{ {
var content = SimpleMapper.Map(value, new MongoContentEntity var content = SimpleMapper.Map(value, new MongoContentEntity
{ {
@ -128,7 +128,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
await collectionAll.UpsertVersionedAsync(content.DocumentId, oldVersion, content); await collectionAll.UpsertVersionedAsync(content.DocumentId, oldVersion, content);
} }
private async Task UpsertPublishedContentAsync(ContentState value, long oldVersion, long newVersion, ISchemaEntity schema) private async Task UpsertPublishedContentAsync(ContentDomainObject.State value, long oldVersion, long newVersion, ISchemaEntity schema)
{ {
var content = SimpleMapper.Map(value, new MongoContentEntity var content = SimpleMapper.Map(value, new MongoContentEntity
{ {

1
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryByQuery.cs

@ -20,7 +20,6 @@ using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.MongoDb.Queries; using Squidex.Infrastructure.MongoDb.Queries;
using Squidex.Infrastructure.Queries; using Squidex.Infrastructure.Queries;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations

1
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Rules/MongoRuleEventRepository.cs

@ -18,7 +18,6 @@ using Squidex.Domain.Apps.Entities.Rules.Repositories;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.MongoDb.Rules namespace Squidex.Domain.Apps.Entities.MongoDb.Rules
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/AppCommandMiddleware.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppCommandMiddleware.cs

@ -14,7 +14,7 @@ using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
{ {
public sealed class AppCommandMiddleware : GrainCommandMiddleware<AppCommand, IAppGrain> public sealed class AppCommandMiddleware : GrainCommandMiddleware<AppCommand, IAppGrain>
{ {

231
backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObject.State.cs

@ -0,0 +1,231 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Apps;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
{
public sealed partial class AppDomainObject
{
[CollectionName("Apps")]
public sealed class State : DomainObjectState<State>, IAppEntity
{
public string Name { get; set; }
public string Label { get; set; }
public string Description { get; set; }
public Roles Roles { get; set; } = Roles.Empty;
public AppImage? Image { get; set; }
public AppPlan? Plan { get; set; }
public AppClients Clients { get; set; } = AppClients.Empty;
public AppPatterns Patterns { get; set; } = AppPatterns.Empty;
public AppContributors Contributors { get; set; } = AppContributors.Empty;
public LanguagesConfig Languages { get; set; } = LanguagesConfig.English;
public Workflows Workflows { get; set; } = Workflows.Empty;
public bool IsArchived { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return Id; }
}
public override bool ApplyEvent(IEvent @event)
{
switch (@event)
{
case AppCreated e:
{
Id = e.AppId.Id;
SimpleMapper.Map(e, this);
return true;
}
case AppUpdated e when Is.Change(Label, e.Label) || Is.Change(Description, e.Description):
{
SimpleMapper.Map(e, this);
return true;
}
case AppImageUploaded e:
return UpdateImage(e, ev => ev.Image);
case AppImageRemoved e when Image != null:
return UpdateImage(e, ev => null);
case AppPlanChanged e when Is.Change(Plan?.PlanId, e.PlanId):
return UpdatePlan(e, ev => ev.ToAppPlan());
case AppPlanReset e when Plan != null:
return UpdatePlan(e, ev => null);
case AppContributorAssigned e:
return UpdateContributors(e, (ev, c) => c.Assign(ev.ContributorId, ev.Role));
case AppContributorRemoved e:
return UpdateContributors(e, (ev, c) => c.Remove(ev.ContributorId));
case AppClientAttached e:
return UpdateClients(e, (ev, c) => c.Add(ev.Id, ev.Secret));
case AppClientUpdated e:
return UpdateClients(e, (ev, c) => c.Update(ev.Id, ev.Name, ev.Role, ev.ApiCallsLimit, ev.ApiTrafficLimit, ev.AllowAnonymous));
case AppClientRevoked e:
return UpdateClients(e, (ev, c) => c.Revoke(ev.Id));
case AppWorkflowAdded e:
return UpdateWorkflows(e, (ev, w) => w.Add(ev.WorkflowId, ev.Name));
case AppWorkflowUpdated e:
return UpdateWorkflows(e, (ev, w) => w.Update(ev.WorkflowId, ev.Workflow));
case AppWorkflowDeleted e:
return UpdateWorkflows(e, (ev, w) => w.Remove(ev.WorkflowId));
case AppPatternAdded e:
return UpdatePatterns(e, (ev, p) => p.Add(ev.PatternId, ev.Name, ev.Pattern, ev.Message));
case AppPatternDeleted e:
return UpdatePatterns(e, (ev, p) => p.Remove(ev.PatternId));
case AppPatternUpdated e:
return UpdatePatterns(e, (ev, p) => p.Update(ev.PatternId, ev.Name, ev.Pattern, ev.Message));
case AppRoleAdded e:
return UpdateRoles(e, (ev, r) => r.Add(ev.Name));
case AppRoleUpdated e:
return UpdateRoles(e, (ev, r) => r.Update(ev.Name, ev.ToPermissions(), ev.Properties));
case AppRoleDeleted e:
return UpdateRoles(e, (ev, r) => r.Remove(ev.Name));
case AppLanguageAdded e:
return UpdateLanguages(e, (ev, l) => l.Set(ev.Language));
case AppLanguageRemoved e:
return UpdateLanguages(e, (ev, l) => l.Remove(ev.Language));
case AppLanguageUpdated e:
return UpdateLanguages(e, (ev, l) =>
{
l = l.Set(ev.Language, ev.IsOptional, ev.Fallback);
if (ev.IsMaster)
{
l = Languages.MakeMaster(ev.Language);
}
return l;
});
case AppArchived _:
{
Plan = null;
IsArchived = true;
return true;
}
}
return false;
}
private bool UpdateContributors<T>(T @event, Func<T, AppContributors, AppContributors> update)
{
var previous = Contributors;
Contributors = update(@event, previous);
return !ReferenceEquals(previous, Contributors);
}
private bool UpdateClients<T>(T @event, Func<T, AppClients, AppClients> update)
{
var previous = Clients;
Clients = update(@event, previous);
return !ReferenceEquals(previous, Clients);
}
private bool UpdateLanguages<T>(T @event, Func<T, LanguagesConfig, LanguagesConfig> update)
{
var previous = Languages;
Languages = update(@event, previous);
return !ReferenceEquals(previous, Languages);
}
private bool UpdatePatterns<T>(T @event, Func<T, AppPatterns, AppPatterns> update)
{
var previous = Patterns;
Patterns = update(@event, previous);
return !ReferenceEquals(previous, Patterns);
}
private bool UpdateRoles<T>(T @event, Func<T, Roles, Roles> update)
{
var previous = Roles;
Roles = update(@event, previous);
return !ReferenceEquals(previous, Roles);
}
private bool UpdateWorkflows<T>(T @event, Func<T, Workflows, Workflows> update)
{
var previous = Workflows;
Workflows = update(@event, previous);
return !ReferenceEquals(previous, Workflows);
}
private bool UpdateImage<T>(T @event, Func<T, AppImage?> update)
{
Image = update(@event);
return true;
}
private bool UpdatePlan<T>(T @event, Func<T, AppPlan?> update)
{
Plan = update(@event);
return true;
}
}
}
}

7
backend/src/Squidex.Domain.Apps.Entities/Apps/AppDomainObject.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObject.cs

@ -10,9 +10,8 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Core.Apps; using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Entities.Apps.Commands; using Squidex.Domain.Apps.Entities.Apps.Commands;
using Squidex.Domain.Apps.Entities.Apps.Guards; using Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards;
using Squidex.Domain.Apps.Entities.Apps.Plans; using Squidex.Domain.Apps.Entities.Apps.Plans;
using Squidex.Domain.Apps.Entities.Apps.State;
using Squidex.Domain.Apps.Events; using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Apps; using Squidex.Domain.Apps.Events.Apps;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -23,9 +22,9 @@ using Squidex.Infrastructure.States;
using Squidex.Log; using Squidex.Log;
using Squidex.Shared.Users; using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
{ {
public class AppDomainObject : DomainObject<AppState> public sealed partial class AppDomainObject : DomainObject<AppDomainObject.State>
{ {
private readonly InitialPatterns initialPatterns; private readonly InitialPatterns initialPatterns;
private readonly IAppPlansProvider appPlansProvider; private readonly IAppPlansProvider appPlansProvider;

5
backend/src/Squidex.Domain.Apps.Entities/Apps/AppDomainObjectGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObjectGrain.cs

@ -7,13 +7,12 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Apps.State;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
{ {
public sealed class AppDomainObjectGrain : DomainObjectGrain<AppDomainObject, AppState>, IAppGrain public sealed class AppDomainObjectGrain : DomainObjectGrain<AppDomainObject, AppDomainObject.State>, IAppGrain
{ {
public AppDomainObjectGrain(IServiceProvider serviceProvider) public AppDomainObjectGrain(IServiceProvider serviceProvider)
: base(serviceProvider) : base(serviceProvider)

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardApp.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardApp.cs

@ -12,7 +12,7 @@ using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Squidex.Text; using Squidex.Text;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public static class GuardApp public static class GuardApp
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppClients.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppClients.cs

@ -11,7 +11,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public static class GuardAppClients public static class GuardAppClients
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppContributors.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppContributors.cs

@ -16,7 +16,7 @@ using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Squidex.Shared.Users; using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public static class GuardAppContributors public static class GuardAppContributors
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppLanguages.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppLanguages.cs

@ -11,7 +11,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public static class GuardAppLanguages public static class GuardAppLanguages
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppPatterns.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppPatterns.cs

@ -12,7 +12,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public static class GuardAppPatterns public static class GuardAppPatterns
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppRoles.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppRoles.cs

@ -13,7 +13,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public static class GuardAppRoles public static class GuardAppRoles
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppWorkflows.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/Guards/GuardAppWorkflows.cs

@ -11,7 +11,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public static class GuardAppWorkflows public static class GuardAppWorkflows
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/IAppGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/IAppGrain.cs

@ -9,7 +9,7 @@ using System.Threading.Tasks;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
{ {
public interface IAppGrain : IDomainObjectGrain public interface IAppGrain : IDomainObjectGrain
{ {

1
backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Caching; using Squidex.Caching;
using Squidex.Domain.Apps.Entities.Apps.Commands; using Squidex.Domain.Apps.Entities.Apps.Commands;
using Squidex.Domain.Apps.Entities.Apps.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;

228
backend/src/Squidex.Domain.Apps.Entities/Apps/State/AppState.cs

@ -1,228 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Apps;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Entities.Apps.State
{
[CollectionName("Apps")]
public class AppState : DomainObjectState<AppState>, IAppEntity
{
public string Name { get; set; }
public string Label { get; set; }
public string Description { get; set; }
public Roles Roles { get; set; } = Roles.Empty;
public AppImage? Image { get; set; }
public AppPlan? Plan { get; set; }
public AppClients Clients { get; set; } = AppClients.Empty;
public AppPatterns Patterns { get; set; } = AppPatterns.Empty;
public AppContributors Contributors { get; set; } = AppContributors.Empty;
public LanguagesConfig Languages { get; set; } = LanguagesConfig.English;
public Workflows Workflows { get; set; } = Workflows.Empty;
public bool IsArchived { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return Id; }
}
public override bool ApplyEvent(IEvent @event)
{
switch (@event)
{
case AppCreated e:
{
Id = e.AppId.Id;
SimpleMapper.Map(e, this);
return true;
}
case AppUpdated e when Is.Change(Label, e.Label) || Is.Change(Description, e.Description):
{
SimpleMapper.Map(e, this);
return true;
}
case AppImageUploaded e:
return UpdateImage(e, ev => ev.Image);
case AppImageRemoved e when Image != null:
return UpdateImage(e, ev => null);
case AppPlanChanged e when Is.Change(Plan?.PlanId, e.PlanId):
return UpdatePlan(e, ev => ev.ToAppPlan());
case AppPlanReset e when Plan != null:
return UpdatePlan(e, ev => null);
case AppContributorAssigned e:
return UpdateContributors(e, (ev, c) => c.Assign(ev.ContributorId, ev.Role));
case AppContributorRemoved e:
return UpdateContributors(e, (ev, c) => c.Remove(ev.ContributorId));
case AppClientAttached e:
return UpdateClients(e, (ev, c) => c.Add(ev.Id, ev.Secret));
case AppClientUpdated e:
return UpdateClients(e, (ev, c) => c.Update(ev.Id, ev.Name, ev.Role, ev.ApiCallsLimit, ev.ApiTrafficLimit, ev.AllowAnonymous));
case AppClientRevoked e:
return UpdateClients(e, (ev, c) => c.Revoke(ev.Id));
case AppWorkflowAdded e:
return UpdateWorkflows(e, (ev, w) => w.Add(ev.WorkflowId, ev.Name));
case AppWorkflowUpdated e:
return UpdateWorkflows(e, (ev, w) => w.Update(ev.WorkflowId, ev.Workflow));
case AppWorkflowDeleted e:
return UpdateWorkflows(e, (ev, w) => w.Remove(ev.WorkflowId));
case AppPatternAdded e:
return UpdatePatterns(e, (ev, p) => p.Add(ev.PatternId, ev.Name, ev.Pattern, ev.Message));
case AppPatternDeleted e:
return UpdatePatterns(e, (ev, p) => p.Remove(ev.PatternId));
case AppPatternUpdated e:
return UpdatePatterns(e, (ev, p) => p.Update(ev.PatternId, ev.Name, ev.Pattern, ev.Message));
case AppRoleAdded e:
return UpdateRoles(e, (ev, r) => r.Add(ev.Name));
case AppRoleUpdated e:
return UpdateRoles(e, (ev, r) => r.Update(ev.Name, ev.ToPermissions(), ev.Properties));
case AppRoleDeleted e:
return UpdateRoles(e, (ev, r) => r.Remove(ev.Name));
case AppLanguageAdded e:
return UpdateLanguages(e, (ev, l) => l.Set(ev.Language));
case AppLanguageRemoved e:
return UpdateLanguages(e, (ev, l) => l.Remove(ev.Language));
case AppLanguageUpdated e:
return UpdateLanguages(e, (ev, l) =>
{
l = l.Set(ev.Language, ev.IsOptional, ev.Fallback);
if (ev.IsMaster)
{
l = Languages.MakeMaster(ev.Language);
}
return l;
});
case AppArchived _:
{
Plan = null;
IsArchived = true;
return true;
}
}
return false;
}
private bool UpdateContributors<T>(T @event, Func<T, AppContributors, AppContributors> update)
{
var previous = Contributors;
Contributors = update(@event, previous);
return !ReferenceEquals(previous, Contributors);
}
private bool UpdateClients<T>(T @event, Func<T, AppClients, AppClients> update)
{
var previous = Clients;
Clients = update(@event, previous);
return !ReferenceEquals(previous, Clients);
}
private bool UpdateLanguages<T>(T @event, Func<T, LanguagesConfig, LanguagesConfig> update)
{
var previous = Languages;
Languages = update(@event, previous);
return !ReferenceEquals(previous, Languages);
}
private bool UpdatePatterns<T>(T @event, Func<T, AppPatterns, AppPatterns> update)
{
var previous = Patterns;
Patterns = update(@event, previous);
return !ReferenceEquals(previous, Patterns);
}
private bool UpdateRoles<T>(T @event, Func<T, Roles, Roles> update)
{
var previous = Roles;
Roles = update(@event, previous);
return !ReferenceEquals(previous, Roles);
}
private bool UpdateWorkflows<T>(T @event, Func<T, Workflows, Workflows> update)
{
var previous = Workflows;
Workflows = update(@event, previous);
return !ReferenceEquals(previous, Workflows);
}
private bool UpdateImage<T>(T @event, Func<T, AppImage?> update)
{
Image = update(@event);
return true;
}
private bool UpdatePlan<T>(T @event, Func<T, AppPlan?> update)
{
Plan = update(@event);
return true;
}
}
}

6
backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs

@ -10,7 +10,7 @@ using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Assets; using Squidex.Assets;
using Squidex.Domain.Apps.Core.Tags; using Squidex.Domain.Apps.Core.Tags;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Domain.Apps.Entities.Backup; using Squidex.Domain.Apps.Entities.Backup;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -101,12 +101,12 @@ namespace Squidex.Domain.Apps.Entities.Assets
if (assetIds.Count > 0) if (assetIds.Count > 0)
{ {
await rebuilder.InsertManyAsync<AssetDomainObject, AssetState>(assetIds); await rebuilder.InsertManyAsync<AssetDomainObject, AssetDomainObject.State>(assetIds);
} }
if (assetFolderIds.Count > 0) if (assetFolderIds.Count > 0)
{ {
await rebuilder.InsertManyAsync<AssetFolderDomainObject, AssetFolderState>(assetFolderIds); await rebuilder.InsertManyAsync<AssetFolderDomainObject, AssetFolderDomainObject.State>(assetFolderIds);
} }
} }

2
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetCommandMiddleware.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetCommandMiddleware.cs

@ -14,7 +14,7 @@ using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public sealed class AssetCommandMiddleware : GrainCommandMiddleware<AssetCommand, IAssetGrain> public sealed class AssetCommandMiddleware : GrainCommandMiddleware<AssetCommand, IAssetGrain>
{ {

178
backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs

@ -0,0 +1,178 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Assets;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{
public sealed partial class AssetDomainObject
{
public sealed class State : DomainObjectState<State>, IAssetEntity
{
public NamedId<DomainId> AppId { get; set; }
public DomainId ParentId { get; set; }
public string FileName { get; set; }
public string FileHash { get; set; }
public string MimeType { get; set; }
public string Slug { get; set; }
public long FileVersion { get; set; }
public long FileSize { get; set; }
public long TotalSize { get; set; }
public bool IsProtected { get; set; }
public HashSet<string> Tags { get; set; }
public AssetMetadata Metadata { get; set; }
public AssetType Type { get; set; }
[IgnoreDataMember]
public DomainId AssetId
{
get { return Id; }
}
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
switch (@event)
{
case AssetCreated e:
{
Id = e.AssetId;
SimpleMapper.Map(e, this);
FileName = e.FileName;
if (string.IsNullOrWhiteSpace(e.Slug))
{
Slug = e.FileName.ToAssetSlug();
}
else
{
Slug = e.Slug;
}
TotalSize += e.FileSize;
EnsureProperties();
return true;
}
case AssetUpdated e:
{
SimpleMapper.Map(e, this);
TotalSize += e.FileSize;
EnsureProperties();
return true;
}
case AssetAnnotated e:
{
var hasChanged = false;
if (Is.OptionalChange(FileName, e.FileName))
{
FileName = e.FileName;
hasChanged = true;
}
if (Is.OptionalChange(Slug, e.Slug))
{
Slug = e.Slug;
hasChanged = true;
}
if (Is.OptionalChange(IsProtected, e.IsProtected))
{
IsProtected = e.IsProtected.Value;
hasChanged = true;
}
if (Is.OptionalChange(Tags, e.Tags))
{
Tags = e.Tags;
hasChanged = true;
}
if (Is.OptionalChange(Metadata, e.Metadata))
{
Metadata = e.Metadata;
hasChanged = true;
}
EnsureProperties();
return hasChanged;
}
case AssetMoved e when e.ParentId != ParentId:
{
ParentId = e.ParentId;
EnsureProperties();
return true;
}
case AssetDeleted _:
{
IsDeleted = true;
return true;
}
}
return false;
}
private void EnsureProperties()
{
if (Tags == null)
{
Tags = new HashSet<string>();
}
if (Metadata == null)
{
Metadata = new AssetMetadata();
}
}
}
}
}

7
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetDomainObject.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.cs

@ -10,8 +10,7 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Core.Tags; using Squidex.Domain.Apps.Core.Tags;
using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.Assets.Guards; using Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards;
using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Domain.Apps.Entities.Contents.Repositories; using Squidex.Domain.Apps.Entities.Contents.Repositories;
using Squidex.Domain.Apps.Events; using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
@ -23,9 +22,9 @@ using Squidex.Infrastructure.States;
using Squidex.Log; using Squidex.Log;
using IAssetTagService = Squidex.Domain.Apps.Core.Tags.ITagService; using IAssetTagService = Squidex.Domain.Apps.Core.Tags.ITagService;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public class AssetDomainObject : LogSnapshotDomainObject<AssetState> public sealed partial class AssetDomainObject : LogSnapshotDomainObject<AssetDomainObject.State>
{ {
private readonly IContentRepository contentRepository; private readonly IContentRepository contentRepository;
private readonly IAssetTagService assetTags; private readonly IAssetTagService assetTags;

5
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetDomainObjectGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObjectGrain.cs

@ -7,14 +7,13 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public sealed class AssetDomainObjectGrain : DomainObjectGrain<AssetDomainObject, AssetState>, IAssetGrain public sealed class AssetDomainObjectGrain : DomainObjectGrain<AssetDomainObject, AssetDomainObject.State>, IAssetGrain
{ {
private static readonly TimeSpan Lifetime = TimeSpan.FromMinutes(5); private static readonly TimeSpan Lifetime = TimeSpan.FromMinutes(5);

72
backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderDomainObject.State.cs

@ -0,0 +1,72 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{
public sealed partial class AssetFolderDomainObject
{
public sealed class State : DomainObjectState<State>, IAssetFolderEntity
{
public NamedId<DomainId> AppId { get; set; }
public string FolderName { get; set; }
public DomainId ParentId { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
switch (@event)
{
case AssetFolderCreated e:
{
Id = e.AssetFolderId;
SimpleMapper.Map(e, this);
return true;
}
case AssetFolderRenamed e when Is.OptionalChange(FolderName, e.FolderName):
{
FolderName = e.FolderName;
return true;
}
case AssetFolderMoved e when Is.Change(ParentId, e.ParentId):
{
ParentId = e.ParentId;
return true;
}
case AssetFolderDeleted _:
{
IsDeleted = true;
return true;
}
}
return false;
}
}
}
}

7
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetFolderDomainObject.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderDomainObject.cs

@ -8,8 +8,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.Assets.Guards; using Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards;
using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Domain.Apps.Events; using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -19,9 +18,9 @@ using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Log; using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public class AssetFolderDomainObject : DomainObject<AssetFolderState> public sealed partial class AssetFolderDomainObject : DomainObject<AssetFolderDomainObject.State>
{ {
private readonly IAssetQueryService assetQuery; private readonly IAssetQueryService assetQuery;

5
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetFolderDomainObjectGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderDomainObjectGrain.cs

@ -7,13 +7,12 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public sealed class AssetFolderDomainObjectGrain : DomainObjectGrain<AssetFolderDomainObject, AssetFolderState>, IAssetFolderGrain public sealed class AssetFolderDomainObjectGrain : DomainObjectGrain<AssetFolderDomainObject, AssetFolderDomainObject.State>, IAssetFolderGrain
{ {
private static readonly TimeSpan Lifetime = TimeSpan.FromMinutes(5); private static readonly TimeSpan Lifetime = TimeSpan.FromMinutes(5);

2
backend/src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAsset.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/GuardAsset.cs

@ -13,7 +13,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Assets.Guards namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
{ {
public static class GuardAsset public static class GuardAsset
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Assets/Guards/GuardAssetFolder.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/Guards/GuardAssetFolder.cs

@ -11,7 +11,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Assets.Guards namespace Squidex.Domain.Apps.Entities.Assets.DomainObject.Guards
{ {
public static class GuardAssetFolder public static class GuardAssetFolder
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Assets/IAssetFolderGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/IAssetFolderGrain.cs

@ -7,7 +7,7 @@
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public interface IAssetFolderGrain : IDomainObjectGrain public interface IAssetFolderGrain : IDomainObjectGrain
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Assets/IAssetGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/IAssetGrain.cs

@ -10,7 +10,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public interface IAssetGrain : IDomainObjectGrain public interface IAssetGrain : IDomainObjectGrain
{ {

1
backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/AssetLoader.cs

@ -7,6 +7,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Log; using Squidex.Log;

69
backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetFolderState.cs

@ -1,69 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Entities.Assets.State
{
public sealed class AssetFolderState : DomainObjectState<AssetFolderState>, IAssetFolderEntity
{
public NamedId<DomainId> AppId { get; set; }
public string FolderName { get; set; }
public DomainId ParentId { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
switch (@event)
{
case AssetFolderCreated e:
{
Id = e.AssetFolderId;
SimpleMapper.Map(e, this);
return true;
}
case AssetFolderRenamed e when Is.OptionalChange(FolderName, e.FolderName):
{
FolderName = e.FolderName;
return true;
}
case AssetFolderMoved e when Is.Change(ParentId, e.ParentId):
{
ParentId = e.ParentId;
return true;
}
case AssetFolderDeleted _:
{
IsDeleted = true;
return true;
}
}
return false;
}
}
}

175
backend/src/Squidex.Domain.Apps.Entities/Assets/State/AssetState.cs

@ -1,175 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Assets;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Entities.Assets.State
{
public class AssetState : DomainObjectState<AssetState>, IAssetEntity
{
public NamedId<DomainId> AppId { get; set; }
public DomainId ParentId { get; set; }
public string FileName { get; set; }
public string FileHash { get; set; }
public string MimeType { get; set; }
public string Slug { get; set; }
public long FileVersion { get; set; }
public long FileSize { get; set; }
public long TotalSize { get; set; }
public bool IsProtected { get; set; }
public HashSet<string> Tags { get; set; }
public AssetMetadata Metadata { get; set; }
public AssetType Type { get; set; }
[IgnoreDataMember]
public DomainId AssetId
{
get { return Id; }
}
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
switch (@event)
{
case AssetCreated e:
{
Id = e.AssetId;
SimpleMapper.Map(e, this);
FileName = e.FileName;
if (string.IsNullOrWhiteSpace(e.Slug))
{
Slug = e.FileName.ToAssetSlug();
}
else
{
Slug = e.Slug;
}
TotalSize += e.FileSize;
EnsureProperties();
return true;
}
case AssetUpdated e:
{
SimpleMapper.Map(e, this);
TotalSize += e.FileSize;
EnsureProperties();
return true;
}
case AssetAnnotated e:
{
var hasChanged = false;
if (Is.OptionalChange(FileName, e.FileName))
{
FileName = e.FileName;
hasChanged = true;
}
if (Is.OptionalChange(Slug, e.Slug))
{
Slug = e.Slug;
hasChanged = true;
}
if (Is.OptionalChange(IsProtected, e.IsProtected))
{
IsProtected = e.IsProtected.Value;
hasChanged = true;
}
if (Is.OptionalChange(Tags, e.Tags))
{
Tags = e.Tags;
hasChanged = true;
}
if (Is.OptionalChange(Metadata, e.Metadata))
{
Metadata = e.Metadata;
hasChanged = true;
}
EnsureProperties();
return hasChanged;
}
case AssetMoved e when e.ParentId != ParentId:
{
ParentId = e.ParentId;
EnsureProperties();
return true;
}
case AssetDeleted _:
{
IsDeleted = true;
return true;
}
}
return false;
}
private void EnsureProperties()
{
if (Tags == null)
{
Tags = new HashSet<string>();
}
if (Metadata == null)
{
Metadata = new AssetMetadata();
}
}
}
}

1
backend/src/Squidex.Domain.Apps.Entities/Comments/CommentsLoader.cs

@ -7,6 +7,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Domain.Apps.Entities.Comments.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Entities.Comments namespace Squidex.Domain.Apps.Entities.Comments

2
backend/src/Squidex.Domain.Apps.Entities/Comments/CommentsCommandMiddleware.cs → backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsCommandMiddleware.cs

@ -17,7 +17,7 @@ using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
using Squidex.Shared.Users; using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.Comments namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
{ {
public sealed class CommentsCommandMiddleware : ICommandMiddleware public sealed class CommentsCommandMiddleware : ICommandMiddleware
{ {

4
backend/src/Squidex.Domain.Apps.Entities/Comments/CommentsGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/CommentsGrain.cs

@ -10,7 +10,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Comments.Commands; using Squidex.Domain.Apps.Entities.Comments.Commands;
using Squidex.Domain.Apps.Entities.Comments.Guards; using Squidex.Domain.Apps.Entities.Comments.DomainObject.Guards;
using Squidex.Domain.Apps.Events.Comments; using Squidex.Domain.Apps.Events.Comments;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
@ -18,7 +18,7 @@ using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Entities.Comments namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
{ {
public sealed class CommentsGrain : GrainOfString, ICommentsGrain public sealed class CommentsGrain : GrainOfString, ICommentsGrain
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Comments/Guards/GuardComments.cs → backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/Guards/GuardComments.cs

@ -13,7 +13,7 @@ using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Comments.Guards namespace Squidex.Domain.Apps.Entities.Comments.DomainObject.Guards
{ {
public static class GuardComments public static class GuardComments
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Comments/ICommentsGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Comments/DomainObject/ICommentsGrain.cs

@ -11,7 +11,7 @@ using Squidex.Domain.Apps.Entities.Comments.Commands;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Comments namespace Squidex.Domain.Apps.Entities.Comments.DomainObject
{ {
public interface ICommentsGrain : IGrainWithStringKey public interface ICommentsGrain : IGrainWithStringKey
{ {

4
backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs

@ -11,7 +11,7 @@ using System.Threading.Tasks;
using Squidex.Domain.Apps.Core; using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities.Backup; using Squidex.Domain.Apps.Entities.Backup;
using Squidex.Domain.Apps.Entities.Contents.State; using Squidex.Domain.Apps.Entities.Contents.DomainObject;
using Squidex.Domain.Apps.Events.Apps; using Squidex.Domain.Apps.Events.Apps;
using Squidex.Domain.Apps.Events.Contents; using Squidex.Domain.Apps.Events.Contents;
using Squidex.Domain.Apps.Events.Schemas; using Squidex.Domain.Apps.Events.Schemas;
@ -216,7 +216,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
if (ids.Any()) if (ids.Any())
{ {
await rebuilder.InsertManyAsync<ContentDomainObject, ContentState>(ids); await rebuilder.InsertManyAsync<ContentDomainObject, ContentDomainObject.State>(ids);
} }
} }

1
backend/src/Squidex.Domain.Apps.Entities/Contents/BulkUpdateCommandMiddleware.cs

@ -14,7 +14,6 @@ using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.Security;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Shared; using Squidex.Shared;

2
backend/src/Squidex.Domain.Apps.Entities/Contents/ContentCommandMiddleware.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentCommandMiddleware.cs

@ -12,7 +12,7 @@ using Squidex.Domain.Apps.Entities.Contents.Queries;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{ {
public sealed class ContentCommandMiddleware : GrainCommandMiddleware<ContentCommand, IContentGrain> public sealed class ContentCommandMiddleware : GrainCommandMiddleware<ContentCommand, IContentGrain>
{ {

159
backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.State.cs

@ -0,0 +1,159 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{
public sealed partial class ContentDomainObject
{
public sealed class State : DomainObjectState<State>, IContentEntity
{
public NamedId<DomainId> AppId { get; set; }
public NamedId<DomainId> SchemaId { get; set; }
public ContentVersion? NewVersion { get; set; }
public ContentVersion CurrentVersion { get; set; }
public ScheduleJob? ScheduleJob { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
[IgnoreDataMember]
public NamedContentData Data
{
get { return NewVersion?.Data ?? CurrentVersion.Data; }
}
[IgnoreDataMember]
public Status EditingStatus
{
get { return NewStatus ?? Status; }
}
[IgnoreDataMember]
public Status Status
{
get { return CurrentVersion.Status; }
}
[IgnoreDataMember]
public Status? NewStatus
{
get { return NewVersion?.Status; }
}
public override bool ApplyEvent(IEvent @event, EnvelopeHeaders headers)
{
switch (@event)
{
case ContentCreated e:
{
Id = e.ContentId;
SimpleMapper.Map(e, this);
CurrentVersion = new ContentVersion(e.Status, e.Data);
break;
}
case ContentDraftCreated e:
{
NewVersion = new ContentVersion(e.Status, e.MigratedData ?? CurrentVersion.Data);
ScheduleJob = null;
break;
}
case ContentDraftDeleted _:
{
NewVersion = null;
ScheduleJob = null;
break;
}
case ContentStatusChanged e:
{
ScheduleJob = null;
if (NewVersion != null)
{
if (e.Status == Status.Published)
{
CurrentVersion = new ContentVersion(e.Status, NewVersion.Data);
NewVersion = null;
}
else
{
NewVersion = NewVersion.WithStatus(e.Status);
}
}
else
{
CurrentVersion = CurrentVersion.WithStatus(e.Status);
}
break;
}
case ContentSchedulingCancelled _:
{
ScheduleJob = null;
break;
}
case ContentStatusScheduled e:
{
ScheduleJob = ScheduleJob.Build(e.Status, e.Actor, e.DueTime);
break;
}
case ContentUpdated e:
{
if (NewVersion != null)
{
NewVersion = NewVersion.WithData(e.Data);
}
else
{
CurrentVersion = CurrentVersion.WithData(e.Data);
}
break;
}
case ContentDeleted _:
{
IsDeleted = true;
break;
}
}
return true;
}
}
}
}

9
backend/src/Squidex.Domain.Apps.Entities/Contents/ContentDomainObject.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs

@ -6,15 +6,12 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using NodaTime; using NodaTime;
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Core.Scripting; using Squidex.Domain.Apps.Core.Scripting;
using Squidex.Domain.Apps.Entities.Contents.Commands; using Squidex.Domain.Apps.Entities.Contents.Commands;
using Squidex.Domain.Apps.Entities.Contents.Guards; using Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards;
using Squidex.Domain.Apps.Entities.Contents.Operations;
using Squidex.Domain.Apps.Entities.Contents.State;
using Squidex.Domain.Apps.Events; using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Contents; using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -24,9 +21,9 @@ using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Log; using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{ {
public class ContentDomainObject : LogSnapshotDomainObject<ContentState> public sealed partial class ContentDomainObject : LogSnapshotDomainObject<ContentDomainObject.State>
{ {
private readonly ContentOperationContext context; private readonly ContentOperationContext context;

5
backend/src/Squidex.Domain.Apps.Entities/Contents/ContentDomainObjectGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObjectGrain.cs

@ -7,13 +7,12 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Contents.State;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{ {
public sealed class ContentDomainObjectGrain : DomainObjectGrain<ContentDomainObject, ContentState>, IContentGrain public sealed class ContentDomainObjectGrain : DomainObjectGrain<ContentDomainObject, ContentDomainObject.State>, IContentGrain
{ {
private static readonly TimeSpan Lifetime = TimeSpan.FromMinutes(5); private static readonly TimeSpan Lifetime = TimeSpan.FromMinutes(5);

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Operations/ContentOperationContext.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentOperationContext.cs

@ -23,7 +23,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Squidex.Log; using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.Contents.Operations namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{ {
public sealed class ContentOperationContext public sealed class ContentOperationContext
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Contents/State/ContentVersion.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentVersion.cs

@ -8,7 +8,7 @@
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Infrastructure; using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Entities.Contents.State namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{ {
public sealed class ContentVersion public sealed class ContentVersion
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Guards/GuardContent.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/GuardContent.cs

@ -16,7 +16,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Contents.Guards namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
{ {
public static class GuardContent public static class GuardContent
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Contents/IContentGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/IContentGrain.cs

@ -10,7 +10,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
{ {
public interface IContentGrain : IDomainObjectGrain public interface IContentGrain : IDomainObjectGrain
{ {

1
backend/src/Squidex.Domain.Apps.Entities/Contents/IContentQueryService.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;

1
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentLoader.cs

@ -7,6 +7,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Domain.Apps.Entities.Contents.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Log; using Squidex.Log;

156
backend/src/Squidex.Domain.Apps.Entities/Contents/State/ContentState.cs

@ -1,156 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Reflection;
namespace Squidex.Domain.Apps.Entities.Contents.State
{
public sealed class ContentState : DomainObjectState<ContentState>, IContentEntity
{
public NamedId<DomainId> AppId { get; set; }
public NamedId<DomainId> SchemaId { get; set; }
public ContentVersion? NewVersion { get; set; }
public ContentVersion CurrentVersion { get; set; }
public ScheduleJob? ScheduleJob { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
[IgnoreDataMember]
public NamedContentData Data
{
get { return NewVersion?.Data ?? CurrentVersion.Data; }
}
[IgnoreDataMember]
public Status EditingStatus
{
get { return NewStatus ?? Status; }
}
[IgnoreDataMember]
public Status Status
{
get { return CurrentVersion.Status; }
}
[IgnoreDataMember]
public Status? NewStatus
{
get { return NewVersion?.Status; }
}
public override bool ApplyEvent(IEvent @event, EnvelopeHeaders headers)
{
switch (@event)
{
case ContentCreated e:
{
Id = e.ContentId;
SimpleMapper.Map(e, this);
CurrentVersion = new ContentVersion(e.Status, e.Data);
break;
}
case ContentDraftCreated e:
{
NewVersion = new ContentVersion(e.Status, e.MigratedData ?? CurrentVersion.Data);
ScheduleJob = null;
break;
}
case ContentDraftDeleted _:
{
NewVersion = null;
ScheduleJob = null;
break;
}
case ContentStatusChanged e:
{
ScheduleJob = null;
if (NewVersion != null)
{
if (e.Status == Status.Published)
{
CurrentVersion = new ContentVersion(e.Status, NewVersion.Data);
NewVersion = null;
}
else
{
NewVersion = NewVersion.WithStatus(e.Status);
}
}
else
{
CurrentVersion = CurrentVersion.WithStatus(e.Status);
}
break;
}
case ContentSchedulingCancelled _:
{
ScheduleJob = null;
break;
}
case ContentStatusScheduled e:
{
ScheduleJob = ScheduleJob.Build(e.Status, e.Actor, e.DueTime);
break;
}
case ContentUpdated e:
{
if (NewVersion != null)
{
NewVersion = NewVersion.WithData(e.Data);
}
else
{
CurrentVersion = CurrentVersion.WithData(e.Data);
}
break;
}
case ContentDeleted _:
{
IsDeleted = true;
break;
}
}
return true;
}
}
}

2
backend/src/Squidex.Domain.Apps.Entities/Rules/Guards/GuardRule.cs → backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/GuardRule.cs

@ -10,7 +10,7 @@ using Squidex.Domain.Apps.Entities.Rules.Commands;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Rules.Guards namespace Squidex.Domain.Apps.Entities.Rules.DomainObject.Guards
{ {
public static class GuardRule public static class GuardRule
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Rules/Guards/RuleTriggerValidator.cs → backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/Guards/RuleTriggerValidator.cs

@ -16,7 +16,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Rules.Guards namespace Squidex.Domain.Apps.Entities.Rules.DomainObject.Guards
{ {
public sealed class RuleTriggerValidator : IRuleTriggerVisitor<Task<IEnumerable<ValidationError>>> public sealed class RuleTriggerValidator : IRuleTriggerVisitor<Task<IEnumerable<ValidationError>>>
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Rules/IRuleGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/IRuleGrain.cs

@ -9,7 +9,7 @@ using System.Threading.Tasks;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Rules namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
{ {
public interface IRuleGrain : IDomainObjectGrain public interface IRuleGrain : IDomainObjectGrain
{ {

96
backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs

@ -0,0 +1,96 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Rules;
using Squidex.Domain.Apps.Events.Rules;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
{
public sealed partial class RuleDomainObject
{
[CollectionName("Rules")]
public sealed class State : DomainObjectState<State>, IRuleEntity
{
public NamedId<DomainId> AppId { get; set; }
public Rule RuleDef { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
var previousRule = RuleDef;
switch (@event)
{
case RuleCreated e:
{
Id = e.RuleId;
RuleDef = new Rule(e.Trigger, e.Action);
RuleDef = RuleDef.Rename(e.Name);
AppId = e.AppId;
return true;
}
case RuleUpdated e:
{
if (e.Trigger != null)
{
RuleDef = RuleDef.Update(e.Trigger);
}
if (e.Action != null)
{
RuleDef = RuleDef.Update(e.Action);
}
if (e.Name != null)
{
RuleDef = RuleDef.Rename(e.Name);
}
break;
}
case RuleEnabled _:
{
RuleDef = RuleDef.Enable();
break;
}
case RuleDisabled _:
{
RuleDef = RuleDef.Disable();
break;
}
case RuleDeleted _:
{
IsDeleted = true;
return true;
}
}
return !ReferenceEquals(previousRule, RuleDef);
}
}
}
}

7
backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDomainObject.cs → backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.cs

@ -8,8 +8,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Rules.Commands; using Squidex.Domain.Apps.Entities.Rules.Commands;
using Squidex.Domain.Apps.Entities.Rules.Guards; using Squidex.Domain.Apps.Entities.Rules.DomainObject.Guards;
using Squidex.Domain.Apps.Entities.Rules.State;
using Squidex.Domain.Apps.Events; using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Rules; using Squidex.Domain.Apps.Events.Rules;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -19,9 +18,9 @@ using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Log; using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.Rules namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
{ {
public class RuleDomainObject : DomainObject<RuleState> public sealed partial class RuleDomainObject : DomainObject<RuleDomainObject.State>
{ {
private readonly IAppProvider appProvider; private readonly IAppProvider appProvider;
private readonly IRuleEnqueuer ruleEnqueuer; private readonly IRuleEnqueuer ruleEnqueuer;

5
backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDomainObjectGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObjectGrain.cs

@ -7,13 +7,12 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Rules.State;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Rules namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
{ {
public sealed class RuleDomainObjectGrain : DomainObjectGrain<RuleDomainObject, RuleState>, IRuleGrain public sealed class RuleDomainObjectGrain : DomainObjectGrain<RuleDomainObject, RuleDomainObject.State>, IRuleGrain
{ {
public RuleDomainObjectGrain(IServiceProvider serviceProvider) public RuleDomainObjectGrain(IServiceProvider serviceProvider)
: base(serviceProvider) : base(serviceProvider)

1
backend/src/Squidex.Domain.Apps.Entities/Rules/Indexes/RulesIndex.cs

@ -10,6 +10,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Domain.Apps.Entities.Rules.Commands; using Squidex.Domain.Apps.Entities.Rules.Commands;
using Squidex.Domain.Apps.Entities.Rules.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Log; using Squidex.Log;

1
backend/src/Squidex.Domain.Apps.Entities/Rules/RuleCommandMiddleware.cs

@ -8,6 +8,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Domain.Apps.Entities.Rules.Commands; using Squidex.Domain.Apps.Entities.Rules.Commands;
using Squidex.Domain.Apps.Entities.Rules.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;

93
backend/src/Squidex.Domain.Apps.Entities/Rules/State/RuleState.cs

@ -1,93 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core.Rules;
using Squidex.Domain.Apps.Events.Rules;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Entities.Rules.State
{
[CollectionName("Rules")]
public sealed class RuleState : DomainObjectState<RuleState>, IRuleEntity
{
public NamedId<DomainId> AppId { get; set; }
public Rule RuleDef { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
var previousRule = RuleDef;
switch (@event)
{
case RuleCreated e:
{
Id = e.RuleId;
RuleDef = new Rule(e.Trigger, e.Action);
RuleDef = RuleDef.Rename(e.Name);
AppId = e.AppId;
return true;
}
case RuleUpdated e:
{
if (e.Trigger != null)
{
RuleDef = RuleDef.Update(e.Trigger);
}
if (e.Action != null)
{
RuleDef = RuleDef.Update(e.Action);
}
if (e.Name != null)
{
RuleDef = RuleDef.Rename(e.Name);
}
break;
}
case RuleEnabled _:
{
RuleDef = RuleDef.Enable();
break;
}
case RuleDisabled _:
{
RuleDef = RuleDef.Disable();
break;
}
case RuleDeleted _:
{
IsDeleted = true;
return true;
}
}
return !ReferenceEquals(previousRule, RuleDef);
}
}
}

2
backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/FieldPropertiesValidator.cs → backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/FieldPropertiesValidator.cs

@ -12,7 +12,7 @@ using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Schemas.Guards namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards
{ {
public sealed class FieldPropertiesValidator : IFieldPropertiesVisitor<IEnumerable<ValidationError>> public sealed class FieldPropertiesValidator : IFieldPropertiesVisitor<IEnumerable<ValidationError>>
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/GuardHelper.cs → backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardHelper.cs

@ -9,7 +9,7 @@ using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
namespace Squidex.Domain.Apps.Entities.Schemas.Guards namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards
{ {
public static class GuardHelper public static class GuardHelper
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/GuardSchema.cs → backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchema.cs

@ -16,7 +16,7 @@ using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Squidex.Text; using Squidex.Text;
namespace Squidex.Domain.Apps.Entities.Schemas.Guards namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards
{ {
public static class GuardSchema public static class GuardSchema
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/GuardSchemaField.cs → backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/Guards/GuardSchemaField.cs

@ -12,7 +12,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
namespace Squidex.Domain.Apps.Entities.Schemas.Guards namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards
{ {
public static class GuardSchemaField public static class GuardSchemaField
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Schemas/ISchemaGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/ISchemaGrain.cs

@ -9,7 +9,7 @@ using System.Threading.Tasks;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Schemas namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject
{ {
public interface ISchemaGrain : IDomainObjectGrain public interface ISchemaGrain : IDomainObjectGrain
{ {

210
backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/SchemaDomainObject.State.cs

@ -0,0 +1,210 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Linq;
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject
{
public sealed partial class SchemaDomainObject
{
[CollectionName("Schemas")]
public sealed class State : DomainObjectState<State>, ISchemaEntity
{
public NamedId<DomainId> AppId { get; set; }
public Schema SchemaDef { get; set; }
public long SchemaFieldsTotal { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
var previousSchema = SchemaDef;
switch (@event)
{
case SchemaCreated e:
{
Id = e.SchemaId.Id;
SchemaDef = e.Schema;
SchemaFieldsTotal = e.Schema.MaxId();
AppId = e.AppId;
return true;
}
case FieldAdded e:
{
if (e.ParentFieldId != null)
{
var field = e.Properties.CreateNestedField(e.FieldId.Id, e.Name);
SchemaDef = SchemaDef.UpdateField(e.ParentFieldId.Id, x => ((ArrayField)x).AddField(field));
}
else
{
var partitioning = Partitioning.FromString(e.Partitioning);
var field = e.Properties.CreateRootField(e.FieldId.Id, e.Name, partitioning);
SchemaDef = SchemaDef.DeleteField(e.FieldId.Id);
SchemaDef = SchemaDef.AddField(field);
}
SchemaFieldsTotal = Math.Max(SchemaFieldsTotal, e.FieldId.Id);
break;
}
case SchemaUIFieldsConfigured e:
{
if (e.FieldsInLists != null)
{
SchemaDef = SchemaDef.SetFieldsInLists(e.FieldsInLists);
}
if (e.FieldsInReferences != null)
{
SchemaDef = SchemaDef.SetFieldsInReferences(e.FieldsInReferences);
}
break;
}
case SchemaCategoryChanged e:
{
SchemaDef = SchemaDef.ChangeCategory(e.Name);
break;
}
case SchemaPreviewUrlsConfigured e:
{
SchemaDef = SchemaDef.SetPreviewUrls(e.PreviewUrls);
break;
}
case SchemaScriptsConfigured e:
{
SchemaDef = SchemaDef.SetScripts(e.Scripts);
break;
}
case SchemaFieldRulesConfigured e:
{
SchemaDef = SchemaDef.SetFieldRules(e.FieldRules);
break;
}
case SchemaPublished _:
{
SchemaDef = SchemaDef.Publish();
break;
}
case SchemaUnpublished _:
{
SchemaDef = SchemaDef.Unpublish();
break;
}
case SchemaUpdated e:
{
SchemaDef = SchemaDef.Update(e.Properties);
break;
}
case SchemaFieldsReordered e:
{
SchemaDef = SchemaDef.ReorderFields(e.FieldIds.ToList(), e.ParentFieldId?.Id);
break;
}
case FieldUpdated e:
{
SchemaDef = SchemaDef.UpdateField(e.FieldId.Id, e.Properties, e.ParentFieldId?.Id);
break;
}
case FieldLocked e:
{
SchemaDef = SchemaDef.LockField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldDisabled e:
{
SchemaDef = SchemaDef.DisableField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldEnabled e:
{
SchemaDef = SchemaDef.EnableField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldHidden e:
{
SchemaDef = SchemaDef.HideField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldShown e:
{
SchemaDef = SchemaDef.ShowField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldDeleted e:
{
SchemaDef = SchemaDef.DeleteField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case SchemaDeleted _:
{
IsDeleted = true;
return true;
}
}
return !ReferenceEquals(previousSchema, SchemaDef);
}
}
}
}

7
backend/src/Squidex.Domain.Apps.Entities/Schemas/SchemaDomainObject.cs → backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/SchemaDomainObject.cs

@ -10,8 +10,7 @@ using System.Threading.Tasks;
using Squidex.Domain.Apps.Core.EventSynchronization; using Squidex.Domain.Apps.Core.EventSynchronization;
using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Entities.Schemas.Commands; using Squidex.Domain.Apps.Entities.Schemas.Commands;
using Squidex.Domain.Apps.Entities.Schemas.Guards; using Squidex.Domain.Apps.Entities.Schemas.DomainObject.Guards;
using Squidex.Domain.Apps.Entities.Schemas.State;
using Squidex.Domain.Apps.Events; using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Schemas; using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -22,9 +21,9 @@ using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Log; using Squidex.Log;
namespace Squidex.Domain.Apps.Entities.Schemas namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject
{ {
public class SchemaDomainObject : DomainObject<SchemaState> public sealed partial class SchemaDomainObject : DomainObject<SchemaDomainObject.State>
{ {
public SchemaDomainObject(IStore<DomainId> store, ISemanticLog log) public SchemaDomainObject(IStore<DomainId> store, ISemanticLog log)
: base(store, log) : base(store, log)

5
backend/src/Squidex.Domain.Apps.Entities/Schemas/SchemaDomainObjectGrain.cs → backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/SchemaDomainObjectGrain.cs

@ -7,13 +7,12 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Schemas.State;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
namespace Squidex.Domain.Apps.Entities.Schemas namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject
{ {
public sealed class SchemaDomainObjectGrain : DomainObjectGrain<SchemaDomainObject, SchemaState>, ISchemaGrain public sealed class SchemaDomainObjectGrain : DomainObjectGrain<SchemaDomainObject, SchemaDomainObject.State>, ISchemaGrain
{ {
public SchemaDomainObjectGrain(IServiceProvider serviceProvider) public SchemaDomainObjectGrain(IServiceProvider serviceProvider)
: base(serviceProvider) : base(serviceProvider)

1
backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Caching; using Squidex.Caching;
using Squidex.Domain.Apps.Entities.Schemas.Commands; using Squidex.Domain.Apps.Entities.Schemas.Commands;
using Squidex.Domain.Apps.Entities.Schemas.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;

207
backend/src/Squidex.Domain.Apps.Entities/Schemas/State/SchemaState.cs

@ -1,207 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Linq;
using System.Runtime.Serialization;
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.States;
namespace Squidex.Domain.Apps.Entities.Schemas.State
{
[CollectionName("Schemas")]
public sealed class SchemaState : DomainObjectState<SchemaState>, ISchemaEntity
{
public NamedId<DomainId> AppId { get; set; }
public Schema SchemaDef { get; set; }
public long SchemaFieldsTotal { get; set; }
[IgnoreDataMember]
public DomainId UniqueId
{
get { return DomainId.Combine(AppId, Id); }
}
public override bool ApplyEvent(IEvent @event)
{
var previousSchema = SchemaDef;
switch (@event)
{
case SchemaCreated e:
{
Id = e.SchemaId.Id;
SchemaDef = e.Schema;
SchemaFieldsTotal = e.Schema.MaxId();
AppId = e.AppId;
return true;
}
case FieldAdded e:
{
if (e.ParentFieldId != null)
{
var field = e.Properties.CreateNestedField(e.FieldId.Id, e.Name);
SchemaDef = SchemaDef.UpdateField(e.ParentFieldId.Id, x => ((ArrayField)x).AddField(field));
}
else
{
var partitioning = Partitioning.FromString(e.Partitioning);
var field = e.Properties.CreateRootField(e.FieldId.Id, e.Name, partitioning);
SchemaDef = SchemaDef.DeleteField(e.FieldId.Id);
SchemaDef = SchemaDef.AddField(field);
}
SchemaFieldsTotal = Math.Max(SchemaFieldsTotal, e.FieldId.Id);
break;
}
case SchemaUIFieldsConfigured e:
{
if (e.FieldsInLists != null)
{
SchemaDef = SchemaDef.SetFieldsInLists(e.FieldsInLists);
}
if (e.FieldsInReferences != null)
{
SchemaDef = SchemaDef.SetFieldsInReferences(e.FieldsInReferences);
}
break;
}
case SchemaCategoryChanged e:
{
SchemaDef = SchemaDef.ChangeCategory(e.Name);
break;
}
case SchemaPreviewUrlsConfigured e:
{
SchemaDef = SchemaDef.SetPreviewUrls(e.PreviewUrls);
break;
}
case SchemaScriptsConfigured e:
{
SchemaDef = SchemaDef.SetScripts(e.Scripts);
break;
}
case SchemaFieldRulesConfigured e:
{
SchemaDef = SchemaDef.SetFieldRules(e.FieldRules);
break;
}
case SchemaPublished _:
{
SchemaDef = SchemaDef.Publish();
break;
}
case SchemaUnpublished _:
{
SchemaDef = SchemaDef.Unpublish();
break;
}
case SchemaUpdated e:
{
SchemaDef = SchemaDef.Update(e.Properties);
break;
}
case SchemaFieldsReordered e:
{
SchemaDef = SchemaDef.ReorderFields(e.FieldIds.ToList(), e.ParentFieldId?.Id);
break;
}
case FieldUpdated e:
{
SchemaDef = SchemaDef.UpdateField(e.FieldId.Id, e.Properties, e.ParentFieldId?.Id);
break;
}
case FieldLocked e:
{
SchemaDef = SchemaDef.LockField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldDisabled e:
{
SchemaDef = SchemaDef.DisableField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldEnabled e:
{
SchemaDef = SchemaDef.EnableField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldHidden e:
{
SchemaDef = SchemaDef.HideField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldShown e:
{
SchemaDef = SchemaDef.ShowField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case FieldDeleted e:
{
SchemaDef = SchemaDef.DeleteField(e.FieldId.Id, e.ParentFieldId?.Id);
break;
}
case SchemaDeleted _:
{
IsDeleted = true;
return true;
}
}
return !ReferenceEquals(previousSchema, SchemaDef);
}
}
}

1
backend/src/Squidex/Config/Domain/AppsServices.cs

@ -11,6 +11,7 @@ using Squidex.Areas.Api.Controllers.UI;
using Squidex.Domain.Apps.Core.Apps; using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Entities; using Squidex.Domain.Apps.Entities;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Domain.Apps.Entities.Apps.DomainObject;
using Squidex.Domain.Apps.Entities.History; using Squidex.Domain.Apps.Entities.History;
using Squidex.Domain.Apps.Entities.Search; using Squidex.Domain.Apps.Entities.Search;
using Squidex.Infrastructure; using Squidex.Infrastructure;

1
backend/src/Squidex/Config/Domain/AssetServices.cs

@ -15,6 +15,7 @@ using MongoDB.Driver.GridFS;
using Squidex.Assets; using Squidex.Assets;
using Squidex.Assets.ImageSharp; using Squidex.Assets.ImageSharp;
using Squidex.Domain.Apps.Entities.Assets; using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Domain.Apps.Entities.Assets.Queries; using Squidex.Domain.Apps.Entities.Assets.Queries;
using Squidex.Domain.Apps.Entities.History; using Squidex.Domain.Apps.Entities.History;
using Squidex.Domain.Apps.Entities.Search; using Squidex.Domain.Apps.Entities.Search;

9
backend/src/Squidex/Config/Domain/CommandsServices.cs

@ -7,19 +7,20 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps.DomainObject;
using Squidex.Domain.Apps.Entities.Apps.Indexes; using Squidex.Domain.Apps.Entities.Apps.Indexes;
using Squidex.Domain.Apps.Entities.Apps.Invitation; using Squidex.Domain.Apps.Entities.Apps.Invitation;
using Squidex.Domain.Apps.Entities.Apps.Templates; using Squidex.Domain.Apps.Entities.Apps.Templates;
using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.Comments; using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Domain.Apps.Entities.Comments.DomainObject;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Contents.DomainObject;
using Squidex.Domain.Apps.Entities.Rules; using Squidex.Domain.Apps.Entities.Rules;
using Squidex.Domain.Apps.Entities.Rules.Indexes; using Squidex.Domain.Apps.Entities.Rules.Indexes;
using Squidex.Domain.Apps.Entities.Rules.UsageTracking; using Squidex.Domain.Apps.Entities.Rules.UsageTracking;
using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Domain.Apps.Entities.Schemas.Commands; using Squidex.Domain.Apps.Entities.Schemas.Commands;
using Squidex.Domain.Apps.Entities.Schemas.DomainObject;
using Squidex.Domain.Apps.Entities.Schemas.Indexes; using Squidex.Domain.Apps.Entities.Schemas.Indexes;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;

2
backend/src/Squidex/Config/Domain/ContentsServices.cs

@ -10,7 +10,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.ValidateContent; using Squidex.Domain.Apps.Core.ValidateContent;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Contents.Operations; using Squidex.Domain.Apps.Entities.Contents.DomainObject;
using Squidex.Domain.Apps.Entities.Contents.Queries; using Squidex.Domain.Apps.Entities.Contents.Queries;
using Squidex.Domain.Apps.Entities.Contents.Queries.Steps; using Squidex.Domain.Apps.Entities.Contents.Queries.Steps;
using Squidex.Domain.Apps.Entities.Contents.Text; using Squidex.Domain.Apps.Entities.Contents.Text;

1
backend/src/Squidex/Config/Domain/RuleServices.cs

@ -15,6 +15,7 @@ using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.Comments; using Squidex.Domain.Apps.Entities.Comments;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Rules; using Squidex.Domain.Apps.Entities.Rules;
using Squidex.Domain.Apps.Entities.Rules.DomainObject;
using Squidex.Domain.Apps.Entities.Rules.Queries; using Squidex.Domain.Apps.Entities.Rules.Queries;
using Squidex.Domain.Apps.Entities.Rules.Runner; using Squidex.Domain.Apps.Entities.Rules.Runner;
using Squidex.Domain.Apps.Entities.Rules.UsageTracking; using Squidex.Domain.Apps.Entities.Rules.UsageTracking;

1
backend/src/Squidex/Config/Domain/SchemasServices.cs

@ -8,6 +8,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Entities.History; using Squidex.Domain.Apps.Entities.History;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Domain.Apps.Entities.Schemas.DomainObject;
using Squidex.Domain.Apps.Entities.Search; using Squidex.Domain.Apps.Entities.Search;
namespace Squidex.Config.Domain namespace Squidex.Config.Domain

10
backend/src/Squidex/Config/Domain/StoreServices.cs

@ -13,10 +13,10 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Migrations.Migrations.MongoDb; using Migrations.Migrations.MongoDb;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Domain.Apps.Entities.Assets.Repositories; using Squidex.Domain.Apps.Entities.Assets.Repositories;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Contents.DomainObject;
using Squidex.Domain.Apps.Entities.Contents.Repositories; using Squidex.Domain.Apps.Entities.Contents.Repositories;
using Squidex.Domain.Apps.Entities.Contents.State;
using Squidex.Domain.Apps.Entities.Contents.Text; using Squidex.Domain.Apps.Entities.Contents.Text;
using Squidex.Domain.Apps.Entities.Contents.Text.State; using Squidex.Domain.Apps.Entities.Contents.Text.State;
using Squidex.Domain.Apps.Entities.History.Repositories; using Squidex.Domain.Apps.Entities.History.Repositories;
@ -107,13 +107,13 @@ namespace Squidex.Config.Domain
.As<IUserStore<IdentityUser>>().As<IUserFactory>(); .As<IUserStore<IdentityUser>>().As<IUserFactory>();
services.AddSingletonAs<MongoAssetRepository>() services.AddSingletonAs<MongoAssetRepository>()
.As<IAssetRepository>().As<ISnapshotStore<AssetState, DomainId>>(); .As<IAssetRepository>().As<ISnapshotStore<AssetDomainObject.State, DomainId>>();
services.AddSingletonAs<MongoAssetFolderRepository>() services.AddSingletonAs<MongoAssetFolderRepository>()
.As<IAssetFolderRepository>().As<ISnapshotStore<AssetFolderState, DomainId>>(); .As<IAssetFolderRepository>().As<ISnapshotStore<AssetFolderDomainObject.State, DomainId>>();
services.AddSingletonAs(c => ActivatorUtilities.CreateInstance<MongoContentRepository>(c, GetDatabase(c, mongoContentDatabaseName))) services.AddSingletonAs(c => ActivatorUtilities.CreateInstance<MongoContentRepository>(c, GetDatabase(c, mongoContentDatabaseName)))
.As<IContentRepository>().As<ISnapshotStore<ContentState, DomainId>>(); .As<IContentRepository>().As<ISnapshotStore<ContentDomainObject.State, DomainId>>();
services.AddSingletonAs<MongoTextIndex>() services.AddSingletonAs<MongoTextIndex>()
.AsOptional<ITextIndex>(); .AsOptional<ITextIndex>();

5
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppCommandMiddlewareTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppCommandMiddlewareTests.cs

@ -12,16 +12,15 @@ using FakeItEasy;
using Orleans; using Orleans;
using Squidex.Assets; using Squidex.Assets;
using Squidex.Domain.Apps.Entities.Apps.Commands; using Squidex.Domain.Apps.Entities.Apps.Commands;
using Squidex.Domain.Apps.Entities.Apps.State;
using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
{ {
public class AppCommandMiddlewareTests : HandlerTestBase<AppState> public class AppCommandMiddlewareTests : HandlerTestBase<AppDomainObject.State>
{ {
private readonly IContextProvider contextProvider = A.Fake<IContextProvider>(); private readonly IContextProvider contextProvider = A.Fake<IContextProvider>();
private readonly IAppImageStore appImageStore = A.Fake<IAppImageStore>(); private readonly IAppImageStore appImageStore = A.Fake<IAppImageStore>();

5
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/AppDomainObjectTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/AppDomainObjectTests.cs

@ -12,7 +12,6 @@ using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities.Apps.Commands; using Squidex.Domain.Apps.Entities.Apps.Commands;
using Squidex.Domain.Apps.Entities.Apps.Plans; using Squidex.Domain.Apps.Entities.Apps.Plans;
using Squidex.Domain.Apps.Entities.Apps.State;
using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Domain.Apps.Events.Apps; using Squidex.Domain.Apps.Events.Apps;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -22,9 +21,9 @@ using Squidex.Log;
using Squidex.Shared.Users; using Squidex.Shared.Users;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
{ {
public class AppDomainObjectTests : HandlerTestBase<AppState> public class AppDomainObjectTests : HandlerTestBase<AppDomainObject.State>
{ {
private readonly IAppPlansProvider appPlansProvider = A.Fake<IAppPlansProvider>(); private readonly IAppPlansProvider appPlansProvider = A.Fake<IAppPlansProvider>();
private readonly IAppPlanBillingManager appPlansBillingManager = A.Fake<IAppPlanBillingManager>(); private readonly IAppPlanBillingManager appPlansBillingManager = A.Fake<IAppPlanBillingManager>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppClientsTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppClientsTests.cs

@ -16,7 +16,7 @@ using Xunit;
#pragma warning disable SA1310 // Field names must not contain underscore #pragma warning disable SA1310 // Field names must not contain underscore
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public class GuardAppClientsTests : IClassFixture<TranslationsFixture> public class GuardAppClientsTests : IClassFixture<TranslationsFixture>
{ {

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppContributorsTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppContributorsTests.cs

@ -19,7 +19,7 @@ using Xunit;
#pragma warning disable SA1310 // Field names must not contain underscore #pragma warning disable SA1310 // Field names must not contain underscore
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public class GuardAppContributorsTests : IClassFixture<TranslationsFixture> public class GuardAppContributorsTests : IClassFixture<TranslationsFixture>
{ {

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppLanguagesTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppLanguagesTests.cs

@ -14,7 +14,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public class GuardAppLanguagesTests : IClassFixture<TranslationsFixture> public class GuardAppLanguagesTests : IClassFixture<TranslationsFixture>
{ {

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppPatternsTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppPatternsTests.cs

@ -16,7 +16,7 @@ using Xunit;
#pragma warning disable SA1310 // Field names must not contain underscore #pragma warning disable SA1310 // Field names must not contain underscore
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public class GuardAppPatternsTests : IClassFixture<TranslationsFixture> public class GuardAppPatternsTests : IClassFixture<TranslationsFixture>
{ {

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppRolesTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppRolesTests.cs

@ -16,7 +16,7 @@ using Xunit;
#pragma warning disable SA1310 // Field names must not contain underscore #pragma warning disable SA1310 // Field names must not contain underscore
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public class GuardAppRolesTests : IClassFixture<TranslationsFixture> public class GuardAppRolesTests : IClassFixture<TranslationsFixture>
{ {

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppTests.cs

@ -16,7 +16,7 @@ using Squidex.Infrastructure.Validation;
using Squidex.Shared.Users; using Squidex.Shared.Users;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public class GuardAppTests : IClassFixture<TranslationsFixture> public class GuardAppTests : IClassFixture<TranslationsFixture>
{ {

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Guards/GuardAppWorkflowTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/DomainObject/Guards/GuardAppWorkflowTests.cs

@ -15,7 +15,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Validation; using Squidex.Infrastructure.Validation;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Apps.Guards namespace Squidex.Domain.Apps.Entities.Apps.DomainObject.Guards
{ {
public class GuardAppWorkflowTests : IClassFixture<TranslationsFixture> public class GuardAppWorkflowTests : IClassFixture<TranslationsFixture>
{ {

1
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs

@ -15,6 +15,7 @@ using Orleans;
using Squidex.Caching; using Squidex.Caching;
using Squidex.Domain.Apps.Core.Apps; using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Entities.Apps.Commands; using Squidex.Domain.Apps.Entities.Apps.Commands;
using Squidex.Domain.Apps.Entities.Apps.DomainObject;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;

6
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs

@ -13,7 +13,7 @@ using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Assets; using Squidex.Assets;
using Squidex.Domain.Apps.Core.Tags; using Squidex.Domain.Apps.Core.Tags;
using Squidex.Domain.Apps.Entities.Assets.State; using Squidex.Domain.Apps.Entities.Assets.DomainObject;
using Squidex.Domain.Apps.Entities.Backup; using Squidex.Domain.Apps.Entities.Backup;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -228,7 +228,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
var rebuildAssets = new HashSet<DomainId>(); var rebuildAssets = new HashSet<DomainId>();
A.CallTo(() => rebuilder.InsertManyAsync<AssetDomainObject, AssetState>(A<IEnumerable<DomainId>>._, A<CancellationToken>._)) A.CallTo(() => rebuilder.InsertManyAsync<AssetDomainObject, AssetDomainObject.State>(A<IEnumerable<DomainId>>._, A<CancellationToken>._))
.Invokes((IEnumerable<DomainId> source, CancellationToken _) => rebuildAssets.AddRange(source)); .Invokes((IEnumerable<DomainId> source, CancellationToken _) => rebuildAssets.AddRange(source));
await sut.RestoreAsync(context); await sut.RestoreAsync(context);
@ -265,7 +265,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
var rebuildAssetFolders = new HashSet<DomainId>(); var rebuildAssetFolders = new HashSet<DomainId>();
A.CallTo(() => rebuilder.InsertManyAsync<AssetFolderDomainObject, AssetFolderState>(A<IEnumerable<DomainId>>._, A<CancellationToken>._)) A.CallTo(() => rebuilder.InsertManyAsync<AssetFolderDomainObject, AssetFolderDomainObject.State>(A<IEnumerable<DomainId>>._, A<CancellationToken>._))
.Invokes((IEnumerable<DomainId> source, CancellationToken _) => rebuildAssetFolders.AddRange(source)); .Invokes((IEnumerable<DomainId> source, CancellationToken _) => rebuildAssetFolders.AddRange(source));
await sut.RestoreAsync(context); await sut.RestoreAsync(context);

5
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetCommandMiddlewareTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetCommandMiddlewareTests.cs

@ -15,7 +15,6 @@ using Orleans;
using Squidex.Assets; using Squidex.Assets;
using Squidex.Domain.Apps.Core.Tags; using Squidex.Domain.Apps.Core.Tags;
using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Domain.Apps.Entities.Contents.Repositories; using Squidex.Domain.Apps.Entities.Contents.Repositories;
using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -24,9 +23,9 @@ using Squidex.Infrastructure.Reflection;
using Squidex.Log; using Squidex.Log;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public class AssetCommandMiddlewareTests : HandlerTestBase<AssetState> public class AssetCommandMiddlewareTests : HandlerTestBase<AssetDomainObject.State>
{ {
private readonly IAssetEnricher assetEnricher = A.Fake<IAssetEnricher>(); private readonly IAssetEnricher assetEnricher = A.Fake<IAssetEnricher>();
private readonly IAssetFileStore assetFileStore = A.Fake<IAssetFileStore>(); private readonly IAssetFileStore assetFileStore = A.Fake<IAssetFileStore>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetDomainObjectGrainTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectGrainTests.cs

@ -13,7 +13,7 @@ using Xunit;
#pragma warning disable RECS0026 // Possible unassigned object created by 'new' #pragma warning disable RECS0026 // Possible unassigned object created by 'new'
#pragma warning disable CA1806 // Do not ignore method results #pragma warning disable CA1806 // Do not ignore method results
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public class AssetDomainObjectGrainTests public class AssetDomainObjectGrainTests
{ {

5
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetDomainObjectTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetDomainObjectTests.cs

@ -13,7 +13,6 @@ using Squidex.Assets;
using Squidex.Domain.Apps.Core.Assets; using Squidex.Domain.Apps.Core.Assets;
using Squidex.Domain.Apps.Core.Tags; using Squidex.Domain.Apps.Core.Tags;
using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Contents.Repositories; using Squidex.Domain.Apps.Entities.Contents.Repositories;
using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Domain.Apps.Entities.TestHelpers;
@ -23,9 +22,9 @@ using Squidex.Infrastructure.Commands;
using Squidex.Log; using Squidex.Log;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public class AssetDomainObjectTests : HandlerTestBase<AssetState> public class AssetDomainObjectTests : HandlerTestBase<AssetDomainObject.State>
{ {
private readonly IContentRepository contentRepository = A.Fake<IContentRepository>(); private readonly IContentRepository contentRepository = A.Fake<IContentRepository>();
private readonly ITagService tagService = A.Fake<ITagService>(); private readonly ITagService tagService = A.Fake<ITagService>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetFolderDomainObjectGrainTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetFolderDomainObjectGrainTests.cs

@ -13,7 +13,7 @@ using Xunit;
#pragma warning disable RECS0026 // Possible unassigned object created by 'new' #pragma warning disable RECS0026 // Possible unassigned object created by 'new'
#pragma warning disable CA1806 // Do not ignore method results #pragma warning disable CA1806 // Do not ignore method results
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public class AssetFolderDomainObjectGrainTests public class AssetFolderDomainObjectGrainTests
{ {

5
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetFolderDomainObjectTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/DomainObject/AssetFolderDomainObjectTests.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.Assets.State;
using Squidex.Domain.Apps.Entities.TestHelpers; using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -17,9 +16,9 @@ using Squidex.Infrastructure.Commands;
using Squidex.Log; using Squidex.Log;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
{ {
public class AssetFolderDomainObjectTests : HandlerTestBase<AssetFolderState> public class AssetFolderDomainObjectTests : HandlerTestBase<AssetDomainObject.State>
{ {
private readonly IAssetQueryService assetQuery = A.Fake<IAssetQueryService>(); private readonly IAssetQueryService assetQuery = A.Fake<IAssetQueryService>();
private readonly DomainId parentId = DomainId.NewGuid(); private readonly DomainId parentId = DomainId.NewGuid();

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

Loading…
Cancel
Save