Browse Source

Many fixes.

pull/590/head
Sebastian 5 years ago
parent
commit
c32c1fb3c6
  1. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository.cs
  2. 4
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository.cs
  3. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryIdsAsync.cs
  4. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerGrain.cs
  5. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs
  6. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/IGraphModel.cs
  7. 109
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs
  8. 1
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs
  9. 62
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentActions.cs
  10. 1
      backend/src/Squidex/Areas/Api/Controllers/Apps/Models/PatternDto.cs
  11. 1
      backend/src/Squidex/Areas/Api/Controllers/Apps/Models/UpdatePatternDto.cs
  12. 1
      backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetFolderDto.cs
  13. 1
      backend/src/Squidex/Areas/Api/Controllers/Assets/Models/CreateAssetFolderDto.cs
  14. 1
      backend/src/Squidex/Areas/Api/Controllers/Assets/Models/RenameAssetFolderDto.cs
  15. 1
      backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ChangeStatusDto.cs
  16. 1
      backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs
  17. 1
      backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ScheduleJobDto.cs
  18. 1
      backend/src/Squidex/Areas/Api/Controllers/History/Models/HistoryEventDto.cs
  19. 1
      backend/src/Squidex/Areas/Api/Controllers/Rules/Models/RuleDto.cs
  20. 1
      backend/src/Squidex/Areas/Api/Controllers/Rules/Models/RuleEventDto.cs
  21. 1
      backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs
  22. 1
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/TestAsset.cs
  23. 1
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/TestContent.cs

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetFolderRepository.cs

@ -87,7 +87,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
private static string GetIdField()
{
return BsonClassMap.LookupClassMap(typeof(MongoAssetFolderEntity)).GetMemberMap(nameof(MongoAssetFolderEntity.Id)).ElementName;
return BsonClassMap.LookupClassMap(typeof(MongoAssetFolderEntity)).GetMemberMap(nameof(MongoAssetFolderEntity.DocumentId)).ElementName;
}
}
}

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

@ -102,7 +102,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
using (Profiler.TraceMethod<MongoAssetRepository>("QueryAsyncByIds"))
{
var assetEntities =
await Collection.Find(BuildFilter(appId, ids)).Only(x => x.DocumentId)
await Collection.Find(BuildFilter(appId, ids)).Only(x => x.Id)
.ToListAsync();
return assetEntities.Select(x => DomainId.Create(x[IdField.Value].AsString)).ToList();
@ -188,7 +188,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
var documentIds = ids.Select(x => DomainId.Combine(appId, x));
return Filter.And(
Filter.In(x => x.Id, documentIds),
Filter.In(x => x.DocumentId, documentIds),
Filter.Ne(x => x.IsDeleted, true));
}

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryIdsAsync.cs

@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations
var filter = BuildFilter(filterNode.AdjustToModel(schema.SchemaDef), appId, schemaId);
var contentEntities =
await Collection.Find(filter).Only(x => x.DocumentId, x => x.IndexedSchemaId)
await Collection.Find(filter).Only(x => x.Id, x => x.IndexedSchemaId)
.ToListAsync();
return contentEntities.Select(x => (DomainId.Create(x[SchemaIdField.Value].AsString), DomainId.Create(x[IdField.Value].AsString))).ToList();

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

@ -82,7 +82,9 @@ namespace Squidex.Domain.Apps.Entities.Contents
var command = new ChangeContentStatus
{
Actor = job.ScheduledBy,
AppId = content.AppId,
ContentId = id,
SchemaId = content.SchemaId,
Status = job.Status,
StatusJobId = job.Id
};

1
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLModel.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GraphQL;
using GraphQL.Resolvers;
using GraphQL.Types;
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Schemas;

1
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/IGraphModel.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using GraphQL.Types;
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Schemas;

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

