Better ioctopus type-safety (#23541)
This commit is contained in:
1 parent
13add03479
commit
b9074aeb81
48 files changed
+227
-168
No files matched your search
@@ -1,13 +0,0 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import type { InstantBookingCreateService } from "../modules/InstantBookingCreateServiceModule";
|
||||
import { instantBookingCreateServiceModule } from "../modules/InstantBookingCreateServiceModule";
|
||||
|
||||
const container = createContainer();
|
||||
container.load(DI_TOKENS.INSTANT_BOOKING_CREATE_SERVICE_MODULE, instantBookingCreateServiceModule);
|
||||
|
||||
export function getInstantBookingCreateService(): InstantBookingCreateService {
|
||||
return container.get<InstantBookingCreateService>(DI_TOKENS.INSTANT_BOOKING_CREATE_SERVICE);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { bookingRepositoryModule } from "@calcom/lib/di/modules/Booking";
|
||||
import { cacheModule } from "@calcom/lib/di/modules/Cache";
|
||||
import { checkBookingAndDurationLimitsModule } from "@calcom/lib/di/modules/CheckBookingAndDurationLimits";
|
||||
import { checkBookingLimitsModule } from "@calcom/lib/di/modules/CheckBookingLimits";
|
||||
import { featuresRepositoryModule } from "@calcom/lib/di/modules/Features";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import type { RecurringBookingService } from "../modules/RecurringBookingServiceModule";
|
||||
import { recurringBookingServiceModule } from "../modules/RecurringBookingServiceModule";
|
||||
|
||||
const container = createContainer();
|
||||
container.load(DI_TOKENS.PRISMA_MODULE, prismaModule);
|
||||
container.load(DI_TOKENS.BOOKING_REPOSITORY_MODULE, bookingRepositoryModule);
|
||||
container.load(DI_TOKENS.CACHE_SERVICE_MODULE, cacheModule);
|
||||
container.load(DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE_MODULE, checkBookingLimitsModule);
|
||||
container.load(DI_TOKENS.FEATURES_REPOSITORY_MODULE, featuresRepositoryModule);
|
||||
container.load(
|
||||
DI_TOKENS.CHECK_BOOKING_AND_DURATION_LIMITS_SERVICE_MODULE,
|
||||
checkBookingAndDurationLimitsModule
|
||||
);
|
||||
container.load(DI_TOKENS.RECURRING_BOOKING_SERVICE_MODULE, recurringBookingServiceModule);
|
||||
|
||||
export function getRecurringBookingService(): RecurringBookingService {
|
||||
return container.get<RecurringBookingService>(DI_TOKENS.RECURRING_BOOKING_SERVICE);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import type { RegularBookingService } from "../modules/RegularBookingServiceModule";
|
||||
import {
|
||||
regularBookingServiceModule,
|
||||
loadModuleDeps,
|
||||
moduleToken,
|
||||
} from "../modules/RegularBookingServiceModule";
|
||||
|
||||
const regularBookingServiceContainer = createContainer();
|
||||
|
||||
regularBookingServiceContainer.load(DI_TOKENS.REGULAR_BOOKING_SERVICE_MODULE, regularBookingServiceModule);
|
||||
|
||||
export function getRegularBookingService(): RegularBookingService {
|
||||
loadModuleDeps(regularBookingServiceContainer);
|
||||
|
||||
return regularBookingServiceContainer.get<RegularBookingService>(moduleToken);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { InstantBookingCreateService } from "@calcom/features/instant-meeting/handleInstantMeeting";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
export const instantBookingCreateServiceModule = createModule();
|
||||
|
||||
instantBookingCreateServiceModule
|
||||
.bind(DI_TOKENS.INSTANT_BOOKING_CREATE_SERVICE)
|
||||
.toClass(InstantBookingCreateService);
|
||||
export type { InstantBookingCreateService };
|
||||
@@ -1,13 +0,0 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import { RecurringBookingService } from "../../handleNewRecurringBooking";
|
||||
|
||||
export const recurringBookingServiceModule = createModule();
|
||||
|
||||
recurringBookingServiceModule.bind(DI_TOKENS.RECURRING_BOOKING_SERVICE).toClass(RecurringBookingService, {
|
||||
regularBookingService: DI_TOKENS.REGULAR_BOOKING_SERVICE,
|
||||
});
|
||||
|
||||
export type { RecurringBookingService };
|
||||
@@ -1,39 +0,0 @@
|
||||
import type { Container } from "@evyweb/ioctopus";
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { bookingRepositoryModule } from "@calcom/lib/di/modules/Booking";
|
||||
import { cacheModule } from "@calcom/lib/di/modules/Cache";
|
||||
import { checkBookingAndDurationLimitsModule } from "@calcom/lib/di/modules/CheckBookingAndDurationLimits";
|
||||
import { checkBookingLimitsModule } from "@calcom/lib/di/modules/CheckBookingLimits";
|
||||
import { featuresRepositoryModule } from "@calcom/lib/di/modules/Features";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import { RegularBookingService } from "../../handleNewBooking";
|
||||
|
||||
export const regularBookingServiceModule = createModule();
|
||||
const moduleToken = DI_TOKENS.REGULAR_BOOKING_SERVICE;
|
||||
regularBookingServiceModule.bind(moduleToken).toClass(RegularBookingService, {
|
||||
cacheService: DI_TOKENS.CACHE_SERVICE,
|
||||
checkBookingAndDurationLimitsService: DI_TOKENS.CHECK_BOOKING_AND_DURATION_LIMITS_SERVICE,
|
||||
prismaClient: DI_TOKENS.PRISMA_CLIENT,
|
||||
bookingRepository: DI_TOKENS.BOOKING_REPOSITORY,
|
||||
featuresRepository: DI_TOKENS.FEATURES_REPOSITORY,
|
||||
checkBookingLimitsService: DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE,
|
||||
});
|
||||
|
||||
// Load the dependencies defined for the module above
|
||||
function loadModuleDeps(container: Container) {
|
||||
container.load(DI_TOKENS.CACHE_SERVICE_MODULE, cacheModule);
|
||||
container.load(
|
||||
DI_TOKENS.CHECK_BOOKING_AND_DURATION_LIMITS_SERVICE_MODULE,
|
||||
checkBookingAndDurationLimitsModule
|
||||
);
|
||||
container.load(DI_TOKENS.PRISMA_MODULE, prismaModule);
|
||||
container.load(DI_TOKENS.BOOKING_REPOSITORY_MODULE, bookingRepositoryModule);
|
||||
container.load(DI_TOKENS.FEATURES_REPOSITORY_MODULE, featuresRepositoryModule);
|
||||
container.load(DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE_MODULE, checkBookingLimitsModule);
|
||||
}
|
||||
|
||||
export { loadModuleDeps, moduleToken };
|
||||
export type { RegularBookingService };
|
||||
@@ -1,5 +1,4 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { createModule } from "@calcom/lib/di/di";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import { NoopRedisService } from "../NoopRedisService";
|
||||
|
||||
Reference in new issue
Block a user