Files
calendar/packages/features/watchlist/lib/interface/IWatchlistRepositories.ts
T
Syed Ali ShahbazandGitHub a2bee76da6 feat: Add spam blocker DI structure (#24040)
* --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
2025-10-14 10:16:18 +03:00

80 lines
2.1 KiB
TypeScript

import type { Watchlist } from "@calcom/prisma/client";
import type { WatchlistAction, WatchlistSource, WatchlistType } from "../types";
/**
* Interface for Global Watchlist Repository
* Follows Dependency Inversion Principle
*/
export interface IGlobalWatchlistRepository {
findBlockedEmail(email: string): Promise<Watchlist | null>;
findBlockedDomain(domain: string): Promise<Watchlist | null>;
findFreeEmailDomain(domain: string): Promise<Watchlist | null>;
findById(id: string): Promise<Watchlist | null>;
listBlockedEntries(): Promise<Watchlist[]>;
// Write operations
createEntry(data: {
type: WatchlistType;
value: string;
description?: string;
action: WatchlistAction;
source?: WatchlistSource;
}): Promise<Watchlist>;
updateEntry(
id: string,
data: {
value?: string;
description?: string;
action?: WatchlistAction;
source?: WatchlistSource;
}
): Promise<Watchlist>;
deleteEntry(id: string): Promise<void>;
}
/**
* Interface for Organization Watchlist Repository
* Follows Dependency Inversion Principle
*/
export interface IOrganizationWatchlistRepository {
findBlockedEmail({
email,
organizationId,
}: {
email: string;
organizationId: number;
}): Promise<Watchlist | null>;
findBlockedDomain(domain: string, organizationId: number): Promise<Watchlist | null>;
findById(id: string, organizationId: number): Promise<Watchlist | null>;
listBlockedEntries(organizationId: number): Promise<Watchlist[]>;
listAllOrganizationEntries(): Promise<Watchlist[]>;
// Write operations
createEntry(
organizationId: number,
data: {
type: WatchlistType;
value: string;
description?: string;
action: WatchlistAction;
source?: WatchlistSource;
}
): Promise<Watchlist>;
updateEntry(
id: string,
organizationId: number,
data: {
value?: string;
description?: string;
action?: WatchlistAction;
source?: WatchlistSource;
}
): Promise<Watchlist>;
deleteEntry(id: string, organizationId: number): Promise<void>;
}