Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update dependencies. * Use new cache settings. * Fix tests. * Fix domain object cache.- * Test subscriptions again. * Disable messaging cache. * Use random name for cluster instances. * Bind settings properly. * Update operation.
- Loading branch information
1 parent
bab6d23
commit 43b895b
Showing
16 changed files
with
662 additions
and
231 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/UpdateValues.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// ========================================================================== | ||
// Squidex Headless CMS | ||
// ========================================================================== | ||
// Copyright (c) Squidex UG (haftungsbeschraenkt) | ||
// All rights reserved. Licensed under the MIT license. | ||
// ========================================================================== | ||
|
||
using Squidex.Domain.Apps.Core.Contents; | ||
using Squidex.Domain.Apps.Core.Schemas; | ||
using Squidex.Domain.Apps.Core.Scripting; | ||
using Squidex.Infrastructure.Json.Objects; | ||
|
||
namespace Squidex.Domain.Apps.Core.ConvertContent; | ||
|
||
public sealed class UpdateValues : IContentValueConverter | ||
{ | ||
private readonly ContentData existingData; | ||
private readonly IScriptEngine scriptEngine; | ||
private ScriptVars? vars; | ||
|
||
public UpdateValues(ContentData existingData, IScriptEngine scriptEngine) | ||
{ | ||
this.existingData = existingData; | ||
this.scriptEngine = scriptEngine; | ||
} | ||
|
||
public (bool Remove, JsonValue) ConvertValue(IField field, JsonValue source, IField? parent) | ||
{ | ||
if (source.Value is not JsonObject jsonObject) | ||
{ | ||
return (false, source); | ||
} | ||
|
||
if (jsonObject.TryGetValue("$unset", out var value1) && !Equals(value1.Value, false)) | ||
{ | ||
return (true, source); | ||
} | ||
|
||
if (!jsonObject.TryGetValue("$update", out var value2) || value2.Value is not string update) | ||
{ | ||
return (false, source); | ||
} | ||
|
||
var options = new ScriptOptions { Readonly = true }; | ||
|
||
vars ??= new ScriptVars | ||
{ | ||
["$data"] = existingData, | ||
["$self"] = jsonObject | ||
}; | ||
|
||
var result = scriptEngine.Execute(vars, update, options); | ||
|
||
return (false, result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.