import type { AuthLogger } from '../../types.js'; import type { BackupCodeRepository, FederatedAccountRepository, InvitationRepository, NotificationPreferenceRepository, NotificationRepository, PasskeyRepository, PushSubscriptionRepository, RefreshTokenRepository, Repositories, UserRepository } from './types.js'; /** * `PrismaLike` intentionally leaves return values untyped — every consumer's * Prisma client generates its own row shapes from its schema. The adapter * implementations cast inside the methods, so a permissive return type * (`PrismaRow`) avoids the `Promise` cascade through every call. */ type PrismaRow = any; export interface PrismaLike { user: { findUnique: (args: unknown) => Promise; create: (args: unknown) => Promise; update: (args: unknown) => Promise; updateMany: (args: unknown) => Promise<{ count: number; }>; deleteMany: (args: unknown) => Promise<{ count: number; }>; }; invitation: { findUnique: (args: unknown) => Promise; findMany: (args?: unknown) => Promise; create: (args: unknown) => Promise; update: (args: unknown) => Promise; updateMany: (args: unknown) => Promise<{ count: number; }>; deleteMany: (args: unknown) => Promise<{ count: number; }>; }; notification?: { findUnique: (args: unknown) => Promise; findMany: (args?: unknown) => Promise; create: (args: unknown) => Promise; updateMany: (args: unknown) => Promise<{ count: number; }>; deleteMany: (args: unknown) => Promise<{ count: number; }>; count: (args?: unknown) => Promise; }; pushSubscription?: { findUnique: (args: unknown) => Promise; findMany: (args?: unknown) => Promise; create: (args: unknown) => Promise; upsert: (args: unknown) => Promise; deleteMany: (args: unknown) => Promise<{ count: number; }>; }; notificationPreference?: { findMany: (args?: unknown) => Promise; upsert: (args: unknown) => Promise; }; passkey?: { findMany: (args?: unknown) => Promise; findUnique: (args: unknown) => Promise; create: (args: unknown) => Promise; updateMany: (args: unknown) => Promise<{ count: number; }>; deleteMany: (args: unknown) => Promise<{ count: number; }>; }; refreshToken?: { findUnique: (args: unknown) => Promise; findMany: (args?: unknown) => Promise; create: (args: unknown) => Promise; update: (args: unknown) => Promise; updateMany: (args: unknown) => Promise<{ count: number; }>; deleteMany: (args: unknown) => Promise<{ count: number; }>; }; twoFactorBackupCode?: { createMany: (args: unknown) => Promise<{ count: number; }>; updateMany: (args: unknown) => Promise<{ count: number; }>; deleteMany: (args: unknown) => Promise<{ count: number; }>; }; federatedAccount?: { findUnique: (args: unknown) => Promise; create: (args: unknown) => Promise; deleteMany: (args: unknown) => Promise<{ count: number; }>; }; /** * Prisma's sequential (array-form) transaction. Used by `user.delete` to drop * the user's sent invitations and the user atomically. The real client takes * an array of lazy `PrismaPromise`s and runs them in one transaction; the * structural type stays permissive (`unknown[]`) at this boundary. */ $transaction: (operations: unknown[]) => Promise; } /** * Where a repository factory reports a Prisma client that lacks its model. * * Six of the optional factories answer a missing model with `undefined`, which * is the right value — the feature is simply not wired — but it used to be the * *whole* answer: no log line, no throw. What that costs varies per model and * is spelled out at each call site; the two that nothing else reports are * `pushSubscription` (every push send is skipped) and `notificationPreference` * (every user's per-type channel choices are ignored, and notifications go out * on all declared channels). * * Default sink is `console`, matching `config.logger ?? console` elsewhere; * pass `{ logger }` to route it with the rest of the auth logs. Shielded, * because a broken sink must not break wiring. */ export interface PrismaRepoOptions { logger?: AuthLogger; } export declare function createPrismaUserRepository(client: PrismaLike): UserRepository; export declare function createPrismaInvitationRepository(client: PrismaLike): InvitationRepository; /** * Notification rows behind ``. `undefined` when the client * has no `notification` model — `createNotificationService` requires this repo * (non-optional in `NotificationServiceDeps`), so wiring the bundle without the * model is a type error rather than a silent drop. */ export declare function createPrismaNotificationRepository(client: PrismaLike, repoOptions?: PrismaRepoOptions): NotificationRepository | undefined; /** * Stored Web Push subscriptions. `undefined` when the client has no * `pushSubscription` model — and this is one of the two absences nothing else * reports: `createNotificationService` takes the repo optionally and simply * skips the push branch, so every notification is delivered by SSE only, with * no error anywhere. */ export declare function createPrismaPushSubscriptionRepository(client: PrismaLike, repoOptions?: PrismaRepoOptions): PushSubscriptionRepository | undefined; /** * Per-user, per-type notification channel preferences. `undefined` when the * client has no `notificationPreference` model — the second absence nothing * else reports: the service falls back to `{ sse: true, push: true, email: true * }` for every user, so a user who turned a channel off keeps receiving on it. */ export declare function createPrismaNotificationPreferenceRepository(client: PrismaLike, repoOptions?: PrismaRepoOptions): NotificationPreferenceRepository | undefined; /** * WebAuthn credential rows. `undefined` when the client has no `passkey` model; * `createPasskeyHandlers` throws on a missing `repos.passkey`, so mounting the * passkey routes without the model fails loudly at wiring time. */ export declare function createPrismaPasskeyRepository(client: PrismaLike, repoOptions?: PrismaRepoOptions): PasskeyRepository | undefined; /** * Refresh-token families for rotation and the session listing. `undefined` when * the client has no `refreshToken` model. With `config.refreshToken` set, both * wiring entry points throw on the missing repo (`assertReposMatchConfig`), and * the session-listing routes answer `feature_unavailable` 400 — so the absence * is silent only when rotation was never configured, where there is nothing to * rotate or revoke in the first place. */ export declare function createPrismaRefreshTokenRepository(client: PrismaLike, repoOptions?: PrismaRepoOptions): RefreshTokenRepository | undefined; /** * Federated-account links for the consumer side of a federation setup * (`createFederatedAuthHandle` → `resolveUser`). Unlike the other optional * factories this one **throws** when the Prisma client lacks the * `federatedAccount` model: no package feature checks this repo's wiring later * (nothing in the shipped handlers calls it), so the explicit factory call is * the only place a missing model can fail loud instead of surfacing as an * `undefined` method call at request time. `createPrismaRepos` still treats it * as optional (wires it only when the model exists). */ export declare function createPrismaFederatedAccountRepository(client: PrismaLike): FederatedAccountRepository; /** * Hashed TOTP recovery codes. `undefined` when the client has no * `twoFactorBackupCode` model; the 2FA handlers check the repo and answer a * visible `feature_unavailable` 400, so the absence surfaces at request time. */ export declare function createPrismaBackupCodeRepository(client: PrismaLike, repoOptions?: PrismaRepoOptions): BackupCodeRepository | undefined; /** * Every repository the package knows, from one client. Optional repos come back * `undefined` when their model is absent, and each such absence is reported * once through `options.logger` (default `console`) — see * {@link PrismaRepoOptions}. Pass the same logger the auth config uses so * wiring diagnostics land with the rest of the auth logs. */ export declare function createPrismaRepos(prisma: PrismaLike, repoOptions?: PrismaRepoOptions): Repositories; export {};