Skip to content

Commit

Permalink
New Patch property.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Apr 25, 2022
1 parent d27b71c commit 485238a
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cli/Squidex.CLI/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Squidex/squidex/</PackageProjectUrl>
<PackageTags>Squidex HeadlessCMS</PackageTags>
<Version>8.9</Version>
<Version>8.10</Version>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public sealed class SyncOptions

public bool Recreate { get; set; }

public bool PatchContent { get; set; }

public bool UpdateCurrentClient { get; set; }
}
}
13 changes: 5 additions & 8 deletions cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; }

Expand All @@ -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<InArguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public class BulkUpdateJob
/// </summary>
public bool Permanent { get; set; }

/// <summary>
/// Makes the update as patch.
/// </summary>
public bool Patch { get; set; }

/// <summary>
/// The number of expected items. Set it to a higher number to update multiple items when a query is defined.
/// </summary>
Expand All @@ -62,4 +67,4 @@ public class BulkUpdateJob
/// </summary>
public long ExpectedVersion { get; set; } = -2;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,26 @@ public record struct ContentUpsertOptions
/// </summary>
public bool Publish { get; set; }

/// <summary>
/// Makes the update as patch.
/// </summary>
public bool Patch { get; set; }

/// <summary>
/// A option where <see cref="Publish"/> is true.
/// </summary>
public static readonly ContentUpsertOptions AsPublish = new ContentUpsertOptions
{
Publish = true
};

/// <summary>
/// A option where <see cref="Patch"/> is true.
/// </summary>
public static readonly ContentUpsertOptions AsPatch = new ContentUpsertOptions
{
Patch = true
};
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public Task<TEntity> UpsertAsync(string id, TData data, ContentUpsertOptions opt
Guard.NotNullOrEmpty(id, nameof(id));
Guard.NotNull(data, nameof(data));

return RequestJsonAsync<TEntity>(HttpMethod.Post, BuildSchemaUrl($"{id}?publish={options.Publish}", false), data.ToContent(), context, ct);
return RequestJsonAsync<TEntity>(HttpMethod.Post, BuildSchemaUrl($"{id}?publish={options.Publish}&patch={options.Patch}", false), data.ToContent(), context, ct);
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageProjectUrl>https://github.com/Squidex/squidex/</PackageProjectUrl>
<PackageTags>Squidex HeadlessCMS</PackageTags>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<Version>8.16.0</Version>
<Version>8.17.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 485238a

Please sign in to comment.