* --init * -- * replace old structure with new DI * fix type * -- * moving stuff around * moving stuff around again * minor clean up * -- * resolve conflict * clea up * old schema clean up * further clean up * removing unwanted merged responsibilities * -- * improve DI and SOLID * some type fixes * --1 * clean up --cont * fix DI in facade for test * more fix * fix * checking * o.o * fix import * fix failing test --2 * fix failing test --3 * fix failing test --4 * normalization use * introduce facade container injection * uniform async telemetry spans * further improvements * replace prismock with repo mocks * ensure we don't pass prisma outside of repo * fix import * remove try catch from repo calls * async await fixes * using deps pattern * more clean up and fixes * more clean up * address feedback --1 * separation of concern * clean up * test clean up * feedback --2 * remove extra fetch * remove await * migrate _post test from prismock * fix type * -- * fix tokens path * rename AuditRepo * test --1 * update _post to integration test * fix test * fix test * test fix maybe? * -- * feedback * feedback * fixes * more feedback * NIT * use sentry and logger imports as planned * assertion in test * add missing test case * add tests for controllers and services * NITs * fix domain normalisation
48 lines
2.0 KiB
TypeScript
48 lines
2.0 KiB
TypeScript
import type { Container } from "@evyweb/ioctopus";
|
|
|
|
import { WATCHLIST_DI_TOKENS } from "@calcom/features/di/watchlist/Watchlist.tokens";
|
|
import logger from "@calcom/lib/logger";
|
|
|
|
import type { IAuditRepository } from "../interface/IAuditRepository";
|
|
import type {
|
|
IGlobalWatchlistRepository,
|
|
IOrganizationWatchlistRepository,
|
|
} from "../interface/IWatchlistRepositories";
|
|
import { GlobalBlockingService } from "../service/GlobalBlockingService";
|
|
import { OrganizationBlockingService } from "../service/OrganizationBlockingService";
|
|
import { WatchlistAuditService } from "../service/WatchlistAuditService";
|
|
import { WatchlistService } from "../service/WatchlistService";
|
|
|
|
export interface WatchlistFeature {
|
|
/** Global blocking service - handles global watchlist entries only */
|
|
globalBlocking: GlobalBlockingService;
|
|
/** Organization blocking service - handles org-specific entries only */
|
|
orgBlocking: OrganizationBlockingService;
|
|
/** Watchlist CRUD service - manages watchlist entries */
|
|
watchlist: WatchlistService;
|
|
/** Audit service - logs blocking attempts and decisions */
|
|
audit: WatchlistAuditService;
|
|
}
|
|
|
|
export function createWatchlistFeature(container: Container): WatchlistFeature {
|
|
// Get repositories from container
|
|
const globalRepo = container.get<IGlobalWatchlistRepository>(
|
|
WATCHLIST_DI_TOKENS.GLOBAL_WATCHLIST_REPOSITORY
|
|
);
|
|
const orgRepo = container.get<IOrganizationWatchlistRepository>(
|
|
WATCHLIST_DI_TOKENS.ORGANIZATION_WATCHLIST_REPOSITORY
|
|
);
|
|
const auditRepo = container.get<IAuditRepository>(WATCHLIST_DI_TOKENS.AUDIT_REPOSITORY);
|
|
|
|
// Create sub-loggers for each service
|
|
const watchlistLogger = logger.getSubLogger({ prefix: ["[WatchlistService]"] });
|
|
|
|
// Create services with Deps pattern
|
|
return {
|
|
globalBlocking: new GlobalBlockingService({ globalRepo }),
|
|
orgBlocking: new OrganizationBlockingService({ orgRepo }),
|
|
watchlist: new WatchlistService({ globalRepo, orgRepo, logger: watchlistLogger }),
|
|
audit: new WatchlistAuditService({ auditRepository: auditRepo }),
|
|
};
|
|
}
|