pg-introspection
Advanced tools
Comparing version 0.0.1-0.3 to 0.0.1-1.1
# pg-introspection | ||
## 0.0.1-1.1 | ||
### Patch Changes | ||
- [#260](https://github.com/benjie/postgraphile-private/pull/260) | ||
[`d5312e6b9`](https://github.com/benjie/postgraphile-private/commit/d5312e6b968fbeb46d074b82a41b4bdbc166598c) | ||
Thanks [@benjie](https://github.com/benjie)! - TypeScript v5 is now required | ||
## 0.0.1-0.3 | ||
@@ -4,0 +12,0 @@ |
@@ -76,3 +76,3 @@ import type { Introspection, PgClass, PgRoles } from "./introspection.js"; | ||
export declare const emptyAclObject: AclObject; | ||
export declare const OBJECT_COLUMN = "OBJECT_COLUMN"; | ||
export declare const OBJECT_ATTRIBUTE = "OBJECT_ATTRIBUTE"; | ||
export declare const OBJECT_TABLE = "OBJECT_TABLE"; | ||
@@ -90,3 +90,3 @@ export declare const OBJECT_SEQUENCE = "OBJECT_SEQUENCE"; | ||
export declare const OBJECT_TYPE = "OBJECT_TYPE"; | ||
export type AclDefaultObjectType = typeof OBJECT_COLUMN | typeof OBJECT_TABLE | typeof OBJECT_SEQUENCE | typeof OBJECT_DATABASE | typeof OBJECT_FUNCTION | typeof OBJECT_LANGUAGE | typeof OBJECT_LARGEOBJECT | typeof OBJECT_SCHEMA | typeof OBJECT_TABLESPACE | typeof OBJECT_FDW | typeof OBJECT_FOREIGN_SERVER | typeof OBJECT_DOMAIN | typeof OBJECT_TYPE; | ||
export type AclDefaultObjectType = typeof OBJECT_ATTRIBUTE | typeof OBJECT_TABLE | typeof OBJECT_SEQUENCE | typeof OBJECT_DATABASE | typeof OBJECT_FUNCTION | typeof OBJECT_LANGUAGE | typeof OBJECT_LARGEOBJECT | typeof OBJECT_SCHEMA | typeof OBJECT_TABLESPACE | typeof OBJECT_FDW | typeof OBJECT_FOREIGN_SERVER | typeof OBJECT_DOMAIN | typeof OBJECT_TYPE; | ||
/** | ||
@@ -93,0 +93,0 @@ * Returns a list of AclObject by parsing the given input ACL strings. If no |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolvePermissions = exports.aclContainsRole = exports.expandRoles = exports.aclsForTable = exports.Permission = exports.parseAcls = exports.OBJECT_TYPE = exports.OBJECT_DOMAIN = exports.OBJECT_FOREIGN_SERVER = exports.OBJECT_FDW = exports.OBJECT_TABLESPACE = exports.OBJECT_SCHEMA = exports.OBJECT_LARGEOBJECT = exports.OBJECT_LANGUAGE = exports.OBJECT_FUNCTION = exports.OBJECT_DATABASE = exports.OBJECT_SEQUENCE = exports.OBJECT_TABLE = exports.OBJECT_COLUMN = exports.emptyAclObject = exports.serializeAcl = exports.parseAcl = exports.PUBLIC_ROLE = void 0; | ||
exports.resolvePermissions = exports.aclContainsRole = exports.expandRoles = exports.aclsForTable = exports.Permission = exports.parseAcls = exports.OBJECT_TYPE = exports.OBJECT_DOMAIN = exports.OBJECT_FOREIGN_SERVER = exports.OBJECT_FDW = exports.OBJECT_TABLESPACE = exports.OBJECT_SCHEMA = exports.OBJECT_LARGEOBJECT = exports.OBJECT_LANGUAGE = exports.OBJECT_FUNCTION = exports.OBJECT_DATABASE = exports.OBJECT_SEQUENCE = exports.OBJECT_TABLE = exports.OBJECT_ATTRIBUTE = exports.emptyAclObject = exports.serializeAcl = exports.parseAcl = exports.PUBLIC_ROLE = void 0; | ||
/** | ||
@@ -182,3 +182,3 @@ * A fake 'pg_roles' record representing the 'public' meta-role. | ||
exports.emptyAclObject = parseAcl("=/postgres"); | ||
exports.OBJECT_COLUMN = "OBJECT_COLUMN"; | ||
exports.OBJECT_ATTRIBUTE = "OBJECT_ATTRIBUTE"; | ||
exports.OBJECT_TABLE = "OBJECT_TABLE"; | ||
@@ -339,29 +339,34 @@ exports.OBJECT_SEQUENCE = "OBJECT_SEQUENCE"; | ||
function resolvePermissions(introspection, acls, role, includeNoInherit = false) { | ||
const expandedRoles = expandRoles(introspection, [role], includeNoInherit); | ||
const isSuperuser = expandedRoles.some((role) => role.rolsuper); | ||
// Just as in life, you start with nothing... | ||
const permissions = { | ||
select: false, | ||
selectGrant: false, | ||
update: false, | ||
updateGrant: false, | ||
insert: false, | ||
insertGrant: false, | ||
delete: false, | ||
deleteGrant: false, | ||
truncate: false, | ||
truncateGrant: false, | ||
references: false, | ||
referencesGrant: false, | ||
trigger: false, | ||
triggerGrant: false, | ||
execute: false, | ||
executeGrant: false, | ||
usage: false, | ||
usageGrant: false, | ||
create: false, | ||
createGrant: false, | ||
connect: false, | ||
connectGrant: false, | ||
temporary: false, | ||
temporaryGrant: false, | ||
select: isSuperuser, | ||
selectGrant: isSuperuser, | ||
update: isSuperuser, | ||
updateGrant: isSuperuser, | ||
insert: isSuperuser, | ||
insertGrant: isSuperuser, | ||
delete: isSuperuser, | ||
deleteGrant: isSuperuser, | ||
truncate: isSuperuser, | ||
truncateGrant: isSuperuser, | ||
references: isSuperuser, | ||
referencesGrant: isSuperuser, | ||
trigger: isSuperuser, | ||
triggerGrant: isSuperuser, | ||
execute: isSuperuser, | ||
executeGrant: isSuperuser, | ||
usage: isSuperuser, | ||
usageGrant: isSuperuser, | ||
create: isSuperuser, | ||
createGrant: isSuperuser, | ||
connect: isSuperuser, | ||
connectGrant: isSuperuser, | ||
temporary: isSuperuser, | ||
temporaryGrant: isSuperuser, | ||
}; | ||
if (isSuperuser) { | ||
return permissions; | ||
} | ||
for (const acl of acls) { | ||
@@ -368,0 +373,0 @@ const appliesToRole = aclContainsRole(introspection, acl, role, includeNoInherit); |
@@ -176,3 +176,3 @@ "use strict"; | ||
entity.getTags = memo(() => entity.getTagsAndDescription().tags); | ||
entity.getACL = memo(() => (0, acl_js_1.parseAcls)(introspection, entity.attacl, entity.getClass().relowner, acl_js_1.OBJECT_COLUMN)); | ||
entity.getACL = memo(() => (0, acl_js_1.parseAcls)(introspection, entity.attacl, entity.getClass().relowner, acl_js_1.OBJECT_ATTRIBUTE)); | ||
}); | ||
@@ -179,0 +179,0 @@ introspection.constraints.forEach((entity) => { |
@@ -1,2 +0,2 @@ | ||
import type { Introspection, PgAttribute, PgAuthMembers, PgClass, PgConstraint, PgDatabase, PgDepend, PgDescription, PgEnum, PgExtension, PgIndex, PgInherits, PgLanguage, PgNamespace, PgProc, PgRange, PgRoles, PgType } from "./introspection.js"; | ||
import type { Introspection, PgAttribute, PgAuthMembers, PgClass, PgConstraint, PgDatabase, PgDepend, PgDescription, PgEnum, PgExtension, PgIndex, PgInherits, PgLanguage, PgNamespace, PgProc, PgProcArgument, PgRange, PgRoles, PgType } from "./introspection.js"; | ||
export { makeIntrospectionQuery } from "./introspection.js"; | ||
@@ -7,3 +7,3 @@ import type { AclObject } from "./acl.js"; | ||
export { parseSmartComment } from "./smartComments.js"; | ||
export { Introspection, PgAttribute, PgAuthMembers, PgClass, PgConstraint, PgDatabase, PgDepend, PgDescription, PgEnum, PgExtension, PgIndex, PgInherits, PgLanguage, PgNamespace, PgProc, PgRange, PgRoles, PgType, }; | ||
export { Introspection, PgAttribute, PgAuthMembers, PgClass, PgConstraint, PgDatabase, PgDepend, PgDescription, PgEnum, PgExtension, PgIndex, PgInherits, PgLanguage, PgNamespace, PgProc, PgProcArgument, PgRange, PgRoles, PgType, }; | ||
export { aclContainsRole, AclObject, expandRoles, resolvePermissions }; | ||
@@ -10,0 +10,0 @@ export declare function parseIntrospectionResults(introspectionResults: string, includeExtensionResources?: boolean): Introspection; |
{ | ||
"name": "pg-introspection", | ||
"version": "0.0.1-0.3", | ||
"version": "0.0.1-1.1", | ||
"description": "Strongly typed PostgreSQL introspection library", | ||
@@ -36,4 +36,4 @@ "main": "dist/index.js", | ||
"@types/jest": "^27.5.1", | ||
"@types/node": "16.11.15", | ||
"jest": "^28.1.0", | ||
"@types/node": "18.15.5", | ||
"jest": "^28.1.3", | ||
"ts-node": "^10.9.1", | ||
@@ -40,0 +40,0 @@ "typescript": "^5.0.0-beta" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169714
2392