Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
43fe592
refactor(backend): update persistence.file project
andrei2699 Mar 23, 2026
c363212
refactor(backend): relocated ports.plugin project
andrei2699 Mar 23, 2026
1cab3f0
refactor(backend): update persistence.inmemory project
andrei2699 Mar 23, 2026
3c25ecf
refactor(backend): relocated persistance.mongodb.tests project
andrei2699 Mar 23, 2026
384a6d8
refactor(backend): relocated usecase.plugin project
andrei2699 Mar 23, 2026
9e9cfd5
refactor(backend): relocated marketplace.client project
andrei2699 Mar 23, 2026
2c9ac59
refactor(backend): relocated persistence.mongodb project
andrei2699 Mar 23, 2026
5a41136
refactor(backend): relocated ports.files project
andrei2699 Mar 23, 2026
79f6859
refactor(backend): relocated service.analysis project
andrei2699 Mar 23, 2026
68cfde6
refactor(backend): update project references
andrei2699 Mar 23, 2026
2bf975c
refactor(backend): relocated tests for persistance mongodb gateway
andrei2699 Mar 24, 2026
c6f88ca
refactor(backend): relocated tests for persistance mongodb analysis
andrei2699 Mar 24, 2026
31149d2
refactor(backend): relocated code for persistance mongodb gateway
andrei2699 Mar 24, 2026
8ddacb1
refactor(backend): relocated code for persistance mongodb analysis
andrei2699 Mar 24, 2026
e04a7f9
refactor(backend): relocated code in persistance mongodb abstractions…
andrei2699 Mar 24, 2026
2e3fe30
refactor(backend): relocated code for instance allocation port
andrei2699 Mar 24, 2026
ca0824e
refactor(backend): relocated code for ports analysis
andrei2699 Mar 24, 2026
9045a26
refactor(backend): relocated code for ports scripts
andrei2699 Mar 24, 2026
17348f3
refactor(backend): relocated tests project for marketplace client
andrei2699 Mar 24, 2026
5ccaf9b
refactor(backend): relocated analyis.service.tests project
andrei2699 Mar 24, 2026
f83751c
refactor(backend): fix the imports after the project reorganization
andrei2699 Mar 24, 2026
acd4228
refactor(backend): relocated scripts mongodb in separate project
andrei2699 Mar 24, 2026
fec2dcd
refactor(backend): use the scripts mongodb from separate project
andrei2699 Mar 24, 2026
a7df1b5
refactor(backend): relocated code in artifacts
andrei2699 Mar 26, 2026
a708e09
refactor(backend): relocated code in artifacts.mongodb
andrei2699 Mar 26, 2026
f76f4df
refactor(backend): use relocated from artifacts and artifacts.mongodb
andrei2699 Mar 26, 2026
59812bb
refactor(backend): use move code in artifacts.mongodb.tests
andrei2699 Mar 26, 2026
885fc29
refactor(backend): relocated artifacts tests in workspace folder
andrei2699 Mar 26, 2026
f7f4b8e
refactor(backend): relocated artifacts in workspace folder
andrei2699 Mar 26, 2026
21b4ba4
refactor(backend): relocated ports.analysis to workspace analysis folder
andrei2699 Mar 26, 2026
9da9049
refactor(backend): relocated analysis mongodb in workspace folder
andrei2699 Mar 27, 2026
31111f1
refactor(backend): relocated analysis mongodb tests in workspace folder
andrei2699 Mar 27, 2026
f586593
refactor(backend): relocated file model service registration
andrei2699 Mar 27, 2026
c5de251
refactor(backend): reorganized csproj for Rest.Tests.csproj
andrei2699 Mar 27, 2026
97c3746
refactor(backend): renamed root names space for instance allocation port
andrei2699 Mar 27, 2026
8be1903
refactor(backend): split test common in 2 so we have mongodb common t…
andrei2699 Mar 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/

