From 64dfde187139c5e8430ca6ec3b89eb92ec42fb32 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Thu, 15 Aug 2024 21:35:41 +0200 Subject: [PATCH] Add a flag to enrich required fields. --- .../Sync/Contents/ContentsSynchronizer.cs | 9 ++++++++- cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) 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 c39988f4..ae428fdf 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 @@ -40,7 +40,14 @@ public async Task ExportAsync(ISyncService sync, SyncOptions options, ISession s var schemas = await session.Client.Schemas.GetSchemasAsync(); var schemaMap = schemas.Items.ToDictionary(x => x.Id, x => x.Name); - var context = QueryContext.Default.Unpublished().IgnoreFallback(); + var context = + QueryContext.Default + .Unpublished() + .WithHeaderHandler(request => + { + request.Headers.TryAddWithoutValidation("X-NoDefaults", "1"); + }) + .IgnoreFallback(); foreach (var schema in schemas.Items) { diff --git a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs index 571eaa3a..72a6c8c9 100644 --- a/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs +++ b/cli/Squidex.CLI/Squidex.CLI/Commands/App_Contents.cs @@ -87,7 +87,14 @@ async Task BulkUpdateAsync() var request = new BulkUpdate { - Jobs = idsRequest.Select(x => new BulkUpdateJob { Id = x, Type = BulkUpdateType.EnrichDefaults }).ToList() + Jobs = idsRequest + .Select(x => new BulkUpdateJob + { + Id = x, + Type = BulkUpdateType.EnrichDefaults + }) + .ToList(), + EnrichRequiredFields = arguments.RequiredFields, }; await session.Client.DynamicContents(arguments.Schema).BulkUpdateAsync(request); @@ -445,6 +452,9 @@ public sealed class EnrichDefaultsArguments : AppArguments [Option('u', "unpublished", Description = "Handle unpublished content.")] public bool Unpublished { get; set; } + [Option("required-fields", Description = "Also enrich required fields.")] + public bool RequiredFields { get; set; } + public sealed class Validator : AbstractValidator { }