Skip to content

Commit

Permalink
Update dependencies. (#1082)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
SebastianStehle committed Mar 26, 2024
1 parent 88d2c11 commit bab6d23
Show file tree
Hide file tree
Showing 79 changed files with 591 additions and 576 deletions.
Expand Up @@ -16,10 +16,10 @@
<PackageReference Include="Confluent.SchemaRegistry.Serdes.Avro" Version="2.3.0" />
<PackageReference Include="CoreTweet" Version="1.0.0.483" />
<PackageReference Include="Elasticsearch.Net" Version="7.17.5" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="5.1.0" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="5.2.0" />
<PackageReference Include="Google.Cloud.Logging.V2" Version="4.2.0" />
<PackageReference Include="Google.Cloud.Monitoring.V3" Version="3.6.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.145">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Migrations/Migrations.csproj
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.145">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Expand Up @@ -12,7 +12,7 @@
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.145">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Expand Up @@ -7,8 +7,8 @@

using Jint.Native;
using Jint.Runtime;
using Squidex.AI;
using Squidex.Domain.Apps.Core.Properties;
using Squidex.Text.ChatBots;
using Squidex.Text.Translations;

#pragma warning disable CA1826 // Do not use Enumerable methods on indexable collections
Expand Down Expand Up @@ -61,17 +61,9 @@ private void Generate(ScriptExecutionContext context, string prompt, Action<JsVa
return;
}
var conversationId = Guid.NewGuid().ToString();
try
{
var result = await chatAgent.PromptAsync(conversationId, prompt, ct);
var result = await chatAgent.PromptAsync(prompt, ct: ct);
scheduler.Run(callback, JsValue.FromObject(context.Engine, result.Text));
}
finally
{
await chatAgent.StopConversationAsync(conversationId);
}
scheduler.Run(callback, JsValue.FromObject(context.Engine, result.Text));
}
catch (Exception ex)
{
Expand Down
Expand Up @@ -18,17 +18,18 @@
<ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fluid.Core" Version="2.5.0" />
<PackageReference Include="Fluid.Core" Version="2.7.0" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="Jint" Version="3.0.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.145">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="NJsonSchema" Version="11.0.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.4.1" />
<PackageReference Include="Squidex.AI" Version="6.6.4" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.6.4" />
<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" />
Expand Down
Expand Up @@ -7,15 +7,15 @@

using Squidex.Domain.Apps.Core.Rules.EnrichedEvents;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Shared;
using Squidex.Messaging.Subscriptions;

namespace Squidex.Domain.Apps.Core.Subscriptions;

public sealed class AssetSubscription : AppSubscription
public sealed class AssetSubscription : ISubscription
{
public EnrichedAssetEventType? Type { get; set; }
public EnrichedAssetEventType? Type { get; init; }

public override ValueTask<bool> ShouldHandle(object message)
public ValueTask<bool> ShouldHandle(object message)
{
return new ValueTask<bool>(ShouldHandleCore(message));
}
Expand All @@ -25,24 +25,14 @@ private bool ShouldHandleCore(object message)
switch (message)
{
case EnrichedAssetEvent enrichedAssetEvent:
return ShouldHandle(enrichedAssetEvent);
return CheckType(enrichedAssetEvent);
case AssetEvent assetEvent:
return ShouldHandle(assetEvent);
return CheckType(assetEvent);
default:
return false;
}
}

private bool ShouldHandle(EnrichedAssetEvent @event)
{
return CheckType(@event) && CheckPermission(@event.AppId.Name);
}

private bool ShouldHandle(AssetEvent @event)
{
return CheckType(@event) && CheckPermission(@event.AppId.Name);
}

private bool CheckType(EnrichedAssetEvent @event)
{
return Type == null || Type.Value == @event.Type;
Expand All @@ -64,11 +54,4 @@ private bool CheckType(AssetEvent @event)
return true;
}
}

private bool CheckPermission(string appName)
{
var permission = PermissionIds.ForApp(PermissionIds.AppAssetsRead, appName);

return Permissions.Includes(permission);
}
}
Expand Up @@ -7,17 +7,21 @@

using Squidex.Domain.Apps.Core.Rules.EnrichedEvents;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure.Security;
using Squidex.Messaging.Subscriptions;
using Squidex.Shared;

namespace Squidex.Domain.Apps.Core.Subscriptions;