@ -5,11 +5,9 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Collections.Generic;
using GraphQL.Types;
using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
{
@ -19,6 +17,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
{
foreach (var schema in schemas)
{
var appId = schema.AppId;
var schemaId = schema.NamedId();
var schemaType = schema.TypeName();
var schemaName = schema.DisplayName();
@ -27,74 +27,53 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
var inputType = new ContentDataInputGraphType(schema, schemaName, schemaType, model);
AddContentCreate(schemaId, schemaType, schemaName, inputType, contentType);
AddContentUpdate(schemaType, schemaName, inputType, contentType);
AddContentPatch(schemaType, schemaName, inputType, contentType);
AddContentChangeStatus(schemaType, schemaName, contentType);
AddContentDelete(schemaType, schemaName);
}
AddField(new FieldType
{
Name = $"create{schemaType}Content",
Arguments = ContentActions.Create.Arguments(inputType),
ResolvedType = contentType,
Resolver = ContentActions.Create.Resolver(appId, schemaId),
Description = $"Creates an {schemaName} content."
});
Description = "The app mutations.";
}
AddField(new FieldType
{
Name = $"update{schemaType}Content",
Arguments = ContentActions.UpdateOrPatch.Arguments(inputType),
ResolvedType = contentType,
Resolver = ContentActions.UpdateOrPatch.Update(appId, schemaId),
Description = $"Update an {schemaName} content by id."
});
private void AddContentCreate(NamedId<DomainId> schemaId, string schemaType, string schemaName, ContentDataInputGraphType inputType, IGraphType contentType)
{
AddField(new FieldType
{
Name = $"create{schemaType}Content",
Arguments = ContentActions.Create.Arguments(inputType),
ResolvedType = contentType,
Resolver = ContentActions.Create.Resolver(schemaId),
Description = $"Creates an {schemaName} content."
});
}
AddField(new FieldType
{
Name = $"patch{schemaType}Content",
Arguments = ContentActions.UpdateOrPatch.Arguments(inputType),
ResolvedType = contentType,
Resolver = ContentActions.UpdateOrPatch.Patch(appId, schemaId),
Description = $"Patch an {schemaName} content by id."
});
private void AddContentUpdate(string schemaType, string schemaName, ContentDataInputGraphType inputType, IGraphType contentType)
{
AddField(new FieldType
{
Name = $"update{schemaType}Content",
Arguments = ContentActions.UpdateOrPatch.Arguments(inputType),
ResolvedType = contentType,
Resolver = ContentActions.UpdateOrPatch.Update,
Description = $"Update an {schemaName} content by id."
});
}
AddField(new FieldType
{
Name = $"publish{schemaType}Content",
Arguments = ContentActions.ChangeStatus.Arguments,
ResolvedType = contentType,
Resolver = ContentActions.ChangeStatus.Resolver(appId, schemaId),
Description = $"Publish a {schemaName} content."
});
private void AddContentPatch(string schemaType, string schemaName, ContentDataInputGraphType inputType, IGraphType contentType)
{
AddField(new FieldType
{
Name = $"patch{schemaType}Content",
Arguments = ContentActions.UpdateOrPatch.Arguments(inputType),
ResolvedType = contentType,
Resolver = ContentActions.UpdateOrPatch.Patch,
Description = $"Patch an {schemaName} content by id."
});
}
private void AddContentChangeStatus(string schemaType, string schemaName, IGraphType contentType)
{
AddField(new FieldType
{
Name = $"publish{schemaType}Content",
Arguments = ContentActions.ChangeStatus.Arguments,
ResolvedType = contentType,
Resolver = ContentActions.ChangeStatus.Resolver,
Description = $"Publish a {schemaName} content."
});
}
AddField(new FieldType
{
Name = $"delete{schemaType}Content",
Arguments = ContentActions.Delete.Arguments,
ResolvedType = EntitySavedGraphType.NonNull,
Resolver = ContentActions.Delete.Resolver(appId, schemaId),
Description = $"Delete an {schemaName} content."
});
}
private void AddContentDelete(string schemaType, string schemaName)
{
AddField(new FieldType
{
Name = $"delete{schemaType}Content",
Arguments = ContentActions.Delete.Arguments,
ResolvedType = EntitySavedGraphType.NonNull,
Resolver = ContentActions.Delete.Resolver,
Description = $"Delete an {schemaName} content."
});
Description = "The app mutations.";
}
}
}

1
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppQueriesGraphType.cs

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

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

@ -164,14 +164,14 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
};
}
public static IFieldResolver Resolver(NamedId<DomainId> schemaId)
public static IFieldResolver Resolver(NamedId<DomainId> appId, NamedId<DomainId> schemaId)
{
return ResolveAsync<IEnrichedContentEntity>(c =>
return ResolveAsync<IEnrichedContentEntity>(appId, schemaId, c =>
{
var contentPublish = c.GetArgument<bool>("publish");
var contentData = GetContentData(c);
return new CreateContent { SchemaId = schemaId, Data = contentData, Publish = contentPublish };
return new CreateContent { Data = contentData, Publish = contentPublish };
});
}
}
@ -206,21 +206,27 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
};
}
public static readonly IFieldResolver Update = ResolveAsync<IEnrichedContentEntity>(c =>
public static IFieldResolver Update(NamedId<DomainId> appId, NamedId<DomainId> schemaId)
{
var contentId = c.GetArgument<Guid>("id");
var contentData = GetContentData(c);
return ResolveAsync<IEnrichedContentEntity>(appId, schemaId, c =>
{
var contentId = c.GetArgument<Guid>("id");
var contentData = GetContentData(c);
return new UpdateContent { ContentId = contentId, Data = contentData };
});
return new UpdateContent { ContentId = contentId, Data = contentData };
});
}
public static readonly IFieldResolver Patch = ResolveAsync<IEnrichedContentEntity>(c =>
public static IFieldResolver Patch(NamedId<DomainId> appId, NamedId<DomainId> schemaId)
{
var contentId = c.GetArgument<Guid>("id");
var contentData = GetContentData(c);
return ResolveAsync<IEnrichedContentEntity>(appId, schemaId, c =>
{
var contentId = c.GetArgument<Guid>("id");
var contentData = GetContentData(c);
return new PatchContent { ContentId = contentId, Data = contentData };
});
return new PatchContent { ContentId = contentId, Data = contentData };
});
}
}
public static class ChangeStatus
@ -257,14 +263,17 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
}
};
public static readonly IFieldResolver Resolver = ResolveAsync<IEnrichedContentEntity>(c =>
public static IFieldResolver Resolver(NamedId<DomainId> appId, NamedId<DomainId> schemaId)
{
var contentId = c.GetArgument<Guid>("id");
var contentStatus = new Status(c.GetArgument<string>("status"));
var contentDueTime = c.GetArgument<Instant?>("dueTime");
return ResolveAsync<IEnrichedContentEntity>(appId, schemaId, c =>
{
var contentId = c.GetArgument<Guid>("id");
var contentStatus = new Status(c.GetArgument<string>("status"));
var contentDueTime = c.GetArgument<Instant?>("dueTime");
return new ChangeContentStatus { ContentId = contentId, Status = contentStatus, DueTime = contentDueTime };
});
return new ChangeContentStatus { ContentId = contentId, Status = contentStatus, DueTime = contentDueTime };
});
}
}
public static class Delete
@ -287,12 +296,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
}
};
public static readonly IFieldResolver Resolver = ResolveAsync<EntitySavedResult>(c =>
public static IFieldResolver Resolver(NamedId<DomainId> appId, NamedId<DomainId> schemaId)
{
var contentId = c.GetArgument<Guid>("id");
return ResolveAsync<EntitySavedResult>(appId, schemaId, c =>
{
var contentId = c.GetArgument<Guid>("id");
return new DeleteContent { ContentId = contentId };
});
return new DeleteContent { ContentId = contentId };
});
}
}
private static NamedContentData GetContentData(IResolveFieldContext c)
@ -302,7 +314,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
return source.ToNamedContentData((IComplexGraphType)c.FieldDefinition.Arguments.Find("data").Flatten());
}
private static IFieldResolver ResolveAsync<T>(Func<IResolveFieldContext, SquidexCommand> action)
private static IFieldResolver ResolveAsync<T>(NamedId<DomainId> appId, NamedId<DomainId> schemaId, Func<IResolveFieldContext, ContentCommand> action)
{
return new FuncFieldResolver<Task<T>>(async c =>
{
@ -312,6 +324,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
{
var command = action(c);
command.AppId = appId;
command.SchemaId = schemaId;
command.ExpectedVersion = c.GetArgument("expectedVersion", EtagVersion.Any);
var commandContext = await e.CommandBus.PublishAsync(command);

1
backend/src/Squidex/Areas/Api/Controllers/Apps/Models/PatternDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Domain.Apps.Core.Apps;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Reflection;

1
backend/src/Squidex/Areas/Api/Controllers/Apps/Models/UpdatePatternDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Domain.Apps.Entities.Apps.Commands;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.Validation;

1
backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetFolderDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Reflection;

1
backend/src/Squidex/Areas/Api/Controllers/Assets/Models/CreateAssetFolderDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Reflection;

1
backend/src/Squidex/Areas/Api/Controllers/Assets/Models/RenameAssetFolderDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.Validation;

1
backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ChangeStatusDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using NodaTime;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities.Contents.Commands;

1
backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Linq;
using NodaTime;
using Squidex.Areas.Api.Controllers.Schemas.Models;

1
backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ScheduleJobDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using NodaTime;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Infrastructure;

1
backend/src/Squidex/Areas/Api/Controllers/History/Models/HistoryEventDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using NodaTime;
using Squidex.Domain.Apps.Entities.History;
using Squidex.Infrastructure;

1
backend/src/Squidex/Areas/Api/Controllers/Rules/Models/RuleDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Newtonsoft.Json;
using NodaTime;
using Squidex.Areas.Api.Controllers.Rules.Models.Converters;

1
backend/src/Squidex/Areas/Api/Controllers/Rules/Models/RuleEventDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using NodaTime;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Domain.Apps.Entities.Rules;

1
backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using NodaTime;
using Squidex.Areas.Api.Controllers.Contents;
using Squidex.Domain.Apps.Entities.Schemas;

1
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/TestAsset.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Linq;
using NodaTime;
using Squidex.Domain.Apps.Core.Assets;

1
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/TestContent.cs

@ -5,7 +5,6 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Collections.Generic;
using NodaTime;
using Squidex.Domain.Apps.Core.Contents;

Loading…
Cancel
Save