UNPKG

prisma-zod-generator

Version:

Prisma 2+ generator to emit Zod schemas from your Prisma schema

51 lines (50 loc) 1.5 kB
/** * PZG Pro - Postgres RLS Generator * DMMF-based implementation for RLS policy generation */ import { ProFeatureBase } from '../../core/ProFeatureBase'; export interface PostgresRLSConfig { outputPath?: string; enableAuditLogging?: boolean; enableRowOwnership?: boolean; ownershipField?: string; tenantField?: string; generateMigrations?: boolean; migrationFormat?: 'sql' | 'prisma'; } export interface RLSPolicy { name: string; table: string; operation: 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'ALL'; role?: string; expression?: string; check?: string; description?: string; } export interface PolicyRule { type: 'read' | 'write' | 'create' | 'update' | 'delete'; subtype?: 'where'; condition: string; field?: string; contextVariable?: string; } export interface ModelPolicies { modelName: string; policies: PolicyRule[]; } export declare class PostgresRLSGenerator extends ProFeatureBase { private config; constructor(context: any, config?: PostgresRLSConfig); protected getFeatureName(): string; protected generateFeature(): Promise<void>; private extractModelPolicies; private parsePolicyAnnotation; private generateRLSPolicies; private convertPolicyToRLS; private convertConditionToSQL; private generateRLSSQL; private generateHelperFunctions; private generatePrismaMigration; private generateRLSHelper; private generateRLSDocumentation; }