Implement XAiMcpServer Stuffs ...

This commit is contained in:
2026-11-02 23:16:50 +03:30
parent 9e7710e345
commit 62aa8d51e6
31 changed files with 641 additions and 7 deletions
+17
View File
@@ -0,0 +1,17 @@
using System;
using xPushService.Base;
using xAiModels.Models.Dtos;
using xAiModels.Interfaces.Dtos;
using xAiModels.Models.Entities;
using Microsoft.Extensions.Logging;
namespace xAiModels.Providers.Dtos
{
public class XAiMcpServerDtoHub : XBaseDtoHub<XAiMcpServer, XAiMcpServerDto, Guid>, IXAiMcpServerDtoHub
{
public XAiMcpServerDtoHub(
ILogger<XAiMcpServerDtoHub> logger
) : base(logger)
{ }
}
}
@@ -0,0 +1,26 @@
using System;
using xAiModels.Models.Dtos;
using xDataService.Providers;
using xAiModels.Configurations;
using xAiModels.Interfaces.Dtos;
using xAiModels.Models.Entities;
using xAiModels.Interfaces.Entities;
using xAiModels.Interfaces.Enrichers;
namespace xAiModels.Providers.Dtos
{
public class XAiMcpServerRepositoryService : XBaseRepositoryService<XAiMcpServer, XAiMcpServerDto, Guid>, IXAiMcpServerRepositoryService
{
private readonly IXAiMcpServerEnricher enricher;
private readonly IXAiMcpServerRepository repository;
public XAiMcpServerRepositoryService(
IXAiMcpServerRepository repository,
IXAiMcpServerEnricher enricher
) : base(repository, mapperProfiles: [new XAiModelMappersProfile()])
{
this.enricher = enricher;
this.repository = repository;
}
}
}
@@ -0,0 +1,22 @@
using System;
using xPushService.Base;
using xAiModels.Models.Dtos;
using xAiModels.Interfaces.Dtos;
using xAiModels.Models.Entities;
using xDataService.Configuration;
using xIdentityService.Interfaces;
using Microsoft.AspNetCore.SignalR;
namespace xAiModels.Providers.Dtos
{
public class XAiMcpServerServiceProvider : XBaseDtoProvider<XAiMcpServer, XAiMcpServerDto, Guid, XAiMcpServerDtoHub>, IXAiMcpServerServiceProvider
{
public XAiMcpServerServiceProvider(
IHubContext<XAiMcpServerDtoHub> hub,
XDataServiceConfiguration dataConfiguration,
IXAiMcpServerRepositoryService service,
IXIdentityProvider identityProvider = null
) : base(hub, dataConfiguration, service, identityProvider)
{ }
}
}
@@ -0,0 +1,79 @@
using System.Linq;
using xModels.Dtos;
using System.Threading;
using xCommons.Extensions;
using xAiModels.Models.Dtos;
using System.Threading.Tasks;
using xAiModels.Models.Entities;
using System.Collections.Generic;
using xIdentityService.Interfaces;
using xAiModels.Interfaces.Enrichers;
namespace xAiModels.Providers.Enrichers
{
public class XAiMcpServerEnricher : IXAiMcpServerEnricher
{
private readonly IXPersonService personService;
public XAiMcpServerEnricher(
IXPersonService personService
)
{
this.personService = personService;
}
public virtual async Task<XAiMcpServerDto> Enrich(
XAiMcpServer source,
CancellationToken cancellationToken = default
)
{
//
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServer>();
result = await Enrich(
source: result,
cancellationToken: cancellationToken
);
//
return result;
}
public virtual async Task<XAiMcpServerDto> Enrich(
XAiMcpServerDto source,
CancellationToken cancellationToken = default
)
{
//
XPersonDto owner = null;
if (!source.OwnerId.IsNullOrEmpty())
{
owner = await personService.GetPerson(source.OwnerId);
}
//
var result = source.MapConvert<XAiMcpServerDto, XAiMcpServerDto>();
result.Owner = owner;
//
return result;
}
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
IEnumerable<XAiMcpServer> sources,
CancellationToken cancellationToken = default
)
{
var tasks = sources.Select(x => Enrich(x, cancellationToken));
return await Task.WhenAll(tasks);
}
public virtual async Task<IEnumerable<XAiMcpServerDto>> EnrichRange(
IEnumerable<XAiMcpServerDto> sources,
CancellationToken cancellationToken = default
)
{
var tasks = sources.Select(x => Enrich(x, cancellationToken));
return await Task.WhenAll(tasks);
}
}
}
@@ -0,0 +1,22 @@
using System;
using xDataService.Db;
using xDataService.Providers;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
using xDataService.Configuration;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.Entities
{
public class XAiMcpServerEFRepository<TContext> : XBaseEFRepository<XAiMcpServer, Guid, TContext>, IXAiMcpServerRepository
where TContext : XDbContext
{
public XAiMcpServerEFRepository(
IXUnitOfWorks<TContext> unitOfWorks,
XDataServiceConfiguration configuration,
IXAiMcpServerKeyGenerator keyGenerator = null,
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
) : base(unitOfWorks, configuration, keyGenerator, baseRepositoryEvents)
{ }
}
}
@@ -0,0 +1,16 @@
using System;
using xPushService.Base;
using xAiModels.Models.Entities;
using Microsoft.Extensions.Logging;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.Entities
{
public class XAiMcpServerEntityHub : XBaseEntityHub<XAiMcpServer, Guid>, IXAiMcpServerEntityHub
{
public XAiMcpServerEntityHub(
ILogger<XAiMcpServerEntityHub> logger
) : base(logger)
{ }
}
}
@@ -0,0 +1,18 @@
using System;
using xDataService.Providers;
using xAiModels.Models.Entities;
using xDataService.Configuration;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.Entities
{
public class XAiMcpServerInMemoryRepository : XBaseInMemoryRepository<XAiMcpServer, Guid>, IXAiMcpServerRepository
{
public XAiMcpServerInMemoryRepository(
XDataServiceConfiguration configuration,
IXAiMcpServerKeyGenerator keyGenerator = null,
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
) : base(configuration, keyGenerator, baseRepositoryEvents)
{ }
}
}
@@ -0,0 +1,9 @@
using xDataService.Providers;
using xAiModels.Models.Entities;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.Entities
{
public class XAiMcpServerKeyGenerator : XGuidKeyGenerator<XAiMcpServer>, IXAiMcpServerKeyGenerator
{ }
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using xAiModels.Interfaces.Entities;
using xAiModels.Models.Entities;
using xDataService.Configuration;
using xDataService.Providers;
namespace xAiModels.Providers.Entities
{
public class XAiMcpServerMongoRepository : XBaseMongoRepository<XAiMcpServer, Guid>, IXAiMcpServerRepository
{
public XAiMcpServerMongoRepository(
XDataBaseConfiguration dbConfiguration,
XDataServiceConfiguration configuration,
string collectionName = null,
IXAiMcpServerKeyGenerator keyGenerator = null,
IXAiMcpServerRepositoryEvents baseRepositoryEvents = null
) : base(dbConfiguration, configuration, collectionName, keyGenerator, baseRepositoryEvents)
{ }
}
}
@@ -0,0 +1,9 @@
using xDataService.Providers;
using xAiModels.Models.Entities;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.Entities
{
public class XAiMcpServerRepositoryEvents : XBaseRepositoryEvents<XAiMcpServer>, IXAiMcpServerRepositoryEvents
{ }
}
@@ -0,0 +1,21 @@
using System;
using xPushService.Base;
using xAiModels.Models.Entities;
using xDataService.Configuration;
using xIdentityService.Interfaces;
using Microsoft.AspNetCore.SignalR;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.Entities
{
public class XAiMcpServerRepositoryProvider : XBaseEntityProvider<XAiMcpServer, Guid, XAiMcpServerEntityHub>, IXAiMcpServerRepositoryProvider
{
public XAiMcpServerRepositoryProvider(
IHubContext<XAiMcpServerEntityHub> hub,
IXAiMcpServerRepository repository,
XDataServiceConfiguration dataConfiguration,
IXIdentityProvider identityProvider = null
) : base(hub, repository, dataConfiguration, identityProvider)
{ }
}
}
@@ -0,0 +1,21 @@
using System;
using xAiModels.Constants;
using xDataService.GraphQL;
using xAiModels.Models.Entities;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.GraphQL
{
public class XAiMcpServerGraphQLTypeHelper : XBaseGraphQLTypeHelper<XAiMcpServer, Guid>, IXAiMcpServerGraphQLTypeHelper
{
public override string GetInQueryCollectionName()
{
return XAiModelsConstants.XAiMcpServerCollectionName;
}
public override string GetInQuerySingleName()
{
return XAiModelsConstants.XAiMcpServerSingleName;
}
}
}
@@ -0,0 +1,23 @@
using System;
using GraphQL.Types;
using xDataService.GraphQL;
using xAiModels.Models.Entities;
using xDataService.Configuration;
using xAiModels.Interfaces.Entities;
namespace xAiModels.Providers.GraphQL
{
public class XAiMcpServerGraphQuery : XBaseGraphQLQuery<XAiMcpServer, Guid, XAiMcpServerGraphType, GuidGraphType>
{
public XAiMcpServerGraphQuery(
XDataServiceConfiguration configuration,
IXAiMcpServerRepository repository,
IXAiMcpServerGraphQLTypeHelper helper
) : base(
configuration,
repository,
helper
)
{ }
}
}
@@ -0,0 +1,13 @@
using System;
using GraphQL.Types;
namespace xAiModels.Providers.GraphQL
{
public class XAiMcpServerGraphSchema : Schema
{
public XAiMcpServerGraphSchema(IServiceProvider services) : base(services)
{
Query = (XAiMcpServerGraphQuery)services.GetService(typeof(XAiMcpServerGraphQuery));
}
}
}
@@ -0,0 +1,23 @@
using System;
using xDataService.GraphQL;
using xAiModels.Models.Entities;
namespace xAiModels.Providers.GraphQL
{
public class XAiMcpServerGraphType: XBaseGraphObjectType<XAiMcpServer, Guid>
{
public XAiMcpServerGraphType() : base()
{
Field(x => x.Name);
Field(x => x.Enabled);
Field(x => x.OwnerId);
Field(x => x.Headers);
Field(x => x.Endpoint);
Field(x => x.CreatedOn);
Field(x => x.UpdatedAt);
Field(x => x.Description);
Field(x => x.TimeoutSeconds);
Field(x => x.EnvironmentVariables);
}
}
}
@@ -0,0 +1,35 @@
using System;
using xDataService.Providers;
using xDataService.Interfaces;
using xAiModels.Models.Entities;
using Microsoft.EntityFrameworkCore;
using xAiModels.Configurations.Entities;
namespace xAiModels.Providers
{
public class XAiMcpServerEntityRegisterar : XBaseEntityRegisterar, IXEntityRegisterar
{
public XAiMcpServerEntityRegisterar()
: base(nameof(XAiMcpServerEntityRegisterar))
{
//
// Add Entity ...
AddEntity<XAiMcpServer, Guid>();
}
/// <summary>
/// Configure Entities ...
/// </summary>
/// <param name="modelBuilder"></param>
public override void ConfigureEntities(ModelBuilder modelBuilder)
{
//
// Configure Entity Using Provided ...
modelBuilder
.ApplyConfigurationsFromAssembly(typeof(XAiMcpServerEntityConfiguration).Assembly);
//
base.ConfigureEntities(modelBuilder);
}
}
}