policies.d.ts 1.0 KB

123456789101112131415161718192021222324
  1. import { entityKind } from "../entity.js";
  2. import type { SQL } from "../sql/sql.js";
  3. import type { GelRole } from "./roles.js";
  4. import type { GelTable } from "./table.js";
  5. export type GelPolicyToOption = 'public' | 'current_role' | 'current_user' | 'session_user' | (string & {}) | GelPolicyToOption[] | GelRole;
  6. export interface GelPolicyConfig {
  7. as?: 'permissive' | 'restrictive';
  8. for?: 'all' | 'select' | 'insert' | 'update' | 'delete';
  9. to?: GelPolicyToOption;
  10. using?: SQL;
  11. withCheck?: SQL;
  12. }
  13. export declare class GelPolicy implements GelPolicyConfig {
  14. readonly name: string;
  15. static readonly [entityKind]: string;
  16. readonly as: GelPolicyConfig['as'];
  17. readonly for: GelPolicyConfig['for'];
  18. readonly to: GelPolicyConfig['to'];
  19. readonly using: GelPolicyConfig['using'];
  20. readonly withCheck: GelPolicyConfig['withCheck'];
  21. constructor(name: string, config?: GelPolicyConfig);
  22. link(table: GelTable): this;
  23. }
  24. export declare function gelPolicy(name: string, config?: GelPolicyConfig): GelPolicy;