import { BaseNode, Keyword } from "./Base"; import { Identifier, ListExpr, EntityName, Expr, ParenExpr, FuncCall } from "./Expr"; import { FunctionSignature } from "./Function"; import { BooleanLiteral, StringLiteral } from "./Literal"; import { RoleSpecification } from "./Role"; export type AllDclNodes = AllDclStatements | Privilege | AllPrivileges | GrantResource | WithGrantOptionClause | GrantOptionForClause | GrantedByClause | GranteeGroup | GranteePublic | GrantDefaultPrivilegesAction | RevokeDefaultPrivilegesAction | DefaultAclForRoleClause | DefaultAclInSchemaClause; export type AllDclStatements = GrantPrivilegeStmt | GrantRoleStmt | RevokePrivilegeStmt | RevokeRoleStmt | AlterDefaultPrivilegesStmt; export interface GrantPrivilegeStmt extends BaseNode { type: "grant_privilege_stmt"; grantKw: Keyword<"GRANT">; privileges: ListExpr | ListExpr | AllPrivileges; onKw: Keyword<"ON">; resource: GrantResource; toKw: Keyword<"TO">; roles: ListExpr | ListExpr; clauses: (WithGrantOptionClause | GrantedByClause)[]; } export interface GrantRoleStmt extends BaseNode { type: "grant_role_stmt"; grantKw: Keyword<"GRANT">; grantedRoles: ListExpr; toKw: Keyword<"TO">; granteeRoles: ListExpr; clauses: (WithGrantOptionClause | GrantedByClause)[]; } export interface Privilege extends BaseNode { type: "privilege"; privilegeKw: Keyword<"SELECT" | "INSERT" | "UPDATE" | "DELETE" | "TRUNCATE" | "REFERENCES" | "TRIGGER" | "MAINTAIN" | "USAGE" | "CREATE" | "CONNECT" | "TEMPORARY" | "TEMP" | "SET" | "EXECUTE"> | [Keyword<"ALTER">, Keyword<"SYSTEM">]; columns?: ParenExpr>; } export interface AllPrivileges extends BaseNode { type: "all_privileges"; allKw: Keyword<"ALL">; privilegesKw?: Keyword<"PRIVILEGES">; columns?: ParenExpr>; } export type GrantResource = GrantResourceTable | GrantResourceAllTablesInSchema | GrantResourceSequence | GrantResourceAllSequencesInSchema | GrantResourceDatabase | GrantResourceDomain | GrantResourceForeignDataWrapper | GrantResourceForeignServer | GrantResourceFunction | GrantResourceAllFunctionsInSchema | GrantResourceLanguage | GrantResourceLargeObject | GrantResourcePostgresqlOption | GrantResourceSchema | GrantResourceTablespace | GrantResourceType | GrantResourceView; export interface GrantResourceTable extends BaseNode { type: "grant_resource_table"; tableKw?: Keyword<"TABLE"> | [Keyword<"EXTERNAL">, Keyword<"TABLE">]; tables: ListExpr; } export interface GrantResourceAllTablesInSchema extends BaseNode { type: "grant_resource_all_tables_in_schema"; allTablesInSchemaKw: [ Keyword<"ALL">, Keyword<"TABLES">, Keyword<"IN">, Keyword<"SCHEMA"> ]; schemas: ListExpr; } export interface GrantResourceSequence extends BaseNode { type: "grant_resource_sequence"; sequenceKw: Keyword<"SEQUENCE">; sequences: ListExpr; } export interface GrantResourceAllSequencesInSchema extends BaseNode { type: "grant_resource_all_sequences_in_schema"; allSequencesInSchemaKw: [ Keyword<"ALL">, Keyword<"SEQUENCES">, Keyword<"IN">, Keyword<"SCHEMA"> ]; schemas: ListExpr; } export interface GrantResourceDatabase extends BaseNode { type: "grant_resource_database"; databaseKw: Keyword<"DATABASE">; databases: ListExpr; } export interface GrantResourceDomain extends BaseNode { type: "grant_resource_domain"; domainKw: Keyword<"DOMAIN">; domains: ListExpr; } export interface GrantResourceForeignDataWrapper extends BaseNode { type: "grant_resource_foreign_data_wrapper"; foreignDataWrapperKw: [ Keyword<"FOREIGN">, Keyword<"DATA">, Keyword<"WRAPPER"> ]; dataWrappers: ListExpr; } export interface GrantResourceForeignServer extends BaseNode { type: "grant_resource_foreign_server"; foreignServerKw: [Keyword<"FOREIGN">, Keyword<"SERVER">]; servers: ListExpr; } export interface GrantResourceFunction extends BaseNode { type: "grant_resource_function"; functionKw: Keyword<"FUNCTION" | "PROCEDURE" | "ROUTINE">; functions: ListExpr; } export interface GrantResourceAllFunctionsInSchema extends BaseNode { type: "grant_resource_all_functions_in_schema"; allFunctionsInSchemaKw: [ Keyword<"ALL">, Keyword<"FUNCTIONS" | "PROCEDURES" | "ROUTINES">, Keyword<"IN">, Keyword<"SCHEMA"> ]; schemas: ListExpr; } export interface GrantResourceLanguage extends BaseNode { type: "grant_resource_language"; languageKw: Keyword<"LANGUAGE">; languages: ListExpr; } export interface GrantResourceLargeObject extends BaseNode { type: "grant_resource_large_object"; largeObjectKw: [Keyword<"LARGE">, Keyword<"OBJECT">]; oids: ListExpr; } export interface GrantResourcePostgresqlOption extends BaseNode { type: "grant_resource_postgresql_option"; parameterKw: Keyword<"PARAMETER">; options: ListExpr; } export interface GrantResourceSchema extends BaseNode { type: "grant_resource_schema"; schemaKw: Keyword<"SCHEMA">; schemas: ListExpr; } export interface GrantResourceTablespace extends BaseNode { type: "grant_resource_tablespace"; tablespaceKw: Keyword<"TABLESPACE">; tablespaces: ListExpr; } export interface GrantResourceType extends BaseNode { type: "grant_resource_type"; typeKw: Keyword<"TYPE">; types: ListExpr; } export interface GrantResourceView extends BaseNode { type: "grant_resource_view"; viewKw: Keyword<"VIEW">; views: ListExpr; } export interface WithGrantOptionClause extends BaseNode { type: "with_grant_option_clause"; withKw: Keyword<"WITH">; nameKw: Keyword<"GRANT" | "ADMIN" | "INHERIT" | "SET">; value: Keyword<"OPTION"> | BooleanLiteral; } export interface GrantOptionForClause extends BaseNode { type: "grant_option_for_clause"; nameKw: Keyword<"GRANT" | "ADMIN" | "INHERIT" | "SET">; optionForKw: [Keyword<"OPTION">, Keyword<"FOR">]; } export interface GrantedByClause extends BaseNode { type: "granted_by_clause"; grantedByKw: [Keyword<"GRANTED">, Keyword<"BY">]; role: Grantee; } export interface RevokePrivilegeStmt extends BaseNode { type: "revoke_privilege_stmt"; revokeKw: Keyword<"REVOKE">; option?: GrantOptionForClause; privileges: ListExpr | ListExpr | AllPrivileges; onKw: Keyword<"ON">; resource: GrantResource; fromKw: Keyword<"FROM">; roles: ListExpr | ListExpr; grantedBy?: GrantedByClause; behaviorKw?: Keyword<"CASCADE" | "RESTRICT">; } export interface RevokeRoleStmt extends BaseNode { type: "revoke_role_stmt"; revokeKw: Keyword<"REVOKE">; option?: GrantOptionForClause; grantedRoles: ListExpr; fromKw: Keyword<"FROM">; granteeRoles: ListExpr; grantedBy?: GrantedByClause; behaviorKw?: Keyword<"CASCADE" | "RESTRICT">; } export type Grantee = Identifier | FuncCall | GranteeGroup | GranteePublic; export interface GranteeGroup extends BaseNode { type: "grantee_group"; groupKw: Keyword<"GROUP">; name: Identifier; } export interface GranteePublic extends BaseNode { type: "grantee_public"; publicKw: Keyword<"PUBLIC">; } export interface AlterDefaultPrivilegesStmt extends BaseNode { type: "alter_default_privileges_stmt"; alterDefaultPrivilegesKw: [ Keyword<"ALTER">, Keyword<"DEFAULT">, Keyword<"PRIVILEGES"> ]; clauses: (DefaultAclForRoleClause | DefaultAclInSchemaClause)[]; action: GrantDefaultPrivilegesAction | RevokeDefaultPrivilegesAction; } export interface DefaultAclForRoleClause extends BaseNode { type: "default_acl_for_role_clause"; forKw: Keyword<"FOR">; roleKw: Keyword<"ROLE" | "USER">; roles: ListExpr; } export interface DefaultAclInSchemaClause extends BaseNode { type: "default_acl_in_schema_clause"; inKw: Keyword<"IN">; schemaKw: Keyword<"SCHEMA">; schemas: ListExpr; } export interface GrantDefaultPrivilegesAction extends BaseNode { type: "grant_default_privileges_action"; grantKw: Keyword<"GRANT">; privileges: ListExpr | AllPrivileges; onKw: Keyword<"ON">; resourcesKw: ResourcesKeyword; toKw: Keyword<"TO">; roles: ListExpr; withGrantOption?: WithGrantOptionClause; } export interface RevokeDefaultPrivilegesAction extends BaseNode { type: "revoke_default_privileges_action"; revokeKw: Keyword<"REVOKE">; grantOptionFor?: GrantOptionForClause; privileges: ListExpr | AllPrivileges; onKw: Keyword<"ON">; resourcesKw: ResourcesKeyword; fromKw: Keyword<"FROM">; roles: ListExpr; behaviorKw?: Keyword<"CASCADE" | "RESTRICT">; } type ResourcesKeyword = Keyword<"TABLES" | "SEQUENCES" | "FUNCTIONS" | "ROUTINES" | "TYPES" | "SCHEMAS"> | [Keyword<"LARGE">, Keyword<"OBJECTS">]; export {};