Skip to content

Commit

Permalink
Fix compile errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Jun 21, 2021
1 parent 07eef9b commit 9926e21
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private static object CreateScalar(FieldPropertiesDto field)

private static JToken CreateValue(FieldPropertiesDto field)
{
var schema = new SchemaDetailsDto
var schema = new SchemaDto
{
Fields = new List<FieldDto>
{
Expand Down
6 changes: 3 additions & 3 deletions cli/Squidex.CLI/Squidex.CLI/Commands/App_Schemas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task Get(GetArguments arguments)
{
var allSchemas = await session.Schemas.GetSchemasAsync(session.App);

var result = new SchemaWithRefs<SchemaDetailsDto>(schema).EnrichSchemaNames(allSchemas.Items);
var result = new SchemaWithRefs<SchemaDto>(schema).EnrichSchemaNames(allSchemas.Items);

log.WriteLine(result.JsonPrettyString());
}
Expand Down Expand Up @@ -104,7 +104,7 @@ public async Task Sync(SyncArguments arguments)
{
try
{
var sourceSchema = SchemaWithRefs<SchemaDetailsDto>.Parse(schemaText);
var sourceSchema = SchemaWithRefs<SchemaDto>.Parse(schemaText);

schemaName = sourceSchema.Schema.Name;
}
Expand All @@ -119,7 +119,7 @@ public async Task Sync(SyncArguments arguments)
throw new CLIException("Schema name cannot be empty.");
}

SchemaDetailsDto targetSchema;
SchemaDto targetSchema;
try
{
targetSchema = await session.Schemas.GetSchemaAsync(session.App, schemaName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Task SaveAsync()
});
}

await client.GetAllAsync(50, async content =>
await client.GetAllAsync(async content =>
{
contents.Add(content.ToModel(schema.Name));

Expand All @@ -74,7 +74,7 @@ await client.GetAllAsync(50, async content =>
contents.Clear();
contentBatch++;
}
}, context);
}, context: context);

if (contents.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@

using Squidex.ClientLibrary.Management;

#pragma warning disable CS0618 // Type or member is obsolete

namespace Squidex.CLI.Commands.Implementation.Sync.Schemas
{
public static class Extensions
{
public static CreateSchemaDto ToRequest(this SchemaCreateModel model)
{
return new CreateSchemaDto { Name = model.Name, IsSingleton = model.IsSingleton };
var isSingleton = model.IsSingleton;

var type = model.Type;

if (model.IsSingleton && type == SchemaType.Default)
{
type = SchemaType.Singleton;
}

return new CreateSchemaDto { Name = model.Name, IsSingleton = isSingleton, Type = type };
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================

using Squidex.ClientLibrary.Management;

namespace Squidex.CLI.Commands.Implementation.Sync.Schemas
{
public sealed class SchemaCreateModel
{
public string Name { get; set; }

public bool IsSingleton { get; set; }

public SchemaType Type { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using System.Threading.Tasks;
using Squidex.ClientLibrary.Management;

#pragma warning disable CS0618 // Type or member is obsolete

namespace Squidex.CLI.Commands.Implementation.Sync.Schemas
{
public sealed class SchemasSynchronizer : ISynchronizer
Expand Down Expand Up @@ -55,7 +57,8 @@ await log.DoSafeAsync($"Exporting '{schema.Name}'", async () =>
Name = schema.Name,
IsSingleton = details.IsSingleton,
IsPublished = false,
Schema = jsonHelper.Convert<SynchronizeSchemaDto>(details)
Schema = jsonHelper.Convert<SynchronizeSchemaDto>(details),
Type = details.Type
};

MapReferences(model.Schema, schemaMap);
Expand Down Expand Up @@ -130,17 +133,10 @@ await log.DoSafeAsync($"Schema {model.Name} creating", async () =>
model.Schema.NoFieldRecreation = true;
}

var fieldRules = GetFieldRules(model);

await log.DoVersionedAsync($"Schema {model.Name} updating", version, async () =>
{
var result = await session.Schemas.PutSchemaSyncAsync(session.App, model.Name, model.Schema);

if (fieldRules?.FieldRules?.Count > 0)
{
await session.Schemas.PutRulesAsync(session.App, model.Name, fieldRules);
}

return result.Version;
});
}
Expand Down Expand Up @@ -233,23 +229,5 @@ private static void MapReferences(FieldPropertiesDto properties, Dictionary<stri
}
}
}

private static ConfigureFieldRulesDto GetFieldRules(SchemeModel model)
{
if (model.Schema.FieldRules == null)
{
return null;
}

var configureFieldRules = new ConfigureFieldRulesDto();
configureFieldRules.FieldRules = new List<FieldRuleDto>();

foreach (var item in model.Schema.FieldRules)
{
configureFieldRules.FieldRules.Add(item);
}

return configureFieldRules;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public sealed class SchemeModel

public bool IsPublished { get; set; }

public SchemaType Type { get; set; }

public SynchronizeSchemaDto Schema { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace Squidex.CLI.Commands.Implementation.TestData
public sealed class TestDataGenerator
{
private readonly SlugHelper slugify = new SlugHelper();
private readonly SchemaDetailsDto schema;
private readonly SchemaDto schema;
private readonly AppLanguagesDto languages;
private readonly Random random = new Random();

public TestDataGenerator(SchemaDetailsDto schema, AppLanguagesDto languages)
public TestDataGenerator(SchemaDto schema, AppLanguagesDto languages)
{
this.schema = schema;
this.languages = languages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Squidex.CLI.Commands.Models
{
public static class SchemaWithRefsExtensions
{
public static SchemaWithRefs<SchemaDetailsDto> EnrichSchemaNames(this SchemaWithRefs<SchemaDetailsDto> target, ICollection<SchemaDto> allSchemas)
public static SchemaWithRefs<SchemaDto> EnrichSchemaNames(this SchemaWithRefs<SchemaDto> target, ICollection<SchemaDto> allSchemas)
{
void Handle(ReferencesFieldPropertiesDto properties)
{
Expand Down

0 comments on commit 9926e21

Please sign in to comment.