diff --git a/cli/Squidex.CLI/Directory.Build.props b/cli/Squidex.CLI/Directory.Build.props index 3db70a2b..f8347116 100644 --- a/cli/Squidex.CLI/Directory.Build.props +++ b/cli/Squidex.CLI/Directory.Build.props @@ -8,6 +8,6 @@ MIT https://github.com/Squidex/squidex/ Squidex HeadlessCMS - 8.9 + 8.10 diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/ContentsSynchronizer.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/ContentsSynchronizer.cs index 3d8799f5..7ba26b70 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/ContentsSynchronizer.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/ContentsSynchronizer.cs @@ -132,7 +132,7 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s DoNotScript = true, DoNotValidate = false, DoNotValidateWorkflow = true, - Jobs = model.Contents.Select(x => x.ToUpsert(schemas)).ToList() + Jobs = model.Contents.Select(x => x.ToUpsert(schemas, options.PatchContent)).ToList() }; var contentIdAssigned = false; diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/Extensions.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/Extensions.cs index 39c6562e..06e4345d 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/Extensions.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/Contents/Extensions.cs @@ -14,9 +14,9 @@ namespace Squidex.CLI.Commands.Implementation.Sync.Contents { public static class Extensions { - public static BulkUpdateJob ToUpsert(this ContentModel model, SchemasDto schemas) + public static BulkUpdateJob ToUpsert(this ContentModel model, SchemasDto schemas, bool patch) { - var result = SimpleMapper.Map(model, new BulkUpdateJob()); + var result = SimpleMapper.Map(model, new BulkUpdateJob { Patch = patch }); #pragma warning disable CS0618 // Type or member is obsolete var singleton = schemas.Items.Find(x => x.Name == model.Schema && (x.IsSingleton || x.Type == SchemaType.Singleton)); diff --git a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/SyncOptions.cs b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/SyncOptions.cs index 204d1ed3..36a74a85 100644 --- a/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/SyncOptions.cs +++ b/cli/Squidex.CLI/Squidex.CLI.Core/Commands/Implementation/Sync/SyncOptions.cs @@ -17,6 +17,8 @@ public sealed class SyncOptions public bool Recreate { get; set; } + public bool PatchContent { get; set; } + public bool UpdateCurrentClient { get; set; } } } diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs index 071b3b15..736d6208 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs @@ -9,6 +9,7 @@ using FluentValidation; using Squidex.CLI.Commands.Implementation; using Squidex.CLI.Commands.Implementation.Sync; +using Squidex.CLI.Commands.Implementation.Utils; using Squidex.CLI.Configuration; namespace Squidex.CLI.Commands @@ -113,6 +114,9 @@ public sealed class InArguments : AppArguments [Option("delete", Description = "Use this flag to also delete entities.")] public bool Delete { get; set; } + [Option("patch-content", Description = "Make content updates as patch.")] + public bool PatchContent { get; set; } + [Option("recreate", Description = "Use this flag to also recreate entities.")] public bool Recreate { get; set; } @@ -127,14 +131,7 @@ public sealed class InArguments : AppArguments public SyncOptions ToOptions() { - return new SyncOptions - { - Delete = Delete, - Recreate = Recreate, - Languages = Languages, - Targets = Targets, - UpdateCurrentClient = UpdateCurrentClient - }; + return SimpleMapper.Map(this, new SyncOptions()); } public sealed class Validator : AbstractValidator diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/BulkUpdateJob.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/BulkUpdateJob.cs index 4a8ce092..2b69f7b2 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/BulkUpdateJob.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/BulkUpdateJob.cs @@ -52,6 +52,11 @@ public class BulkUpdateJob /// public bool Permanent { get; set; } + /// + /// Makes the update as patch. + /// + public bool Patch { get; set; } + /// /// The number of expected items. Set it to a higher number to update multiple items when a query is defined. /// @@ -62,4 +67,4 @@ public class BulkUpdateJob /// public long ExpectedVersion { get; set; } = -2; } -} \ No newline at end of file +} diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentOptions.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentOptions.cs index bcb17729..cb845734 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentOptions.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentOptions.cs @@ -62,6 +62,11 @@ public record struct ContentUpsertOptions /// public bool Publish { get; set; } + /// + /// Makes the update as patch. + /// + public bool Patch { get; set; } + /// /// A option where is true. /// @@ -69,6 +74,14 @@ public record struct ContentUpsertOptions { Publish = true }; + + /// + /// A option where is true. + /// + public static readonly ContentUpsertOptions AsPatch = new ContentUpsertOptions + { + Patch = true + }; } /// diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs index d50f2119..429841e0 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs @@ -276,7 +276,7 @@ public Task UpsertAsync(string id, TData data, ContentUpsertOptions opt Guard.NotNullOrEmpty(id, nameof(id)); Guard.NotNull(data, nameof(data)); - return RequestJsonAsync(HttpMethod.Post, BuildSchemaUrl($"{id}?publish={options.Publish}", false), data.ToContent(), context, ct); + return RequestJsonAsync(HttpMethod.Post, BuildSchemaUrl($"{id}?publish={options.Publish}&patch={options.Patch}", false), data.ToContent(), context, ct); } /// diff --git a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Squidex.ClientLibrary.csproj b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Squidex.ClientLibrary.csproj index fbe5d5d1..4e4d1d9e 100644 --- a/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Squidex.ClientLibrary.csproj +++ b/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Squidex.ClientLibrary.csproj @@ -13,7 +13,7 @@ https://github.com/Squidex/squidex/ Squidex HeadlessCMS netstandard2.0;netcoreapp3.1;net5.0;net6.0 - 8.16.0 + 8.17.0