mirror of https://github.com/Squidex/squidex.git
52 changed files with 457 additions and 374 deletions
@ -0,0 +1,55 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.Infrastructure; |
|||
using System; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
public static class SchemaExtensions |
|||
{ |
|||
public static long MaxId(this Schema schema) |
|||
{ |
|||
var id = 0L; |
|||
|
|||
foreach (var field in schema.Fields) |
|||
{ |
|||
if (field is IArrayField arrayField) |
|||
{ |
|||
foreach (var nestedField in arrayField.Fields) |
|||
{ |
|||
id = Math.Max(id, nestedField.Id); |
|||
} |
|||
} |
|||
|
|||
id = Math.Max(id, field.Id); |
|||
} |
|||
|
|||
return id; |
|||
} |
|||
|
|||
public static string TypeName(this IField field) |
|||
{ |
|||
return field.Name.ToPascalCase(); |
|||
} |
|||
|
|||
public static string DisplayName(this IField field) |
|||
{ |
|||
return field.RawProperties.Label.WithFallback(field.TypeName()); |
|||
} |
|||
|
|||
public static string TypeName(this Schema schema) |
|||
{ |
|||
return schema.Name.ToPascalCase(); |
|||
} |
|||
|
|||
public static string DisplayName(this Schema schema) |
|||
{ |
|||
return schema.Properties.Label.WithFallback(schema.TypeName()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
public sealed class SchemaScripts : Freezable |
|||
{ |
|||
public string Change { get; set; } |
|||
|
|||
public string Create { get; set; } |
|||
|
|||
public string Update { get; set; } |
|||
|
|||
public string Delete { get; set; } |
|||
|
|||
public string Query { get; set; } |
|||
} |
|||
} |
|||
@ -1,47 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.Infrastructure; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.Schemas |
|||
{ |
|||
public static class Scripts |
|||
{ |
|||
public const string Change = "Change"; |
|||
public const string Create = "Create"; |
|||
public const string Delete = "Delete"; |
|||
public const string Update = "Update"; |
|||
|
|||
public const string Query = "Query"; |
|||
|
|||
public static string GetChange(this IReadOnlyDictionary<string, string> scripts) |
|||
{ |
|||
return scripts?.GetOrDefault(Change); |
|||
} |
|||
|
|||
public static string GetCreate(this IReadOnlyDictionary<string, string> scripts) |
|||
{ |
|||
return scripts?.GetOrDefault(Create); |
|||
} |
|||
|
|||
public static string GetQuery(this IReadOnlyDictionary<string, string> scripts) |
|||
{ |
|||
return scripts?.GetOrDefault(Query); |
|||
} |
|||
|
|||
public static string GetUpdate(this IReadOnlyDictionary<string, string> scripts) |
|||
{ |
|||
return scripts?.GetOrDefault(Update); |
|||
} |
|||
|
|||
public static string GetDelete(this IReadOnlyDictionary<string, string> scripts) |
|||
{ |
|||
return scripts?.GetOrDefault(Delete); |
|||
} |
|||
} |
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace Squidex.Areas.Api.Controllers.Schemas.Models |
|||
{ |
|||
public sealed class PreviewUrlsDto : Dictionary<string, string> |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.Domain.Apps.Core.Schemas; |
|||
using Squidex.Domain.Apps.Entities.Schemas.Commands; |
|||
using Squidex.Infrastructure.Reflection; |
|||
|
|||
namespace Squidex.Areas.Api.Controllers.Schemas.Models |
|||
{ |
|||
public sealed class SchemaScriptsDto |
|||
{ |
|||
/// <summary>
|
|||
/// The script that is executed for each query when querying contents.
|
|||
/// </summary>
|
|||
public string Query { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The script that is executed when creating a content.
|
|||
/// </summary>
|
|||
public string Create { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The script that is executed when updating a content.
|
|||
/// </summary>
|
|||
public string Update { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The script that is executed when deleting a content.
|
|||
/// </summary>
|
|||
public string Delete { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// The script that is executed when change a content status.
|
|||
/// </summary>
|
|||
public string Change { get; set; } |
|||
|
|||
public ConfigureScripts ToCommand() |
|||
{ |
|||
var scripts = SimpleMapper.Map(this, new SchemaScripts()); |
|||
|
|||
return new ConfigureScripts { Scripts = scripts }; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Squidex.Domain.Apps.Entities.Schemas.State; |
|||
using Squidex.Infrastructure.Migrations; |
|||
using Squidex.Infrastructure.States; |
|||
|
|||
namespace Migrate_01.Migrations |
|||
{ |
|||
public sealed class ClearSchemas : IMigration |
|||
{ |
|||
private readonly IStore<Guid> store; |
|||
|
|||
public ClearSchemas(IStore<Guid> store) |
|||
{ |
|||
this.store = store; |
|||
} |
|||
|
|||
public Task UpdateAsync() |
|||
{ |
|||
return store.ClearSnapshotsAsync<Guid, SchemaState>(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue