Files
SerpentRace/SerpentRace_Backend/dist/Application/Services/DIContainer.js
T

384 lines
19 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.container = exports.DIContainer = void 0;
// Repository Implementations
const UserRepository_1 = require("../../Infrastructure/Repository/UserRepository");
const ChatRepository_1 = require("../../Infrastructure/Repository/ChatRepository");
const ChatArchiveRepository_1 = require("../../Infrastructure/Repository/ChatArchiveRepository");
const DeckRepository_1 = require("../../Infrastructure/Repository/DeckRepository");
const OrganizationRepository_1 = require("../../Infrastructure/Repository/OrganizationRepository");
const ContactRepository_1 = require("../../Infrastructure/Repository/ContactRepository");
// Command Handlers
const CreateUserCommandHandler_1 = require("../User/commands/CreateUserCommandHandler");
const LoginCommandHandler_1 = require("../User/commands/LoginCommandHandler");
const UpdateUserCommandHandler_1 = require("../User/commands/UpdateUserCommandHandler");
const DeactivateUserCommandHandler_1 = require("../User/commands/DeactivateUserCommandHandler");
const DeleteUserCommandHandler_1 = require("../User/commands/DeleteUserCommandHandler");
const VerifyEmailCommandHandler_1 = require("../User/commands/VerifyEmailCommandHandler");
const RequestPasswordResetCommandHandler_1 = require("../User/commands/RequestPasswordResetCommandHandler");
const ResetPasswordCommandHandler_1 = require("../User/commands/ResetPasswordCommandHandler");
const CreateChatCommandHandler_1 = require("../Chat/commands/CreateChatCommandHandler");
const SendMessageCommandHandler_1 = require("../Chat/commands/SendMessageCommandHandler");
const ChatArchiveCommandHandlers_1 = require("../Chat/commands/ChatArchiveCommandHandlers");
const CreateDeckCommandHandler_1 = require("../Deck/commands/CreateDeckCommandHandler");
const UpdateDeckCommandHandler_1 = require("../Deck/commands/UpdateDeckCommandHandler");
const DeleteDeckCommandHandler_1 = require("../Deck/commands/DeleteDeckCommandHandler");
const CreateOrganizationCommandHandler_1 = require("../Organization/commands/CreateOrganizationCommandHandler");
const UpdateOrganizationCommandHandler_1 = require("../Organization/commands/UpdateOrganizationCommandHandler");
const DeleteOrganizationCommandHandler_1 = require("../Organization/commands/DeleteOrganizationCommandHandler");
const ProcessOrgAuthCallbackCommandHandler_1 = require("../Organization/commands/ProcessOrgAuthCallbackCommandHandler");
const CreateContactCommandHandler_1 = require("../Contact/commands/CreateContactCommandHandler");
const UpdateContactCommandHandler_1 = require("../Contact/commands/UpdateContactCommandHandler");
const DeleteContactCommandHandler_1 = require("../Contact/commands/DeleteContactCommandHandler");
// Query Handlers
const GetUserByIdQueryHandler_1 = require("../User/queries/GetUserByIdQueryHandler");
const GetUsersByPageQueryHandler_1 = require("../User/queries/GetUsersByPageQueryHandler");
const GetUserChatsQueryHandler_1 = require("../Chat/queries/GetUserChatsQueryHandler");
const ChatHistoryQueryHandlers_1 = require("../Chat/queries/ChatHistoryQueryHandlers");
const GetChatsByPageQueryHandler_1 = require("../Chat/queries/GetChatsByPageQueryHandler");
const GetDeckByIdQueryHandler_1 = require("../Deck/queries/GetDeckByIdQueryHandler");
const GetDecksByPageQueryHandler_1 = require("../Deck/queries/GetDecksByPageQueryHandler");
const GetOrganizationByIdQueryHandler_1 = require("../Organization/queries/GetOrganizationByIdQueryHandler");
const GetOrganizationsByPageQueryHandler_1 = require("../Organization/queries/GetOrganizationsByPageQueryHandler");
const GetOrganizationLoginUrlQueryHandler_1 = require("../Organization/queries/GetOrganizationLoginUrlQueryHandler");
const GetContactByIdQueryHandler_1 = require("../Contact/queries/GetContactByIdQueryHandler");
const GetContactsByPageQueryHandler_1 = require("../Contact/queries/GetContactsByPageQueryHandler");
// Services
const JWTService_1 = require("./JWTService");
const ContactEmailService_1 = require("./ContactEmailService");
const DeckImportExportService_1 = require("./DeckImportExportService");
/**
* Central Dependency Injection Container
* Manages all repositories, command handlers, and query handlers as singletons
*/
class DIContainer {
constructor() {
// Repositories - Using interfaces for better abstraction
this._userRepository = null;
this._chatRepository = null;
this._chatArchiveRepository = null;
this._deckRepository = null;
this._organizationRepository = null;
this._contactRepository = null;
// Services
this._jwtService = null;
this._contactEmailService = null;
this._deckImportExportService = null;
// Command Handlers
this._createUserCommandHandler = null;
this._loginCommandHandler = null;
this._updateUserCommandHandler = null;
this._deactivateUserCommandHandler = null;
this._deleteUserCommandHandler = null;
this._verifyEmailCommandHandler = null;
this._requestPasswordResetCommandHandler = null;
this._resetPasswordCommandHandler = null;
this._createChatCommandHandler = null;
this._sendMessageCommandHandler = null;
this._archiveChatCommandHandler = null;
this._restoreChatCommandHandler = null;
this._createDeckCommandHandler = null;
this._updateDeckCommandHandler = null;
this._deleteDeckCommandHandler = null;
this._createOrganizationCommandHandler = null;
this._updateOrganizationCommandHandler = null;
this._deleteOrganizationCommandHandler = null;
this._processOrgAuthCallbackCommandHandler = null;
this._createContactCommandHandler = null;
this._updateContactCommandHandler = null;
this._deleteContactCommandHandler = null;
// Query Handlers
this._getUserByIdQueryHandler = null;
this._getUsersByPageQueryHandler = null;
this._getUserChatsQueryHandler = null;
this._getChatHistoryQueryHandler = null;
this._getArchivedChatsQueryHandler = null;
this._getChatsByPageQueryHandler = null;
this._getDeckByIdQueryHandler = null;
this._getDecksByPageQueryHandler = null;
this._getOrganizationByIdQueryHandler = null;
this._getOrganizationsByPageQueryHandler = null;
this._getOrganizationLoginUrlQueryHandler = null;
this._getContactByIdQueryHandler = null;
this._getContactsByPageQueryHandler = null;
}
static getInstance() {
if (!DIContainer.instance) {
DIContainer.instance = new DIContainer();
}
return DIContainer.instance;
}
// Repository getters - Return interfaces for better abstraction
get userRepository() {
if (!this._userRepository) {
this._userRepository = new UserRepository_1.UserRepository();
}
return this._userRepository;
}
get chatRepository() {
if (!this._chatRepository) {
this._chatRepository = new ChatRepository_1.ChatRepository();
}
return this._chatRepository;
}
get chatArchiveRepository() {
if (!this._chatArchiveRepository) {
this._chatArchiveRepository = new ChatArchiveRepository_1.ChatArchiveRepository();
}
return this._chatArchiveRepository;
}
get deckRepository() {
if (!this._deckRepository) {
this._deckRepository = new DeckRepository_1.DeckRepository();
}
return this._deckRepository;
}
get organizationRepository() {
if (!this._organizationRepository) {
this._organizationRepository = new OrganizationRepository_1.OrganizationRepository();
}
return this._organizationRepository;
}
get contactRepository() {
if (!this._contactRepository) {
this._contactRepository = new ContactRepository_1.ContactRepository();
}
return this._contactRepository;
}
// Services getters
get jwtService() {
if (!this._jwtService) {
this._jwtService = new JWTService_1.JWTService();
}
return this._jwtService;
}
get contactEmailService() {
if (!this._contactEmailService) {
this._contactEmailService = new ContactEmailService_1.ContactEmailService(this.contactRepository);
}
return this._contactEmailService;
}
get deckImportExportService() {
if (!this._deckImportExportService) {
this._deckImportExportService = new DeckImportExportService_1.DeckImportExportService(this.deckRepository);
}
return this._deckImportExportService;
}
// Command Handler getters
get createUserCommandHandler() {
if (!this._createUserCommandHandler) {
this._createUserCommandHandler = new CreateUserCommandHandler_1.CreateUserCommandHandler(this.userRepository);
}
return this._createUserCommandHandler;
}
get loginCommandHandler() {
if (!this._loginCommandHandler) {
this._loginCommandHandler = new LoginCommandHandler_1.LoginCommandHandler(this.userRepository, this.jwtService, this.organizationRepository);
}
return this._loginCommandHandler;
}
get updateUserCommandHandler() {
if (!this._updateUserCommandHandler) {
this._updateUserCommandHandler = new UpdateUserCommandHandler_1.UpdateUserCommandHandler(this.userRepository);
}
return this._updateUserCommandHandler;
}
get deactivateUserCommandHandler() {
if (!this._deactivateUserCommandHandler) {
this._deactivateUserCommandHandler = new DeactivateUserCommandHandler_1.DeactivateUserCommandHandler(this.userRepository);
}
return this._deactivateUserCommandHandler;
}
get deleteUserCommandHandler() {
if (!this._deleteUserCommandHandler) {
this._deleteUserCommandHandler = new DeleteUserCommandHandler_1.DeleteUserCommandHandler(this.userRepository);
}
return this._deleteUserCommandHandler;
}
get verifyEmailCommandHandler() {
if (!this._verifyEmailCommandHandler) {
this._verifyEmailCommandHandler = new VerifyEmailCommandHandler_1.VerifyEmailCommandHandler(this.userRepository);
}
return this._verifyEmailCommandHandler;
}
get requestPasswordResetCommandHandler() {
if (!this._requestPasswordResetCommandHandler) {
this._requestPasswordResetCommandHandler = new RequestPasswordResetCommandHandler_1.RequestPasswordResetCommandHandler(this.userRepository);
}
return this._requestPasswordResetCommandHandler;
}
get resetPasswordCommandHandler() {
if (!this._resetPasswordCommandHandler) {
this._resetPasswordCommandHandler = new ResetPasswordCommandHandler_1.ResetPasswordCommandHandler(this.userRepository);
}
return this._resetPasswordCommandHandler;
}
get createChatCommandHandler() {
if (!this._createChatCommandHandler) {
this._createChatCommandHandler = new CreateChatCommandHandler_1.CreateChatCommandHandler(this.chatRepository, this.userRepository);
}
return this._createChatCommandHandler;
}
get sendMessageCommandHandler() {
if (!this._sendMessageCommandHandler) {
this._sendMessageCommandHandler = new SendMessageCommandHandler_1.SendMessageCommandHandler(this.chatRepository);
}
return this._sendMessageCommandHandler;
}
get archiveChatCommandHandler() {
if (!this._archiveChatCommandHandler) {
this._archiveChatCommandHandler = new ChatArchiveCommandHandlers_1.ArchiveChatCommandHandler(this.chatRepository);
}
return this._archiveChatCommandHandler;
}
get restoreChatCommandHandler() {
if (!this._restoreChatCommandHandler) {
this._restoreChatCommandHandler = new ChatArchiveCommandHandlers_1.RestoreChatCommandHandler(this.chatRepository);
}
return this._restoreChatCommandHandler;
}
get createDeckCommandHandler() {
if (!this._createDeckCommandHandler) {
this._createDeckCommandHandler = new CreateDeckCommandHandler_1.CreateDeckCommandHandler(this.deckRepository, this.userRepository, this.organizationRepository);
}
return this._createDeckCommandHandler;
}
get updateDeckCommandHandler() {
if (!this._updateDeckCommandHandler) {
this._updateDeckCommandHandler = new UpdateDeckCommandHandler_1.UpdateDeckCommandHandler(this.deckRepository);
}
return this._updateDeckCommandHandler;
}
get deleteDeckCommandHandler() {
if (!this._deleteDeckCommandHandler) {
this._deleteDeckCommandHandler = new DeleteDeckCommandHandler_1.DeleteDeckCommandHandler(this.deckRepository);
}
return this._deleteDeckCommandHandler;
}
get createOrganizationCommandHandler() {
if (!this._createOrganizationCommandHandler) {
this._createOrganizationCommandHandler = new CreateOrganizationCommandHandler_1.CreateOrganizationCommandHandler(this.organizationRepository);
}
return this._createOrganizationCommandHandler;
}
get updateOrganizationCommandHandler() {
if (!this._updateOrganizationCommandHandler) {
this._updateOrganizationCommandHandler = new UpdateOrganizationCommandHandler_1.UpdateOrganizationCommandHandler(this.organizationRepository);
}
return this._updateOrganizationCommandHandler;
}
get deleteOrganizationCommandHandler() {
if (!this._deleteOrganizationCommandHandler) {
this._deleteOrganizationCommandHandler = new DeleteOrganizationCommandHandler_1.DeleteOrganizationCommandHandler(this.organizationRepository);
}
return this._deleteOrganizationCommandHandler;
}
get processOrgAuthCallbackCommandHandler() {
if (!this._processOrgAuthCallbackCommandHandler) {
this._processOrgAuthCallbackCommandHandler = new ProcessOrgAuthCallbackCommandHandler_1.ProcessOrgAuthCallbackCommandHandler(this.userRepository, this.organizationRepository);
}
return this._processOrgAuthCallbackCommandHandler;
}
get createContactCommandHandler() {
if (!this._createContactCommandHandler) {
this._createContactCommandHandler = new CreateContactCommandHandler_1.CreateContactCommandHandler(this.contactRepository);
}
return this._createContactCommandHandler;
}
get updateContactCommandHandler() {
if (!this._updateContactCommandHandler) {
this._updateContactCommandHandler = new UpdateContactCommandHandler_1.UpdateContactCommandHandler(this.contactRepository);
}
return this._updateContactCommandHandler;
}
get deleteContactCommandHandler() {
if (!this._deleteContactCommandHandler) {
this._deleteContactCommandHandler = new DeleteContactCommandHandler_1.DeleteContactCommandHandler(this.contactRepository);
}
return this._deleteContactCommandHandler;
}
// Query Handler getters
get getUserByIdQueryHandler() {
if (!this._getUserByIdQueryHandler) {
this._getUserByIdQueryHandler = new GetUserByIdQueryHandler_1.GetUserByIdQueryHandler(this.userRepository);
}
return this._getUserByIdQueryHandler;
}
get getUserChatsQueryHandler() {
if (!this._getUserChatsQueryHandler) {
this._getUserChatsQueryHandler = new GetUserChatsQueryHandler_1.GetUserChatsQueryHandler(this.chatRepository, this.chatArchiveRepository);
}
return this._getUserChatsQueryHandler;
}
get getChatHistoryQueryHandler() {
if (!this._getChatHistoryQueryHandler) {
this._getChatHistoryQueryHandler = new ChatHistoryQueryHandlers_1.GetChatHistoryQueryHandler(this.chatRepository, this.chatArchiveRepository);
}
return this._getChatHistoryQueryHandler;
}
get getArchivedChatsQueryHandler() {
if (!this._getArchivedChatsQueryHandler) {
this._getArchivedChatsQueryHandler = new ChatHistoryQueryHandlers_1.GetArchivedChatsQueryHandler(this.chatArchiveRepository);
}
return this._getArchivedChatsQueryHandler;
}
get getDeckByIdQueryHandler() {
if (!this._getDeckByIdQueryHandler) {
this._getDeckByIdQueryHandler = new GetDeckByIdQueryHandler_1.GetDeckByIdQueryHandler(this.deckRepository);
}
return this._getDeckByIdQueryHandler;
}
get getOrganizationByIdQueryHandler() {
if (!this._getOrganizationByIdQueryHandler) {
this._getOrganizationByIdQueryHandler = new GetOrganizationByIdQueryHandler_1.GetOrganizationByIdQueryHandler(this.organizationRepository);
}
return this._getOrganizationByIdQueryHandler;
}
get getOrganizationLoginUrlQueryHandler() {
if (!this._getOrganizationLoginUrlQueryHandler) {
this._getOrganizationLoginUrlQueryHandler = new GetOrganizationLoginUrlQueryHandler_1.GetOrganizationLoginUrlQueryHandler(this.organizationRepository);
}
return this._getOrganizationLoginUrlQueryHandler;
}
get getContactByIdQueryHandler() {
if (!this._getContactByIdQueryHandler) {
this._getContactByIdQueryHandler = new GetContactByIdQueryHandler_1.GetContactByIdQueryHandler(this.contactRepository);
}
return this._getContactByIdQueryHandler;
}
get getContactsByPageQueryHandler() {
if (!this._getContactsByPageQueryHandler) {
this._getContactsByPageQueryHandler = new GetContactsByPageQueryHandler_1.GetContactsByPageQueryHandler(this.contactRepository);
}
return this._getContactsByPageQueryHandler;
}
// New paginated query handlers
get getUsersByPageQueryHandler() {
if (!this._getUsersByPageQueryHandler) {
this._getUsersByPageQueryHandler = new GetUsersByPageQueryHandler_1.GetUsersByPageQueryHandler(this.userRepository);
}
return this._getUsersByPageQueryHandler;
}
get getDecksByPageQueryHandler() {
if (!this._getDecksByPageQueryHandler) {
this._getDecksByPageQueryHandler = new GetDecksByPageQueryHandler_1.GetDecksByPageQueryHandler(this.deckRepository);
}
return this._getDecksByPageQueryHandler;
}
get getOrganizationsByPageQueryHandler() {
if (!this._getOrganizationsByPageQueryHandler) {
this._getOrganizationsByPageQueryHandler = new GetOrganizationsByPageQueryHandler_1.GetOrganizationsByPageQueryHandler(this.organizationRepository);
}
return this._getOrganizationsByPageQueryHandler;
}
get getChatsByPageQueryHandler() {
if (!this._getChatsByPageQueryHandler) {
this._getChatsByPageQueryHandler = new GetChatsByPageQueryHandler_1.GetChatsByPageQueryHandler(this.chatRepository);
}
return this._getChatsByPageQueryHandler;
}
}
exports.DIContainer = DIContainer;
// Export singleton instance
exports.container = DIContainer.getInstance();
//# sourceMappingURL=DIContainer.js.map