Browse Source

Code cleanup

pull/636/head
Sebastian 5 years ago
parent
commit
f86b98b307
  1. 3
      backend/extensions/Squidex.Extensions/Actions/RuleHelper.cs
  2. 5
      backend/extensions/Squidex.Extensions/Actions/Twitter/TwitterOptions.cs
  3. 14
      backend/extensions/Squidex.Extensions/Validation/CompositeUniqueValidator.cs
  4. 17
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppPermission.cs
  5. 8
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/RolesConverter.cs
  6. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs
  7. 3
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs
  8. 10
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs
  9. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs
  10. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs
  11. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/StringFormatter.cs
  12. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ValueConverters.cs
  13. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueGenerator.cs
  14. 25
      backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ContentReferencesExtensions.cs
  15. 39
      backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ReferencesExtensions.cs
  16. 5
      backend/src/Squidex.Domain.Apps.Core.Operations/GenerateEdmSchema/EdmTypeVisitor.cs
  17. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/ContentSchemaBuilder.cs
  18. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/Result.cs
  19. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs
  20. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/IUrlGenerator.cs
  21. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs
  22. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs
  23. 12
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
  24. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/NullPropagation.cs
  25. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Templates/Extensions/ContentFluidExtension.cs
  26. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/DefaultFieldValueValidatorsFactory.cs
  27. 83
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/FieldBagValidatorsFactory.cs
  28. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ValidationContext.cs
  29. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs
  30. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AssetsValidator.cs
  31. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionItemValidator.cs
  32. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs
  33. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs
  34. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ReferencesValidator.cs
  35. 8
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringTextValidator.cs
  36. 4
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/AdaptionVisitor.cs
  37. 5
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/History/MongoHistoryEventRepository.cs
  38. 4
      backend/src/Squidex.Domain.Apps.Entities/Apps/BackupApps.cs
  39. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObject.State.cs
  40. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObject.cs
  41. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs
  42. 8
      backend/src/Squidex.Domain.Apps.Entities/Apps/RolePermissionsProvider.cs
  43. 8
      backend/src/Squidex.Domain.Apps.Entities/Assets/AssetChangedTriggerHandler.cs
  44. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs
  45. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetDomainObject.State.cs
  46. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/DomainObject/AssetFolderDomainObject.State.cs
  47. 2
      backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/FilterTagTransformer.cs
  48. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs
  49. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/BulkUpdateCommandMiddleware.cs
  50. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentChangedTriggerHandler.cs
  51. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.State.cs
  52. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs
  53. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs
  54. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs
  55. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetGraphType.cs
  56. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs
  57. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs
  58. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataInputGraphType.cs
  59. 3
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs
  60. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/SchemaInfos.cs
  61. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Extensions.cs
  62. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Primitives/EntitySavedGraphType.cs
  63. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs
  64. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/GeoQueryTransformer.cs
  65. 50
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/QueryExecutionContext.cs
  66. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/SingletonCommandMiddleware.cs
  67. 6
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Elastic/CommandFactory.cs
  68. 18
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/SearchContext.cs
  69. 16
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/WriteonlyGeoJsonConverter.cs
  70. 12
      backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs
  71. 10
      backend/src/Squidex.Domain.Apps.Entities/Notifications/NotificationEmailSender.cs
  72. 6
      backend/src/Squidex.Domain.Apps.Entities/Rules/DomainObject/RuleDomainObject.State.cs
  73. 6
      backend/src/Squidex.Domain.Apps.Entities/Schemas/DomainObject/SchemaDomainObject.State.cs
  74. 18
      backend/src/Squidex.Domain.Apps.Entities/Schemas/SchemaChangedTriggerHandler.cs
  75. 5
      backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/Filtering.cs
  76. 28
      backend/src/Squidex.Infrastructure/DelegateDisposable.cs
  77. 4
      backend/src/Squidex.Infrastructure/EventSourcing/Grains/BatchSubscriber.cs
  78. 2
      backend/src/Squidex.Infrastructure/Json/Newtonsoft/ConverterContractResolver.cs
  79. 2
      backend/src/Squidex.Infrastructure/Json/Newtonsoft/JsonValueConverter.cs
  80. 19
      backend/src/Squidex.Infrastructure/Orleans/ILockGrain.cs
  81. 45
      backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs
  82. 2
      backend/src/Squidex.Infrastructure/Queries/Json/ValueConverter.cs
  83. 2
      backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs
  84. 16
      backend/src/Squidex.Infrastructure/Validation/IValidatable.cs
  85. 14
      backend/src/Squidex.Web/ApiExceptionConverter.cs
  86. 2
      backend/src/Squidex.Web/ApiExceptionFilterAttribute.cs
  87. 2
      backend/src/Squidex.Web/Pipeline/DeferredActionFilter.cs
  88. 15
      backend/src/Squidex.Web/Services/UrlGenerator.cs
  89. 2
      backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs
  90. 3
      backend/src/Squidex/Areas/Api/Startup.cs
  91. 8
      backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
  92. 4
      backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ProfileController.cs
  93. 2
      backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs
  94. 1
      backend/src/Squidex/Config/Domain/SerializationInitializer.cs
  95. 4
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/FieldCompareTests.cs
  96. 8
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs
  97. 1
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetEnricherTests.cs
  98. 1
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/UserMappingTests.cs
  99. 8
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BulkUpdateCommandMiddlewareTests.cs
  100. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs

3
backend/extensions/Squidex.Extensions/Actions/RuleHelper.cs

@ -42,8 +42,7 @@ namespace Squidex.Extensions.Actions
public static bool IsAssetDeletion(this EnrichedEvent @event) public static bool IsAssetDeletion(this EnrichedEvent @event)
{ {
return @event is EnrichedAssetEvent assetEvent && return @event is EnrichedAssetEvent { Type: EnrichedAssetEventType.Deleted };
(assetEvent.Type == EnrichedAssetEventType.Deleted);
} }
public static async Task<Result> OneWayRequestAsync(this HttpClient client, HttpRequestMessage request, string requestBody = null, CancellationToken ct = default) public static async Task<Result> OneWayRequestAsync(this HttpClient client, HttpRequestMessage request, string requestBody = null, CancellationToken ct = default)

5
backend/extensions/Squidex.Extensions/Actions/Twitter/TwitterOptions.cs

@ -12,10 +12,5 @@ namespace Squidex.Extensions.Actions.Twitter
public string ClientId { get; set; } public string ClientId { get; set; }
public string ClientSecret { get; set; } public string ClientSecret { get; set; }
public bool IsConfigured()
{
return !string.IsNullOrWhiteSpace(ClientId) && !string.IsNullOrWhiteSpace(ClientSecret);
}
} }
} }

14
backend/extensions/Squidex.Extensions/Validation/CompositeUniqueValidator.cs

@ -76,19 +76,19 @@ namespace Squidex.Extensions.Validation
switch (field.RawProperties) switch (field.RawProperties)
{ {
case BooleanFieldProperties _ when value is JsonBoolean boolean: case BooleanFieldProperties when value is JsonBoolean boolean:
return boolean.Value; return boolean.Value;
case BooleanFieldProperties _ when value is JsonNull: case BooleanFieldProperties when value is JsonNull:
return ClrValue.Null; return ClrValue.Null;
case NumberFieldProperties _ when value is JsonNumber number: case NumberFieldProperties when value is JsonNumber number:
return number.Value; return number.Value;
case NumberFieldProperties _ when value is JsonNull: case NumberFieldProperties when value is JsonNull:
return ClrValue.Null; return ClrValue.Null;
case StringFieldProperties _ when value is JsonString @string: case StringFieldProperties when value is JsonString @string:
return @string.Value; return @string.Value;
case StringFieldProperties _ when value is JsonNull: case StringFieldProperties when value is JsonNull:
return ClrValue.Null; return ClrValue.Null;
case ReferencesFieldProperties _ when value is JsonArray array && array.FirstOrDefault() is JsonString @string: case ReferencesFieldProperties when value is JsonArray array && array.FirstOrDefault() is JsonString @string:
return @string.Value; return @string.Value;
} }

17
backend/src/Squidex.Domain.Apps.Core.Model/Apps/AppPermission.cs

@ -1,17 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
namespace Squidex.Domain.Apps.Core.Apps
{
public enum AppPermission
{
Owner,
Developer,
Editor,
Reader
}
}

8
backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/RolesConverter.cs

@ -43,14 +43,16 @@ namespace Squidex.Domain.Apps.Core.Apps.Json
return new Roles(json.ToDictionary(x => x.Key, x => return new Roles(json.ToDictionary(x => x.Key, x =>
{ {
var (key, value) = x;
var permissions = PermissionSet.Empty; var permissions = PermissionSet.Empty;
if (x.Value.Permissions.Length > 0) if (value.Permissions.Length > 0)
{ {
permissions = new PermissionSet(x.Value.Permissions); permissions = new PermissionSet(value.Permissions);
} }
return new Role(x.Key, permissions, x.Value.Properties); return new Role(key, permissions, value.Properties);
})); }));
} }
} }