# ASP.NET Scaffolding
ScaffoldingReadMe.txt
Expand Down
31 changes: 21 additions & 10 deletions ScriptBee.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,62 @@
<Project Path="ScriptBeeWebApp/src/Common/Common/Common.csproj" />
<Project Path="ScriptBeeWebApp/src/Common/Common.Web/Common.Web.csproj" />
<Project Path="ScriptBeeWebApp/src/Common/Model/Model.csproj" />
<Project Path="ScriptBeeWebApp/src/Workspace/Analysis/Analysis/Analysis.csproj" />
<Project Path="ScriptBeeWebApp/src/Common/Marketplace.Client/Marketplace.Client.csproj" />
<Project Path="ScriptBeeWebApp/src/Common/Persistence.Mongodb.Abstractions/Persistence.Mongodb.Abstractions.csproj" />

<Project Path="ScriptBeeWebApp/src/Workspace/Artifacts/Artifacts/Artifacts.csproj" />
<Project Path="ScriptBeeWebApp/src/Workspace/Artifacts/Artifacts.Mongodb/Artifacts.Mongodb.csproj" />

<!-- Analysis Bounded Context -->
<!-- Adapters -->
<Project Path="ScriptBeeWebApp/src/Analysis/Adapters/Analysis.Web/Analysis.Web.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Adapters/Persistence.File/Persistence.File.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Adapters/Persistence.InMemory/Persistence.InMemory.csproj" />
<Project Path="ScriptBeeWebApp/src/Workspace/Analysis/Analysis.Mongodb/Analysis.Mongodb.csproj" />
<!-- Application Layer -->
<Project Path="ScriptBeeWebApp/src/Analysis/Application/Ports.Analysis/Ports.Analysis.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Application/Ports.Files/Ports.Files.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Application/Ports.Plugins/Ports.Plugins.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Application/Service.Plugin/Service.Plugin.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Application/Service.Analysis/Service.Analysis.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Application/UseCases.Analysis/UseCases.Analysis.csproj" />
<Project Path="ScriptBeeWebApp/src/Analysis/Application/UseCases.Plugin/UseCases.Plugin.csproj" />

<!-- Gateway Bounded Context -->
<!-- Adapters -->
<Project Path="ScriptBeeWebApp/src/Gateway/Adapters/Analysis.Instance.Docker/Analysis.Instance.Docker.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Adapters/Marketplace.Client/Marketplace.Client.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Adapters/Persistence.Mongodb/Persistence.Mongodb.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Adapters/Rest/Rest.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Adapters/Web/Web.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Adapters/Persistence.Mongodb.Gateway/Persistence.Mongodb.Gateway.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/Ports.Instance.Allocation/Ports.Instance.Allocation.csproj" />
<!-- Application Layer -->
<Project Path="ScriptBeeWebApp/src/Gateway/Application/Ports.Instance/Ports.Instance.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/Ports.Plugins/Ports.Plugins.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/Ports.Project/Ports.Project.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/Service.Analysis/Service.Analysis.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/Ports.Plugins.Fetching/Ports.Plugins.Fetching.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/Service.Project/Service.Project.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/UseCases.Plugin/UseCases.Plugin.csproj" />
<Project Path="ScriptBeeWebApp/src/Gateway/Application/UseCases.Project/UseCases.Project.csproj" />

<!-- Tests - Common Layer -->
<Project Path="ScriptBeeWebApp/test/Common/Common.Tests/Common.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Common/Model.Tests/Model.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Common/Tests.Common/Tests.Common.csproj" />
<Project Path="ScriptBeeWebApp/test/Common/Tests.Common.Mongodb/Tests.Common.Mongodb.csproj" />
<Project Path="ScriptBeeWebApp/test/Common/Marketplace.Client.Tests/Marketplace.Client.Tests.csproj" />

<Project Path="ScriptBeeWebApp/test/Workspace/Artifacts/Artifacts.Tests/Artifacts.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Workspace/Artifacts/Artifacts.Mongodb.Tests/Artifacts.Mongodb.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Workspace/Analysis/Analysis.Mongodb.Tests/Analysis.Mongodb.Tests.csproj" />

<!-- Tests - Analysis Context -->
<Project Path="ScriptBeeWebApp/test/Analysis/Adapters/Analysis.Web.Tests/Analysis.Web.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Analysis/Adapters/Persistence.File.Tests/Persistence.File.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Analysis/Adapters/Persistence.InMemory.Tests/Persistence.InMemory.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Analysis/Application/Service.Analysis.Tests/Service.Analysis.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Analysis/Application/Service.Plugin.Tests/Service.Plugin.Tests.csproj" />

<!-- Tests - Gateway Context -->
<Project Path="ScriptBeeWebApp/test/Gateway/Adapters/Analysis.Instance.Docker.Tests/Analysis.Instance.Docker.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Gateway/Adapters/Marketplace.Client.Tests/Marketplace.Client.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Gateway/Adapters/Persistence.Mongodb.Tests/Persistence.Mongodb.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Gateway/Adapters/Rest.Tests/Rest.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Gateway/Adapters/Web.Tests/Web.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Gateway/Application/Service.Analysis.Tests/Service.Analysis.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Gateway/Adapters/Persistence.Mongodb.Gateway.Tests/Persistence.Mongodb.Gateway.Tests.csproj" />
<Project Path="ScriptBeeWebApp/test/Gateway/Application/Service.Project.Tests/Service.Project.Tests.csproj" />
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common\Common\Common.csproj" />
<ProjectReference Include="..\Persistence.InMemory\Persistence.InMemory.csproj" />
<ProjectReference Include="..\..\..\Common\Common.Web\Common.Web.csproj" />
<ProjectReference Include="..\..\..\Gateway\Application\Service.Analysis\Service.Analysis.csproj" />
<ProjectReference Include="..\..\..\Analysis\Application\Service.Plugin\Service.Plugin.csproj" />
<ProjectReference Include="..\..\..\Analysis\Application\UseCases.Analysis\UseCases.Analysis.csproj" />
<ProjectReference Include="..\..\..\Workspace\Artifacts\Artifacts\Artifacts.csproj" />
<ProjectReference Include="..\..\..\Workspace\Artifacts\Artifacts.Mongodb\Artifacts.Mongodb.csproj" />
<ProjectReference Include="..\..\..\Workspace\Analysis\Analysis\Analysis.csproj" />
<ProjectReference Include="..\..\..\Workspace\Analysis\Analysis.Mongodb\Analysis.Mongodb.csproj" />
<ProjectReference Include="..\Persistence.InMemory\Persistence.InMemory.csproj" />
<ProjectReference Include="..\Persistence.File\Persistence.File.csproj" />
<ProjectReference Include="..\..\..\Gateway\Adapters\Persistence.Mongodb\Persistence.Mongodb.csproj" />
<ProjectReference Include="..\..\Application\Service.Plugin\Service.Plugin.csproj" />
<ProjectReference Include="..\..\Application\Service.Analysis\Service.Analysis.csproj" />
<ProjectReference Include="..\..\Application\UseCases.Analysis\UseCases.Analysis.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using static ScriptBee.Persistence.Mongodb.Extensions.MongoDbExtensions;
using ScriptBee.Analysis.Mongodb.Extensions;
using ScriptBee.Artifacts.Mongodb.Extensions;
using ScriptBee.Persistence.Mongodb.Extensions;

namespace ScriptBee.Analysis.Web.Extensions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ScriptBee.Persistence.File.Config;
using ScriptBee.Artifacts.Extensions;
using ScriptBee.Persistence.File.Plugin;
using ScriptBee.Ports.Files;
using ScriptBee.Ports.Plugins;

