pg-introspection 0.0.1-alpha.4 → 0.0.1-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,109 @@
1
1
  # pg-introspection
2
2
 
3
+ ## 0.0.1-beta.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2256](https://github.com/graphile/crystal/pull/2256)
8
+ [`dc5746594`](https://github.com/graphile/crystal/commit/dc5746594d7870a13296f405f4327f89d17dac1e)
9
+ Thanks [@benjie](https://github.com/benjie)! - Add support for introspecting
10
+ RLS policies.
11
+
12
+ ## 0.0.1-beta.9
13
+
14
+ ### Patch Changes
15
+
16
+ - [#2202](https://github.com/graphile/crystal/pull/2202)
17
+ [`2efadc0f8`](https://github.com/graphile/crystal/commit/2efadc0f80c3a0c172fb94c770afecc5447e832b)
18
+ Thanks [@benjie](https://github.com/benjie)! - Postgres v17 support
19
+
20
+ ## 0.0.1-beta.8
21
+
22
+ ### Patch Changes
23
+
24
+ - [#1962](https://github.com/graphile/crystal/pull/1962)
25
+ [`7606a5b87`](https://github.com/graphile/crystal/commit/7606a5b87aed747fad4eb11744ef7b01cfa3b879)
26
+ Thanks [@DanielFGray](https://github.com/DanielFGray)! - Export PgEntity type
27
+ in pg-introspection
28
+
29
+ ## 0.0.1-beta.7
30
+
31
+ ### Patch Changes
32
+
33
+ - [#1943](https://github.com/graphile/crystal/pull/1943)
34
+ [`46d8289b4`](https://github.com/graphile/crystal/commit/46d8289b44ab10aea1ff3d2915184650d6896b81)
35
+ Thanks [@benjie](https://github.com/benjie)! - `pg-introspection` now exports
36
+ `reservedWords` which are a list of reserved keywords in PostgreSQL (in
37
+ uppercase; though SQL is case insensitive).
38
+
39
+ ## 0.0.1-beta.6
40
+
41
+ ### Patch Changes
42
+
43
+ - [#1927](https://github.com/graphile/crystal/pull/1927)
44
+ [`00d32d887`](https://github.com/graphile/crystal/commit/00d32d887a6ae01374a4fda1babab7c8f14832c0)
45
+ Thanks [@benjie](https://github.com/benjie)! - Excludes table constraints on
46
+ tables from extensions if configured to not include extensions.
47
+
48
+ - [#1927](https://github.com/graphile/crystal/pull/1927)
49
+ [`c62eee10b`](https://github.com/graphile/crystal/commit/c62eee10b445f9455bf2a0524ad2b828bdf4ffa6)
50
+ Thanks [@benjie](https://github.com/benjie)! - Add pg_am to pg-introspection
51
+ to enable determining index access method
52
+
53
+ ## 0.0.1-beta.5
54
+
55
+ ### Patch Changes
56
+
57
+ - [#1894](https://github.com/graphile/crystal/pull/1894)
58
+ [`7851d89ab`](https://github.com/graphile/crystal/commit/7851d89ab4216b0252583f0068a69900fa2ddc88)
59
+ Thanks [@benjie](https://github.com/benjie)! - Fix logic around RBAC
60
+ permissions for tables and sequences.
61
+
62
+ - [#1893](https://github.com/graphile/crystal/pull/1893)
63
+ [`470ee4000`](https://github.com/graphile/crystal/commit/470ee40008689de7cf6f206a9897abbe4891ff9b)
64
+ Thanks [@benjie](https://github.com/benjie)! - Import latest PG16 docs into
65
+ pg-introspection
66
+
67
+ ## 0.0.1-beta.4
68
+
69
+ ### Patch Changes
70
+
71
+ - [#1801](https://github.com/graphile/crystal/pull/1801)
72
+ [`2d447a6b4`](https://github.com/graphile/crystal/commit/2d447a6b45d7db2813bd957f412cd959e2185759)
73
+ Thanks [@benjie](https://github.com/benjie)! - Fix bug where the owner of a
74
+ database object wasn't seen as having any privileges.
75
+
76
+ ## 0.0.1-beta.3
77
+
78
+ ### Patch Changes
79
+
80
+ - [#514](https://github.com/graphile/crystal-pre-merge/pull/514)
81
+ [`c9848f693`](https://github.com/graphile/crystal-pre-merge/commit/c9848f6936a5abd7740c0638bfb458fb5551f03b)
82
+ Thanks [@benjie](https://github.com/benjie)! - Update package.json repository
83
+ information
84
+
85
+ ## 0.0.1-beta.2
86
+
87
+ ### Patch Changes
88
+
89
+ - [#496](https://github.com/benjie/crystal/pull/496)
90
+ [`c9bfd9892`](https://github.com/benjie/crystal/commit/c9bfd989247f9433fb5b18c5175c9d8d64cd21a1)
91
+ Thanks [@benjie](https://github.com/benjie)! - Update dependencies (sometimes
92
+ through major versions).
93
+
94
+ ## 0.0.1-beta.1
95
+
96
+ ### Patch Changes
97
+
98
+ - [`cbd987385`](https://github.com/benjie/crystal/commit/cbd987385f99bd1248bc093ac507cc2f641ba3e8)
99
+ Thanks [@benjie](https://github.com/benjie)! - Bump all packages to beta
100
+
3
101
  ## 0.0.1-alpha.4
4
102
 
5
103
  ### Patch Changes
6
104
 
7
- - [#408](https://github.com/benjie/postgraphile-private/pull/408)
8
- [`bc14d488d`](https://github.com/benjie/postgraphile-private/commit/bc14d488d5385f350b6d377716e43c46a405dc57)
105
+ - [#408](https://github.com/benjie/crystal/pull/408)
106
+ [`bc14d488d`](https://github.com/benjie/crystal/commit/bc14d488d5385f350b6d377716e43c46a405dc57)
9
107
  Thanks [@benjie](https://github.com/benjie)! - When sorting, specify a
10
108
  concrete locale to localeCompare to ensure stable ordering across machines.
11
109
 
@@ -13,8 +111,8 @@
13
111
 
14
112
  ### Patch Changes
15
113
 
16
- - [#386](https://github.com/benjie/postgraphile-private/pull/386)
17
- [`8230fcaeb`](https://github.com/benjie/postgraphile-private/commit/8230fcaeb0286c905fc0dad4b7af2d94bac88a44)
114
+ - [#386](https://github.com/benjie/crystal/pull/386)
115
+ [`8230fcaeb`](https://github.com/benjie/crystal/commit/8230fcaeb0286c905fc0dad4b7af2d94bac88a44)
18
116
  Thanks [@benjie](https://github.com/benjie)! - If an issue occurs whilst
19
117
  retrieving attributes for a constraint, we now log an error and return an
20
118
  empty array.
@@ -23,7 +121,7 @@
23
121
 
24
122
  ### Patch Changes
25
123
 
26
- - [`7f857950a`](https://github.com/benjie/postgraphile-private/commit/7f857950a7e4ec763c936eb6bd1fb77824041d71)
124
+ - [`7f857950a`](https://github.com/benjie/crystal/commit/7f857950a7e4ec763c936eb6bd1fb77824041d71)
27
125
  Thanks [@benjie](https://github.com/benjie)! - Upgrade to the latest
28
126
  TypeScript/tslib
29
127
 
@@ -31,7 +129,7 @@
31
129
 
32
130
  ### Patch Changes
33
131
 
34
- - [`759ad403d`](https://github.com/benjie/postgraphile-private/commit/759ad403d71363312c5225c165873ae84b8a098c)
132
+ - [`759ad403d`](https://github.com/benjie/crystal/commit/759ad403d71363312c5225c165873ae84b8a098c)
35
133
  Thanks [@benjie](https://github.com/benjie)! - Alpha release - see
36
134
  https://postgraphile.org/news/2023-04-26-version-5-alpha
37
135
 
@@ -39,8 +137,8 @@
39
137
 
40
138
  ### Patch Changes
41
139
 
42
- - [#260](https://github.com/benjie/postgraphile-private/pull/260)
43
- [`d5312e6b9`](https://github.com/benjie/postgraphile-private/commit/d5312e6b968fbeb46d074b82a41b4bdbc166598c)
140
+ - [#260](https://github.com/benjie/crystal/pull/260)
141
+ [`d5312e6b9`](https://github.com/benjie/crystal/commit/d5312e6b968fbeb46d074b82a41b4bdbc166598c)
44
142
  Thanks [@benjie](https://github.com/benjie)! - TypeScript v5 is now required
45
143
 
46
144
  ## 0.0.1-0.3
@@ -71,6 +169,6 @@
71
169
 
72
170
  ### Patch Changes
73
171
 
74
- - [#125](https://github.com/benjie/postgraphile-private/pull/125)
75
- [`91f2256b3`](https://github.com/benjie/postgraphile-private/commit/91f2256b3fd699bec19fc86f1ca79df057e58639)
172
+ - [#125](https://github.com/benjie/crystal/pull/125)
173
+ [`91f2256b3`](https://github.com/benjie/crystal/commit/91f2256b3fd699bec19fc86f1ca79df057e58639)
76
174
  Thanks [@benjie](https://github.com/benjie)! - Initial changesets release
package/LICENSE.md CHANGED
@@ -26,7 +26,8 @@ license applies to those excerpts:
26
26
 
27
27
  PostgreSQL is Copyright © 1996–2022 by the PostgreSQL Global Development Group.
28
28
 
29
- Postgres95 is Copyright © 1994–5 by the Regents of the University of California.
29
+ Postgres95 is Copyright © 1994–5 by the Regents of the University of
30
+ California.
30
31
 
31
32
  Permission to use, copy, modify, and distribute this software and its
32
33
  documentation for any purpose, without fee, and without a written agreement is
package/README.md CHANGED
@@ -15,9 +15,9 @@ PostgreSQL documentation for easy reference directly in your editor.
15
15
 
16
16
  ## Crowd-funded open-source software
17
17
 
18
- To help us develop this software sustainably under the MIT license, we ask all
19
- individuals and businesses that use it to help support its ongoing maintenance
20
- and development via sponsorship.
18
+ To help us develop this software sustainably, we ask all individuals and
19
+ businesses that use it to help support its ongoing maintenance and development
20
+ via sponsorship.
21
21
 
22
22
  ### [Click here to find out more about sponsors and sponsorship.](https://www.graphile.org/sponsor/)
23
23
 
@@ -26,11 +26,10 @@ And please give some love to our featured sponsors 🤩:
26
26
  <table><tr>
27
27
  <td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td>
28
28
  <td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td>
29
- <td align="center"><a href="https://qwick.com/"><img src="https://graphile.org/images/sponsors/qwick.png" width="90" height="90" alt="Qwick" /><br />Qwick</a> *</td>
30
- <td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td>
31
- </tr><tr>
32
- <td align="center"><a href=""><img src="https://graphile.org/images/sponsors/chadf.png" width="90" height="90" alt="Chad Furman" /><br />Chad Furman</a> *</td>
33
29
  <td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
30
+ <td align="center"><a href="https://gosteelhead.com/"><img src="https://graphile.org/images/sponsors/steelhead.svg" width="90" height="90" alt="Steelhead" /><br />Steelhead</a> *</td>
31
+ </tr><tr>
32
+ <td align="center"><a href=""><img src="https://graphile.org/images/sponsors/latchbio.jpg" width="90" height="90" alt="LatchBio" /><br />LatchBio</a> *</td>
34
33
  </tr></table>
35
34
 
36
35
  <em>\* Sponsors the entire Graphile suite</em>
@@ -59,7 +58,7 @@ const pool = new Pool({
59
58
  async function main() {
60
59
  const sql = makeIntrospectionQuery();
61
60
  const { rows } = await pool.query(sql);
62
- const introspection = parseIntrospectionResults(row[0].introspection);
61
+ const introspection = parseIntrospectionResults(rows[0].introspection);
63
62
 
64
63
  console.log(
65
64
  `The ${introspection.database.datname} DBA is ${
package/dist/acl.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Introspection, PgClass, PgRoles } from "./introspection.js";
1
+ import type { Introspection, PgEntity, PgRoles } from "./introspection.js";
2
2
  /**
3
3
  * A fake 'pg_roles' record representing the 'public' meta-role.
4
4
  */
@@ -60,6 +60,10 @@ export interface AclObject {
60
60
  temporary?: boolean;
61
61
  /** T* */
62
62
  temporaryGrant?: boolean;
63
+ /** m */
64
+ maintain?: boolean;
65
+ /** m* */
66
+ maintainGrant?: boolean;
63
67
  }
64
68
  export type ResolvedPermissions = Omit<AclObject, "role" | "granter">;
65
69
  /**
@@ -73,7 +77,7 @@ export declare function parseAcl(aclString: string): AclObject;
73
77
  */
74
78
  export declare function serializeAcl(acl: AclObject): string;
75
79
  export declare const emptyAclObject: AclObject;
76
- export declare const OBJECT_ATTRIBUTE = "OBJECT_ATTRIBUTE";
80
+ export declare const OBJECT_COLUMN = "OBJECT_COLUMN";
77
81
  export declare const OBJECT_TABLE = "OBJECT_TABLE";
78
82
  export declare const OBJECT_SEQUENCE = "OBJECT_SEQUENCE";
79
83
  export declare const OBJECT_DATABASE = "OBJECT_DATABASE";
@@ -86,7 +90,7 @@ export declare const OBJECT_FDW = "OBJECT_FDW";
86
90
  export declare const OBJECT_FOREIGN_SERVER = "OBJECT_FOREIGN_SERVER";
87
91
  export declare const OBJECT_DOMAIN = "OBJECT_DOMAIN";
88
92
  export declare const OBJECT_TYPE = "OBJECT_TYPE";
89
- 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
+ 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;
90
94
  /**
91
95
  * Returns a list of AclObject by parsing the given input ACL strings. If no
92
96
  * ACL strings are present then it will return the default (implied) ACL for
@@ -100,7 +104,7 @@ export type AclDefaultObjectType = typeof OBJECT_ATTRIBUTE | typeof OBJECT_TABLE
100
104
  *
101
105
  * https://github.com/postgres/postgres/blob/fb3b098fe88441f9531a5169008ea17eac01301f/src/include/utils/acl.h#L153-L167
102
106
  */
103
- export declare function parseAcls(introspection: Introspection, inAcls: readonly string[] | null, ownerId: string, type: AclDefaultObjectType): AclObject[];
107
+ export declare function parseAcls(introspection: Introspection, inAcls: readonly string[] | null, ownerId: string, objtype: AclDefaultObjectType): AclObject[];
104
108
  export declare const Permission: {
105
109
  readonly select: "select";
106
110
  readonly selectGrant: "selectGrant";
@@ -126,8 +130,9 @@ export declare const Permission: {
126
130
  readonly connectGrant: "connectGrant";
127
131
  readonly temporary: "temporary";
128
132
  readonly temporaryGrant: "temporaryGrant";
133
+ readonly maintain: "maintain";
134
+ readonly maintainGrant: "maintainGrant";
129
135
  };
130
- export declare function aclsForTable(introspection: Introspection, table: PgClass): AclObject[];
131
136
  /**
132
137
  * Returns all the roles role has been granted (including PUBLIC),
133
138
  * respecting `NOINHERIT`
@@ -147,5 +152,8 @@ export declare function aclContainsRole(introspection: Introspection, acl: AclOb
147
152
  * Filters the ACL objects to only those that apply to `role`, then calculates
148
153
  * the `OR` of all the permissions to see what permissions the role has.
149
154
  */
150
- export declare function resolvePermissions(introspection: Introspection, acls: AclObject[], role: PgRoles, includeNoInherit?: boolean): ResolvedPermissions;
155
+ export declare function resolvePermissions(introspection: Introspection, acls: AclObject[], role: PgRoles, includeNoInherit?: boolean, isOwnerAndHasNoExplicitACLs?: boolean): ResolvedPermissions;
156
+ export declare function entityPermissions(introspection: Introspection, entity: Extract<PgEntity, {
157
+ getACL(): readonly AclObject[];
158
+ }>, role: PgRoles, includeNoInherit?: boolean): ResolvedPermissions;
151
159
  //# sourceMappingURL=acl.d.ts.map
package/dist/acl.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"acl.d.ts","sourceRoot":"","sources":["../src/acl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,OAcxB,CAAC;AA8BH;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAEhB,QAAQ;IACR,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS;IACT,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,QAAQ;IACR,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS;IACT,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,QAAQ;IACR,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS;IACT,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,QAAQ;IACR,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS;IACT,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,QAAQ;IACR,QAAQ,CAAC,EAAE,OAAO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AwBzB"}
package/dist/acl.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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;
3
+ exports.entityPermissions = exports.resolvePermissions = exports.aclContainsRole = exports.expandRoles = 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;
4
4
  /**
5
5
  * A fake 'pg_roles' record representing the 'public' meta-role.
6
6
  */
@@ -58,7 +58,7 @@ const parseIdentifier = (str) => str.startsWith('"') ? str.replace(/"("?)/g, "$1
58
58
  */
59
59
  function parseAcl(aclString) {
60
60
  // https://www.postgresql.org/docs/current/ddl-priv.html#PRIVILEGE-ABBREVS-TABLE
61
- const matches = aclString.match(/^([^=]*)=([rwadDxtXUCcT*]*)\/([^=]+)$/);
61
+ const matches = aclString.match(/^([^=]*)=([rwadDxtXUCcTm*]*)\/([^=]+)$/);
62
62
  if (!matches) {
63
63
  throw new Error(`Could not parse ACL string '${aclString}'`);
64
64
  }
@@ -89,6 +89,8 @@ function parseAcl(aclString) {
89
89
  const connectGrant = permissions.includes("c*");
90
90
  const temporary = permissions.includes("T");
91
91
  const temporaryGrant = permissions.includes("T*");
92
+ const maintain = permissions.includes("m");
93
+ const maintainGrant = permissions.includes("m*");
92
94
  const acl = {
93
95
  role: role || "public",
94
96
  granter,
@@ -116,6 +118,8 @@ function parseAcl(aclString) {
116
118
  connectGrant,
117
119
  temporary,
118
120
  temporaryGrant,
121
+ maintain,
122
+ maintainGrant,
119
123
  };
120
124
  return acl;
121
125
  }
@@ -174,12 +178,16 @@ function serializeAcl(acl) {
174
178
  permissions += "T*";
175
179
  else if (acl.temporary)
176
180
  permissions += "T";
181
+ if (acl.maintainGrant)
182
+ permissions += "m*";
183
+ else if (acl.maintain)
184
+ permissions += "m";
177
185
  permissions += `/${acl.granter}`;
178
186
  return permissions;
179
187
  }
180
188
  exports.serializeAcl = serializeAcl;
181
189
  exports.emptyAclObject = parseAcl("=/postgres");
182
- exports.OBJECT_ATTRIBUTE = "OBJECT_ATTRIBUTE";
190
+ exports.OBJECT_COLUMN = "OBJECT_COLUMN";
183
191
  exports.OBJECT_TABLE = "OBJECT_TABLE";
184
192
  exports.OBJECT_SEQUENCE = "OBJECT_SEQUENCE";
185
193
  exports.OBJECT_DATABASE = "OBJECT_DATABASE";
@@ -192,6 +200,37 @@ exports.OBJECT_FDW = "OBJECT_FDW";
192
200
  exports.OBJECT_FOREIGN_SERVER = "OBJECT_FOREIGN_SERVER";
193
201
  exports.OBJECT_DOMAIN = "OBJECT_DOMAIN";
194
202
  exports.OBJECT_TYPE = "OBJECT_TYPE";
203
+ // https://github.com/postgres/postgres/blob/4908c5872059c409aa647bcde758dfeffe07996e/src/include/nodes/parsenodes.h#L76-L89
204
+ // https://www.postgresql.org/docs/current/ddl-priv.html#PRIVILEGE-ABBREVS-TABLE
205
+ const ACL_SELECT = "r";
206
+ const ACL_INSERT = "a";
207
+ const ACL_UPDATE = "w";
208
+ const ACL_DELETE = "d";
209
+ const ACL_TRUNCATE = "D";
210
+ const ACL_REFERENCES = "x";
211
+ const ACL_TRIGGER = "t";
212
+ const ACL_CREATE = "C";
213
+ const ACL_CONNECT = "c";
214
+ const ACL_CREATE_TEMP = "T";
215
+ const ACL_MAINTAIN = "m";
216
+ const ACL_EXECUTE = "X";
217
+ const ACL_USAGE = "U";
218
+ // const ACL_SET = "s";
219
+ // const ACL_ALTER_SYSTEM = "A";
220
+ /** @see {@link https://github.com/postgres/postgres/blob/4908c5872059c409aa647bcde758dfeffe07996e/src/include/nodes/parsenodes.h#L91} */
221
+ const ACL_NO_RIGHTS = "";
222
+ /** @see {@link https://github.com/postgres/postgres/blob/4908c5872059c409aa647bcde758dfeffe07996e/src/include/utils/acl.h#L159} */
223
+ const ACL_ALL_RIGHTS_RELATION = `${ACL_INSERT}${ACL_SELECT}${ACL_UPDATE}${ACL_DELETE}${ACL_TRUNCATE}${ACL_REFERENCES}${ACL_TRIGGER}${ACL_MAINTAIN}`;
224
+ const ACL_ALL_RIGHTS_SEQUENCE = `${ACL_USAGE}${ACL_SELECT}${ACL_UPDATE}`;
225
+ const ACL_ALL_RIGHTS_DATABASE = `${ACL_CREATE}${ACL_CREATE_TEMP}${ACL_CONNECT}`;
226
+ const ACL_ALL_RIGHTS_FDW = ACL_USAGE;
227
+ const ACL_ALL_RIGHTS_FOREIGN_SERVER = ACL_USAGE;
228
+ const ACL_ALL_RIGHTS_FUNCTION = ACL_EXECUTE;
229
+ const ACL_ALL_RIGHTS_LANGUAGE = ACL_USAGE;
230
+ const ACL_ALL_RIGHTS_LARGEOBJECT = `${ACL_SELECT}${ACL_UPDATE}`;
231
+ const ACL_ALL_RIGHTS_SCHEMA = `${ACL_USAGE}${ACL_CREATE}`;
232
+ const ACL_ALL_RIGHTS_TABLESPACE = ACL_CREATE;
233
+ const ACL_ALL_RIGHTS_TYPE = ACL_USAGE;
195
234
  /**
196
235
  * Returns a list of AclObject by parsing the given input ACL strings. If no
197
236
  * ACL strings are present then it will return the default (implied) ACL for
@@ -205,40 +244,75 @@ exports.OBJECT_TYPE = "OBJECT_TYPE";
205
244
  *
206
245
  * https://github.com/postgres/postgres/blob/fb3b098fe88441f9531a5169008ea17eac01301f/src/include/utils/acl.h#L153-L167
207
246
  */
208
- function parseAcls(introspection, inAcls, ownerId, type) {
247
+ function parseAcls(introspection, inAcls, ownerId, objtype) {
209
248
  const aclStrings = inAcls ||
210
249
  (() => {
211
250
  const owner = getRole(introspection, ownerId);
212
- switch (type) {
251
+ let worldDefault;
252
+ let ownerDefault;
253
+ switch (objtype) {
254
+ case exports.OBJECT_COLUMN:
255
+ worldDefault = ACL_NO_RIGHTS;
256
+ ownerDefault = ACL_NO_RIGHTS;
257
+ break;
213
258
  case exports.OBJECT_TABLE:
214
- return [`${owner.rolname}=arwdDxt/${owner.rolname}`];
259
+ worldDefault = ACL_NO_RIGHTS;
260
+ ownerDefault = ACL_ALL_RIGHTS_RELATION;
261
+ break;
215
262
  case exports.OBJECT_SEQUENCE:
216
- return [`${owner.rolname}=Urw/${owner.rolname}`];
263
+ worldDefault = ACL_NO_RIGHTS;
264
+ ownerDefault = ACL_ALL_RIGHTS_SEQUENCE;
265
+ break;
217
266
  case exports.OBJECT_DATABASE:
218
- return [
219
- `=Tc/${owner.rolname}`,
220
- `${owner.rolname}=CTc/${owner.rolname}`,
221
- ];
267
+ worldDefault = `${ACL_CREATE_TEMP}${ACL_CONNECT}`;
268
+ ownerDefault = ACL_ALL_RIGHTS_DATABASE;
269
+ break;
222
270
  case exports.OBJECT_FUNCTION:
223
- return [`=X/${owner.rolname}`, `${owner.rolname}=X/${owner.rolname}`];
271
+ worldDefault = ACL_EXECUTE;
272
+ ownerDefault = ACL_ALL_RIGHTS_FUNCTION;
273
+ break;
224
274
  case exports.OBJECT_LANGUAGE:
225
- return [`=U/${owner.rolname}`, `${owner.rolname}=U/${owner.rolname}`];
275
+ worldDefault = ACL_USAGE;
276
+ ownerDefault = ACL_ALL_RIGHTS_LANGUAGE;
277
+ break;
226
278
  case exports.OBJECT_LARGEOBJECT:
227
- return [`${owner.rolname}=rw/${owner.rolname}`];
279
+ worldDefault = ACL_NO_RIGHTS;
280
+ ownerDefault = ACL_ALL_RIGHTS_LARGEOBJECT;
281
+ break;
228
282
  case exports.OBJECT_SCHEMA:
229
- return [`${owner.rolname}=UC/${owner.rolname}`];
283
+ worldDefault = ACL_NO_RIGHTS;
284
+ ownerDefault = ACL_ALL_RIGHTS_SCHEMA;
285
+ break;
230
286
  case exports.OBJECT_TABLESPACE:
231
- return [`${owner.rolname}=C/${owner.rolname}`];
287
+ worldDefault = ACL_NO_RIGHTS;
288
+ ownerDefault = ACL_ALL_RIGHTS_TABLESPACE;
289
+ break;
232
290
  case exports.OBJECT_FDW:
233
- return [`${owner.rolname}=U/${owner.rolname}`];
291
+ worldDefault = ACL_NO_RIGHTS;
292
+ ownerDefault = ACL_ALL_RIGHTS_FDW;
293
+ break;
234
294
  case exports.OBJECT_FOREIGN_SERVER:
235
- return [`${owner.rolname}=U/${owner.rolname}`];
295
+ worldDefault = ACL_NO_RIGHTS;
296
+ ownerDefault = ACL_ALL_RIGHTS_FOREIGN_SERVER;
297
+ break;
236
298
  case exports.OBJECT_DOMAIN:
237
299
  case exports.OBJECT_TYPE:
238
- return [`=U/${owner.rolname}`, `${owner.rolname}=U/${owner.rolname}`];
300
+ worldDefault = ACL_USAGE;
301
+ ownerDefault = ACL_ALL_RIGHTS_TYPE;
302
+ break;
239
303
  default:
240
- return [];
304
+ worldDefault = ACL_NO_RIGHTS;
305
+ ownerDefault = ACL_NO_RIGHTS;
306
+ break;
241
307
  }
308
+ const acl = [];
309
+ if (worldDefault !== ACL_NO_RIGHTS) {
310
+ acl.push(`=${worldDefault}/${owner.rolname}`);
311
+ }
312
+ if (ownerDefault !== ACL_NO_RIGHTS) {
313
+ acl.push(`${owner.rolname}=${ownerDefault}/${owner.rolname}`);
314
+ }
315
+ return acl;
242
316
  })();
243
317
  const acls = aclStrings.map((aclString) => parseAcl(aclString));
244
318
  return acls;
@@ -271,25 +345,9 @@ exports.Permission = {
271
345
  connectGrant: "connectGrant",
272
346
  temporary: "temporary",
273
347
  temporaryGrant: "temporaryGrant",
348
+ maintain: "maintain",
349
+ maintainGrant: "maintainGrant",
274
350
  };
275
- /*
276
- * For default permissions, see:
277
- * https://github.com/postgres/postgres/blob/14aec03502302eff6c67981d8fd121175c436ce9/src/backend/utils/adt/acl.c#L748-L854
278
- *
279
- * For what the privileges mean, see:
280
- * https://www.postgresql.org/docs/current/ddl-priv.html#PRIVILEGE-ABBREVS-TABLE
281
- */
282
- function aclsForTable(introspection, table) {
283
- const dbOwner = getRole(introspection, introspection.database.datdba);
284
- const isSequence = table.relkind === "S";
285
- const tableOwner = getRole(introspection, table.relowner);
286
- const defaultAcl = isSequence
287
- ? [`${tableOwner.rolname}=/${dbOwner.rolname}`]
288
- : [`=/${dbOwner.rolname}`, `${dbOwner.rolname}=/${dbOwner.rolname}`];
289
- const acls = (table.relacl || defaultAcl).map((aclString) => parseAcl(aclString));
290
- return acls;
291
- }
292
- exports.aclsForTable = aclsForTable;
293
351
  /**
294
352
  * Returns all the roles role has been granted (including PUBLIC),
295
353
  * respecting `NOINHERIT`
@@ -334,37 +392,42 @@ exports.aclContainsRole = aclContainsRole;
334
392
  * Filters the ACL objects to only those that apply to `role`, then calculates
335
393
  * the `OR` of all the permissions to see what permissions the role has.
336
394
  */
337
- function resolvePermissions(introspection, acls, role, includeNoInherit = false) {
395
+ function resolvePermissions(introspection, acls, role, includeNoInherit = false, isOwnerAndHasNoExplicitACLs = false) {
338
396
  const expandedRoles = expandRoles(introspection, [role], includeNoInherit);
339
397
  const isSuperuser = expandedRoles.some((role) => role.rolsuper);
340
- // Just as in life, you start with nothing...
398
+ // Superusers have all permissions. An owner of an object has all permissions
399
+ // _unless_ there's a specific ACL for that owner. In all other cases, just as
400
+ // in life, you start with nothing...
401
+ const grantAll = isSuperuser || isOwnerAndHasNoExplicitACLs;
341
402
  const permissions = {
342
- select: isSuperuser,
343
- selectGrant: isSuperuser,
344
- update: isSuperuser,
345
- updateGrant: isSuperuser,
346
- insert: isSuperuser,
347
- insertGrant: isSuperuser,
348
- delete: isSuperuser,
349
- deleteGrant: isSuperuser,
350
- truncate: isSuperuser,
351
- truncateGrant: isSuperuser,
352
- references: isSuperuser,
353
- referencesGrant: isSuperuser,
354
- trigger: isSuperuser,
355
- triggerGrant: isSuperuser,
356
- execute: isSuperuser,
357
- executeGrant: isSuperuser,
358
- usage: isSuperuser,
359
- usageGrant: isSuperuser,
360
- create: isSuperuser,
361
- createGrant: isSuperuser,
362
- connect: isSuperuser,
363
- connectGrant: isSuperuser,
364
- temporary: isSuperuser,
365
- temporaryGrant: isSuperuser,
403
+ select: grantAll,
404
+ selectGrant: grantAll,
405
+ update: grantAll,
406
+ updateGrant: grantAll,
407
+ insert: grantAll,
408
+ insertGrant: grantAll,
409
+ delete: grantAll,
410
+ deleteGrant: grantAll,
411
+ truncate: grantAll,
412
+ truncateGrant: grantAll,
413
+ references: grantAll,
414
+ referencesGrant: grantAll,
415
+ trigger: grantAll,
416
+ triggerGrant: grantAll,
417
+ execute: grantAll,
418
+ executeGrant: grantAll,
419
+ usage: grantAll,
420
+ usageGrant: grantAll,
421
+ create: grantAll,
422
+ createGrant: grantAll,
423
+ connect: grantAll,
424
+ connectGrant: grantAll,
425
+ temporary: grantAll,
426
+ temporaryGrant: grantAll,
427
+ maintain: grantAll,
428
+ maintainGrant: grantAll,
366
429
  };
367
- if (isSuperuser) {
430
+ if (grantAll) {
368
431
  return permissions;
369
432
  }
370
433
  for (const acl of acls) {
@@ -397,9 +460,29 @@ function resolvePermissions(introspection, acls, role, includeNoInherit = false)
397
460
  permissions.temporary = permissions.temporary || acl.temporary;
398
461
  permissions.temporaryGrant =
399
462
  permissions.temporaryGrant || acl.temporaryGrant;
463
+ permissions.maintain = permissions.maintain || acl.maintain;
464
+ permissions.maintainGrant =
465
+ permissions.maintainGrant || acl.maintainGrant;
400
466
  }
401
467
  }
402
468
  return permissions;
403
469
  }
404
470
  exports.resolvePermissions = resolvePermissions;
471
+ function entityPermissions(introspection, entity, role, includeNoInherit = false) {
472
+ const acls = entity.getACL();
473
+ const owner = entity._type === "PgAttribute"
474
+ ? entity.getClass()?.getOwner()
475
+ : entity.getOwner();
476
+ // If the role is the owner, and no explicit ACLs have been granted to this role, then the owner has all privileges.
477
+ const isOwnerAndHasNoExplicitACLs = owner &&
478
+ owner === role &&
479
+ !acls.some((acl) => acl.role === owner.rolname) &&
480
+ (entity._type !== "PgAttribute" ||
481
+ !entity
482
+ .getClass()
483
+ ?.getACL()
484
+ .some((acl) => acl.role === owner.rolname));
485
+ return resolvePermissions(introspection, acls, role, includeNoInherit, isOwnerAndHasNoExplicitACLs);
486
+ }
487
+ exports.entityPermissions = entityPermissions;
405
488
  //# sourceMappingURL=acl.js.map