Browse Source

Improved mongo config. (#1272)

* Improved mongo config.

* Update dependencies.

* Disable test in CI for now.
master
Sebastian Stehle 1 week ago
committed by GitHub
parent
commit
0a22ecffbd
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 14
      backend/src/Squidex.Data.EntityFramework/Squidex.Data.EntityFramework.csproj
  2. 5
      backend/src/Squidex.Data.MongoDb/ServiceExtensions.cs
  3. 12
      backend/src/Squidex.Data.MongoDb/Squidex.Data.MongoDb.csproj
  4. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj
  5. 1
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/AssetScriptVars.cs
  6. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintObjectConverter.cs
  7. 50
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptVars.cs
  8. 6
      backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj
  9. 14
      backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
  10. 4
      backend/src/Squidex.Infrastructure/States/Persistence.cs
  11. 24
      backend/src/Squidex/Squidex.csproj
  12. 13
      backend/src/Squidex/appsettings.json
  13. 1
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs
  14. 8
      frontend/package-lock.json
  15. 2
      frontend/package.json
  16. 4
      frontend/src/app/features/content/pages/contents/contents-page.component.html
  17. 4
      frontend/src/app/framework/angular/layout.component.html
  18. 2
      frontend/src/app/shared/components/search/search-form.component.ts
  19. 4
      frontend/src/app/theme/_common.scss
  20. 2
      tools/TestSuite/docker-compose-ferretdb.yml

14
backend/src/Squidex.Data.EntityFramework/Squidex.Data.EntityFramework.csproj

@ -40,13 +40,13 @@
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Json.Microsoft" Version="8.0.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.NetTopologySuite" Version="8.0.3" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.AI.EntityFramework" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.EntityFramework" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="7.34.0" />
<PackageReference Include="Squidex.Events.EntityFramework" Version="7.34.0" />
<PackageReference Include="Squidex.Flows.EntityFramework" Version="7.34.0" />
<PackageReference Include="Squidex.Hosting" Version="7.34.0" />
<PackageReference Include="Squidex.Messaging.EntityFramework" Version="7.34.0" />
<PackageReference Include="Squidex.AI.EntityFramework" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.EntityFramework" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="7.37.0" />
<PackageReference Include="Squidex.Events.EntityFramework" Version="7.37.0" />
<PackageReference Include="Squidex.Flows.EntityFramework" Version="7.37.0" />
<PackageReference Include="Squidex.Hosting" Version="7.37.0" />
<PackageReference Include="Squidex.Messaging.EntityFramework" Version="7.37.0" />
<PackageReference Include="Squidex.OpenIdDict.EntityFramework" Version="5.8.4" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />

5
backend/src/Squidex.Data.MongoDb/ServiceExtensions.cs

@ -202,8 +202,9 @@ public static class ServiceExtensions
shardKey => ActivatorUtilities.CreateInstance<MongoContentRepository>(c, shardKey, contentDatabase));
}).As<IContentRepository>().As<ISnapshotStore<WriteContent>>().As<IDeleter>();
var atlasOptions = config.GetSection("store:mongoDb:atlas").Get<AtlasOptions>() ?? new ();
var derivate = config.GetValue<MongoDerivate>("store:mongoDb:derivate");
var atlasOptions = config.GetSection("store:mongoDb:atlas").Get<AtlasOptions>() ?? new ();
if (atlasOptions.IsConfigured() && atlasOptions.FullTextEnabled)
{
services.Configure<AtlasOptions>(config.GetSection("store:mongoDb:atlas"));
@ -226,7 +227,7 @@ public static class ServiceExtensions
shardKey => ActivatorUtilities.CreateInstance<AtlasTextIndex>(c, shardKey));
}).AsOptional<ITextIndex>().As<IDeleter>();
}
else if (config.GetValue<bool>("store:mongoDb:documentDb"))
else if (config.GetValue<MongoDerivate>("store:mongoDb:derivate") == MongoDerivate.DocumentDB)
{
services.AddSingletonAs(c =>
{

12
backend/src/Squidex.Data.MongoDb/Squidex.Data.MongoDb.csproj

@ -25,12 +25,12 @@
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.30.0" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.3.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.AI.Mongo" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="7.34.0" />
<PackageReference Include="Squidex.Events.Mongo" Version="7.34.0" />
<PackageReference Include="Squidex.Flows.Mongo" Version="7.34.0" />
<PackageReference Include="Squidex.Hosting" Version="7.34.0" />
<PackageReference Include="Squidex.Messaging.Mongo" Version="7.34.0" />
<PackageReference Include="Squidex.AI.Mongo" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="7.37.0" />
<PackageReference Include="Squidex.Events.Mongo" Version="7.37.0" />
<PackageReference Include="Squidex.Flows.Mongo" Version="7.37.0" />
<PackageReference Include="Squidex.Hosting" Version="7.37.0" />
<PackageReference Include="Squidex.Messaging.Mongo" Version="7.37.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="5.8.5" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />

2
backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj

@ -20,7 +20,7 @@
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.3.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Flows" Version="7.34.0" />
<PackageReference Include="Squidex.Flows" Version="7.37.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />

1
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/AssetScriptVars.cs

@ -6,7 +6,6 @@
// ==========================================================================
using System.Security.Claims;
using NodaTime;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.Scripting;

3
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintObjectConverter.cs

@ -45,6 +45,9 @@ public sealed class JintObjectConverter : IObjectConverter
case ClaimsPrincipal principal:
result = JintUser.Create(engine, principal);
return true;
case ScriptVars vars:
result = ObjectWrapper.Create(engine, vars);
return true;
case JsonValue jsonValue:
result = JsonMapper.Map(jsonValue, engine);
return true;

50
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptVars.cs

@ -13,7 +13,7 @@ using Squidex.Text;
namespace Squidex.Domain.Apps.Core.Scripting;
public class ScriptVars : IReadOnlyDictionary<string, object?>
public class ScriptVars : IDictionary<string, object?>
{
private readonly Dictionary<string, object?> values = new Dictionary<string, object?>(StringComparer.OrdinalIgnoreCase);
private readonly HashSet<string> lockedKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
@ -33,6 +33,18 @@ public class ScriptVars : IReadOnlyDictionary<string, object?>
get => values.Count;
}
ICollection<string> IDictionary<string, object?>.Keys
{
get => values.Keys;
}
ICollection<object?> IDictionary<string, object?>.Values
{
get => values.Values;
}
public bool IsReadOnly => throw new NotImplementedException();
public object? this[string key]
{
get
@ -46,6 +58,12 @@ public class ScriptVars : IReadOnlyDictionary<string, object?>
}
}
public void CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex)
{
Guard.NotNull(array);
((IDictionary)values).CopyTo(array, arrayIndex);
}
public void CopyFrom(ScriptVars vars)
{
Guard.NotNull(vars);
@ -129,6 +147,11 @@ public class ScriptVars : IReadOnlyDictionary<string, object?>
return values.ContainsKey(key);
}
public bool Contains(KeyValuePair<string, object?> item)
{
return values.Contains(item);
}
IEnumerator<KeyValuePair<string, object?>> IEnumerable<KeyValuePair<string, object?>>.GetEnumerator()
{
return values.GetEnumerator();
@ -138,4 +161,29 @@ public class ScriptVars : IReadOnlyDictionary<string, object?>
{
return values.GetEnumerator();
}
public void Add(string key, object? value)
{
throw new NotSupportedException();
}
public void Add(KeyValuePair<string, object?> item)
{
throw new NotSupportedException();
}
public bool Remove(string key)
{
throw new NotSupportedException();
}
public bool Remove(KeyValuePair<string, object?> item)
{
throw new NotSupportedException();
}
public void Clear()
{
throw new NotSupportedException();
}
}

6
backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj

@ -20,7 +20,7 @@
<ItemGroup>
<PackageReference Include="Fluid.Core" Version="2.12.0" />
<PackageReference Include="GeoJSON.Net" Version="1.4.1" />
<PackageReference Include="Jint" Version="4.4.1" />
<PackageReference Include="Jint" Version="4.4.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.179">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -29,8 +29,8 @@
<PackageReference Include="NJsonSchema" Version="11.0.2" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.3.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.AI" Version="7.34.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="7.34.0" />
<PackageReference Include="Squidex.AI" Version="7.37.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="7.37.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />

14
backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj

@ -24,13 +24,13 @@
<PackageReference Include="NodaTime" Version="3.2.0" />
<PackageReference Include="OpenTelemetry.Api" Version="1.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="7.34.0" />
<PackageReference Include="Squidex.Caching" Version="7.34.0" />
<PackageReference Include="Squidex.Events" Version="7.34.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="7.34.0" />
<PackageReference Include="Squidex.Log" Version="7.34.0" />
<PackageReference Include="Squidex.Messaging" Version="7.34.0" />
<PackageReference Include="Squidex.Text" Version="7.34.0" />
<PackageReference Include="Squidex.Assets" Version="7.37.0" />
<PackageReference Include="Squidex.Caching" Version="7.37.0" />
<PackageReference Include="Squidex.Events" Version="7.37.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="7.37.0" />
<PackageReference Include="Squidex.Log" Version="7.37.0" />
<PackageReference Include="Squidex.Messaging" Version="7.37.0" />
<PackageReference Include="Squidex.Text" Version="7.37.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />

4
backend/src/Squidex.Infrastructure/States/Persistence.cs

@ -137,7 +137,6 @@ internal sealed class Persistence<T>(
foreach (var @event in events)
{
var newVersion = versionEvents + 1;
if (@event.EventStreamNumber != newVersion)
{
ThrowHelper.InvalidOperationException("Events must follow the snapshot version in consecutive order with no gaps.");
@ -146,7 +145,6 @@ internal sealed class Persistence<T>(
if (!isStopped)
{
var parsedEvent = eventFormatter.ParseIfKnown(@event);
if (applyEvent != null && parsedEvent != null)
{
isStopped = !applyEvent(parsedEvent);
@ -161,14 +159,12 @@ internal sealed class Persistence<T>(
CancellationToken ct = default)
{
var oldVersion = versionSnapshot;
if (oldVersion == EtagVersion.Empty && UseEventSourcing)
{
oldVersion = versionEvents - 1;
}
var newVersion = UseEventSourcing ? versionEvents : oldVersion + 1;
if (newVersion == versionSnapshot)
{
return;

24
backend/src/Squidex/Squidex.csproj

@ -60,17 +60,17 @@
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="ReportGenerator" Version="5.4.1" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets.Azure" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.S3" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.S3" Version="7.37.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="7.37.0" />
<PackageReference Include="Squidex.ClientLibrary" Version="21.8.0" />
<PackageReference Include="Squidex.Events.GetEventStore" Version="7.34.0" />
<PackageReference Include="Squidex.Hosting" Version="7.34.0" />
<PackageReference Include="Squidex.Messaging.All" Version="7.34.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="7.34.0" />
<PackageReference Include="Squidex.Events.GetEventStore" Version="7.37.0" />
<PackageReference Include="Squidex.Hosting" Version="7.37.0" />
<PackageReference Include="Squidex.Messaging.All" Version="7.37.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="7.37.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="YDotNet" Version="0.4.3" />
<PackageReference Include="YDotNet.Native" Version="0.4.3" />
@ -84,11 +84,11 @@
</ItemGroup>
<ItemGroup Condition="'$(IncludeMagick)' == 'true'">
<PackageReference Include="Squidex.Assets.ImageMagick" Version="7.34.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="7.37.0" />
</ItemGroup>
<ItemGroup Condition="'$(IncludeKafka)' == 'true'">
<PackageReference Include="Squidex.Messaging.Kafka" Version="7.34.0" />
<PackageReference Include="Squidex.Messaging.Kafka" Version="7.37.0" />
</ItemGroup>
<PropertyGroup>

13
backend/src/Squidex/appsettings.json

@ -585,6 +585,11 @@
// Read More: https://docs.mongodb.com/manual/reference/connection-string/
"configuration": "mongodb://localhost",
// Indicates what MongoDB compatible instance is used.
//
// Allowed Values: MongoDB, FerretDb, DocumentDb, CosmosDb
"derivate": "MongoDb",
// The path to the certificate.
"certificate": "",
@ -633,6 +638,11 @@
// Read More: https://docs.mongodb.com/manual/reference/connection-string/
"configuration": "mongodb://localhost",
// Indicates what MongoDB compatible instance is used.
//
// Allowed Values: MongoDB, FerretDb, DocumentDb, CosmosDb
"derivate": "MongoDb",
// The path to the certificate.
"certificate": "",
@ -656,9 +666,6 @@
// SUPPORTED: Document, String, Binary (from slow to fast).
"valueRepresentation": "Undefined",
// Indicates that we use document db.
"documentDb": false,
"atlas": {
// The organization id.
"groupId": "",

1
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/JintScriptEngineTests.cs

@ -654,6 +654,7 @@ public class JintScriptEngineTests : IClassFixture<TranslationsFixture>
Assert.Equal(113.0, vars["shared"]);
}
[Trait("Category", "Dependencies")]
[Theory]
[InlineData(0)]
[InlineData(1)]

8
frontend/package-lock.json

@ -42,7 +42,7 @@
"mousetrap": "1.6.5",
"ng2-charts": "^8.0.0",
"ngx-doc-viewer": "15.0.1",
"ngx-inline-filter": "^0.2.1",
"ngx-inline-filter": "^0.2.3",
"ngx-scrollbar": "^18.0.0",
"ngx-ui-tour-core": "14.0.0",
"oidc-client-ts": "^3.2.1",
@ -19915,9 +19915,9 @@
}
},
"node_modules/ngx-inline-filter": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/ngx-inline-filter/-/ngx-inline-filter-0.2.1.tgz",
"integrity": "sha512-Szqe/ld24c2bWN2QqVC62u/X2tKRdBiyjvQytsRwRZ9iiLIxbz3X8xjMVgSA2UB0FcLV+rQdgJ7/wnlzTYGYKQ==",
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/ngx-inline-filter/-/ngx-inline-filter-0.2.3.tgz",
"integrity": "sha512-JE/a8/G8MKcNuZB7kKSsCbzsmWKoq2neRME+Y49wNjisANdYCKx6Pv3oeDSbnSi+wVkfdJz+mFO1BWAg/PL5mA==",
"dependencies": {
"tslib": "^2.3.0"
},

2
frontend/package.json

@ -50,7 +50,7 @@
"mousetrap": "1.6.5",
"ng2-charts": "^8.0.0",
"ngx-doc-viewer": "15.0.1",
"ngx-inline-filter": "^0.2.1",
"ngx-inline-filter": "^0.2.3",
"ngx-scrollbar": "^18.0.0",
"ngx-ui-tour-core": "14.0.0",
"oidc-client-ts": "^3.2.1",

4
frontend/src/app/features/content/pages/contents/contents-page.component.html

@ -1,7 +1,7 @@
<sqx-title [message]="schema.displayName" />
<sqx-layout layout="main">
<ng-container menu>
<div class="row flex-nowrap flex-grow-1 gx-2">
<div class="row flex-nowrap flex-grow-1 gx-2 overflow-hidden">
<div class="col-auto ms-8">
<sqx-notifo position="bottom-left" topic="apps/{{ contentsState.appId }}/schemas/{{ schema.id }}/contents" />
<button class="btn btn-text-secondary" (click)="reload()" shortcut="CTRL + B" title="i18n:contents.refreshTooltip" type="button">
@ -9,7 +9,7 @@
</button>
</div>
<div class="col">
<div class="col overflow-hidden">
<sqx-search-form
enableShortcut="true"
formClass="form"

4
frontend/src/app/framework/angular/layout.component.html

@ -54,7 +54,7 @@
<div><ng-container *ngTemplateOutlet="titleTemplate"></ng-container></div>
<div class="flex-grow-1 d-flex justify-content-end align-items-center">
<div class="flex-grow-1 d-flex justify-content-end align-items-center max-w-full">
<ng-container *ngTemplateOutlet="menuTemplate"></ng-container>
</div>
</div>
@ -89,7 +89,7 @@
<div><ng-container *ngTemplateOutlet="titleTemplate"></ng-container></div>
<div class="flex-grow-1 d-flex justify-content-end align-items-center">
<div class="flex-grow-1 d-flex justify-content-end align-items-center max-w-full">
<ng-container *ngTemplateOutlet="menuTemplate"></ng-container>
</div>
</div>

2
frontend/src/app/shared/components/search/search-form.component.ts

@ -89,7 +89,7 @@ export class SearchFormComponent {
...BootstrapClasses,
buttonAdd: 'btn btn-success',
buttonAddOutline: 'btn btn-outline-success btn-sm',
buttonDefault: () => 'btn',
buttonDefault: (active: boolean) => `btn ${active ? 'fw-bold' : ''}`,
buttonLogical: active => `btn btn-sm btn-secondary btn-toggle ${active ? 'btn-primary' : ''}`,
dropdown: 'bg-white',
dropdownItem: active => `control-dropdown-item control-dropdown-item-selectable separated ${active ? 'active' : ''}`,

4
frontend/src/app/theme/_common.scss

@ -125,6 +125,10 @@ hr {
}
}
.max-w-full {
max-width: 100%;
}
//
// Help texts
//

2
tools/TestSuite/docker-compose-ferretdb.yml

@ -24,8 +24,10 @@ services:
service: squidex_base
environment:
- EVENTSTORE__MONGODB__CONFIGURATION=mongodb://username:password@db_ferretdb/
- EVENTSTORE__MONGODB__DERIVATE=FerretDb
- STORE__TYPE=MongoDb
- STORE__MONGODB__CONFIGURATION=mongodb://username:password@db_ferretdb/
- STORE__MONGODB__DERIVATE=FerretDb
- URLS__BASEURL=http://localhost:8080
depends_on:
db_ferretdb:

Loading…
Cancel
Save