namespace ScriptBee.Persistence.File.Extensions;
Expand All @@ -14,12 +13,8 @@ public static IServiceCollection AddFileAdapters(
IConfigurationSection userFolderConfigurationSection
)
{
services.Configure<UserFolderSettings>(userFolderConfigurationSection);
return services
.AddSingleton<IConfigFoldersService, ConfigFoldersService>()
.AddSingleton<ICreateFile, CreateFileAdapter>()
.AddSingleton<ILoadFile, LoadFileAdapter>()
.AddSingleton<IFileService, FileService>()
.AddArtifactFileAdapters(userFolderConfigurationSection)
.AddSingleton<IPluginDiscriminatorHolder, PluginDiscriminatorHolder>()
.AddSingleton<IPluginManifestYamlFileReader, PluginManifestYamlFileReader>()
.AddSingleton<IPluginReader, PluginReader>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
<PackageReference Include="YamlDotNet" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Analysis\Application\Ports.Files\Ports.Files.csproj" />
<ProjectReference Include="..\..\..\Gateway\Application\Ports.Plugins\Ports.Plugins.csproj" />
<ProjectReference Include="..\..\..\Gateway\Application\Ports.Project\Ports.Project.csproj" />
<ProjectReference Include="..\..\..\Analysis\Application\Ports.Analysis\Ports.Analysis.csproj" />
<ProjectReference Include="..\..\..\Common\Marketplace.Client\Marketplace.Client.csproj" />
<ProjectReference Include="..\..\..\Workspace\Artifacts\Artifacts\Artifacts.csproj" />
<ProjectReference Include="..\..\Application\Ports.Plugins\Ports.Plugins.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using ScriptBee.Domain.Model.Config;
using ScriptBee.Domain.Model.Plugin.Manifest;
using ScriptBee.Marketplace.Client;
using ScriptBee.Ports.Plugins;
using ScriptBee.Ports.Plugins.Installer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using ScriptBee.Artifacts;
using ScriptBee.Domain.Model.Config;
using ScriptBee.Domain.Model.Plugin.Manifest;
using ScriptBee.Ports.Plugins;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using ScriptBee.Artifacts;
using ScriptBee.Domain.Model.Config;

namespace ScriptBee.Persistence.File.Plugin.Installer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using ScriptBee.Artifacts;
using ScriptBee.Domain.Model.Config;
using ScriptBee.Persistence.File.Exceptions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using ScriptBee.Artifacts;
using ScriptBee.Domain.Model.Plugin.Manifest;
using ScriptBee.Ports.Plugins;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<RootNamespace>ScriptBee.Persistence.InMemory</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Gateway\Application\Ports.Plugins\Ports.Plugins.csproj" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<ProjectReference Include="..\..\Application\Ports.Plugins\Ports.Plugins.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Text;
using DxWorks.ScriptBee.Plugin.Api.Services;
using ScriptBee.Artifacts;
using ScriptBee.Common;
using ScriptBee.Domain.Model.Analysis;
using ScriptBee.Ports.Files;

namespace ScriptBee.Service.Analysis;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using DxWorks.ScriptBee.Plugin.Api;
using DxWorks.ScriptBee.Plugin.Api.Model;
using ScriptBee.Artifacts;
using ScriptBee.Domain.Model.File;
using ScriptBee.Ports.Files;
using ScriptBee.Ports.Plugins;

namespace ScriptBee.Service.Analysis;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Threading.Channels;
using DxWorks.ScriptBee.Plugin.Api;
using OneOf;
using ScriptBee.Analysis;
using ScriptBee.Artifacts;
using ScriptBee.Common;
using ScriptBee.Domain.Model.Analysis;
using ScriptBee.Domain.Model.Errors;
using ScriptBee.Domain.Model.ProjectStructure;
using ScriptBee.Ports.Analysis;
using ScriptBee.Ports.Plugins;
using ScriptBee.Ports.Project.Structure;
using ScriptBee.UseCases.Analysis;

namespace ScriptBee.Service.Analysis;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Text;
using DxWorks.ScriptBee.Plugin.Api;
using DxWorks.ScriptBee.Plugin.Api.Services;
using ScriptBee.Analysis;
using ScriptBee.Artifacts;
using ScriptBee.Common;
using ScriptBee.Domain.Model.Analysis;
using ScriptBee.Domain.Model.File;
using ScriptBee.Domain.Model.ProjectStructure;
using ScriptBee.Ports.Analysis;
using ScriptBee.Ports.Files;
using ScriptBee.Ports.Plugins;

namespace ScriptBee.Service.Analysis;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>ScriptBee.Service.Analysis</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common\Common\Common.csproj" />
<ProjectReference Include="..\..\..\Workspace\Analysis\Analysis\Analysis.csproj" />
<ProjectReference Include="..\..\..\Workspace\Artifacts\Artifacts\Artifacts.csproj" />
<ProjectReference Include="..\Ports.Plugins\Ports.Plugins.csproj" />
<ProjectReference Include="..\..\Application\UseCases.Analysis\UseCases.Analysis.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ScriptBee.Domain.Model.Plugin;
using ScriptBee.Domain.Model.Plugin.MarketPlace;
using ScriptBee.Marketplace.Client;
using ScriptBee.Ports.Plugins;
using ScriptBee.UseCases.Plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<RootNamespace>ScriptBee.Service.Plugin</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common\Common\Common.csproj" />
<ProjectReference Include="..\..\..\Gateway\Application\Ports.Plugins\Ports.Plugins.csproj" />
<ProjectReference Include="..\..\..\Gateway\Application\UseCases.Plugin\UseCases.Plugin.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<ProjectReference Include="..\..\..\Common\Common\Common.csproj" />
<ProjectReference Include="..\..\..\Common\Marketplace.Client\Marketplace.Client.csproj" />
<ProjectReference Include="..\Ports.Plugins\Ports.Plugins.csproj" />
<ProjectReference Include="..\UseCases.Plugin\UseCases.Plugin.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ScriptBee.Domain.Model.Plugin.MarketPlace;

namespace ScriptBee.Ports.Plugins;
namespace ScriptBee.Marketplace.Client;

public interface IMarketPluginFetcher
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ScriptBee.Ports.Plugins;
namespace ScriptBee.Marketplace.Client;

public interface IPluginUrlFetcher
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using DxWorks.Hub.Sdk.Project;
using ScriptBee.Domain.Model.Plugin;
using ScriptBee.Domain.Model.Plugin.MarketPlace;
using ScriptBee.Ports.Plugins;

namespace ScriptBee.Marketplace.Client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<PackageReference Include="Microsoft.Extensions.Http" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common\Model\Model.csproj" />
<ProjectReference Include="..\..\..\Gateway\Application\Ports.Plugins\Ports.Plugins.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ScriptBee.Marketplace.Client.Exceptions;
using ScriptBee.Ports.Plugins;

namespace ScriptBee.Marketplace.Client;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using DxWorks.Hub.Sdk;
using Microsoft.Extensions.DependencyInjection;
using ScriptBee.Ports.Plugins;

namespace ScriptBee.Marketplace.Client;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace ScriptBee.Persistence.Mongodb.Exceptions;
namespace ScriptBee.Persistence.Mongodb.Exceptions;

[Serializable]
public sealed class InvalidMongoConfigurationException()
: Exception("MongoDB connection string is not set");

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.Extensions.DependencyInjection;
using MongoDB.Driver;
using ScriptBee.Persistence.Mongodb.Exceptions;
using ScriptBee.Persistence.Mongodb.Repository;

namespace ScriptBee.Persistence.Mongodb.Extensions;

public static class MongoDbAbstractionsExtensions
{
public static IMongoDatabase AddMongodbDatabase(
this IServiceCollection services,
string? connectionString
)
{
if (string.IsNullOrEmpty(connectionString))
{
throw new InvalidMongoConfigurationException();
}

var mongoUrl = new MongoUrl(connectionString);
var mongoClient = new MongoClient(mongoUrl);
var mongoDatabase = mongoClient.GetDatabase(mongoUrl.DatabaseName);

services
.AddSingleton<IMongoClient>(mongoClient)
.AddSingleton(mongoDatabase);

return mongoDatabase;
}

public static IServiceCollection AddMongoCollection<T>(
this IServiceCollection services,
IMongoDatabase mongoDatabase,
string collectionName
)
where T : IDocument
{
return services
.AddSingleton<IMongoCollection<T>>(_ => mongoDatabase.GetCollection<T>(collectionName))
.AddSingleton<IMongoRepository<T>, MongoRepository<T>>();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>ScriptBee.Persistence.Mongodb</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Bson" />
<PackageReference Include="MongoDB.Driver" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace ScriptBee.Persistence.Mongodb.Repository;
namespace ScriptBee.Persistence.Mongodb.Repository;

public interface IDocument
{
public string Id { get; set; }
}

Loading
Loading