public sealed class ContentSubscription : AppSubscription
public sealed class ContentSubscription : ISubscription
{
public PermissionSet Permissions { get; set; }

public string? SchemaName { get; set; }

public EnrichedContentEventType? Type { get; set; }

public override ValueTask<bool> ShouldHandle(object message)
public ValueTask<bool> ShouldHandle(object message)
{
return new ValueTask<bool>(ShouldHandleCore(message));
}
Expand Down

This file was deleted.

Expand Up @@ -13,31 +13,29 @@ namespace Squidex.Domain.Apps.Core.Subscriptions;

public sealed class EventMessageWrapper : IPayloadWrapper
{
private readonly IEnumerable<ISubscriptionEventCreator> subscriptionEventCreators;
private readonly IEnumerable<ISubscriptionEventCreator> creators;

public Envelope<AppEvent> Event { get; }

object IPayloadWrapper.Message => Event.Payload;

public EventMessageWrapper(Envelope<AppEvent> @event, IEnumerable<ISubscriptionEventCreator> subscriptionEventCreators)
public EventMessageWrapper(Envelope<AppEvent> @event, IEnumerable<ISubscriptionEventCreator> creators)
{
Event = @event;

this.subscriptionEventCreators = subscriptionEventCreators;
this.creators = creators;
}

public async ValueTask<object> CreatePayloadAsync()
{
foreach (var creator in subscriptionEventCreators)
foreach (var creator in creators)
{
if (!creator.Handles(Event.Payload))
{
continue;
}

var result = await creator.CreateEnrichedEventsAsync(Event, default);

if (result != null)
if (await creator.CreateEnrichedEventsAsync(Event, default) is object result)
{
return result;
}
Expand Down
Expand Up @@ -6,6 +6,9 @@
// ==========================================================================

using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Assets;
using Squidex.Domain.Apps.Events.Contents;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Messaging.Subscriptions;

Expand All @@ -14,7 +17,7 @@ namespace Squidex.Domain.Apps.Core.Subscriptions;
public sealed class SubscriptionPublisher : IEventConsumer
{
private readonly ISubscriptionService subscriptionService;
private readonly IEnumerable<ISubscriptionEventCreator> subscriptionEventCreators;
private readonly IEnumerable<ISubscriptionEventCreator> subscriptionCreators;

public string Name => "Subscriptions";

Expand All @@ -24,26 +27,36 @@ public sealed class SubscriptionPublisher : IEventConsumer

public bool CanClear => false;

public SubscriptionPublisher(ISubscriptionService subscriptionService, IEnumerable<ISubscriptionEventCreator> subscriptionEventCreators)
public SubscriptionPublisher(ISubscriptionService subscriptionService,
IEnumerable<ISubscriptionEventCreator> subscriptionCreators)
{
this.subscriptionService = subscriptionService;
this.subscriptionEventCreators = subscriptionEventCreators;
this.subscriptionCreators = subscriptionCreators;
}

public bool Handles(StoredEvent @event)
public async ValueTask<bool> HandlesAsync(StoredEvent @event)
{
return subscriptionService.HasSubscriptions;
var key = @event.StreamName.Split(DomainId.IdSeparator)[0];

return await subscriptionService.HasSubscriptionsAsync(key);
}

public Task On(Envelope<IEvent> @event)
{
if (@event.Payload is not AppEvent)
if (@event.Payload is AssetEvent assetEvent)
{
return Task.CompletedTask;
var wrapper = new EventMessageWrapper(@event.To<AppEvent>(), subscriptionCreators);

return subscriptionService.PublishAsync($"asset-{assetEvent.AppId.Id}", wrapper);
}

var wrapper = new EventMessageWrapper(@event.To<AppEvent>(), subscriptionEventCreators);
if (@event.Payload is ContentEvent contentEvent)
{
var wrapper = new EventMessageWrapper(@event.To<AppEvent>(), subscriptionCreators);

return subscriptionService.PublishAsync($"content-{contentEvent.AppId.Id}", wrapper);
}

return subscriptionService.PublishAsync(wrapper);
return Task.CompletedTask;
}
}
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.145">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Expand Up @@ -5,17 +5,9 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================

using Squidex.Infrastructure;
using Squidex.Infrastructure.Security;
using Squidex.Messaging.Subscriptions;
namespace Squidex.Domain.Apps.Entities.Apps;

namespace Squidex.Domain.Apps.Core.Subscriptions;

public abstract class AppSubscription : ISubscription
public sealed class AppCacheOptions
{
public DomainId AppId { get; set; }

public PermissionSet Permissions { get; set; }

public abstract ValueTask<bool> ShouldHandle(object message);
public TimeSpan CacheDuration { get; set; }
}
Expand Up @@ -35,9 +35,9 @@ public AppPermanentDeleter(IEnumerable<IDeleter> deleters, IDomainObjectFactory
];
}

public bool Handles(StoredEvent @event)
public ValueTask<bool> HandlesAsync(StoredEvent @event)
{
return consumingTypes.Contains(@event.Data.Type);
return new ValueTask<bool>(consumingTypes.Contains(@event.Data.Type));
}

public async Task On(Envelope<IEvent> @event)
Expand Down

0 comments on commit bab6d23

Please sign in to comment.