import { Prisma } from '@prisma/client/extension'; import { StandardSchemaV1 } from '@standard-schema/spec'; declare type Narrowable = string | number | bigint | boolean | []; declare type Exact = (A extends unknown ? (W extends A ? { [K in keyof A]: Exact; } : W) : never) | (A extends Narrowable ? A : never); type CoerceAnyToNever = unknown extends T ? never : T; type CoerceNeverToValue = [T] extends [never] ? V : T; type ModelKeys = { [K in keyof T]: K extends `$${string}` ? never : K; }[keyof T]; type Rules = ModelKeys> = { [K in AllModelKeys]?: { read?: OpRuleShape; create?: OpRuleShape; delete?: OpRuleShape; update?: OpRuleShape; $allOperations?: OpRuleShape; } | boolean; } & { $transaction?: boolean; $allModels?: { read?: AnyOpRuleShape; create?: AnyOpRuleShape; delete?: AnyOpRuleShape; update?: AnyOpRuleShape; $allOperations?: AnyOpRuleShape; } | boolean; }; /** */ type DeleteOperation = "delete" | "deleteMany"; type UpdateOperation = "update" | "updateMany" | "updateManyAndReturn" | "upsert"; type CreateOperation = "create" | "upsert" | "createMany" | "createManyAndReturn"; type ReadOperation = "aggregate" | "count" | "findFirst" | "findFirstOrThrow" | "findMany" | "findUnique" | "findUniqueOrThrow" | "groupBy"; type Operation = CreateOperation | DeleteOperation | UpdateOperation | ReadOperation; /** */ type OpRuleShape = boolean | OpRuleShapeWhere | OpRuleShapeCallback | OpRuleShapeVerbose; type OpRuleShapeWhere = Prisma.Args extends { where?: infer W; } ? { $where: W; $rule?: never; } : never; type OpCtx = K extends unknown ? O extends unknown ? { model: K; operation: O; args: readonly [CoerceAnyToNever>]; context: StandardSchemaV1.InferOutput | undefined; uuid?: string; } : never : never; type OpRuleShapeCallback = { (ctx: OpCtx): MaybePromise>; }; type OpRuleShapeBefore = { (ctx: OpCtx): MaybePromise; }; type OpRuleShapeAfter = { (ctx: OpCtx & { result: unknown; }): MaybePromise; }; type OpRuleShapeVerbose = { $rule: boolean | OpRuleShapeWhere | OpRuleShapeCallback; $after?: OpRuleShapeAfter; $before?: OpRuleShapeBefore; $blockedFields?: FieldsOf[]; $where?: never; }; /** */ /** */ type AnyOpRuleShape = boolean | AnyOpRuleShapeCallback | AnyOpRuleShapeVerbose; type AnyOpRuleShapeWhere = object; type AnyOpCtx = { model: string; operation: O; args: object; context: StandardSchemaV1.InferOutput; uuid?: string; }; type AnyOpRuleShapeCallback = { (ctx: AnyOpCtx): MaybePromise; }; type AnyOpRuleShapeBefore = { (ctx: AnyOpCtx): MaybePromise; }; type AnyOpRuleShapeAfter = { (ctx: AnyOpCtx & { result: unknown; }): MaybePromise; }; type AnyOpRuleShapeVerbose = { $rule: boolean | AnyOpRuleShapeCallback; $after?: AnyOpRuleShapeAfter; $before?: AnyOpRuleShapeBefore; $blockedFields?: string[]; }; /** */ /** */ type MaybePromise = T | Promise; type FieldsOf = Prisma.Payload> = CoerceNeverToValue; declare function defineRules(args: { prisma: C; contextSchema?: CtxSchema; rules: Exact>; }): C & { $rules: { setGlobalContext(ctx: StandardSchemaV1.InferInput): void; contextSchema: unknown; rules: Exact>>; }; }; /** * Allow only accessing the models on the client object. */ type KeepObjectsOnly = { [K in keyof T as K extends `$${string}` ? (K extends "$transaction" | "$rules" ? K : never) : K]: T[K]; }; type AuthorizedClient = KeepObjectsOnly; declare const AuthorizedClient: new (args: { url?: string; publicKey: string; }) => AuthorizedClient; export { AuthorizedClient, defineRules };