rls.d.cts 1.5 KB

1234567891011121314151617181920
  1. import { type AnyPgColumn, type PgPolicyToOption } from "../pg-core/index.cjs";
  2. import { PgRole } from "../pg-core/roles.cjs";
  3. import { type SQL } from "../sql/sql.cjs";
  4. /**
  5. * Generates a set of PostgreSQL row-level security (RLS) policies for CRUD operations based on the provided options.
  6. *
  7. * @param options - An object containing the policy configuration.
  8. * @param options.role - The PostgreSQL role(s) to apply the policy to. Can be a single `PgRole` instance or an array of `PgRole` instances or role names.
  9. * @param options.read - The SQL expression or boolean value that defines the read policy. Set to `true` to allow all reads, `false` to deny all reads, or provide a custom SQL expression. Set to `null` to prevent the policy from being generated.
  10. * @param options.modify - The SQL expression or boolean value that defines the modify (insert, update, delete) policies. Set to `true` to allow all modifications, `false` to deny all modifications, or provide a custom SQL expression. Set to `null` to prevent policies from being generated.
  11. * @returns An array of PostgreSQL policy definitions, one for each CRUD operation.
  12. */
  13. export declare const crudPolicy: (options: {
  14. role: PgPolicyToOption;
  15. read: SQL | boolean | null;
  16. modify: SQL | boolean | null;
  17. }) => (import("../pg-core/index.ts").PgPolicy | undefined)[];
  18. export declare const authenticatedRole: PgRole;
  19. export declare const anonymousRole: PgRole;
  20. export declare const authUid: (userIdColumn: AnyPgColumn) => SQL<unknown>;