Better ioctopus type-safety (#23541)
This commit is contained in:
@@ -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,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";
|
||||
|
||||
+5
-4
@@ -1,9 +1,10 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import type { InstantBookingCreateService } from "../modules/InstantBookingCreateServiceModule";
|
||||
import { instantBookingCreateServiceModule } from "../modules/InstantBookingCreateServiceModule";
|
||||
import { createContainer } from "../../di";
|
||||
import {
|
||||
type InstantBookingCreateService,
|
||||
instantBookingCreateServiceModule,
|
||||
} from "../modules/InstantBookingCreateService.module";
|
||||
|
||||
const container = createContainer();
|
||||
container.load(DI_TOKENS.INSTANT_BOOKING_CREATE_SERVICE_MODULE, instantBookingCreateServiceModule);
|
||||
+5
-4
@@ -1,5 +1,3 @@
|
||||
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";
|
||||
@@ -8,8 +6,11 @@ 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";
|
||||
import { createContainer } from "../../di";
|
||||
import {
|
||||
type RecurringBookingService,
|
||||
recurringBookingServiceModule,
|
||||
} from "../modules/RecurringBookingService.module";
|
||||
|
||||
const container = createContainer();
|
||||
container.load(DI_TOKENS.PRISMA_MODULE, prismaModule);
|
||||
@@ -0,0 +1,13 @@
|
||||
import { createContainer } from "../../di";
|
||||
import {
|
||||
type RegularBookingService,
|
||||
regularBookingServiceModule,
|
||||
} from "../modules/RegularBookingService.module";
|
||||
|
||||
const regularBookingServiceContainer = createContainer();
|
||||
|
||||
export function getRegularBookingService(): RegularBookingService {
|
||||
regularBookingServiceModule.loadModule(regularBookingServiceContainer);
|
||||
|
||||
return regularBookingServiceContainer.get<RegularBookingService>(regularBookingServiceModule.token);
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { InstantBookingCreateService } from "@calcom/features/instant-meeting/handleInstantMeeting";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import { createModule } from "../../di";
|
||||
|
||||
export const instantBookingCreateServiceModule = createModule();
|
||||
|
||||
instantBookingCreateServiceModule
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { RecurringBookingService } from "@calcom/features/bookings/lib/handleNewRecurringBooking";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import { RecurringBookingService } from "../../handleNewRecurringBooking";
|
||||
import { createModule } from "../../di";
|
||||
|
||||
export const recurringBookingServiceModule = createModule();
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { RegularBookingService } from "@calcom/features/bookings/lib/handleNewBooking";
|
||||
import { moduleLoader as bookingRepositoryModuleLoader } from "@calcom/lib/di/modules/Booking";
|
||||
import { moduleLoader as cacheModuleLoader } from "@calcom/lib/di/modules/Cache";
|
||||
import { moduleLoader as checkBookingAndDurationLimitsModuleLoader } from "@calcom/lib/di/modules/CheckBookingAndDurationLimits";
|
||||
import { moduleLoader as checkBookingLimitsModuleLoader } from "@calcom/lib/di/modules/CheckBookingLimits";
|
||||
import { moduleLoader as featuresRepositoryModuleLoader } from "@calcom/lib/di/modules/Features";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { moduleLoader as prismaModuleLoader } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import { bindModuleToClassOnToken, createModule } from "../../di";
|
||||
|
||||
const thisModule = createModule();
|
||||
const token = DI_TOKENS.REGULAR_BOOKING_SERVICE;
|
||||
const moduleToken = DI_TOKENS.REGULAR_BOOKING_SERVICE_MODULE;
|
||||
const loadModule = bindModuleToClassOnToken({
|
||||
module: thisModule,
|
||||
moduleToken,
|
||||
token,
|
||||
classs: RegularBookingService,
|
||||
depsMap: {
|
||||
cacheService: cacheModuleLoader,
|
||||
checkBookingAndDurationLimitsService: checkBookingAndDurationLimitsModuleLoader,
|
||||
prismaClient: prismaModuleLoader,
|
||||
bookingRepository: bookingRepositoryModuleLoader,
|
||||
featuresRepository: featuresRepositoryModuleLoader,
|
||||
checkBookingLimitsService: checkBookingLimitsModuleLoader,
|
||||
},
|
||||
});
|
||||
|
||||
export const regularBookingServiceModule = {
|
||||
token,
|
||||
loadModule,
|
||||
};
|
||||
|
||||
export type { RegularBookingService };
|
||||
@@ -0,0 +1,8 @@
|
||||
export const BOOKING_DI_TOKENS = {
|
||||
REGULAR_BOOKING_SERVICE: Symbol("RegularBookingService"),
|
||||
REGULAR_BOOKING_SERVICE_MODULE: Symbol("RegularBookingServiceModule"),
|
||||
RECURRING_BOOKING_SERVICE: Symbol("RecurringBookingService"),
|
||||
RECURRING_BOOKING_SERVICE_MODULE: Symbol("RecurringBookingServiceModule"),
|
||||
INSTANT_BOOKING_CREATE_SERVICE: Symbol("InstantBookingCreateService"),
|
||||
INSTANT_BOOKING_CREATE_SERVICE_MODULE: Symbol("InstantBookingCreateServiceModule"),
|
||||
};
|
||||
@@ -1,10 +1,9 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { redisModule } from "@calcom/features/redis/di/redisModule";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
import type { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
|
||||
import { createContainer } from "../di";
|
||||
import { availableSlotsModule } from "../modules/AvailableSlots";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
import { busyTimesModule } from "../modules/BusyTimes";
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import type { CheckBookingAndDurationLimitsService } from "../../../features/bookings/lib/handleNewBooking/checkBookingAndDurationLimits";
|
||||
import type { CheckBookingLimitsService } from "../../intervalLimits/server/checkBookingLimits";
|
||||
import { createContainer } from "../di";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
import { checkBookingAndDurationLimitsModule } from "../modules/CheckBookingAndDurationLimits";
|
||||
import { checkBookingLimitsModule } from "../modules/CheckBookingLimits";
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import type { BusyTimesService } from "../../getBusyTimes";
|
||||
import { createContainer } from "../di";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
import { busyTimesModule } from "../modules/BusyTimes";
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import type { CacheService } from "../../../features/calendar-cache/lib/getShouldServeCache";
|
||||
import { createContainer } from "../di";
|
||||
import { cacheModule } from "../modules/Cache";
|
||||
import { featuresRepositoryModule } from "../modules/Features";
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import type { FilterHostsService } from "../../bookings/filterHostsBySameRoundRobinHost";
|
||||
import { createContainer } from "../di";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
import { filterHostsModule } from "../modules/FilterHosts";
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { redisModule } from "@calcom/features/redis/di/redisModule";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import type { UserAvailabilityService } from "../../getUserAvailability";
|
||||
import { createContainer } from "../di";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
import { busyTimesModule } from "../modules/BusyTimes";
|
||||
import { eventTypeRepositoryModule } from "../modules/EventType";
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import type {
|
||||
InsightsBookingServicePublicOptions,
|
||||
@@ -9,6 +7,7 @@ import type {
|
||||
import type { InsightsBookingService } from "@calcom/lib/server/service/InsightsBookingDIService";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import { createContainer } from "../di";
|
||||
import { insightsBookingModule } from "../modules/InsightsBooking";
|
||||
|
||||
export function getInsightsBookingService({
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import type {
|
||||
InsightsRoutingServicePublicOptions,
|
||||
@@ -9,6 +7,7 @@ import type {
|
||||
import type { InsightsRoutingService } from "@calcom/lib/server/service/InsightsRoutingDIService";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import { createContainer } from "../di";
|
||||
import { insightsRoutingModule } from "../modules/InsightsRouting";
|
||||
|
||||
export function getInsightsRoutingService({
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import type { LuckyUserService } from "@calcom/lib/server/getLuckyUser";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import { createContainer } from "../di";
|
||||
import { attributeRepositoryModule } from "../modules/Attribute";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
import { hostRepositoryModule } from "../modules/Host";
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { redisModule } from "@calcom/features/redis/di/redisModule";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
import type { NoSlotsNotificationService } from "@calcom/trpc/server/routers/viewer/slots/handleNotificationWhenNoSlots";
|
||||
|
||||
import { createContainer } from "../di";
|
||||
import { membershipRepositoryModule } from "../modules/Membership";
|
||||
import { noSlotsNotificationModule } from "../modules/NoSlotsNotification";
|
||||
import { teamRepositoryModule } from "../modules/Team";
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createContainer } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { prismaModule } from "@calcom/prisma/prisma.module";
|
||||
|
||||
import type { QualifiedHostsService } from "../../bookings/findQualifiedHostsWithDelegationCredentials";
|
||||
import { createContainer } from "../di";
|
||||
import { bookingRepositoryModule } from "../modules/Booking";
|
||||
import { filterHostsModule } from "../modules/FilterHosts";
|
||||
import { qualifiedHostsModule } from "../modules/QualifiedHosts";
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { Container, Module } from "@evyweb/ioctopus";
|
||||
import { createContainer, createModule } from "@evyweb/ioctopus";
|
||||
|
||||
/**
|
||||
* A type-safe alternative to module.bind(token).toClass(classs, deps) that automatically ensures that all dependencies required by the Class are provided.
|
||||
* It assumes that dependencies are stored under the `deps` property of the Class, which is a good convention to follow anyway
|
||||
*
|
||||
* @returns A function that can be used to load the dependencies into the container automatically.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function bindModuleToClassOnToken<TClass extends new (...args: any[]) => any>({
|
||||
module,
|
||||
token,
|
||||
classs,
|
||||
depsMap,
|
||||
moduleToken,
|
||||
}: {
|
||||
module: Module;
|
||||
moduleToken: string | symbol;
|
||||
token: string | symbol;
|
||||
classs: TClass;
|
||||
depsMap: Record<
|
||||
keyof InstanceType<TClass>["deps"],
|
||||
{ token: string | symbol; loadModule: (container: Container) => void }
|
||||
>;
|
||||
}) {
|
||||
const depsObject = Object.fromEntries(Object.entries(depsMap).map(([key, value]) => [key, value.token]));
|
||||
module.bind(token).toClass(classs, depsObject);
|
||||
|
||||
return function loadModule(container: Container) {
|
||||
container.load(moduleToken, module);
|
||||
for (const key in depsMap) {
|
||||
const loadModule = depsMap[key as keyof typeof depsMap].loadModule;
|
||||
loadModule(container);
|
||||
}
|
||||
};
|
||||
}
|
||||
export { createContainer, createModule, type Container, type Module };
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { PrismaAttributeRepository } from "@calcom/lib/server/repository/PrismaAttributeRepository";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const attributeRepositoryModule = createModule();
|
||||
attributeRepositoryModule
|
||||
.bind(DI_TOKENS.ATTRIBUTE_REPOSITORY)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { IAvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
import { AvailableSlotsService } from "@calcom/trpc/server/routers/viewer/slots/util";
|
||||
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const availableSlotsModule = createModule();
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { BookingRepository } from "@calcom/lib/server/repository/booking";
|
||||
|
||||
import { type Container, createModule } from "../di";
|
||||
|
||||
export const bookingRepositoryModule = createModule();
|
||||
bookingRepositoryModule
|
||||
.bind(DI_TOKENS.BOOKING_REPOSITORY)
|
||||
.toClass(BookingRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
const token = DI_TOKENS.BOOKING_REPOSITORY;
|
||||
const moduleToken = DI_TOKENS.BOOKING_REPOSITORY_MODULE;
|
||||
bookingRepositoryModule.bind(token).toClass(BookingRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
|
||||
export const moduleLoader = {
|
||||
token,
|
||||
loadModule: function (container: Container) {
|
||||
container.load(moduleToken, bookingRepositoryModule);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { IBusyTimesService } from "../../getBusyTimes";
|
||||
import { BusyTimesService } from "../../getBusyTimes";
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const busyTimesModule = createModule();
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { ICacheService } from "@calcom/features/calendar-cache/lib/getShouldServeCache";
|
||||
import { CacheService } from "@calcom/features/calendar-cache/lib/getShouldServeCache";
|
||||
|
||||
import { type Container, createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const cacheModule = createModule();
|
||||
cacheModule.bind(DI_TOKENS.CACHE_SERVICE).toClass(CacheService, {
|
||||
const token = DI_TOKENS.CACHE_SERVICE;
|
||||
const moduleToken = DI_TOKENS.CACHE_SERVICE_MODULE;
|
||||
cacheModule.bind(token).toClass(CacheService, {
|
||||
featuresRepository: DI_TOKENS.FEATURES_REPOSITORY,
|
||||
} satisfies Record<keyof ICacheService, symbol>);
|
||||
|
||||
export const moduleLoader = {
|
||||
token,
|
||||
loadModule: (container: Container) => {
|
||||
container.load(moduleToken, cacheModule);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { ICheckBookingAndDurationLimitsService } from "@calcom/features/bookings/lib/handleNewBooking/checkBookingAndDurationLimits";
|
||||
import { CheckBookingAndDurationLimitsService } from "@calcom/features/bookings/lib/handleNewBooking/checkBookingAndDurationLimits";
|
||||
|
||||
import { type Container, createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const checkBookingAndDurationLimitsModule = createModule();
|
||||
checkBookingAndDurationLimitsModule
|
||||
.bind(DI_TOKENS.CHECK_BOOKING_AND_DURATION_LIMITS_SERVICE)
|
||||
.toClass(CheckBookingAndDurationLimitsService, {
|
||||
checkBookingLimitsService: DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE,
|
||||
} satisfies Record<keyof ICheckBookingAndDurationLimitsService, symbol>);
|
||||
const token = DI_TOKENS.CHECK_BOOKING_AND_DURATION_LIMITS_SERVICE;
|
||||
const moduleToken = DI_TOKENS.CHECK_BOOKING_AND_DURATION_LIMITS_SERVICE_MODULE;
|
||||
checkBookingAndDurationLimitsModule.bind(token).toClass(CheckBookingAndDurationLimitsService, {
|
||||
checkBookingLimitsService: DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE,
|
||||
} satisfies Record<keyof ICheckBookingAndDurationLimitsService, symbol>);
|
||||
|
||||
export const moduleLoader = {
|
||||
token,
|
||||
loadModule: (container: Container) => {
|
||||
container.load(moduleToken, checkBookingAndDurationLimitsModule);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { CheckBookingLimitsService } from "@calcom/lib/intervalLimits/server/checkBookingLimits";
|
||||
|
||||
import { type Container, createModule } from "../di";
|
||||
|
||||
const token = DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE;
|
||||
const moduleToken = DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE_MODULE;
|
||||
export const checkBookingLimitsModule = createModule();
|
||||
checkBookingLimitsModule
|
||||
.bind(DI_TOKENS.CHECK_BOOKING_LIMITS_SERVICE)
|
||||
.bind(token)
|
||||
.toClass(CheckBookingLimitsService, { bookingRepo: DI_TOKENS.BOOKING_REPOSITORY });
|
||||
|
||||
export const moduleLoader = {
|
||||
token,
|
||||
loadModule: (container: Container) => {
|
||||
container.load(moduleToken, checkBookingLimitsModule);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { EventTypeRepository } from "@calcom/lib/server/repository/eventTypeRepository";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const eventTypeRepositoryModule = createModule();
|
||||
eventTypeRepositoryModule
|
||||
.bind(DI_TOKENS.EVENT_TYPE_REPOSITORY)
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import { type Container, createModule } from "../di";
|
||||
|
||||
export const featuresRepositoryModule = createModule();
|
||||
featuresRepositoryModule
|
||||
.bind(DI_TOKENS.FEATURES_REPOSITORY)
|
||||
.toClass(FeaturesRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
const token = DI_TOKENS.FEATURES_REPOSITORY;
|
||||
const moduleToken = DI_TOKENS.FEATURES_REPOSITORY_MODULE;
|
||||
featuresRepositoryModule.bind(token).toClass(FeaturesRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
|
||||
export const moduleLoader = {
|
||||
token,
|
||||
loadModule: (container: Container) => {
|
||||
container.load(moduleToken, featuresRepositoryModule);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { IFilterHostsService } from "../../bookings/filterHostsBySameRoundRobinHost";
|
||||
import { FilterHostsService } from "../../bookings/filterHostsBySameRoundRobinHost";
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const filterHostsModule = createModule();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { IUserAvailabilityService } from "../../getUserAvailability";
|
||||
import { UserAvailabilityService } from "../../getUserAvailability";
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const getUserAvailabilityModule = createModule();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { HostRepository } from "@calcom/lib/server/repository/host";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const hostRepositoryModule = createModule();
|
||||
hostRepositoryModule.bind(DI_TOKENS.HOST_REPOSITORY).toClass(HostRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { IInsightsBookingService } from "@calcom/lib/server/service/InsightsBookingDIService";
|
||||
import { InsightsBookingService } from "@calcom/lib/server/service/InsightsBookingDIService";
|
||||
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const insightsBookingModule = createModule();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { IInsightsRoutingService } from "@calcom/lib/server/service/InsightsRoutingDIService";
|
||||
import { InsightsRoutingService } from "@calcom/lib/server/service/InsightsRoutingDIService";
|
||||
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const insightsRoutingModule = createModule();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { LuckyUserService } from "@calcom/lib/server/getLuckyUser";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const luckyUserServiceModule = createModule();
|
||||
luckyUserServiceModule.bind(DI_TOKENS.LUCKY_USER_SERVICE).toClass(LuckyUserService, {
|
||||
bookingRepository: DI_TOKENS.BOOKING_REPOSITORY,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { MembershipRepository } from "@calcom/lib/server/repository/membership";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const membershipRepositoryModule = createModule();
|
||||
membershipRepositoryModule
|
||||
.bind(DI_TOKENS.MEMBERSHIP_REPOSITORY)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { INoSlotsNotificationService } from "@calcom/trpc/server/routers/viewer/slots/handleNotificationWhenNoSlots";
|
||||
import { NoSlotsNotificationService } from "@calcom/trpc/server/routers/viewer/slots/handleNotificationWhenNoSlots";
|
||||
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const noSlotsNotificationModule = createModule();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { PrismaOOORepository } from "@calcom/lib/server/repository/ooo";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const oooRepositoryModule = createModule();
|
||||
oooRepositoryModule.bind(DI_TOKENS.OOO_REPOSITORY).toClass(PrismaOOORepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import type { IQualifiedHostsService } from "../../bookings/findQualifiedHostsWithDelegationCredentials";
|
||||
import { QualifiedHostsService } from "../../bookings/findQualifiedHostsWithDelegationCredentials";
|
||||
import { createModule } from "../di";
|
||||
import { DI_TOKENS } from "../tokens";
|
||||
|
||||
export const qualifiedHostsModule = createModule();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { RoutingFormResponseRepository } from "@calcom/lib/server/repository/formResponse";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const routingFormResponseRepositoryModule = createModule();
|
||||
routingFormResponseRepositoryModule
|
||||
.bind(DI_TOKENS.ROUTING_FORM_RESPONSE_REPOSITORY)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { ScheduleRepository } from "@calcom/lib/server/repository/schedule";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const scheduleRepositoryModule = createModule();
|
||||
scheduleRepositoryModule
|
||||
.bind(DI_TOKENS.SCHEDULE_REPOSITORY)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { PrismaSelectedSlotRepository } from "@calcom/lib/server/repository/PrismaSelectedSlotRepository";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const selectedSlotsRepositoryModule = createModule();
|
||||
selectedSlotsRepositoryModule
|
||||
.bind(DI_TOKENS.SELECTED_SLOT_REPOSITORY)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { TeamRepository } from "@calcom/lib/server/repository/team";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const teamRepositoryModule = createModule();
|
||||
teamRepositoryModule.bind(DI_TOKENS.TEAM_REPOSITORY).toClass(TeamRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
import { UserRepository } from "@calcom/lib/server/repository/user";
|
||||
|
||||
import { createModule } from "../di";
|
||||
|
||||
export const userRepositoryModule = createModule();
|
||||
userRepositoryModule.bind(DI_TOKENS.USER_REPOSITORY).toClass(UserRepository, [DI_TOKENS.PRISMA_CLIENT]);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { BOOKING_DI_TOKENS } from "./bookings/tokens";
|
||||
|
||||
export const DI_TOKENS = {
|
||||
PRISMA_CLIENT: Symbol("PrismaClient"),
|
||||
READ_ONLY_PRISMA_CLIENT: Symbol("ReadOnlyPrismaClient"),
|
||||
@@ -51,10 +53,6 @@ export const DI_TOKENS = {
|
||||
HOST_REPOSITORY_MODULE: Symbol("HostRepositoryModule"),
|
||||
ATTRIBUTE_REPOSITORY: Symbol("AttributeRepository"),
|
||||
ATTRIBUTE_REPOSITORY_MODULE: Symbol("AttributeRepositoryModule"),
|
||||
REGULAR_BOOKING_SERVICE: Symbol("RegularBookingService"),
|
||||
REGULAR_BOOKING_SERVICE_MODULE: Symbol("RegularBookingServiceModule"),
|
||||
RECURRING_BOOKING_SERVICE: Symbol("RecurringBookingService"),
|
||||
RECURRING_BOOKING_SERVICE_MODULE: Symbol("RecurringBookingServiceModule"),
|
||||
INSTANT_BOOKING_CREATE_SERVICE: Symbol("InstantBookingCreateService"),
|
||||
INSTANT_BOOKING_CREATE_SERVICE_MODULE: Symbol("InstantBookingCreateServiceModule"),
|
||||
// Booking service tokens
|
||||
...BOOKING_DI_TOKENS,
|
||||
};
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import { createModule } from "@evyweb/ioctopus";
|
||||
|
||||
import { type Container, createModule } from "@calcom/lib/di/di";
|
||||
import { DI_TOKENS } from "@calcom/lib/di/tokens";
|
||||
|
||||
import { prisma, readonlyPrisma } from "./index";
|
||||
|
||||
export const prismaModule = createModule();
|
||||
const token = DI_TOKENS.PRISMA_CLIENT;
|
||||
const readOnlyToken = DI_TOKENS.READ_ONLY_PRISMA_CLIENT;
|
||||
const moduleToken = DI_TOKENS.PRISMA_MODULE;
|
||||
prismaModule.bind(token).toFactory(() => prisma, "singleton");
|
||||
prismaModule.bind(readOnlyToken).toFactory(() => readonlyPrisma, "singleton");
|
||||
|
||||
prismaModule.bind(DI_TOKENS.PRISMA_CLIENT).toFactory(() => prisma, "singleton");
|
||||
|
||||
prismaModule.bind(DI_TOKENS.READ_ONLY_PRISMA_CLIENT).toFactory(() => readonlyPrisma, "singleton");
|
||||
export const moduleLoader = {
|
||||
token,
|
||||
readOnlyToken,
|
||||
loadModule: (container: Container) => {
|
||||
container.load(moduleToken, prismaModule);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user