-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff3441b
commit 0f3c332
Showing
5 changed files
with
83 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,79 @@ | ||
import { Name } from '..' | ||
import { CascadeOption, Name } from '..' | ||
|
||
interface WithAdminOption { | ||
readonly withAdminOption?: boolean | ||
} | ||
|
||
interface OnlyAdminOption { | ||
readonly onlyAdminOption?: boolean | ||
} | ||
|
||
interface OnlyGrantOption { | ||
readonly onlyGrantOption?: boolean | ||
} | ||
|
||
interface RestrictOption { | ||
readonly restrict?: boolean | ||
} | ||
|
||
interface WithGrantOption { | ||
readonly withGrantOption?: boolean | ||
} | ||
|
||
type DropRolesOptions = OnlyAdminOption & RestrictOption | ||
|
||
type GrantRolesFn = ( | ||
rolesFrom: Name | Name[], | ||
rolesTo: Name | Name[], | ||
roleOptions?: WithAdminOption, | ||
grantRolesOptions?: WithAdminOption & DropRolesOptions, | ||
) => string | string[] | ||
export type GrantRoles = GrantRolesFn & { reverse: GrantRolesFn } | ||
export type RevokeRoles = ( | ||
roles: Name | Name[], | ||
rolesFrom: Name | Name[], | ||
dropRolesOptions?: DropRolesOptions, | ||
) => string | string[] | ||
|
||
type TablePrivilege = 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'TRUNCATE' | 'REFERENCES' | 'TRIGGER' | ||
type SchemaPrivilege = 'CREATE' | 'USAGE' | ||
|
||
export interface GrantOnSomeTablesProps extends WithGrantOption { | ||
interface CommonOnTablesProps { | ||
privileges: TablePrivilege | TablePrivilege[] | 'ALL' | ||
tables: Name | Name[] | ||
roles: Name | Name[] | ||
} | ||
|
||
export interface GrantOnAllTablesProps extends WithGrantOption { | ||
privileges: TablePrivilege | TablePrivilege[] | 'ALL' | ||
type CommonGrantOnTablesProps = CommonOnTablesProps & WithGrantOption | ||
|
||
interface OnlyGrantOnSomeTablesProps { | ||
tables: Name | Name[] | ||
} | ||
|
||
interface OnlyGrantOnAllTablesProps { | ||
tables: 'ALL' | ||
schema: string | ||
roles: Name | Name[] | ||
} | ||
|
||
type RevokeOnObjectsProps = OnlyGrantOption & RestrictOption & CascadeOption | ||
|
||
export type GrantOnSomeTablesProps = CommonGrantOnTablesProps & OnlyGrantOnSomeTablesProps | ||
export type GrantOnAllTablesProps = CommonGrantOnTablesProps & OnlyGrantOnAllTablesProps | ||
|
||
export type GrantOnTablesProps = GrantOnSomeTablesProps | GrantOnAllTablesProps | ||
export type RevokeOnTablesProps = CommonOnTablesProps & | ||
(OnlyGrantOnAllTablesProps | OnlyGrantOnSomeTablesProps) & | ||
RevokeOnObjectsProps | ||
|
||
type GrantOnTablesFn = (props: GrantOnTablesProps) => string | string[] | ||
type GrantOnTablesFn = (props: GrantOnTablesProps & RevokeOnObjectsProps) => string | string[] | ||
|
||
export type GrantOnTables = GrantOnTablesFn & { reverse: GrantOnTablesFn } | ||
export type RevokeOnTables = (props: RevokeOnTablesProps) => string | string[] | ||
|
||
interface GrantOnSchemasProps { | ||
privileges: SchemaPrivilege | SchemaPrivilege[] | 'ALL' | ||
schemas: string[] | string | ||
roles: Name | Name[] | ||
} | ||
|
||
type GrantOnSchemasFn = (props: GrantOnSchemasProps & WithGrantOption) => string | string[] | ||
type GrantOnSchemasFn = (props: GrantOnSchemasProps & WithGrantOption & RevokeOnObjectsProps) => string | string[] | ||
export type GrantOnSchemas = GrantOnSchemasFn & { reverse: GrantOnSchemasFn } | ||
export type RevokeOnSchemas = (props: GrantOnSchemasProps & RevokeOnObjectsProps) => string | string[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters