mirror of https://github.com/Squidex/squidex.git
395 changed files with 5465 additions and 2692 deletions
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
@ -0,0 +1,79 @@ |
|||||
|
// ==========================================================================
|
||||
|
// ContentEnricher.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using Squidex.Core.Contents; |
||||
|
using Squidex.Core.Schemas; |
||||
|
using Squidex.Infrastructure; |
||||
|
using Squidex.Infrastructure.Json; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Squidex.Core |
||||
|
{ |
||||
|
public sealed class ContentEnricher |
||||
|
{ |
||||
|
private readonly Schema schema; |
||||
|
private readonly HashSet<Language> languages; |
||||
|
|
||||
|
public ContentEnricher(HashSet<Language> languages, Schema schema) |
||||
|
{ |
||||
|
Guard.NotNull(schema, nameof(schema)); |
||||
|
Guard.NotNull(languages, nameof(languages)); |
||||
|
|
||||
|
this.schema = schema; |
||||
|
|
||||
|
this.languages = languages; |
||||
|
} |
||||
|
|
||||
|
public void Enrich(ContentData data) |
||||
|
{ |
||||
|
Guard.NotNull(data, nameof(data)); |
||||
|
Guard.NotEmpty(languages, nameof(languages)); |
||||
|
|
||||
|
foreach (var field in schema.FieldsByName.Values) |
||||
|
{ |
||||
|
var fieldData = data.GetOrCreate(field.Name, k => new ContentFieldData()); |
||||
|
|
||||
|
if (field.RawProperties.IsLocalizable) |
||||
|
{ |
||||
|
foreach (var language in languages) |
||||
|
{ |
||||
|
Enrich(field, fieldData, language); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
Enrich(field, fieldData, Language.Invariant); |
||||
|
} |
||||
|
|
||||
|
if (fieldData.Count > 0) |
||||
|
{ |
||||
|
data.AddField(field.Name, fieldData); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void Enrich(Field field, ContentFieldData fieldData, Language language) |
||||
|
{ |
||||
|
Guard.NotNull(fieldData, nameof(fieldData)); |
||||
|
Guard.NotNull(language, nameof(language)); |
||||
|
|
||||
|
var defaultValue = field.RawProperties.GetDefaultValue(); |
||||
|
|
||||
|
if (field.RawProperties.IsRequired || defaultValue.IsNull()) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (!fieldData.TryGetValue(language.Iso2Code, out JToken value) || value == null || value.Type == JTokenType.Null) |
||||
|
{ |
||||
|
fieldData.AddValue(language.Iso2Code, defaultValue); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,52 @@ |
|||||
|
// ==========================================================================
|
||||
|
// ContentExtensions.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Squidex.Core.Contents; |
||||
|
using Squidex.Core.Schemas; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Squidex.Core |
||||
|
{ |
||||
|
public static class ContentExtensions |
||||
|
{ |
||||
|
public static ContentData Enrich(this ContentData data, Schema schema, HashSet<Language> languages) |
||||
|
{ |
||||
|
var validator = new ContentEnricher(languages, schema); |
||||
|
|
||||
|
validator.Enrich(data); |
||||
|
|
||||
|
return data; |
||||
|
} |
||||
|
|
||||
|
public static async Task ValidateAsync(this ContentData data, Schema schema, HashSet<Language> languages, IList<ValidationError> errors) |
||||
|
{ |
||||
|
var validator = new ContentValidator(schema, languages); |
||||
|
|
||||
|
await validator.ValidateAsync(data); |
||||
|
|
||||
|
foreach (var error in validator.Errors) |
||||
|
{ |
||||
|
errors.Add(error); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static async Task ValidatePartialAsync(this ContentData data, Schema schema, HashSet<Language> languages, IList<ValidationError> errors) |
||||
|
{ |
||||
|
var validator = new ContentValidator(schema, languages); |
||||
|
|
||||
|
await validator.ValidatePartialAsync(data); |
||||
|
|
||||
|
foreach (var error in validator.Errors) |
||||
|
{ |
||||
|
errors.Add(error); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,190 @@ |
|||||
|
// ==========================================================================
|
||||
|
// ContentValidator.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using Squidex.Core.Contents; |
||||
|
using Squidex.Core.Schemas; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Squidex.Core |
||||
|
{ |
||||
|
public sealed class ContentValidator |
||||
|
{ |
||||
|
private readonly Schema schema; |
||||
|
private readonly HashSet<Language> languages; |
||||
|
private readonly List<ValidationError> errors = new List<ValidationError>(); |
||||
|
|
||||
|
public ContentValidator(Schema schema, HashSet<Language> languages) |
||||
|
{ |
||||
|
Guard.NotNull(schema, nameof(schema)); |
||||
|
Guard.NotNull(languages, nameof(languages)); |
||||
|
|
||||
|
this.schema = schema; |
||||
|
|
||||
|
this.languages = languages; |
||||
|
} |
||||
|
|
||||
|
public IReadOnlyList<ValidationError> Errors |
||||
|
{ |
||||
|
get { return errors; } |
||||
|
} |
||||
|
|
||||
|
public async Task ValidatePartialAsync(ContentData data) |
||||
|
{ |
||||
|
Guard.NotNull(data, nameof(data)); |
||||
|
|
||||
|
foreach (var fieldData in data) |
||||
|
{ |
||||
|
var fieldName = fieldData.Key; |
||||
|
|
||||
|
if (!schema.FieldsByName.TryGetValue(fieldData.Key, out Field field)) |
||||
|
{ |
||||
|
AddError("<FIELD> is not a known field", fieldName); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (field.RawProperties.IsLocalizable) |
||||
|
{ |
||||
|
await ValidateLocalizableFieldPartialAsync(field, fieldData.Value); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
await ValidateNonLocalizableFieldPartialAsync(field, fieldData.Value); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task ValidateLocalizableFieldPartialAsync(Field field, ContentFieldData fieldData) |
||||
|
{ |
||||
|
foreach (var languageValue in fieldData) |
||||
|
{ |
||||
|
if (!Language.TryGetLanguage(languageValue.Key, out Language language)) |
||||
|
{ |
||||
|
AddError($"<FIELD> has an invalid language '{languageValue.Key}'", field); |
||||
|
} |
||||
|
else if (!languages.Contains(language)) |
||||
|
{ |
||||
|
AddError($"<FIELD> has an unsupported language '{languageValue.Key}'", field); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
await ValidateAsync(field, languageValue.Value, language); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task ValidateNonLocalizableFieldPartialAsync(Field field, ContentFieldData fieldData) |
||||
|
{ |
||||
|
if (fieldData.Keys.Any(x => x != Language.Invariant.Iso2Code)) |
||||
|
{ |
||||
|
AddError($"<FIELD> can only contain a single entry for invariant language ({Language.Invariant.Iso2Code})", field); |
||||
|
} |
||||
|
|
||||
|
if (fieldData.TryGetValue(Language.Invariant.Iso2Code, out JToken value)) |
||||
|
{ |
||||
|
await ValidateAsync(field, value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public async Task ValidateAsync(ContentData data) |
||||
|
{ |
||||
|
Guard.NotNull(data, nameof(data)); |
||||
|
|
||||
|
ValidateUnknownFields(data); |
||||
|
|
||||
|
foreach (var field in schema.FieldsByName.Values) |
||||
|
{ |
||||
|
var fieldData = data.GetOrCreate(field.Name, k => new ContentFieldData()); |
||||
|
|
||||
|
if (field.RawProperties.IsLocalizable) |
||||
|
{ |
||||
|
await ValidateLocalizableFieldAsync(field, fieldData); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
await ValidateNonLocalizableField(field, fieldData); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ValidateUnknownFields(ContentData data) |
||||
|
{ |
||||
|
foreach (var fieldData in data) |
||||
|
{ |
||||
|
if (!schema.FieldsByName.ContainsKey(fieldData.Key)) |
||||
|
{ |
||||
|
AddError("<FIELD> is not a known field", fieldData.Key); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task ValidateLocalizableFieldAsync(Field field, ContentFieldData fieldData) |
||||
|
{ |
||||
|
foreach (var valueLanguage in fieldData.Keys) |
||||
|
{ |
||||
|
if (!Language.TryGetLanguage(valueLanguage, out Language language)) |
||||
|
{ |
||||
|
AddError($"<FIELD> has an invalid language '{valueLanguage}'", field); |
||||
|
} |
||||
|
else if (!languages.Contains(language)) |
||||
|
{ |
||||
|
AddError($"<FIELD> has an unsupported language '{valueLanguage}'", field); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
foreach (var language in languages) |
||||
|
{ |
||||
|
var value = fieldData.GetOrCreate(language.Iso2Code, k => JValue.CreateNull()); |
||||
|
|
||||
|
await ValidateAsync(field, value, language); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task ValidateNonLocalizableField(Field field, ContentFieldData fieldData) |
||||
|
{ |
||||
|
if (fieldData.Keys.Any(x => x != Language.Invariant.Iso2Code)) |
||||
|
{ |
||||
|
AddError($"<FIELD> can only contain a single entry for invariant language ({Language.Invariant.Iso2Code})", field); |
||||
|
} |
||||
|
|
||||
|
var value = fieldData.GetOrCreate(Language.Invariant.Iso2Code, k => JValue.CreateNull()); |
||||
|
|
||||
|
await ValidateAsync(field, value); |
||||
|
} |
||||
|
|
||||
|
private Task ValidateAsync(Field field, JToken value, Language language = null) |
||||
|
{ |
||||
|
return field.ValidateAsync(value, m => AddError(m, field, language)); |
||||
|
} |
||||
|
|
||||
|
private void AddError(string message, Field field, Language language = null) |
||||
|
{ |
||||
|
var displayName = !string.IsNullOrWhiteSpace(field.RawProperties.Label) ? field.RawProperties.Label : field.Name; |
||||
|
|
||||
|
if (language != null) |
||||
|
{ |
||||
|
displayName += $" ({language.Iso2Code})"; |
||||
|
} |
||||
|
|
||||
|
message = message.Replace("<FIELD>", displayName); |
||||
|
|
||||
|
errors.Add(new ValidationError(message, field.Name)); |
||||
|
} |
||||
|
|
||||
|
private void AddError(string message, string fieldName) |
||||
|
{ |
||||
|
message = message.Replace("<FIELD>", fieldName); |
||||
|
|
||||
|
errors.Add(new ValidationError(message, fieldName)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
// ==========================================================================
|
||||
|
// FieldExtensions.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using Squidex.Core.Schemas; |
||||
|
using Squidex.Infrastructure; |
||||
|
using Squidex.Infrastructure.Json; |
||||
|
|
||||
|
namespace Squidex.Core |
||||
|
{ |
||||
|
public static class FieldExtensions |
||||
|
{ |
||||
|
public static async Task ValidateAsync(this Field field, JToken value, Action<string> addError) |
||||
|
{ |
||||
|
Guard.NotNull(value, nameof(value)); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
var typedValue = value.IsNull() ? null : field.ConvertValue(value); |
||||
|
|
||||
|
foreach (var validator in field.Validators) |
||||
|
{ |
||||
|
await validator.ValidateAsync(typedValue, addError); |
||||
|
} |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
addError("<FIELD> is not a valid value"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,89 @@ |
|||||
|
// ==========================================================================
|
||||
|
// GeolocationField.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using Microsoft.OData.Edm; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using NJsonSchema; |
||||
|
using Squidex.Core.Schemas.Validators; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Squidex.Core.Schemas |
||||
|
{ |
||||
|
public sealed class GeolocationField : Field<GeolocationFieldProperties> |
||||
|
{ |
||||
|
public GeolocationField(long id, string name, GeolocationFieldProperties properties) |
||||
|
: base(id, name, properties) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
protected override IEnumerable<IValidator> CreateValidators() |
||||
|
{ |
||||
|
if (Properties.IsRequired) |
||||
|
{ |
||||
|
yield return new RequiredValidator(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public override object ConvertValue(JToken value) |
||||
|
{ |
||||
|
var geolocation = (JObject)value; |
||||
|
|
||||
|
foreach (var property in geolocation.Properties()) |
||||
|
{ |
||||
|
if (!string.Equals(property.Name, "latitude", StringComparison.OrdinalIgnoreCase) && |
||||
|
!string.Equals(property.Name, "longitude", StringComparison.OrdinalIgnoreCase)) |
||||
|
{ |
||||
|
throw new InvalidCastException("Geolocation can only have latitude and longitude property."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
var lat = (double)geolocation["latitude"]; |
||||
|
var lon = (double)geolocation["longitude"]; |
||||
|
|
||||
|
Guard.Between(lat, -90, 90, "latitude"); |
||||
|
Guard.Between(lon, -180, 180, "longitude"); |
||||
|
|
||||
|
return value; |
||||
|
} |
||||
|
|
||||
|
protected override void PrepareJsonSchema(JsonProperty jsonProperty, Func<string, JsonSchema4, JsonSchema4> schemaResolver) |
||||
|
{ |
||||
|
jsonProperty.Type = JsonObjectType.Object; |
||||
|
|
||||
|
var geolocationSchema = new JsonSchema4(); |
||||
|
|
||||
|
geolocationSchema.Properties.Add("latitude", new JsonProperty |
||||
|
{ |
||||
|
Type = JsonObjectType.Number, |
||||
|
Minimum = -90, |
||||
|
Maximum = 90, |
||||
|
IsRequired = true |
||||
|
}); |
||||
|
geolocationSchema.Properties.Add("longitude", new JsonProperty |
||||
|
{ |
||||
|
Type = JsonObjectType.Number, |
||||
|
Minimum = -180, |
||||
|
Maximum = 180, |
||||
|
IsRequired = true |
||||
|
}); |
||||
|
|
||||
|
geolocationSchema.AllowAdditionalProperties = false; |
||||
|
|
||||
|
var schemaReference = schemaResolver("GeolocationDto", geolocationSchema); |
||||
|
|
||||
|
jsonProperty.SchemaReference = schemaReference; |
||||
|
} |
||||
|
|
||||
|
protected override IEdmTypeReference CreateEdmType() |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
// ==========================================================================
|
||||
|
// GeolocationFieldEditor.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
namespace Squidex.Core.Schemas |
||||
|
{ |
||||
|
public enum GeolocationFieldEditor |
||||
|
{ |
||||
|
Map |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
// ==========================================================================
|
||||
|
// GeolocationFieldProperties.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using Squidex.Infrastructure; |
||||
|
|
||||
|
namespace Squidex.Core.Schemas |
||||
|
{ |
||||
|
[TypeName("GeolocationField")] |
||||
|
public sealed class GeolocationFieldProperties : FieldProperties |
||||
|
{ |
||||
|
private GeolocationFieldEditor editor; |
||||
|
|
||||
|
public GeolocationFieldEditor Editor |
||||
|
{ |
||||
|
get { return editor; } |
||||
|
set |
||||
|
{ |
||||
|
ThrowIfFrozen(); |
||||
|
|
||||
|
editor = value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public override JToken GetDefaultValue() |
||||
|
{ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
protected override IEnumerable<ValidationError> ValidateCore() |
||||
|
{ |
||||
|
if (!Editor.IsEnumValue()) |
||||
|
{ |
||||
|
yield return new ValidationError("Editor ist not a valid value", nameof(Editor)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,234 +0,0 @@ |
|||||
## Ignore Visual Studio temporary files, build results, and |
|
||||
## files generated by popular Visual Studio add-ons. |
|
||||
|
|
||||
# User-specific files |
|
||||
*.suo |
|
||||
*.user |
|
||||
*.userosscache |
|
||||
*.sln.docstates |
|
||||
|
|
||||
# User-specific files (MonoDevelop/Xamarin Studio) |
|
||||
*.userprefs |
|
||||
|
|
||||
# Build results |
|
||||
[Dd]ebug/ |
|
||||
[Dd]ebugPublic/ |
|
||||
[Rr]elease/ |
|
||||
[Rr]eleases/ |
|
||||
x64/ |
|
||||
x86/ |
|
||||
build/ |
|
||||
bld/ |
|
||||
[Bb]in/ |
|
||||
[Oo]bj/ |
|
||||
|
|
||||
# Visual Studio 2015 cache/options directory |
|
||||
.vs/ |
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot |
|
||||
#wwwroot/ |
|
||||
|
|
||||
# MSTest test Results |
|
||||
[Tt]est[Rr]esult*/ |
|
||||
[Bb]uild[Ll]og.* |
|
||||
|
|
||||
# NUNIT |
|
||||
*.VisualState.xml |
|
||||
TestResult.xml |
|
||||
|
|
||||
# Build Results of an ATL Project |
|
||||
[Dd]ebugPS/ |
|
||||
[Rr]eleasePS/ |
|
||||
dlldata.c |
|
||||
|
|
||||
# DNX |
|
||||
project.lock.json |
|
||||
artifacts/ |
|
||||
|
|
||||
*_i.c |
|
||||
*_p.c |
|
||||
*_i.h |
|
||||
*.ilk |
|
||||
*.meta |
|
||||
*.obj |
|
||||
*.pch |
|
||||
*.pdb |
|
||||
*.pgc |
|
||||
*.pgd |
|
||||
*.rsp |
|
||||
*.sbr |
|
||||
*.tlb |
|
||||
*.tli |
|
||||
*.tlh |
|
||||
*.tmp |
|
||||
*.tmp_proj |
|
||||
*.log |
|
||||
*.vspscc |
|
||||
*.vssscc |
|
||||
.builds |
|
||||
*.pidb |
|
||||
*.svclog |
|
||||
*.scc |
|
||||
|
|
||||
# Chutzpah Test files |
|
||||
_Chutzpah* |
|
||||
|
|
||||
# Visual C++ cache files |
|
||||
ipch/ |
|
||||
*.aps |
|
||||
*.ncb |
|
||||
*.opendb |
|
||||
*.opensdf |
|
||||
*.sdf |
|
||||
*.cachefile |
|
||||
|
|
||||
# Visual Studio profiler |
|
||||
*.psess |
|
||||
*.vsp |
|
||||
*.vspx |
|
||||
*.sap |
|
||||
|
|
||||
# TFS 2012 Local Workspace |
|
||||
$tf/ |
|
||||
|
|
||||
# Guidance Automation Toolkit |
|
||||
*.gpState |
|
||||
|
|
||||
# ReSharper is a .NET coding add-in |
|
||||
_ReSharper*/ |
|
||||
*.[Rr]e[Ss]harper |
|
||||
*.DotSettings.user |
|
||||
|
|
||||
# JustCode is a .NET coding add-in |
|
||||
.JustCode |
|
||||
|
|
||||
# TeamCity is a build add-in |
|
||||
_TeamCity* |
|
||||
|
|
||||
# DotCover is a Code Coverage Tool |
|
||||
*.dotCover |
|
||||
|
|
||||
# NCrunch |
|
||||
_NCrunch_* |
|
||||
.*crunch*.local.xml |
|
||||
nCrunchTemp_* |
|
||||
|
|
||||
# MightyMoose |
|
||||
*.mm.* |
|
||||
AutoTest.Net/ |
|
||||
|
|
||||
# Web workbench (sass) |
|
||||
.sass-cache/ |
|
||||
|
|
||||
# Installshield output folder |
|
||||
[Ee]xpress/ |
|
||||
|
|
||||
# DocProject is a documentation generator add-in |
|
||||
DocProject/buildhelp/ |
|
||||
DocProject/Help/*.HxT |
|
||||
DocProject/Help/*.HxC |
|
||||
DocProject/Help/*.hhc |
|
||||
DocProject/Help/*.hhk |
|
||||
DocProject/Help/*.hhp |
|
||||
DocProject/Help/Html2 |
|
||||
DocProject/Help/html |
|
||||
|
|
||||
# Click-Once directory |
|
||||
publish/ |
|
||||
|
|
||||
# Publish Web Output |
|
||||
*.[Pp]ublish.xml |
|
||||
*.azurePubxml |
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings |
|
||||
# but database connection strings (with potential passwords) will be unencrypted |
|
||||
*.pubxml |
|
||||
*.publishproj |
|
||||
|
|
||||
# NuGet Packages |
|
||||
*.nupkg |
|
||||
# The packages folder can be ignored because of Package Restore |
|
||||
**/packages/* |
|
||||
# except build/, which is used as an MSBuild target. |
|
||||
!**/packages/build/ |
|
||||
# Uncomment if necessary however generally it will be regenerated when needed |
|
||||
#!**/packages/repositories.config |
|
||||
|
|
||||
# Microsoft Azure Build Output |
|
||||
csx/ |
|
||||
*.build.csdef |
|
||||
|
|
||||
# Microsoft Azure Emulator |
|
||||
ecf/ |
|
||||
rcf/ |
|
||||
|
|
||||
# Microsoft Azure ApplicationInsights config file |
|
||||
ApplicationInsights.config |
|
||||
|
|
||||
# Windows Store app package directory |
|
||||
AppPackages/ |
|
||||
BundleArtifacts/ |
|
||||
|
|
||||
# Visual Studio cache files |
|
||||
# files ending in .cache can be ignored |
|
||||
*.[Cc]ache |
|
||||
# but keep track of directories ending in .cache |
|
||||
!*.[Cc]ache/ |
|
||||
|
|
||||
# Others |
|
||||
ClientBin/ |
|
||||
~$* |
|
||||
*~ |
|
||||
*.dbmdl |
|
||||
*.dbproj.schemaview |
|
||||
*.pfx |
|
||||
*.publishsettings |
|
||||
node_modules/ |
|
||||
orleans.codegen.cs |
|
||||
|
|
||||
# RIA/Silverlight projects |
|
||||
Generated_Code/ |
|
||||
|
|
||||
# Backup & report files from converting an old project file |
|
||||
# to a newer Visual Studio version. Backup files are not needed, |
|
||||
# because we have git ;-) |
|
||||
_UpgradeReport_Files/ |
|
||||
Backup*/ |
|
||||
UpgradeLog*.XML |
|
||||
UpgradeLog*.htm |
|
||||
|
|
||||
# SQL Server files |
|
||||
*.mdf |
|
||||
*.ldf |
|
||||
|
|
||||
# Business Intelligence projects |
|
||||
*.rdl.data |
|
||||
*.bim.layout |
|
||||
*.bim_*.settings |
|
||||
|
|
||||
# Microsoft Fakes |
|
||||
FakesAssemblies/ |
|
||||
|
|
||||
# GhostDoc plugin setting file |
|
||||
*.GhostDoc.xml |
|
||||
|
|
||||
# Node.js Tools for Visual Studio |
|
||||
.ntvs_analysis.dat |
|
||||
|
|
||||
# Visual Studio 6 build log |
|
||||
*.plg |
|
||||
|
|
||||
# Visual Studio 6 workspace options file |
|
||||
*.opt |
|
||||
|
|
||||
# Visual Studio LightSwitch build output |
|
||||
**/*.HTMLClient/GeneratedArtifacts |
|
||||
**/*.DesktopClient/GeneratedArtifacts |
|
||||
**/*.DesktopClient/ModelManifest.xml |
|
||||
**/*.Server/GeneratedArtifacts |
|
||||
**/*.Server/ModelManifest.xml |
|
||||
_Pvt_Extensions |
|
||||
|
|
||||
# Paket dependency manager |
|
||||
.paket/paket.exe |
|
||||
|
|
||||
# FAKE - F# Make |
|
||||
.fake/ |
|
||||
@ -0,0 +1,18 @@ |
|||||
|
// ==========================================================================
|
||||
|
// EntityCreatedResult.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
namespace Squidex.Infrastructure.CQRS.Commands |
||||
|
{ |
||||
|
public static class EntityCreatedResult |
||||
|
{ |
||||
|
public static EntityCreatedResult<T> Create<T>(T idOrValue, long version) |
||||
|
{ |
||||
|
return new EntityCreatedResult<T>(idOrValue, version); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,23 +1,21 @@ |
|||||
// ==========================================================================
|
// ==========================================================================
|
||||
// WebpackServices.cs
|
// EntityCreatedResult_T.cs
|
||||
// Squidex Headless CMS
|
// Squidex Headless CMS
|
||||
// ==========================================================================
|
// ==========================================================================
|
||||
// Copyright (c) Squidex Group
|
// Copyright (c) Squidex Group
|
||||
// All rights reserved.
|
// All rights reserved.
|
||||
// ==========================================================================
|
// ==========================================================================
|
||||
|
|
||||
using Microsoft.Extensions.DependencyInjection; |
namespace Squidex.Infrastructure.CQRS.Commands |
||||
using Squidex.Pipeline; |
|
||||
|
|
||||
namespace Squidex.Config.Web |
|
||||
{ |
{ |
||||
public static class WebpackServices |
public sealed class EntityCreatedResult<T> : EntitySavedResult |
||||
{ |
{ |
||||
public static IServiceCollection AddWebpackBuilder(this IServiceCollection services) |
public T IdOrValue { get; } |
||||
{ |
|
||||
services.AddSingleton<WebpackRunner>(); |
|
||||
|
|
||||
return services; |
public EntityCreatedResult(T idOrValue, long version) |
||||
|
: base(version) |
||||
|
{ |
||||
|
IdOrValue = idOrValue; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
// ==========================================================================
|
||||
|
// EntitySavedResult.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
namespace Squidex.Infrastructure.CQRS.Commands |
||||
|
{ |
||||
|
public class EntitySavedResult |
||||
|
{ |
||||
|
public long Version { get; } |
||||
|
|
||||
|
public EntitySavedResult(long version) |
||||
|
{ |
||||
|
Version = version; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,29 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// EnrichWithAggregateIdProcessor.cs
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex Group
|
|
||||
// All rights reserved.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Threading.Tasks; |
|
||||
using Squidex.Infrastructure.CQRS.Commands; |
|
||||
using Squidex.Infrastructure.Tasks; |
|
||||
|
|
||||
namespace Squidex.Infrastructure.CQRS.Events |
|
||||
{ |
|
||||
public sealed class EnrichWithAggregateIdProcessor : IEventProcessor |
|
||||
{ |
|
||||
public Task ProcessEventAsync(Envelope<IEvent> @event, IAggregate aggregate, ICommand command) |
|
||||
{ |
|
||||
var aggregateCommand = command as IAggregateCommand; |
|
||||
|
|
||||
if (aggregateCommand != null) |
|
||||
{ |
|
||||
@event.SetAggregateId(aggregateCommand.AggregateId); |
|
||||
} |
|
||||
|
|
||||
return TaskHelper.Done; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,44 @@ |
|||||
|
// ==========================================================================
|
||||
|
// ConverterContractResolver.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using Newtonsoft.Json; |
||||
|
using Newtonsoft.Json.Serialization; |
||||
|
|
||||
|
namespace Squidex.Infrastructure.Json |
||||
|
{ |
||||
|
public sealed class ConverterContractResolver : CamelCasePropertyNamesContractResolver |
||||
|
{ |
||||
|
private readonly JsonConverter[] converters; |
||||
|
|
||||
|
public ConverterContractResolver(params JsonConverter[] converters) |
||||
|
{ |
||||
|
this.converters = converters; |
||||
|
} |
||||
|
|
||||
|
protected override JsonConverter ResolveContractConverter(Type objectType) |
||||
|
{ |
||||
|
var result = base.ResolveContractConverter(objectType); |
||||
|
|
||||
|
if (result != null) |
||||
|
{ |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
foreach (var converter in converters) |
||||
|
{ |
||||
|
if (converter.CanConvert(objectType)) |
||||
|
{ |
||||
|
return converter; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
// ==========================================================================
|
||||
|
// JsonExtension.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using Newtonsoft.Json.Linq; |
||||
|
|
||||
|
namespace Squidex.Infrastructure.Json |
||||
|
{ |
||||
|
public static class JsonExtension |
||||
|
{ |
||||
|
public static bool IsNull(this JToken token) |
||||
|
{ |
||||
|
if (token == null) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
if (token.Type == JTokenType.Null) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
if (token is JValue value) |
||||
|
{ |
||||
|
return value.Value == null; |
||||
|
} |
||||
|
|
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
// ==========================================================================
|
||||
|
// SchemaExtensions.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using Microsoft.OData.Core.UriParser; |
||||
|
using Microsoft.OData.Edm; |
||||
|
|
||||
|
namespace Squidex.Read.MongoDb.Contents.Visitors |
||||
|
{ |
||||
|
public static class EdmModelExtensions |
||||
|
{ |
||||
|
public static ODataUriParser ParseQuery(this IEdmModel model, string query) |
||||
|
{ |
||||
|
var path = model.EntityContainer.EntitySets().First().Path.Path.Last().Split('.').Last(); |
||||
|
|
||||
|
var parser = new ODataUriParser(model, new Uri($"{path}?{query}", UriKind.Relative)); |
||||
|
|
||||
|
return parser; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue