/** * The structural Prisma surface: the exact subset of a generated Prisma * client the driver calls, written out as plain interfaces so `@prisma/client` * is NOT a dependency of this package. Any client generated from the v2 * schema fragment in `prisma/schema.prisma` satisfies `AlfizPrismaDelegates` * structurally — pass the `PrismaClient` instance straight to `prismaDriver`. * So does the in-memory mock the test suite uses. * * Deliberately narrow: * - Where-clauses are equality and `{ in: [...] }` only, so every query * shape stays portable across databases (and trivially mockable). * - Json columns read back as `unknown` — the driver casts at the boundary * with dedicated helpers; no `any` anywhere. * - BigInt columns are `bigint` on both sides; nullable columns are * `T | null`, never `undefined` (Prisma's convention). Optional Json * columns are OMITTED from create data when absent (Prisma requires a * sentinel, not plain `null`, to write SQL NULL into a Json column). * - Optional properties are declared Prisma-style (`prop?: T`, no explicit * `| undefined`), so the structural match also holds for adopters * compiling with `exactOptionalPropertyTypes`. * * v2 — the partition discriminator is UNFORGETTABLE. Every record, create * shape, where shape, and where-unique shape carries `app` as a REQUIRED * field, matching the composite keys the v2 schema fragment declares * (`@@id([app, id])` et al.). A query inside the driver that omits the * partition fails to compile rather than silently scanning every tenant — * the same posture this package already takes with its structural surface, * pinned by the compile-only fixture (`prisma-client-shape.ts`) exactly as * the no-cast promise is. */ /** A JSON value as read back from a Json column. */ export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue; }; /** * A JSON value as WRITTEN to a Json column: everything except bare `null`. * Prisma's create/update inputs reject top-level `null` — writing SQL NULL * requires the `Prisma.JsonNull` sentinel, so the driver OMITS optional Json * fields instead (nested nulls are fine). Keeping the create-data fields * this narrow is what makes a generated `PrismaClient` satisfy * `AlfizPrismaDelegates` structurally, with no cast — the package's headline * promise, pinned by `prisma-client-shape.ts`. */ export type InputJsonValue = Exclude; /** The only string conditions the driver uses: equality or membership. */ export type StringWhere = string | { in: string[]; }; export interface AlfizGrantRecord { app: string; id: string; subject: string; roleId: string | null; pattern: string | null; scope: string; expiresAt: bigint | null; provenance: unknown; createdAt: bigint; } export interface AlfizGrantCreateData { app: string; id: string; subject: string; roleId: string | null; pattern: string | null; scope: string; expiresAt: bigint | null; provenance: InputJsonValue; createdAt: bigint; } export interface AlfizGrantWhere { app: string; subject?: StringWhere; scope?: string; roleId?: string; } /** The compound-`@@id([app, id])` where-unique input Prisma generates. */ export interface AlfizAppIdWhereUnique { app_id: { app: string; id: string; }; } export interface AlfizGrantDelegate { create(args: { data: AlfizGrantCreateData; }): Promise; findUnique(args: { where: AlfizAppIdWhereUnique; }): Promise; findMany(args: { where: AlfizGrantWhere; }): Promise; /** `SELECT count(*)`: sizing a grant set without materializing it. */ count(args: { where: AlfizGrantWhere; }): Promise; /** Returns the affected-row count: the caller distinguishes a delete it * performed from one a concurrent actor already did. */ deleteMany(args: { where: { app: string; id: string; }; }): Promise<{ count: number; }>; } export interface AlfizRevokeRecord { app: string; id: string; userId: string; pattern: string; scope: string; provenance: unknown; createdAt: bigint; } export interface AlfizRevokeCreateData { app: string; id: string; userId: string; pattern: string; scope: string; provenance: InputJsonValue; createdAt: bigint; } export interface AlfizRevokeWhere { app: string; userId?: string; scope?: string; } export interface AlfizRevokeDelegate { create(args: { data: AlfizRevokeCreateData; }): Promise; findUnique(args: { where: AlfizAppIdWhereUnique; }): Promise; findMany(args: { where: AlfizRevokeWhere; }): Promise; /** Returns the affected-row count: the caller distinguishes a delete it * performed from one a concurrent actor already did. */ deleteMany(args: { where: { app: string; id: string; }; }): Promise<{ count: number; }>; } export interface AlfizRoleRecord { app: string; id: string; name: string; description: string | null; patterns: unknown; /** `null` when the role is not requestable. */ requestable: unknown; } export interface AlfizRoleCreateData { app: string; id: string; name: string; description: string | null; patterns: InputJsonValue; /** Omitted (not `null`) when absent — the column defaults to NULL. */ requestable?: InputJsonValue; } /** * The update half of `upsertRole`. Fields are optional, mirroring Prisma's * generated update inputs. * * Unlike the create form, `requestable` is written on EVERY update — a role * that lost its requestable policy must have the column cleared, and * omitting the field would silently keep the old policy alive, so a * de-privileging edit would not de-privilege. Clearing a nullable `Json` * column is the one place a client needs its own sentinel * (`Prisma.DbNull`), which this package cannot name without taking * `@prisma/client` as a dependency; `PrismaDriverOptions.jsonNull` supplies * it and the driver casts it at the boundary, alongside its other casts. */ export interface AlfizRoleUpdateData { name?: string; description?: string | null; patterns?: InputJsonValue; requestable?: InputJsonValue; } export interface AlfizRoleDelegate { create(args: { data: AlfizRoleCreateData; }): Promise; findUnique(args: { where: AlfizAppIdWhereUnique; }): Promise; /** The batch read behind `getRoles`: `WHERE id IN (...)` when filtered. */ findMany(args: { where: { app: string; id?: StringWhere; }; }): Promise; /** * One atomic statement, so `upsertRole` never has to delete first — the * same shape `AlfizGroupDelegate` already uses. * * Every grant conferring a role denies while that role is unreadable * ("unknown roles confer nothing"), so a delete-then-create window was a * live authorization outage; a failure between the two halves lost the * role outright; and two concurrent writers collided on the primary key. */ upsert(args: { where: AlfizAppIdWhereUnique; create: AlfizRoleCreateData; update: AlfizRoleUpdateData; }): Promise; /** Returns the affected-row count: the caller distinguishes a delete it * performed from one a concurrent actor already did. */ deleteMany(args: { where: { app: string; id: string; }; }): Promise<{ count: number; }>; } export interface AlfizGroupRecord { app: string; id: string; name: string; description: string | null; virtual: boolean; } export interface AlfizGroupData { name: string; description: string | null; virtual: boolean; } export interface AlfizGroupDelegate { upsert(args: { where: AlfizAppIdWhereUnique; create: AlfizGroupData & { app: string; id: string; }; update: AlfizGroupData; }): Promise; findUnique(args: { where: AlfizAppIdWhereUnique; }): Promise; findMany(args: { where: { app: string; }; }): Promise; /** Returns the affected-row count: the caller distinguishes a delete it * performed from one a concurrent actor already did. */ deleteMany(args: { where: { app: string; id: string; }; }): Promise<{ count: number; }>; } export interface AlfizGroupParentRecord { app: string; childId: string; parentId: string; } export interface AlfizGroupParentWhere { app: string; childId?: StringWhere; parentId?: StringWhere; } export interface AlfizGroupParentDelegate { findMany(args: { where: AlfizGroupParentWhere; }): Promise; createMany(args: { data: AlfizGroupParentRecord[]; }): Promise; deleteMany(args: { where: AlfizGroupParentWhere; }): Promise; } export interface AlfizUserRecord { app: string; userId: string; active: boolean; orgIds: unknown; managerUserId: string | null; } export interface AlfizUserData { active: boolean; orgIds: InputJsonValue; managerUserId: string | null; } /** The compound-`@@id([app, userId])` where-unique input Prisma generates. */ export interface AlfizAppUserIdWhereUnique { app_userId: { app: string; userId: string; }; } export interface AlfizUserDelegate { upsert(args: { where: AlfizAppUserIdWhereUnique; create: AlfizUserData & { app: string; userId: string; }; update: AlfizUserData; }): Promise; findUnique(args: { where: AlfizAppUserIdWhereUnique; }): Promise; findMany(args: { where: { app: string; }; }): Promise; /** deleteMany, not delete: Prisma's `delete` throws on absent rows and the seam wants a no-op. */ deleteMany(args: { where: { app: string; userId: string; }; }): Promise; } export interface AlfizMembershipRecord { app: string; userId: string; groupId: string; } export interface AlfizMembershipWhere { app: string; userId?: StringWhere; groupId?: StringWhere; } export interface AlfizMembershipDelegate { findMany(args: { where: AlfizMembershipWhere; }): Promise; createMany(args: { data: AlfizMembershipRecord[]; }): Promise; deleteMany(args: { where: AlfizMembershipWhere; }): Promise; } export interface AlfizRequestRecord { app: string; id: string; requesterUserId: string; roleId: string | null; pattern: string | null; scope: string; proposedExpiresAt: bigint | null; justification: unknown; state: string; stageIndex: number; stages: unknown; decisions: unknown; createdAt: bigint; decidedAt: bigint | null; } export interface AlfizRequestData { requesterUserId: string; roleId: string | null; pattern: string | null; scope: string; proposedExpiresAt: bigint | null; justification: InputJsonValue; state: string; stageIndex: number; stages: InputJsonValue; decisions: InputJsonValue; createdAt: bigint; decidedAt: bigint | null; } export interface AlfizRequestWhere { app: string; state?: string; requesterUserId?: string; } export interface AlfizRequestDelegate { create(args: { data: AlfizRequestData & { app: string; id: string; }; }): Promise; upsert(args: { where: AlfizAppIdWhereUnique; create: AlfizRequestData & { app: string; id: string; }; update: AlfizRequestData; }): Promise; findUnique(args: { where: AlfizAppIdWhereUnique; }): Promise; findMany(args: { where: AlfizRequestWhere; }): Promise; } export interface AlfizCatalogRecord { app: string; id: number; version: number; document: unknown; } /** The compound-`@@id([app, id])` input for the Int-id singletons. */ export interface AlfizAppIntIdWhereUnique { app_id: { app: string; id: number; }; } export interface AlfizCatalogDelegate { upsert(args: { where: AlfizAppIntIdWhereUnique; create: { app: string; id: number; version: number; document: InputJsonValue; }; update: { version: number; document: InputJsonValue; }; }): Promise; findUnique(args: { where: AlfizAppIntIdWhereUnique; }): Promise; } export interface AlfizCatalogVersionRecord { app: string; version: number; document: unknown; publishedAt: bigint; } /** The compound-`@@id([app, version])` where-unique input. */ export interface AlfizAppVersionWhereUnique { app_version: { app: string; version: number; }; } export interface AlfizCatalogVersionDelegate { upsert(args: { where: AlfizAppVersionWhereUnique; create: { app: string; version: number; document: InputJsonValue; publishedAt: bigint; }; update: { document: InputJsonValue; publishedAt: bigint; }; }): Promise; findUnique(args: { where: AlfizAppVersionWhereUnique; }): Promise; findMany(args: { where: { app: string; }; orderBy?: { version: "asc"; }; }): Promise; } export interface AlfizImportsRecord { app: string; id: number; version: number; manifest: unknown; } export interface AlfizImportsDelegate { upsert(args: { where: AlfizAppIntIdWhereUnique; create: { app: string; id: number; version: number; manifest: InputJsonValue; }; update: { version: number; manifest: InputJsonValue; }; }): Promise; findUnique(args: { where: AlfizAppIntIdWhereUnique; }): Promise; } export interface AlfizAuditRecord { app: string; id: string; at: bigint; actor: string; action: string; target: string; /** `null` when the event carries no detail. */ detail: unknown; /** `null` unless the writing Application chains audit hashes. */ prevHash?: string | null; hash?: string | null; } export interface AlfizAuditCreateData { app: string; id: string; at: bigint; actor: string; action: string; target: string; /** Omitted (not `null`) when absent — the column defaults to NULL. */ detail?: InputJsonValue; prevHash?: string; hash?: string; } /** * The cursor half of a paged audit read: the compound (`at`, `id`) * condition, expressed through `OR` disjuncts NESTED under a top-level * where that already carries `app` (Prisma ANDs the top-level fields with * `OR`), so the disjuncts themselves stay partition-free. */ export interface AlfizAuditCursorCondition { at?: bigint | { gte?: bigint; lt?: bigint; gt?: bigint; }; id?: { gt?: string; }; } /** * Exactly the `where` shapes `listAudit` emits: the partition (required — * an audit read that could forget it would leak every tenant's log), * equality filters, an `at` range, and the compound cursor condition. */ export interface AlfizAuditWhere { app: string; target?: string; actor?: string; action?: string; at?: bigint | { gte?: bigint; lt?: bigint; gt?: bigint; }; OR?: AlfizAuditCursorCondition[]; } export interface AlfizAuditDelegate { create(args: { data: AlfizAuditCreateData; }): Promise; /** * Ordered reads: ascending by (`at`, `id`), with Prisma's negative-`take` * convention ("last N of the ordered result") for audit tail reads and a * compound (`at`, `id`) cursor condition for export paging. */ findMany(args: { where: AlfizAuditWhere; orderBy?: { at: "asc"; id?: "asc"; } | Array<{ at?: "asc"; id?: "asc"; }>; take?: number; }): Promise; } export interface AlfizEpochRecord { app: string; id: number; seq: bigint; prunedThrough: bigint; } export interface AlfizEpochDelegate { upsert(args: { where: AlfizAppIntIdWhereUnique; create: { app: string; id: number; seq: bigint; prunedThrough: bigint; }; update: Record; }): Promise; /** Atomic head advance: increment and read back in one statement. */ update(args: { where: AlfizAppIntIdWhereUnique; data: { seq: { increment: bigint; }; } | { prunedThrough: bigint; }; }): Promise; findUnique(args: { where: AlfizAppIntIdWhereUnique; }): Promise; } export interface AlfizEventRecord { app: string; seq: bigint; type: string; payload: unknown; at: bigint; } export interface AlfizEventCreateData { app: string; seq: bigint; type: string; payload: InputJsonValue; at: bigint; } export interface AlfizEventDelegate { createMany(args: { data: AlfizEventCreateData[]; }): Promise; findMany(args: { where: { app: string; seq: { gt: bigint; }; }; orderBy: { seq: "asc"; }; take?: number; }): Promise; /** Newest event older than a cutoff — sizing a prune without a scan. */ findFirst(args: { where: { app: string; at: { lt: bigint; }; }; orderBy: { seq: "desc"; }; }): Promise; deleteMany(args: { where: { app: string; seq: { lte: bigint; }; }; }): Promise<{ count: number; }>; } export interface AlfizMetricRecord { app: string; bucket: bigint; dimension: string; subject: string; metric: string; count: bigint; } /** The composite identity of a bucket — Prisma's generated `@@id` input. */ export interface AlfizMetricWhereUnique { app_bucket_dimension_subject_metric: { app: string; bucket: bigint; dimension: string; subject: string; metric: string; }; } export interface AlfizMetricWhere { app: string; dimension?: string; subject?: { in: string[]; }; bucket?: { gte?: bigint; lt?: bigint; }; } export interface AlfizMetricDelegate { /** * Increment-or-create. Counters ACCUMULATE across every app server * reporting into the same bucket, which is what makes the numbers * deployment-wide rather than per-process. */ upsert(args: { where: AlfizMetricWhereUnique; create: AlfizMetricRecord; update: { count: { increment: bigint; }; }; }): Promise; findMany(args: { where: AlfizMetricWhere; }): Promise; deleteMany(args: { where: { app: string; bucket: { lt: bigint; }; }; }): Promise<{ count: number; }>; } /** * Everything `prismaDriver` needs from a Prisma client. A generated * `PrismaClient` for a schema containing the v2 Alfiz models satisfies this * structurally; no `@prisma/client` import required. */ export interface AlfizPrismaDelegates { alfizGrant: AlfizGrantDelegate; alfizRevoke: AlfizRevokeDelegate; alfizRole: AlfizRoleDelegate; alfizGroup: AlfizGroupDelegate; alfizGroupParent: AlfizGroupParentDelegate; alfizUser: AlfizUserDelegate; alfizMembership: AlfizMembershipDelegate; alfizRequest: AlfizRequestDelegate; alfizCatalog: AlfizCatalogDelegate; alfizAudit: AlfizAuditDelegate; /** * OPTIONAL — present when the schema includes the AlfizCatalogVersion * model. A client generated without it still satisfies this interface; * the driver then keeps only the catalog head, and the wildcard-drift * report answers `unsupported` instead of wrongly. */ alfizCatalogVersion?: AlfizCatalogVersionDelegate; /** * OPTIONAL — present when the schema includes the AlfizImports model. A * client generated without it still satisfies this interface; the driver * then omits the import methods and `capabilities().imports` is false. */ alfizImports?: AlfizImportsDelegate; /** * OPTIONAL — present when the schema includes the AlfizEpoch/AlfizEvent * models (the persisted invalidation log). A client generated without * them still satisfies this interface; the driver then simply omits the * event methods, and `events.persist` on the Application refuses loudly. */ alfizEpoch?: AlfizEpochDelegate; alfizEvent?: AlfizEventDelegate; /** * OPTIONAL — present when the schema includes the AlfizMetric model * (rolling permission-usage buckets). Absent, the driver omits the metric * methods and the Application refuses `metrics` loudly rather than * accepting batches that go nowhere. */ alfizMetric?: AlfizMetricDelegate; } //# sourceMappingURL=delegates.d.ts.map