diff --git a/frontend/src/app/framework/angular/pipes/markdown.pipe.ts b/frontend/src/app/framework/angular/pipes/markdown.pipe.ts
index 4ba1428560..cedb9ed2ce 100644
--- a/frontend/src/app/framework/angular/pipes/markdown.pipe.ts
+++ b/frontend/src/app/framework/angular/pipes/markdown.pipe.ts
@@ -14,8 +14,8 @@ import { renderMarkdown } from '@app/framework/internal';
standalone: true,
})
export class MarkdownPipe implements PipeTransform {
- public transform(text: string | undefined | null): string {
- return renderMarkdown(text, false);
+ public transform(text: string | undefined | null, trusted = false): string {
+ return renderMarkdown(text, false, trusted);
}
}
@@ -25,7 +25,7 @@ export class MarkdownPipe implements PipeTransform {
standalone: true,
})
export class MarkdownInlinePipe implements PipeTransform {
- public transform(text: string | undefined | null): string {
- return renderMarkdown(text, true);
+ public transform(text: string | undefined | null, trusted = false): string {
+ return renderMarkdown(text, true, trusted);
}
}
\ No newline at end of file
diff --git a/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs b/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
index 5c84831156..46afeaa4a2 100644
--- a/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
+++ b/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs
@@ -790,4 +790,66 @@ await Parallel.ForEachAsync(Enumerable.Range(0, 20), async (i, ct) =>
Assert.Equal(2, content.Data.Number);
}
+
+ [Theory]
+ [InlineData(ContentStrategies.EnrichDefaults.Normal)]
+ [InlineData(ContentStrategies.EnrichDefaults.Update)]
+ [InlineData(ContentStrategies.EnrichDefaults.UpdateBulk)]
+ [InlineData(ContentStrategies.EnrichDefaults.Upsert)]
+ [InlineData(ContentStrategies.EnrichDefaults.UpsertBulk)]
+ [InlineData(ContentStrategies.EnrichDefaults.Bulk)]
+ [InlineData(ContentStrategies.EnrichDefaults.BulkWithSchema)]
+ [InlineData(ContentStrategies.EnrichDefaults.BulkShared)]
+ public async Task Should_enrich_defaults(ContentStrategies.EnrichDefaults strategy)
+ {
+ var schemaName = $"schema-{Guid.NewGuid()}";
+
+ // STEP 0: Create initial schema.
+ var schemaRequest = new CreateSchemaDto
+ {
+ Name = schemaName,
+ Fields =
+ [
+ new UpsertSchemaFieldDto
+ {
+ Name = TestEntityData.NumberField,
+ Properties = new NumberFieldPropertiesDto()
+ },
+ ],
+ IsPublished = true
+ };
+
+ await _.Client.Schemas.PostSchemaAsync(schemaRequest);
+
+ var contents = _.Client.DynamicContents(schemaName);
+
+
+ // STEP 1: Create a new item.
+ var content_0 = await contents.CreateAsync(new DynamicData(), ContentCreateOptions.AsPublish);
+
+ Assert.Null(content_0.Data.GetValueOrDefault(TestEntityData.StringField));
+
+
+ // STEP 2: Add required field.
+ var fieldRequest = new AddFieldDto
+ {
+ Name = TestEntityData.StringField,
+ Properties = new StringFieldPropertiesDto
+ {
+ DefaultValue = "Hello Squidex"
+ }
+ };
+
+ await _.Client.Schemas.PostFieldAsync(schemaName, fieldRequest);
+
+
+ // STEP 3: Create required field.
+ await _.Client.EnrichDefaultsAsync(content_0, content_0.Data, strategy);
+
+
+ // STEP 4: Get content.
+ var content_1 = await contents.GetAsync(content_0.Id);
+
+ Assert.Equal("Hello Squidex", content_1.Data[TestEntityData.StringField]!["iv"]!.ToString());
+ }
}
diff --git a/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj b/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj
index 4e5a48a983..7e0bb06209 100644
--- a/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj
+++ b/tools/TestSuite/TestSuite.ApiTests/TestSuite.ApiTests.csproj
@@ -7,22 +7,22 @@
enable
-
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj b/tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj
index 446d8d7a36..c86e2bbc51 100644
--- a/tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj
+++ b/tools/TestSuite/TestSuite.LoadTests/TestSuite.LoadTests.csproj
@@ -7,14 +7,14 @@
enable
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/tools/TestSuite/TestSuite.Shared/ContentStrategies.cs b/tools/TestSuite/TestSuite.Shared/ContentStrategies.cs
index 4253c09fbc..6b3a2503e5 100644
--- a/tools/TestSuite/TestSuite.Shared/ContentStrategies.cs
+++ b/tools/TestSuite/TestSuite.Shared/ContentStrategies.cs
@@ -88,29 +88,29 @@ IContentsClient GetClient()
return GetClient().UpdateAsync(content.Id, data);
case Update.Upsert:
return GetClient().UpsertAsync(content.Id, data);
- case Update.UpsertBulk:
+ case Update.Bulk:
return GetClient().BulkUpdateAsync(new BulkUpdate
{
Jobs =
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Update,
Id = content.Id,
- Data = data,
- Type = BulkUpdateType.Upsert
+ Data = data
},
]
});
- case Update.Bulk:
+ case Update.UpsertBulk:
return GetClient().BulkUpdateAsync(new BulkUpdate
{
Jobs =
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Upsert,
Id = content.Id,
- Data = data,
- Type = BulkUpdateType.Update,
+ Data = data
},
]
});
@@ -121,23 +121,23 @@ IContentsClient GetClient()
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Update,
Id = content.Id,
Data = data,
- Type = BulkUpdateType.Update,
Schema = content.SchemaName
},
]
});
case Update.BulkShared:
- return client.SharedContents().BulkUpdateAsync(new BulkUpdate
+ return GetSharedClient(client).BulkUpdateAsync(new BulkUpdate
{
Jobs =
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Update,
Id = content.Id,
Data = data,
- Type = BulkUpdateType.Update,
Schema = content.SchemaName
},
]
@@ -151,10 +151,10 @@ public enum Patch
{
Normal,
Upsert,
+ UpsertBulk,
Bulk,
BulkWithSchema,
- BulkShared,
- UpsertBulk
+ BulkShared
}
public static Task PatchAsync(this ISquidexClient client, ContentBase content, object data, Patch strategy)
@@ -177,9 +177,10 @@ IContentsClient GetClient()
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Upsert,
Id = content.Id,
Data = data,
- Patch = true,
+ Patch = true
},
]
});
@@ -190,9 +191,9 @@ IContentsClient GetClient()
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Patch,
Id = content.Id,
Data = data,
- Type = BulkUpdateType.Patch
},
]
});
@@ -203,23 +204,23 @@ IContentsClient GetClient()
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Patch,
Id = content.Id,
Data = data,
- Type = BulkUpdateType.Patch,
Schema = content.SchemaName
},
]
});
case Patch.BulkShared:
- return client.SharedContents().BulkUpdateAsync(new BulkUpdate
+ return GetSharedClient(client).BulkUpdateAsync(new BulkUpdate
{
Jobs =
[
new BulkUpdateJob
{
+ Type = BulkUpdateType.Patch,
Id = content.Id,
Data = data,
- Type = BulkUpdateType.Patch,
Schema = content.SchemaName
},
]
@@ -229,6 +230,109 @@ IContentsClient GetClient()
}
}
+ public enum EnrichDefaults
+ {
+ Normal,
+ Upsert,
+ Update,
+ Bulk,
+ BulkWithSchema,
+ BulkShared,
+ UpsertBulk,
+ UpdateBulk
+ }
+
+ public static Task EnrichDefaultsAsync(this ISquidexClient client, ContentBase content, object data, EnrichDefaults strategy)
+ {
+ IContentsClient GetClient()
+ {
+ return client.Contents(content.SchemaName);
+ }
+
+ switch (strategy)
+ {
+ case EnrichDefaults.Normal:
+ return GetClient().EnrichDefaultsAsync(content.Id);
+ case EnrichDefaults.Update:
+ return GetClient().UpdateAsync(content.Id, data, ContentUpdateOptions.AsEnrichDefaults);
+ case EnrichDefaults.Upsert:
+ return GetClient().UpsertAsync(content.Id, data, ContentUpsertOptions.AsEnrichDefaults);
+ case EnrichDefaults.Bulk:
+ return GetClient().BulkUpdateAsync(new BulkUpdate
+ {
+ Jobs =
+ [
+ new BulkUpdateJob
+ {
+ Type = BulkUpdateType.EnrichDefaults,
+ Id = content.Id
+ },
+ ]
+ });
+ case EnrichDefaults.UpdateBulk:
+ return GetClient().BulkUpdateAsync(new BulkUpdate
+ {
+ Jobs =
+ [
+ new BulkUpdateJob
+ {
+ Type = BulkUpdateType.Update,
+ Id = content.Id,
+ Data = data,
+ EnrichDefaults = true,
+ },
+ ]
+ });
+ case EnrichDefaults.UpsertBulk:
+ return GetClient().BulkUpdateAsync(new BulkUpdate
+ {
+ Jobs =
+ [
+ new BulkUpdateJob
+ {
+ Type = BulkUpdateType.Upsert,
+ Id = content.Id,
+ Data = data,
+ EnrichDefaults = true,
+ },
+ ]
+ });
+ case EnrichDefaults.BulkWithSchema:
+ return GetClient().BulkUpdateAsync(new BulkUpdate
+ {
+ Jobs =
+ [
+ new BulkUpdateJob
+ {
+ Type = BulkUpdateType.EnrichDefaults,
+ Id = content.Id,
+ Schema = content.SchemaName
+ },
+ ]
+ });
+ case EnrichDefaults.BulkShared:
+ return GetSharedClient(client).BulkUpdateAsync(new BulkUpdate
+ {
+ Jobs =
+ [
+ new BulkUpdateJob
+ {
+ Type = BulkUpdateType.EnrichDefaults,
+ Id = content.Id,
+ Schema = content.SchemaName
+ },
+ ]
+ });
+ default:
+ return Task.CompletedTask;
+ }
+ }
+
+ private static IContentsSharedClient GetSharedClient(ISquidexClient client)
+ {
+ return client.SharedContents();
+ }
+
private sealed class MyContent : Content