2
backend/src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs

@ -14,7 +14,7 @@ namespace Squidex.Domain.Apps.Core.Apps
{ {
public sealed class LanguagesConfig : IFieldPartitioning public sealed class LanguagesConfig : IFieldPartitioning
{ {
public static readonly LanguagesConfig English = new LanguagesConfig( public static readonly LanguagesConfig English = new (
new Dictionary<string, LanguageConfig> new Dictionary<string, LanguageConfig>
{ {
[Language.EN] = new LanguageConfig() [Language.EN] = new LanguageConfig()

3
backend/src/Squidex.Domain.Apps.Core.Model/Apps/Role.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using Squidex.Infrastructure; using Squidex.Infrastructure;
@ -40,8 +39,6 @@ namespace Squidex.Domain.Apps.Core.Apps
public const string Owner = "Owner"; public const string Owner = "Owner";
public const string Reader = "Reader"; public const string Reader = "Reader";
public static readonly ReadOnlyCollection<string> EmptyProperties = new ReadOnlyCollection<string>(new List<string>());
public PermissionSet Permissions { get; } public PermissionSet Permissions { get; }
public JsonObject Properties { get; } public JsonObject Properties { get; }

10
backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs

@ -59,7 +59,7 @@ namespace Squidex.Domain.Apps.Core.Contents
{ {
if (contentFieldData != null) if (contentFieldData != null)
{ {
var fieldValue = target.GetOrAdd(key, x => new ContentFieldData()); var fieldValue = target.GetOrAdd(key, _ => new ContentFieldData());
if (fieldValue != null) if (fieldValue != null)
{ {
@ -89,20 +89,20 @@ namespace Squidex.Domain.Apps.Core.Contents
{ {
var target = new ContentData(); var target = new ContentData();
foreach (var fieldValue in ValidValues) foreach (var (fieldName, fieldValue) in ValidValues)
{ {
if (fieldValue.Value != null) if (fieldValue != null)
{ {
var resultValue = new ContentFieldData(); var resultValue = new ContentFieldData();
foreach (var (key, value) in fieldValue.Value.Where(x => x.Value.Type != JsonValueType.Null)) foreach (var (key, value) in fieldValue.Where(x => x.Value.Type != JsonValueType.Null))
{ {
resultValue[key] = value; resultValue[key] = value;
} }
if (resultValue.Count > 0) if (resultValue.Count > 0)
{ {
target[fieldValue.Key] = resultValue; target[fieldName] = resultValue;
} }
} }
} }

2
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/FieldCollection.cs

@ -160,7 +160,7 @@ namespace Squidex.Domain.Apps.Core.Schemas
return this; return this;
} }
if (!(newField is T)) if (newField is not T)
{ {
throw new InvalidOperationException($"Field must be of type {typeof(T)}"); throw new InvalidOperationException($"Field must be of type {typeof(T)}");
} }

4
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs

@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
public static class FieldConverters public static class FieldConverters
{ {
public static readonly FieldConverter Noop = (data, field) => data; public static readonly FieldConverter Noop = (data, _) => data;
public static readonly FieldConverter ExcludeHidden = (data, field) => public static readonly FieldConverter ExcludeHidden = (data, field) =>
{ {
@ -182,7 +182,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
foreach (var (key, value) in data.ToList()) foreach (var (key, value) in data.ToList())
{ {
IJsonValue? newValue = value; var newValue = value;
for (var i = 0; i < converters.Length; i++) for (var i = 0; i < converters.Length; i++)
{ {

2
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/StringFormatter.cs

@ -55,7 +55,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
public string Visit(BooleanFieldProperties properties, Args args) public string Visit(BooleanFieldProperties properties, Args args)
{ {
if (args.Value is JsonBoolean boolean && boolean.Value) if (args.Value is JsonBoolean { Value: true })
{ {
return "Yes"; return "Yes";
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ValueConverters.cs

@ -126,7 +126,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
foreach (var (fieldName, nestedValue) in nested.ToList()) foreach (var (fieldName, nestedValue) in nested.ToList())
{ {
IJsonValue? newValue = nestedValue; var newValue = nestedValue;
if (arrayField.FieldsByName.TryGetValue(fieldName, out var nestedField)) if (arrayField.FieldsByName.TryGetValue(fieldName, out var nestedField))
{ {

2
backend/src/Squidex.Domain.Apps.Core.Operations/DefaultValues/DefaultValueGenerator.cs

@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Core.DefaultValues
foreach (var field in schema.Fields) foreach (var field in schema.Fields)
{ {
var fieldData = data.GetOrCreate(field.Name, k => new ContentFieldData()); var fieldData = data.GetOrCreate(field.Name, _ => new ContentFieldData());
if (fieldData != null) if (fieldData != null)
{ {

25
backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ContentReferencesExtensions.cs

@ -16,17 +16,6 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
{ {
public static class ContentReferencesExtensions public static class ContentReferencesExtensions
{ {
public static HashSet<DomainId> GetReferencedIds(this ContentData source, Schema schema, int referencesPerField = int.MaxValue)
{
Guard.NotNull(schema, nameof(schema));
var result = new HashSet<DomainId>();
AddReferencedIds(source, schema.Fields, result, referencesPerField);
return result;
}
public static void AddReferencedIds(this ContentData source, Schema schema, HashSet<DomainId> result, int referencesPerField = int.MaxValue) public static void AddReferencedIds(this ContentData source, Schema schema, HashSet<DomainId> result, int referencesPerField = int.MaxValue)
{ {
Guard.NotNull(schema, nameof(schema)); Guard.NotNull(schema, nameof(schema));
@ -45,20 +34,6 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
} }
} }
public static void AddReferencedIds(this ContentData source, IField field, HashSet<DomainId> result, int referencesPerField = int.MaxValue)
{
Guard.NotNull(field, nameof(field));
Guard.NotNull(result, nameof(result));
if (source.TryGetValue(field.Name, out var fieldData) && fieldData != null)
{
foreach (var partitionValue in fieldData)
{
ReferencesExtractor.Extract(field, partitionValue.Value, result, referencesPerField);
}
}
}
private static void AddReferencedIds(ContentData source, HashSet<DomainId> result, int referencesPerField, IField field) private static void AddReferencedIds(ContentData source, HashSet<DomainId> result, int referencesPerField, IField field)
{ {
if (source.TryGetValue(field.Name, out var fieldData) && fieldData != null) if (source.TryGetValue(field.Name, out var fieldData) && fieldData != null)

39
backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ReferencesExtensions.cs

@ -1,39 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Json.Objects;
namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
{
public static class ReferencesExtensions
{
public static void AddIds(this IJsonValue? value, HashSet<DomainId> result, int take)
{
var added = 0;
if (value is JsonArray array)
{
foreach (var id in array)
{
if (id is JsonString s)
{
result.Add(DomainId.Create(s.Value));
added++;
if (added >= take)
{
break;
}
}
}
}
}
}
}

5
backend/src/Squidex.Domain.Apps.Core.Operations/GenerateEdmSchema/EdmTypeVisitor.cs

@ -37,11 +37,6 @@ namespace Squidex.Domain.Apps.Core.GenerateEdmSchema
return field.Accept(Instance, args); return field.Accept(Instance, args);
} }
public IEdmTypeReference? CreateEdmType(IField field, Args args)
{
return field.Accept(this, args);
}
public IEdmTypeReference? Visit(IArrayField field, Args args) public IEdmTypeReference? Visit(IArrayField field, Args args)
{ {
var (fieldEdmType, created) = args.Factory($"Data.{field.Name.ToPascalCase()}.Item"); var (fieldEdmType, created) = args.Factory($"Data.{field.Name.ToPascalCase()}.Item");

4
backend/src/Squidex.Domain.Apps.Core.Operations/GenerateJsonSchema/ContentSchemaBuilder.cs

@ -32,8 +32,8 @@ namespace Squidex.Domain.Apps.Core.GenerateJsonSchema
["createdBy"] = SchemaBuilder.StringProperty($"The user that has created the {schemaName} content.", true), ["createdBy"] = SchemaBuilder.StringProperty($"The user that has created the {schemaName} content.", true),
["lastModified"] = SchemaBuilder.DateTimeProperty($"The date and time when the {schemaName} content has been modified last.", true), ["lastModified"] = SchemaBuilder.DateTimeProperty($"The date and time when the {schemaName} content has been modified last.", true),
["lastModifiedBy"] = SchemaBuilder.StringProperty($"The user that has updated the {schemaName} content last.", true), ["lastModifiedBy"] = SchemaBuilder.StringProperty($"The user that has updated the {schemaName} content last.", true),
["newStatus"] = SchemaBuilder.StringProperty($"The new status of the content.", false), ["newStatus"] = SchemaBuilder.StringProperty("The new status of the content."),
["status"] = SchemaBuilder.StringProperty($"The status of the content.", true) ["status"] = SchemaBuilder.StringProperty("The status of the content.", true)
}, },
Type = JsonObjectType.Object Type = JsonObjectType.Object
}; };

2
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/Result.cs

@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Core.HandleRules
{ {
public sealed class Result public sealed class Result
{ {
public Exception? Exception { get; private set; } public Exception? Exception { get; private init; }
public string? Dump { get; private set; } public string? Dump { get; private set; }

2
backend/src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleService.cs

@ -144,7 +144,7 @@ namespace Squidex.Domain.Apps.Core.HandleRules
return result; return result;
} }
if (!(@event.Payload is AppEvent)) if (@event.Payload is not AppEvent)
{ {
return result; return result;
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/IUrlGenerator.cs

@ -18,8 +18,6 @@ namespace Squidex.Domain.Apps.Core
string? AssetThumbnail(NamedId<DomainId> appId, string idOrSlug, AssetType assetType); string? AssetThumbnail(NamedId<DomainId> appId, string idOrSlug, AssetType assetType);
string AppSettingsUI(NamedId<DomainId> appId);
string AssetsUI(NamedId<DomainId> appId, string? query = null); string AssetsUI(NamedId<DomainId> appId, string? query = null);
string AssetContent(NamedId<DomainId> appId, string idOrSlug); string AssetContent(NamedId<DomainId> appId, string idOrSlug);

2
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs

@ -102,7 +102,7 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
var propertyName = property.AsString(); var propertyName = property.AsString();
valueProperties.GetOrAdd(propertyName, k => new ContentFieldProperty(this)).Value = value; valueProperties.GetOrAdd(propertyName, _ => new ContentFieldProperty(this)).Value = value;
return true; return true;
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs

@ -24,7 +24,7 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
switch (value) switch (value)
{ {
case JsonNull _: case JsonNull:
return JsValue.Null; return JsValue.Null;
case JsonString s: case JsonString s:
return new JsString(s.Value); return new JsString(s.Value);

12
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs

@ -84,7 +84,7 @@ namespace Squidex.Domain.Apps.Core.Scripting
{ {
var context = CreateEngine(vars, options, tcs.TrySetException, true, cts.Token); var context = CreateEngine(vars, options, tcs.TrySetException, true, cts.Token);
context.Engine.SetValue("complete", new Action<JsValue?>(value => context.Engine.SetValue("complete", new Action<JsValue?>(_ =>
{ {
tcs.TrySetResult(vars.Data!); tcs.TrySetResult(vars.Data!);
})); }));
@ -135,12 +135,12 @@ namespace Squidex.Domain.Apps.Core.Scripting
private ExecutionContext CreateEngine(ScriptVars vars, ScriptOptions options, ExceptionHandler? exceptionHandler = null, bool async = false, CancellationToken ct = default) private ExecutionContext CreateEngine(ScriptVars vars, ScriptOptions options, ExceptionHandler? exceptionHandler = null, bool async = false, CancellationToken ct = default)
{ {
var engine = new Engine(options => var engine = new Engine(engineOptions =>
{ {
options.AddObjectConverter(DefaultConverter.Instance); engineOptions.AddObjectConverter(DefaultConverter.Instance);
options.SetReferencesResolver(NullPropagation.Instance); engineOptions.SetReferencesResolver(NullPropagation.Instance);
options.Strict(); engineOptions.Strict();
options.TimeoutInterval(TimeoutScript); engineOptions.TimeoutInterval(TimeoutScript);
}); });
if (options.CanDisallow) if (options.CanDisallow)

2
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/NullPropagation.cs

@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Core.Scripting
public bool TryGetCallable(Engine engine, object reference, out JsValue value) public bool TryGetCallable(Engine engine, object reference, out JsValue value)
{ {
value = new ClrFunctionInstance(engine, "anonymous", (thisObj, values) => thisObj); value = new ClrFunctionInstance(engine, "anonymous", (thisObj, _) => thisObj);
return true; return true;
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/Templates/Extensions/ContentFluidExtension.cs

@ -22,7 +22,7 @@ namespace Squidex.Domain.Apps.Core.Templates.Extensions
FluidValue.SetTypeMapping<JsonString>(x => FluidValue.Create(x.Value)); FluidValue.SetTypeMapping<JsonString>(x => FluidValue.Create(x.Value));
FluidValue.SetTypeMapping<JsonBoolean>(x => FluidValue.Create(x.Value)); FluidValue.SetTypeMapping<JsonBoolean>(x => FluidValue.Create(x.Value));
FluidValue.SetTypeMapping<JsonNumber>(x => FluidValue.Create(x.Value)); FluidValue.SetTypeMapping<JsonNumber>(x => FluidValue.Create(x.Value));
FluidValue.SetTypeMapping<JsonNull>(x => FluidValue.Create(null)); FluidValue.SetTypeMapping<JsonNull>(_ => FluidValue.Create(null));
memberAccessStrategy.Register<ContentData, object?>( memberAccessStrategy.Register<ContentData, object?>(
(value, name) => value.GetOrDefault(name)); (value, name) => value.GetOrDefault(name));

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/DefaultFieldValueValidatorsFactory.cs

@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent
{ {
private static readonly DefaultFieldValueValidatorsFactory Instance = new DefaultFieldValueValidatorsFactory(); private static readonly DefaultFieldValueValidatorsFactory Instance = new DefaultFieldValueValidatorsFactory();
public struct Args public readonly struct Args
{ {
public readonly ValidatorContext Context; public readonly ValidatorContext Context;

83
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/FieldBagValidatorsFactory.cs

@ -1,83 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Core.ValidateContent.Validators;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.ValidateContent
{
internal sealed class FieldBagValidatorsFactory : IFieldVisitor<IEnumerable<IValidator>, None>
{
private static readonly FieldBagValidatorsFactory Instance = new FieldBagValidatorsFactory();
private FieldBagValidatorsFactory()
{
}
public static IEnumerable<IValidator> CreateValidators(IField field)
{
return field.Accept(Instance, None.Value);
}
public IEnumerable<IValidator> Visit(IArrayField field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<AssetsFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<BooleanFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<DateTimeFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<GeolocationFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<JsonFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<NumberFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<ReferencesFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<StringFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<TagsFieldProperties> field, None args)
{
yield break;
}
public IEnumerable<IValidator> Visit(IField<UIFieldProperties> field, None args)
{
yield return NoValueValidator.Instance;
}
}
}

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/ValidationContext.cs

@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent
{ {
public ImmutableQueue<string> Path { get; private set; } = ImmutableQueue<string>.Empty; public ImmutableQueue<string> Path { get; private set; } = ImmutableQueue<string>.Empty;
public IJsonSerializer JsonSerializer { get; private set; } public IJsonSerializer JsonSerializer { get; }
public DomainId ContentId { get; } public DomainId ContentId { get; }

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs

@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
public Task ValidateAsync(object? value, ValidationContext context, AddError addError) public Task ValidateAsync(object? value, ValidationContext context, AddError addError)
{ {
if (value != null && value is TValue typedValue && !allowedValues.Contains(typedValue)) if (value is TValue typedValue && !allowedValues.Contains(typedValue))
{ {
addError(context.Path, T.Get("contents.validation.notAllowed")); addError(context.Path, T.Get("contents.validation.notAllowed"));
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AssetsValidator.cs

@ -50,7 +50,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
var foundIds = new List<DomainId>(); var foundIds = new List<DomainId>();
if (value is ICollection<DomainId> assetIds && assetIds.Count > 0) if (value is ICollection<DomainId> { Count: > 0 } assetIds)
{ {
var assets = await checkAssets(assetIds); var assets = await checkAssets(assetIds);
var index = 0; var index = 0;

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionItemValidator.cs

@ -25,7 +25,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
public async Task ValidateAsync(object? value, ValidationContext context, AddError addError) public async Task ValidateAsync(object? value, ValidationContext context, AddError addError)
{ {
if (value is ICollection items && items.Count > 0) if (value is ICollection { Count: > 0 } items)
{ {
var innerTasks = new List<Task>(); var innerTasks = new List<Task>();
var index = 1; var index = 1;

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs

@ -20,7 +20,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
public CollectionValidator(bool isRequired, int? minItems = null, int? maxItems = null) public CollectionValidator(bool isRequired, int? minItems = null, int? maxItems = null)
{ {
if (minItems.HasValue && maxItems.HasValue && minItems > maxItems) if (minItems.HasValue && minItems > maxItems)
{ {
throw new ArgumentException("Min length must be greater than max length.", nameof(minItems)); throw new ArgumentException("Min length must be greater than max length.", nameof(minItems));
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs

@ -29,7 +29,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
public Task ValidateAsync(object? value, ValidationContext context, AddError addError) public Task ValidateAsync(object? value, ValidationContext context, AddError addError)
{ {
if (value != null && value is TValue typedValue) if (value is TValue typedValue)
{ {
if (min.HasValue && max.HasValue) if (min.HasValue && max.HasValue)
{ {

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ReferencesValidator.cs

@ -48,7 +48,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
var foundIds = new List<DomainId>(); var foundIds = new List<DomainId>();
if (value is ICollection<DomainId> contentIds && contentIds.Count > 0) if (value is ICollection<DomainId> { Count: > 0 } contentIds)
{ {
var references = await checkReferences(contentIds.ToHashSet()); var references = await checkReferences(contentIds.ToHashSet());
var index = 0; var index = 0;

8
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringTextValidator.cs

@ -69,12 +69,12 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
} }
else else
{ {
if (minWords.HasValue && words < minWords) if (words < minWords)
{ {
addError(context.Path, T.Get("contents.validation.minWords", new { min = minWords })); addError(context.Path, T.Get("contents.validation.minWords", new { min = minWords }));
} }
if (maxWords.HasValue && words > maxWords) if (words > maxWords)
{ {
addError(context.Path, T.Get("contents.validation.maxWords", new { max = maxWords })); addError(context.Path, T.Get("contents.validation.maxWords", new { max = maxWords }));
} }
@ -98,12 +98,12 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
} }
else else
{ {
if (minCharacters.HasValue && characters < minCharacters) if (characters < minCharacters)
{ {
addError(context.Path, T.Get("contents.validation.minNormalCharacters", new { min = minCharacters })); addError(context.Path, T.Get("contents.validation.minNormalCharacters", new { min = minCharacters }));
} }
if (maxCharacters.HasValue && characters > maxCharacters) if (characters > maxCharacters)
{ {
addError(context.Path, T.Get("contents.validation.maxCharacters", new { max = maxCharacters })); addError(context.Path, T.Get("contents.validation.maxCharacters", new { max = maxCharacters }));
} }

4
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/AdaptionVisitor.cs

@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations
{ {
private static readonly AdaptionVisitor Instance = new AdaptionVisitor(); private static readonly AdaptionVisitor Instance = new AdaptionVisitor();
public struct Args public readonly struct Args
{ {
public readonly DomainId AppId; public readonly DomainId AppId;
@ -43,7 +43,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations
{ {
var result = nodeIn; var result = nodeIn;
var (path, op, value) = nodeIn; var (path, _, value) = nodeIn;
var clrValue = value.Value; var clrValue = value.Value;

5
backend/src/Squidex.Domain.Apps.Entities.MongoDb/History/MongoHistoryEventRepository.cs

@ -80,10 +80,5 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.History
await Collection.BulkWriteAsync(writes); await Collection.BulkWriteAsync(writes);
} }
} }
public Task RemoveAsync(DomainId appId)
{
return Collection.DeleteManyAsync(x => x.AppId == appId);
}
} }
} }

4
backend/src/Squidex.Domain.Apps.Entities/Apps/BackupApps.cs

@ -48,7 +48,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
case AppContributorAssigned appContributorAssigned: case AppContributorAssigned appContributorAssigned:
context.UserMapping.Backup(appContributorAssigned.ContributorId); context.UserMapping.Backup(appContributorAssigned.ContributorId);
break; break;
case AppImageUploaded _: case AppImageUploaded:
await WriteAssetAsync(context.AppId, context.Writer); await WriteAssetAsync(context.AppId, context.Writer);
break; break;
} }
@ -72,7 +72,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
break; break;
} }
case AppImageUploaded _: case AppImageUploaded:
{ {
await ReadAssetAsync(context.AppId, context.Reader); await ReadAssetAsync(context.AppId, context.Reader);

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

@ -146,7 +146,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
return l; return l;
}); });
case AppArchived _: case AppArchived:
{ {
Plan = null; Plan = null;

2
backend/src/Squidex.Domain.Apps.Entities/Apps/DomainObject/AppDomainObject.cs

@ -295,7 +295,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.DomainObject
switch (result) switch (result)
{ {
case PlanChangedResult _: case PlanChangedResult:
ChangePlan(c); ChangePlan(c);
break; break;
} }

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

@ -244,7 +244,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
await RemoveContributorAsync(removeContributor); await RemoveContributorAsync(removeContributor);
break; break;
case ArchiveApp _: case ArchiveApp:
await ArchiveAppAsync(app); await ArchiveAppAsync(app);
break; break;
} }

8
backend/src/Squidex.Domain.Apps.Entities/Apps/RolePermissionsProvider.cs

@ -12,8 +12,6 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Security; using Squidex.Infrastructure.Security;
using Squidex.Shared; using Squidex.Shared;
#pragma warning disable IDE0028 // Simplify collection initialization
namespace Squidex.Domain.Apps.Entities.Apps namespace Squidex.Domain.Apps.Entities.Apps
{ {
public sealed class RolePermissionsProvider public sealed class RolePermissionsProvider
@ -65,9 +63,11 @@ namespace Squidex.Domain.Apps.Entities.Apps
{ {
var schemas = await appProvider.GetSchemasAsync(app.Id); var schemas = await appProvider.GetSchemasAsync(app.Id);
var schemaNames = new List<string>(); var schemaNames = new List<string>
{
Permission.Any
};
schemaNames.Add(Permission.Any);
schemaNames.AddRange(schemas.Select(x => x.SchemaDef.Name)); schemaNames.AddRange(schemas.Select(x => x.SchemaDef.Name));
return schemaNames; return schemaNames;

8
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetChangedTriggerHandler.cs

@ -84,16 +84,16 @@ namespace Squidex.Domain.Apps.Entities.Assets
switch (@event.Payload) switch (@event.Payload)
{ {
case AssetCreated _: case AssetCreated:
result.Type = EnrichedAssetEventType.Created; result.Type = EnrichedAssetEventType.Created;
break; break;
case AssetAnnotated _: case AssetAnnotated:
result.Type = EnrichedAssetEventType.Annotated; result.Type = EnrichedAssetEventType.Annotated;
break; break;
case AssetUpdated _: case AssetUpdated:
result.Type = EnrichedAssetEventType.Updated; result.Type = EnrichedAssetEventType.Updated;
break; break;
case AssetDeleted _: case AssetDeleted:
result.Type = EnrichedAssetEventType.Deleted; result.Type = EnrichedAssetEventType.Deleted;
break; break;
} }

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

@ -71,7 +71,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{ {
switch (@event.Payload) switch (@event.Payload)
{ {
case AssetFolderCreated _: case AssetFolderCreated:
assetFolderIds.Add(@event.Headers.AggregateId()); assetFolderIds.Add(@event.Headers.AggregateId());
break; break;
case AssetCreated assetCreated: case AssetCreated assetCreated:

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

@ -150,7 +150,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
return true; return true;
} }
case AssetDeleted _: case AssetDeleted:
{ {
IsDeleted = true; IsDeleted = true;

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

@ -57,7 +57,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.DomainObject
return true; return true;
} }
case AssetFolderDeleted _: case AssetFolderDeleted:
{ {
IsDeleted = true; IsDeleted = true;

2
backend/src/Squidex.Domain.Apps.Entities/Assets/Queries/FilterTagTransformer.cs

@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries
{ {
private static readonly FilterTagTransformer Instance = new FilterTagTransformer(); private static readonly FilterTagTransformer Instance = new FilterTagTransformer();
public struct Args public readonly struct Args
{ {
public readonly DomainId AppId; public readonly DomainId AppId;

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

@ -200,7 +200,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
break; break;
case JsonArray arr: case JsonArray:
break; break;
case JsonObject obj: case JsonObject obj:

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

@ -134,7 +134,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{ {
ContentId = id, ContentId = id,
JobIndex = task.JobIndex, JobIndex = task.JobIndex,
Exception = exception, Exception = exception
}); });
} }
@ -165,7 +165,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{ {
ContentId = id, ContentId = id,
JobIndex = task.JobIndex, JobIndex = task.JobIndex,
Exception = ex, Exception = ex
}); });
} }
} }
@ -175,7 +175,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
task.Results.Add(new BulkUpdateResultItem task.Results.Add(new BulkUpdateResultItem
{ {
JobIndex = task.JobIndex, JobIndex = task.JobIndex,
Exception = ex, Exception = ex
}); });
} }

6
backend/src/Squidex.Domain.Apps.Entities/Contents/ContentChangedTriggerHandler.cs

@ -86,10 +86,10 @@ namespace Squidex.Domain.Apps.Entities.Contents
switch (@event.Payload) switch (@event.Payload)
{ {
case ContentCreated _: case ContentCreated:
result.Type = EnrichedContentEventType.Created; result.Type = EnrichedContentEventType.Created;
break; break;
case ContentDeleted _: case ContentDeleted:
result.Type = EnrichedContentEventType.Deleted; result.Type = EnrichedContentEventType.Deleted;
break; break;
@ -111,7 +111,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
break; break;
} }
case ContentUpdated _: case ContentUpdated:
{ {
result.Type = EnrichedContentEventType.Updated; result.Type = EnrichedContentEventType.Updated;

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

@ -82,7 +82,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
break; break;
} }
case ContentDraftDeleted _: case ContentDraftDeleted:
{ {
NewVersion = null; NewVersion = null;
@ -116,7 +116,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
break; break;
} }
case ContentSchedulingCancelled _: case ContentSchedulingCancelled:
{ {
ScheduleJob = null; ScheduleJob = null;
@ -144,7 +144,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject
break; break;
} }
case ContentDeleted _: case ContentDeleted:
{ {
IsDeleted = true; IsDeleted = true;

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs

@ -75,7 +75,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
execution.UserContext = this; execution.UserContext = this;
} }
public override async Task<IEnrichedAssetEntity?> FindAssetAsync(DomainId id) public async Task<IEnrichedAssetEntity?> FindAssetAsync(DomainId id)
{ {
var dataLoader = GetAssetsLoader(); var dataLoader = GetAssetsLoader();

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs

@ -9,7 +9,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using GraphQL.Types; using GraphQL.Types;
using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents; using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents;
using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Utils; using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Primitives;
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs

@ -69,7 +69,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets
new QueryArgument(AllTypes.None) new QueryArgument(AllTypes.None)
{ {
Name = "top", Name = "top",
Description = $"Optional number of assets to take.", Description = "Optional number of assets to take.",
DefaultValue = null, DefaultValue = null,
ResolvedType = AllTypes.Int ResolvedType = AllTypes.Int
}, },

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetGraphType.cs

@ -198,7 +198,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets
Name = "tags", Name = "tags",
ResolvedType = AllTypes.NonNullStrings, ResolvedType = AllTypes.NonNullStrings,
Resolver = Resolve(x => x.TagNames), Resolver = Resolve(x => x.TagNames),
Description = "The asset tags.", Description = "The asset tags."
}); });
AddField(new FieldType AddField(new FieldType

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentActions.cs

@ -104,7 +104,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
new QueryArgument(AllTypes.None) new QueryArgument(AllTypes.None)
{ {
Name = "top", Name = "top",
Description = $"Optional number of contents to take.", Description = "Optional number of contents to take.",
DefaultValue = null, DefaultValue = null,
ResolvedType = AllTypes.Int ResolvedType = AllTypes.Int
}, },

6
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs

@ -51,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
Name = "url", Name = "url",
ResolvedType = AllTypes.NonNullString, ResolvedType = AllTypes.NonNullString,
Resolver = ContentResolvers.Url, Resolver = ContentResolvers.Url,
Description = $"The url to the content." Description = "The url to the content."
}); });
var contentDataType = new DataGraphType(builder, schemaInfo); var contentDataType = new DataGraphType(builder, schemaInfo);
@ -63,7 +63,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
Name = "data", Name = "data",
ResolvedType = new NonNullGraphType(contentDataType), ResolvedType = new NonNullGraphType(contentDataType),
Resolver = ContentResolvers.Data, Resolver = ContentResolvers.Data,
Description = $"The data of the content." Description = "The data of the content."
}); });
} }
@ -76,7 +76,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
Name = "flatData", Name = "flatData",
ResolvedType = new NonNullGraphType(contentDataTypeFlat), ResolvedType = new NonNullGraphType(contentDataTypeFlat),
Resolver = ContentResolvers.FlatData, Resolver = ContentResolvers.FlatData,
Description = $"The flat data of the content." Description = "The flat data of the content."
}); });
} }

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/DataInputGraphType.cs

@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
{ {
Name = fieldInfo.FieldName, Name = fieldInfo.FieldName,
ResolvedType = fieldGraphType, ResolvedType = fieldGraphType,
Resolver = null, Resolver = null
}).WithSourceName(fieldInfo); }).WithSourceName(fieldInfo);
} }
} }

3
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs

@ -7,9 +7,8 @@
using GraphQL.Types; using GraphQL.Types;
using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents;
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
{ {
internal sealed class FieldInputVisitor : IFieldVisitor<IGraphType?, FieldInfo> internal sealed class FieldInputVisitor : IFieldVisitor<IGraphType?, FieldInfo>
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/SchemaInfos.cs

@ -15,7 +15,7 @@ using Squidex.Text;
#pragma warning disable SA1649 // File name should match first type name #pragma warning disable SA1649 // File name should match first type name
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
{ {
internal sealed class SchemaInfo internal sealed class SchemaInfo
{ {

6
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Extensions.cs

@ -10,7 +10,7 @@ using System.Linq;
using GraphQL; using GraphQL;
using GraphQL.Types; using GraphQL.Types;
using GraphQL.Utilities; using GraphQL.Utilities;
using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.ObjectPool; using Squidex.Infrastructure.ObjectPool;
@ -171,7 +171,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
} }
} }
if (type is IObjectGraphType objectGraphType && objectGraphType.ResolvedInterfaces != null) if (type is IObjectGraphType { ResolvedInterfaces: { } } objectGraphType)
{ {
foreach (var @interface in objectGraphType.ResolvedInterfaces) foreach (var @interface in objectGraphType.ResolvedInterfaces)
{ {
@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
} }
} }
if (type is IAbstractGraphType abstractGraphType && abstractGraphType.PossibleTypes != null) if (type is IAbstractGraphType { PossibleTypes: { } } abstractGraphType)
{ {
foreach (var possibleType in abstractGraphType.PossibleTypes) foreach (var possibleType in abstractGraphType.PossibleTypes)
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Primitives/EntitySavedGraphType.cs

@ -9,7 +9,7 @@ using GraphQL.Resolvers;
using GraphQL.Types; using GraphQL.Types;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Utils namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Primitives
{ {
internal sealed class EntitySavedGraphType : ObjectGraphType<EntitySavedResult> internal sealed class EntitySavedGraphType : ObjectGraphType<EntitySavedResult>
{ {

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentQueryParser.cs

@ -247,8 +247,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
[nameof(IContentEntity.CreatedBy).ToCamelCase()] = SchemaBuilder.StringProperty($"The user that has created the {name} content.", true), [nameof(IContentEntity.CreatedBy).ToCamelCase()] = SchemaBuilder.StringProperty($"The user that has created the {name} content.", true),
[nameof(IContentEntity.LastModified).ToCamelCase()] = SchemaBuilder.DateTimeProperty($"The date and time when the {name} content has been modified last.", true), [nameof(IContentEntity.LastModified).ToCamelCase()] = SchemaBuilder.DateTimeProperty($"The date and time when the {name} content has been modified last.", true),
[nameof(IContentEntity.LastModifiedBy).ToCamelCase()] = SchemaBuilder.StringProperty($"The user that has updated the {name} content last.", true), [nameof(IContentEntity.LastModifiedBy).ToCamelCase()] = SchemaBuilder.StringProperty($"The user that has updated the {name} content last.", true),
[nameof(IContentEntity.NewStatus).ToCamelCase()] = SchemaBuilder.StringProperty($"The new status of the content.", false), [nameof(IContentEntity.NewStatus).ToCamelCase()] = SchemaBuilder.StringProperty("The new status of the content."),
[nameof(IContentEntity.Status).ToCamelCase()] = SchemaBuilder.StringProperty($"The status of the content.", true) [nameof(IContentEntity.Status).ToCamelCase()] = SchemaBuilder.StringProperty("The status of the content.", true)
}, },
Type = JsonObjectType.Object Type = JsonObjectType.Object
}; };

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/GeoQueryTransformer.cs

@ -17,7 +17,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
{ {
public static readonly GeoQueryTransformer Instance = new GeoQueryTransformer(); public static readonly GeoQueryTransformer Instance = new GeoQueryTransformer();
public struct Args public readonly struct Args
{ {
public readonly ITextIndex TextIndex; public readonly ITextIndex TextIndex;

50
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/QueryExecutionContext.cs

@ -39,56 +39,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
return contentQuery.FindAsync(Context, schemaIdOrName, id, version); return contentQuery.FindAsync(Context, schemaIdOrName, id, version);
} }
public virtual async Task<IEnrichedAssetEntity?> FindAssetAsync(DomainId id)
{
var asset = cachedAssets.GetOrDefault(id);
if (asset == null)
{
await maxRequests.WaitAsync();
try
{
asset = await assetQuery.FindAsync(Context, id);
}
finally
{
maxRequests.Release();
}
if (asset != null)
{
cachedAssets[asset.Id] = asset;
}
}
return asset;
}
public virtual async Task<IEnrichedContentEntity?> FindContentAsync(DomainId schemaId, DomainId id)
{
var content = cachedContents.GetOrDefault(id);
if (content == null)
{
await maxRequests.WaitAsync();
try
{
content = await contentQuery.FindAsync(Context, schemaId.ToString(), id);
}
finally
{
maxRequests.Release();
}
if (content != null)
{
cachedContents[content.Id] = content;
}
}
return content;
}
public virtual async Task<IResultList<IEnrichedAssetEntity>> QueryAssetsAsync(string odata) public virtual async Task<IResultList<IEnrichedAssetEntity>> QueryAssetsAsync(string odata)
{ {
var q = Q.Empty.WithODataQuery(odata); var q = Q.Empty.WithODataQuery(odata);

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

@ -21,9 +21,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{ {
await next(context); await next(context);
if (context.IsCompleted && if (context.IsCompleted && context.Command is CreateSchema { IsSingleton: true } createSchema)
context.Command is CreateSchema createSchema &&
createSchema.IsSingleton)
{ {
var schemaId = NamedId.Of(createSchema.SchemaId, createSchema.Name); var schemaId = NamedId.Of(createSchema.SchemaId, createSchema.Name);

6
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Elastic/CommandFactory.cs

@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic
index = new index = new
{ {
_id = upsert.DocId, _id = upsert.DocId,
_index = indexName, _index = indexName
} }
}); });
@ -58,7 +58,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic
update = new update = new
{ {
_id = update.DocId, _id = update.DocId,
_index = indexName, _index = indexName
} }
}); });
@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic
delete = new delete = new
{ {
_id = delete.DocId, _id = delete.DocId,
_index = indexName, _index = indexName
} }
}); });
} }

18
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/SearchContext.cs

@ -1,18 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
namespace Squidex.Domain.Apps.Entities.Contents.Text
{
public sealed class SearchContext
{
public SearchScope Scope { get; set; }
public HashSet<string> Languages { get; set; }
}
}

16
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/WriteonlyGeoJsonConverter.cs

@ -1,16 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using GeoJSON.Net.Converters;
namespace Squidex.Domain.Apps.Entities.Contents.Text
{
public sealed class WriteonlyGeoJsonConverter : GeoJsonConverter
{
public override bool CanWrite => false;
}
}

12
backend/src/Squidex.Domain.Apps.Entities/History/NotifoService.cs

@ -96,7 +96,7 @@ namespace Squidex.Domain.Apps.Entities.History
FullName = user.Claims.DisplayName(), FullName = user.Claims.DisplayName(),
PreferredLanguage = "en", PreferredLanguage = "en",
PreferredTimezone = null, PreferredTimezone = null,
Settings = settings, Settings = settings
}; };
if (user.Email.IsEmail()) if (user.Email.IsEmail())
@ -149,8 +149,14 @@ namespace Squidex.Domain.Apps.Entities.History
}; };
publishRequest.Properties["SquidexApp"] = comment.AppId.Name; publishRequest.Properties["SquidexApp"] = comment.AppId.Name;
publishRequest.Preformatted = new NotificationFormattingDto();
publishRequest.Preformatted.Subject["en"] = comment.Text; publishRequest.Preformatted = new NotificationFormattingDto
{
Subject =
{
["en"] = comment.Text
}
};
if (comment.Url?.IsAbsoluteUri == true) if (comment.Url?.IsAbsoluteUri == true)
{ {

10
backend/src/Squidex.Domain.Apps.Entities/Notifications/NotificationEmailSender.cs

@ -26,15 +26,15 @@ namespace Squidex.Domain.Apps.Entities.Notifications
private sealed class TemplatesVars private sealed class TemplatesVars
{ {
public IUser User { get; set; } public IUser? User { get; set; }
public IUser? Assigner { get; set; } public IUser? Assigner { get; init; }
public string AppName { get; set; } public string AppName { get; init; }
public long? ApiCalls { get; set; } public long? ApiCalls { get; init; }
public long? ApiCallsLimit { get; set; } public long? ApiCallsLimit { get; init; }
public string URL { get; set; } public string URL { get; set; }
} }

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

@ -67,21 +67,21 @@ namespace Squidex.Domain.Apps.Entities.Rules.DomainObject
break; break;
} }
case RuleEnabled _: case RuleEnabled:
{ {
RuleDef = RuleDef.Enable(); RuleDef = RuleDef.Enable();
break; break;
} }
case RuleDisabled _: case RuleDisabled:
{ {
RuleDef = RuleDef.Disable(); RuleDef = RuleDef.Disable();
break; break;
} }
case RuleDeleted _: case RuleDeleted:
{ {
IsDeleted = true; IsDeleted = true;

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

@ -118,14 +118,14 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject
break; break;
} }
case SchemaPublished _: case SchemaPublished:
{ {
SchemaDef = SchemaDef.Publish(); SchemaDef = SchemaDef.Publish();
break; break;
} }
case SchemaUnpublished _: case SchemaUnpublished:
{ {
SchemaDef = SchemaDef.Unpublish(); SchemaDef = SchemaDef.Unpublish();
@ -195,7 +195,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.DomainObject
break; break;
} }
case SchemaDeleted _: case SchemaDeleted:
{ {
IsDeleted = true; IsDeleted = true;

18
backend/src/Squidex.Domain.Apps.Entities/Schemas/SchemaChangedTriggerHandler.cs

@ -37,23 +37,23 @@ namespace Squidex.Domain.Apps.Entities.Schemas
switch (@event.Payload) switch (@event.Payload)
{ {
case FieldEvent _: case FieldEvent:
case SchemaPreviewUrlsConfigured _: case SchemaPreviewUrlsConfigured:
case SchemaScriptsConfigured _: case SchemaScriptsConfigured:
case SchemaUpdated _: case SchemaUpdated:
case ParentFieldEvent _: case ParentFieldEvent:
result.Type = EnrichedSchemaEventType.Updated; result.Type = EnrichedSchemaEventType.Updated;
break; break;
case SchemaCreated _: case SchemaCreated:
result.Type = EnrichedSchemaEventType.Created; result.Type = EnrichedSchemaEventType.Created;
break; break;
case SchemaPublished _: case SchemaPublished:
result.Type = EnrichedSchemaEventType.Published; result.Type = EnrichedSchemaEventType.Published;
break; break;
case SchemaUnpublished _: case SchemaUnpublished:
result.Type = EnrichedSchemaEventType.Unpublished; result.Type = EnrichedSchemaEventType.Unpublished;
break; break;
case SchemaDeleted _: case SchemaDeleted:
result.Type = EnrichedSchemaEventType.Deleted; result.Type = EnrichedSchemaEventType.Deleted;
break; break;
default: default:

5
backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/Filtering.cs

@ -12,11 +12,6 @@ namespace Squidex.Infrastructure.EventSourcing
{ {
internal static class Filtering internal static class Filtering
{ {
public static string CreateIndexPath(string property)
{
return $"Events.Metadata.{property}";
}
public static FilterDefinition<MongoEventCommit> ByPosition(StreamPosition streamPosition) public static FilterDefinition<MongoEventCommit> ByPosition(StreamPosition streamPosition)
{ {
if (streamPosition.IsEndOfCommit) if (streamPosition.IsEndOfCommit)

28
backend/src/Squidex.Infrastructure/DelegateDisposable.cs

@ -1,28 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
namespace Squidex.Infrastructure
{
public sealed class DelegateDisposable : IDisposable
{
private readonly Action action;
public DelegateDisposable(Action action)
{
Guard.NotNull(action, nameof(action));
this.action = action;
}
public void Dispose()
{
action();
}
}
}

4
backend/src/Squidex.Infrastructure/EventSourcing/Grains/BatchSubscriber.cs

@ -27,7 +27,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
private sealed class Job private sealed class Job
{ {
public StoredEvent? StoredEvent { get; set; } public StoredEvent? StoredEvent { get; init; }
public Exception? Exception { get; set; } public Exception? Exception { get; set; }
@ -35,7 +35,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
public bool ShouldHandle { get; set; } public bool ShouldHandle { get; set; }
public object Sender { get; set; } public object Sender { get; init; }
} }
public BatchSubscriber( public BatchSubscriber(

2
backend/src/Squidex.Infrastructure/Json/Newtonsoft/ConverterContractResolver.cs

@ -62,7 +62,7 @@ namespace Squidex.Infrastructure.Json.Newtonsoft
protected override JsonConverter? ResolveContractConverter(Type objectType) protected override JsonConverter? ResolveContractConverter(Type objectType)
{ {
JsonConverter? result = base.ResolveContractConverter(objectType); var result = base.ResolveContractConverter(objectType);
if (result != null) if (result != null)
{ {

2
backend/src/Squidex.Infrastructure/Json/Newtonsoft/JsonValueConverter.cs

@ -132,7 +132,7 @@ namespace Squidex.Infrastructure.Json.Newtonsoft
{ {
switch (value) switch (value)
{ {
case JsonNull _: case JsonNull:
writer.WriteNull(); writer.WriteNull();
break; break;
case JsonBoolean s: case JsonBoolean s:

19
backend/src/Squidex.Infrastructure/Orleans/ILockGrain.cs

@ -1,19 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Threading.Tasks;
using Orleans;
namespace Squidex.Infrastructure.Orleans
{
public interface ILockGrain : IGrainWithStringKey
{
Task<string?> AcquireLockAsync(string key);
Task ReleaseLockAsync(string releaseToken);
}
}

45
backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs

@ -1,45 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Squidex.Infrastructure.Orleans
{
public sealed class LockGrain : GrainOfString, ILockGrain
{
private readonly Dictionary<string, string> locks = new Dictionary<string, string>();
public Task<string?> AcquireLockAsync(string key)
{
string? releaseToken = null;
if (!locks.ContainsKey(key))
{
releaseToken = Guid.NewGuid().ToString();
locks.Add(key, releaseToken);
}
return Task.FromResult(releaseToken);
}
public Task ReleaseLockAsync(string releaseToken)
{
var key = locks.FirstOrDefault(x => x.Value == releaseToken).Key;
if (!string.IsNullOrWhiteSpace(key))
{
locks.Remove(key);
}
return Task.CompletedTask;
}
}
}

2
backend/src/Squidex.Infrastructure/Queries/Json/ValueConverter.cs

@ -288,7 +288,7 @@ namespace Squidex.Infrastructure.Queries.Json
switch (value) switch (value)
{ {
case JsonNull _: case JsonNull:
return true; return true;
case JsonNumber jsonNumber: case JsonNumber jsonNumber:
result = jsonNumber.Value; result = jsonNumber.Value;

2
backend/src/Squidex.Infrastructure/Translations/MissingKeys.cs

@ -36,7 +36,7 @@ namespace Squidex.Infrastructure.Translations
{ {
if (!missingTranslations.Add(key)) if (!missingTranslations.Add(key))
{ {
File.AppendAllLines(MissingFileName, new string[] { key }); File.AppendAllLines(MissingFileName, new[] { key });
} }
} }
} }

16
backend/src/Squidex.Infrastructure/Validation/IValidatable.cs

@ -1,16 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Generic;
namespace Squidex.Infrastructure.Validation
{
public interface IValidatable
{
void Validate(IList<ValidationError> errors);
}
}

14
backend/src/Squidex.Web/ApiExceptionConverter.cs

@ -85,25 +85,25 @@ namespace Squidex.Web
case ValidationException ex: case ValidationException ex:
return (CreateError(400, T.Get("common.httpValidationError"), ToErrors(ex.Errors).ToArray()), true); return (CreateError(400, T.Get("common.httpValidationError"), ToErrors(ex.Errors).ToArray()), true);
case DomainObjectNotFoundException _: case DomainObjectNotFoundException:
return (CreateError(404), true); return (CreateError(404), true);
case DomainObjectVersionException _: case DomainObjectVersionException:
return (CreateError(412, exception.Message), true); return (CreateError(412, exception.Message), true);
case DomainObjectConflictException _: case DomainObjectConflictException:
return (CreateError(409, exception.Message), true); return (CreateError(409, exception.Message), true);
case DomainForbiddenException _: case DomainForbiddenException:
return (CreateError(403, exception.Message), true); return (CreateError(403, exception.Message), true);
case DomainException _: case DomainException:
return (CreateError(400, exception.Message), true); return (CreateError(400, exception.Message), true);
case SecurityException _: case SecurityException:
return (CreateError(403), false); return (CreateError(403), false);
case DecoderFallbackException _: case DecoderFallbackException:
return (CreateError(400, exception.Message), true); return (CreateError(400, exception.Message), true);
case BadHttpRequestException ex: case BadHttpRequestException ex:

2
backend/src/Squidex.Web/ApiExceptionFilterAttribute.cs

@ -19,7 +19,7 @@ namespace Squidex.Web
{ {
var resultContext = await next(); var resultContext = await next();
if (resultContext.Result is ObjectResult objectResult && objectResult.Value is ProblemDetails problem) if (resultContext.Result is ObjectResult { Value: ProblemDetails problem })
{ {
var (error, _) = problem.ToErrorDto(context.HttpContext); var (error, _) = problem.ToErrorDto(context.HttpContext);

2
backend/src/Squidex.Web/Pipeline/DeferredActionFilter.cs

@ -17,7 +17,7 @@ namespace Squidex.Web.Pipeline
{ {
var resultContext = await next(); var resultContext = await next();
if (resultContext.Result is ObjectResult objectResult && objectResult.Value is Deferred deferred) if (resultContext.Result is ObjectResult { Value: Deferred deferred } objectResult)
{ {
objectResult.Value = await deferred.Value; objectResult.Value = await deferred.Value;
} }

15
backend/src/Squidex.Web/Services/UrlGenerator.cs

@ -42,11 +42,6 @@ namespace Squidex.Web.Services
return urlGenerator.BuildUrl($"api/assets/{appId.Name}/{idOrSlug}?width=100&mode=Max"); return urlGenerator.BuildUrl($"api/assets/{appId.Name}/{idOrSlug}?width=100&mode=Max");
} }
public string AppSettingsUI(NamedId<DomainId> appId)
{
return urlGenerator.BuildUrl($"app/{appId.Name}/settings", false);
}
public string AssetContentBase() public string AssetContentBase()
{ {
return urlGenerator.BuildUrl("api/assets/"); return urlGenerator.BuildUrl("api/assets/");
@ -77,11 +72,6 @@ namespace Squidex.Web.Services
return urlGenerator.BuildUrl($"app/{appId.Name}/assets", false) + query != null ? $"?query={query}" : string.Empty; return urlGenerator.BuildUrl($"app/{appId.Name}/assets", false) + query != null ? $"?query={query}" : string.Empty;
} }
public string AssetsUI(NamedId<Named> appId, string? query = null)
{
return urlGenerator.BuildUrl($"app/{appId.Name}/assets?query={query}", false);
}
public string BackupsUI(NamedId<DomainId> appId) public string BackupsUI(NamedId<DomainId> appId)
{ {
return urlGenerator.BuildUrl($"app/{appId.Name}/settings/backups", false); return urlGenerator.BuildUrl($"app/{appId.Name}/settings/backups", false);
@ -92,11 +82,6 @@ namespace Squidex.Web.Services
return urlGenerator.BuildUrl($"app/{appId.Name}/settings/clients", false); return urlGenerator.BuildUrl($"app/{appId.Name}/settings/clients", false);
} }
public string ContentsUI(NamedId<DomainId> appId)
{
return urlGenerator.BuildUrl($"app/{appId.Name}/content", false);
}
public string ContentsUI(NamedId<DomainId> appId, NamedId<DomainId> schemaId) public string ContentsUI(NamedId<DomainId> appId, NamedId<DomainId> schemaId)
{ {
return urlGenerator.BuildUrl($"app/{appId.Name}/content/{schemaId.Name}", false); return urlGenerator.BuildUrl($"app/{appId.Name}/content/{schemaId.Name}", false);

2
backend/src/Squidex/Areas/Api/Controllers/Assets/AssetContentController.cs

@ -118,7 +118,7 @@ namespace Squidex.Areas.Api.Controllers.Assets
if (asset.IsProtected && !Resources.CanReadAssets) if (asset.IsProtected && !Resources.CanReadAssets)
{ {
Response.Headers[HeaderNames.CacheControl] = $"public,max-age=0"; Response.Headers[HeaderNames.CacheControl] = "public,max-age=0";
return StatusCode(403); return StatusCode(403);
} }

3
backend/src/Squidex/Areas/Api/Startup.cs

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Builder;
using Squidex.Areas.Api.Config; using Squidex.Areas.Api.Config;
using Squidex.Areas.Api.Config.OpenApi; using Squidex.Areas.Api.Config.OpenApi;
using Squidex.Web; using Squidex.Web;
using Squidex.Web.Pipeline;
namespace Squidex.Areas.Api namespace Squidex.Areas.Api
{ {
@ -20,6 +21,8 @@ namespace Squidex.Areas.Api
{ {
appApi.UseMiddleware<IdentityServerPathMiddleware>(); appApi.UseMiddleware<IdentityServerPathMiddleware>();
appApi.UseAccessTokenQueryString();
appApi.UseRouting(); appApi.UseRouting();
appApi.UseAuthentication(); appApi.UseAuthentication();

8
backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs

@ -18,11 +18,9 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Squidex.Config; using Squidex.Config;
using Squidex.Domain.Users; using Squidex.Domain.Users;
using Squidex.Hosting;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Security; using Squidex.Infrastructure.Security;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Log;
using Squidex.Shared.Identity; using Squidex.Shared.Identity;
using Squidex.Shared.Users; using Squidex.Shared.Users;
using Squidex.Web; using Squidex.Web;
@ -32,23 +30,17 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
public sealed class AccountController : IdentityServerController public sealed class AccountController : IdentityServerController
{ {
private readonly IUserService userService; private readonly IUserService userService;
private readonly IUrlGenerator urlGenerator;
private readonly MyIdentityOptions identityOptions; private readonly MyIdentityOptions identityOptions;
private readonly ISemanticLog log;
private readonly IIdentityServerInteractionService interactions; private readonly IIdentityServerInteractionService interactions;
public AccountController( public AccountController(
IUserService userService, IUserService userService,
IUrlGenerator urlGenerator,
IOptions<MyIdentityOptions> identityOptions, IOptions<MyIdentityOptions> identityOptions,
ISemanticLog log,
IIdentityServerInteractionService interactions) IIdentityServerInteractionService interactions)
{ {
this.identityOptions = identityOptions.Value; this.identityOptions = identityOptions.Value;
this.interactions = interactions; this.interactions = interactions;
this.urlGenerator = urlGenerator;
this.userService = userService; this.userService = userService;
this.log = log;
} }
[HttpGet] [HttpGet]

4
backend/src/Squidex/Areas/IdentityServer/Controllers/Profile/ProfileController.cs

@ -76,7 +76,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/login-add-callback/")] [Route("/account/profile/login-add-callback/")]
public Task<IActionResult> AddLoginCallback() public Task<IActionResult> AddLoginCallback()
{ {
return MakeChangeAsync<None>(u => AddLoginAsync(u), return MakeChangeAsync(u => AddLoginAsync(u),
T.Get("users.profile.addLoginDone"), None.Value); T.Get("users.profile.addLoginDone"), None.Value);
} }
@ -132,7 +132,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Profile
[Route("/account/profile/upload-picture/")] [Route("/account/profile/upload-picture/")]
public Task<IActionResult> UploadPicture(List<IFormFile> file) public Task<IActionResult> UploadPicture(List<IFormFile> file)
{ {
return MakeChangeAsync<None>(user => UpdatePictureAsync(file, user), return MakeChangeAsync(user => UpdatePictureAsync(file, user),
T.Get("users.profile.uploadPictureDone"), None.Value); T.Get("users.profile.uploadPictureDone"), None.Value);
} }

2
backend/src/Squidex/Areas/IdentityServer/Controllers/Setup/SetupController.cs

@ -111,7 +111,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Setup
IsAssetStoreFile = assetStore is FolderAssetStore, IsAssetStoreFile = assetStore is FolderAssetStore,
IsAssetStoreFtp = assetStore is FTPAssetStore, IsAssetStoreFtp = assetStore is FTPAssetStore,
HasExternalLogin = externalProviders.Any(), HasExternalLogin = externalProviders.Any(),
HasPasswordAuth = identityOptions.AllowPasswordAuth, HasPasswordAuth = identityOptions.AllowPasswordAuth
}; };
if (model != null) if (model != null)

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

@ -12,7 +12,6 @@ using Newtonsoft.Json;
using Squidex.Areas.Api.Controllers.Rules.Models; using Squidex.Areas.Api.Controllers.Rules.Models;
using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Hosting; using Squidex.Hosting;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;

4
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/FieldCompareTests.cs

@ -41,7 +41,7 @@ namespace Squidex.Domain.Apps.Core.Model.Schemas
{ {
DefaultValues = new LocalizedValue<string[]?> DefaultValues = new LocalizedValue<string[]?>
{ {
["iv"] = new string[] { "A", "B", "C" } ["iv"] = new[] { "A", "B", "C" }
} }
}; };
@ -49,7 +49,7 @@ namespace Squidex.Domain.Apps.Core.Model.Schemas
{ {
DefaultValues = new LocalizedValue<string[]?> DefaultValues = new LocalizedValue<string[]?>
{ {
["iv"] = new string[] { "A", "B", "C" } ["iv"] = new[] { "A", "B", "C" }
} }
}; };

8
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/AssetUsageTrackerTests.cs

@ -81,17 +81,17 @@ namespace Squidex.Domain.Apps.Entities.Assets
(dateFrom.AddDays(0), new Counters (dateFrom.AddDays(0), new Counters
{ {
["TotalSize"] = 128, ["TotalSize"] = 128,
["TotalAssets"] = 2, ["TotalAssets"] = 2
}), }),
(dateFrom.AddDays(1), new Counters (dateFrom.AddDays(1), new Counters
{ {
["TotalSize"] = 256, ["TotalSize"] = 256,
["TotalAssets"] = 3, ["TotalAssets"] = 3
}), }),
(dateFrom.AddDays(2), new Counters (dateFrom.AddDays(2), new Counters
{ {
["TotalSize"] = 512, ["TotalSize"] = 512,
["TotalAssets"] = 4, ["TotalAssets"] = 4
}) })
} }
}); });
@ -102,7 +102,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{ {
new AssetStats(dateFrom.AddDays(0), 2, 128), new AssetStats(dateFrom.AddDays(0), 2, 128),
new AssetStats(dateFrom.AddDays(1), 3, 256), new AssetStats(dateFrom.AddDays(1), 3, 256),
new AssetStats(dateFrom.AddDays(2), 4, 512), new AssetStats(dateFrom.AddDays(2), 4, 512)
}); });
} }

1
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetEnricherTests.cs

@ -10,7 +10,6 @@ using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Domain.Apps.Core.Tags; using Squidex.Domain.Apps.Core.Tags;
using Squidex.Domain.Apps.Core.TestHelpers; using Squidex.Domain.Apps.Core.TestHelpers;
using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Caching; using Squidex.Infrastructure.Caching;
using Xunit; using Xunit;

1
backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/UserMappingTests.cs

@ -10,7 +10,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Domain.Apps.Core.TestHelpers; using Squidex.Domain.Apps.Core.TestHelpers;
using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Shared.Users; using Squidex.Shared.Users;
using Xunit; using Xunit;

8
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BulkUpdateCommandMiddlewareTests.cs

@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{ {
SetupContext(Permissions.AppContentsUpdateOwn); SetupContext(Permissions.AppContentsUpdateOwn);
var (_, _, query) = CreateTestData(true); CreateTestData(true);
var command = BulkCommand(BulkUpdateType.ChangeStatus); var command = BulkCommand(BulkUpdateType.ChangeStatus);
@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{ {
var requestContext = SetupContext(Permissions.AppContentsUpdateOwn); var requestContext = SetupContext(Permissions.AppContentsUpdateOwn);
var (id, data, query) = CreateTestData(true); var (id, _, query) = CreateTestData(true);
A.CallTo(() => contentQuery.QueryAsync(requestContext, A<string>._, A<Q>.That.Matches(x => x.JsonQuery == query))) A.CallTo(() => contentQuery.QueryAsync(requestContext, A<string>._, A<Q>.That.Matches(x => x.JsonQuery == query)))
.Returns(ResultList.CreateFrom(2, CreateContent(id), CreateContent(id))); .Returns(ResultList.CreateFrom(2, CreateContent(id), CreateContent(id)));
@ -205,7 +205,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
[Fact] [Fact]
public async Task Should_upsert_content_with_custom_id() public async Task Should_upsert_content_with_custom_id()
{ {
var requestContext = SetupContext(Permissions.AppContentsUpsert); SetupContext(Permissions.AppContentsUpsert);
var (id, data, _) = CreateTestData(true); var (id, data, _) = CreateTestData(true);
@ -471,7 +471,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
Id = id, Id = id,
Data = data!, Data = data!,
DueTime = dueTime, DueTime = dueTime,
Query = query, Query = query
} }
}, },
SchemaId = schemaId SchemaId = schemaId

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentChangedTriggerHandlerTests.cs

@ -19,7 +19,6 @@ using Squidex.Domain.Apps.Core.Rules.Triggers;
using Squidex.Domain.Apps.Core.Scripting; using Squidex.Domain.Apps.Core.Scripting;
using Squidex.Domain.Apps.Core.TestHelpers; using Squidex.Domain.Apps.Core.TestHelpers;
using Squidex.Domain.Apps.Entities.Contents.Repositories; using Squidex.Domain.Apps.Entities.Contents.Repositories;
using Squidex.Domain.Apps.Entities.TestHelpers;
using Squidex.Domain.Apps.Events; using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Domain.Apps.Events.Contents; using Squidex.Domain.Apps.Events.Contents;
@ -32,7 +31,6 @@ namespace Squidex.Domain.Apps.Entities.Contents
public class ContentChangedTriggerHandlerTests public class ContentChangedTriggerHandlerTests
{ {
private readonly IScriptEngine scriptEngine = A.Fake<IScriptEngine>(); private readonly IScriptEngine scriptEngine = A.Fake<IScriptEngine>();
private readonly ILocalCache localCache = new AsyncLocalCache();
private readonly IContentLoader contentLoader = A.Fake<IContentLoader>(); private readonly IContentLoader contentLoader = A.Fake<IContentLoader>();
private readonly IContentRepository contentRepository = A.Fake<IContentRepository>(); private readonly IContentRepository contentRepository = A.Fake<IContentRepository>();
private readonly NamedId<DomainId> appId = NamedId.Of(DomainId.NewGuid(), "my-app"); private readonly NamedId<DomainId> appId = NamedId.Of(DomainId.NewGuid(), "my-app");

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

Loading…
Cancel
Save