@nest-boot/row-level-security 7.3.1 → 8.0.0-beta.0
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/dist/decorators/policy.decorator.d.ts +4 -4
- package/dist/decorators/policy.decorator.js +25 -31
- package/dist/decorators/policy.decorator.js.map +1 -1
- package/dist/enums/policy-command.enum.js +2 -5
- package/dist/enums/policy-command.enum.js.map +1 -1
- package/dist/enums/policy-mode.enum.js +2 -5
- package/dist/enums/policy-mode.enum.js.map +1 -1
- package/dist/enums/row-level-security-role.enum.js +2 -5
- package/dist/enums/row-level-security-role.enum.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -27
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +4 -4
- package/dist/interfaces/index.js +3 -19
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/policy-metadata.interface.d.ts +2 -2
- package/dist/interfaces/policy-metadata.interface.js +1 -2
- package/dist/interfaces/policy-options.interface.d.ts +2 -2
- package/dist/interfaces/policy-options.interface.js +1 -2
- package/dist/interfaces/policy-sql-options.interface.d.ts +2 -2
- package/dist/interfaces/policy-sql-options.interface.js +1 -2
- package/dist/interfaces/row-level-security-migration-generator.interface.d.ts +1 -1
- package/dist/interfaces/row-level-security-migration-generator.interface.js +1 -2
- package/dist/row-level-security-driver.d.ts +4 -3
- package/dist/row-level-security-driver.js +8 -19
- package/dist/row-level-security-driver.js.map +1 -1
- package/dist/row-level-security-migration-generator.d.ts +1 -1
- package/dist/row-level-security-migration-generator.js +40 -41
- package/dist/row-level-security-migration-generator.js.map +1 -1
- package/dist/row-level-security-migration.d.ts +1 -1
- package/dist/row-level-security-migration.js +9 -13
- package/dist/row-level-security-migration.js.map +1 -1
- package/dist/row-level-security-migrator.d.ts +2 -2
- package/dist/row-level-security-migrator.js +9 -13
- package/dist/row-level-security-migrator.js.map +1 -1
- package/dist/row-level-security.d.ts +1 -1
- package/dist/row-level-security.js +19 -23
- package/dist/row-level-security.js.map +1 -1
- package/dist/utils/assert-identifier.js +1 -4
- package/dist/utils/assert-identifier.js.map +1 -1
- package/dist/utils/assert-snake-case.js +1 -4
- package/dist/utils/assert-snake-case.js.map +1 -1
- package/dist/utils/create-policy-bootstrap-sql-statements.js +1 -4
- package/dist/utils/create-policy-bootstrap-sql-statements.js.map +1 -1
- package/dist/utils/create-policy-down-sql.d.ts +1 -1
- package/dist/utils/create-policy-down-sql.js +5 -8
- package/dist/utils/create-policy-down-sql.js.map +1 -1
- package/dist/utils/create-policy-privilege-down-sql-statements.d.ts +1 -1
- package/dist/utils/create-policy-privilege-down-sql-statements.js +19 -22
- package/dist/utils/create-policy-privilege-down-sql-statements.js.map +1 -1
- package/dist/utils/create-policy-role-sql-statements.js +8 -13
- package/dist/utils/create-policy-role-sql-statements.js.map +1 -1
- package/dist/utils/create-policy-up-sql-statements.d.ts +1 -1
- package/dist/utils/create-policy-up-sql-statements.js +26 -29
- package/dist/utils/create-policy-up-sql-statements.js.map +1 -1
- package/dist/utils/create-row-level-security-transaction-setup.js +15 -18
- package/dist/utils/create-row-level-security-transaction-setup.js.map +1 -1
- package/dist/utils/escape-sql-literal.js +1 -4
- package/dist/utils/escape-sql-literal.js.map +1 -1
- package/dist/utils/index.d.ts +12 -12
- package/dist/utils/index.js +11 -27
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/is-postgres-keyword-requiring-quote.js +1 -4
- package/dist/utils/is-postgres-keyword-requiring-quote.js.map +1 -1
- package/dist/utils/normalize-postgres-type-alias.util.js +1 -4
- package/dist/utils/normalize-postgres-type-alias.util.js.map +1 -1
- package/dist/utils/quote-identifier.js +3 -6
- package/dist/utils/quote-identifier.js.map +1 -1
- package/dist/utils/quote-qualified-identifier.js +3 -6
- package/dist/utils/quote-qualified-identifier.js.map +1 -1
- package/dist/utils/row-level-security-context-builder.d.ts +1 -1
- package/dist/utils/row-level-security-context-builder.js +7 -13
- package/dist/utils/row-level-security-context-builder.js.map +1 -1
- package/dist/utils/row-level-security-context-builder.types.js +1 -2
- package/package.json +31 -31
- package/dist/decorators/policy.decorator.spec.d.ts +0 -1
- package/dist/decorators/policy.decorator.spec.js +0 -550
- package/dist/decorators/policy.decorator.spec.js.map +0 -1
- package/dist/index.spec.d.ts +0 -1
- package/dist/index.spec.js +0 -64
- package/dist/index.spec.js.map +0 -1
- package/dist/row-level-security-driver.spec.d.ts +0 -1
- package/dist/row-level-security-driver.spec.js +0 -267
- package/dist/row-level-security-driver.spec.js.map +0 -1
- package/dist/row-level-security-migration-generator.spec.d.ts +0 -1
- package/dist/row-level-security-migration-generator.spec.js +0 -1135
- package/dist/row-level-security-migration-generator.spec.js.map +0 -1
- package/dist/row-level-security-migration.spec.d.ts +0 -1
- package/dist/row-level-security-migration.spec.js +0 -32
- package/dist/row-level-security-migration.spec.js.map +0 -1
- package/dist/row-level-security.spec.d.ts +0 -1
- package/dist/row-level-security.spec.js +0 -52
- package/dist/row-level-security.spec.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/utils/normalize-postgres-type-alias.spec.d.ts +0 -1
- package/dist/utils/normalize-postgres-type-alias.spec.js +0 -28
- package/dist/utils/normalize-postgres-type-alias.spec.js.map +0 -1
- package/dist/utils/policy-migration-sql.spec.d.ts +0 -1
- package/dist/utils/policy-migration-sql.spec.js +0 -273
- package/dist/utils/policy-migration-sql.spec.js.map +0 -1
- package/dist/utils/row-level-security-context-builder.spec.d.ts +0 -1
- package/dist/utils/row-level-security-context-builder.spec.js +0 -40
- package/dist/utils/row-level-security-context-builder.spec.js.map +0 -1
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RowLevelSecurityContextBuilder = void 0;
|
|
4
|
-
const assert_snake_case_1 = require("./assert-snake-case");
|
|
5
|
-
const escape_sql_literal_1 = require("./escape-sql-literal");
|
|
1
|
+
import { assertSnakeCase } from "./assert-snake-case.js";
|
|
2
|
+
import { escapeSqlLiteral } from "./escape-sql-literal.js";
|
|
6
3
|
/** Builds SQL that writes RLS context values into PostgreSQL transaction settings. */
|
|
7
|
-
class RowLevelSecurityContextBuilder {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.namespace = "app";
|
|
11
|
-
}
|
|
4
|
+
export class RowLevelSecurityContextBuilder {
|
|
5
|
+
ctx = new Map();
|
|
6
|
+
namespace = "app";
|
|
12
7
|
/** Adds a context key and value, ignoring nullish values. */
|
|
13
8
|
set(key, value) {
|
|
14
|
-
|
|
9
|
+
assertSnakeCase(key, "Row level security context key");
|
|
15
10
|
if (value === null || value === undefined) {
|
|
16
11
|
return this;
|
|
17
12
|
}
|
|
@@ -26,7 +21,7 @@ class RowLevelSecurityContextBuilder {
|
|
|
26
21
|
toSQL() {
|
|
27
22
|
const statements = this.entries()
|
|
28
23
|
.map(([key, value]) => {
|
|
29
|
-
const escapedValue =
|
|
24
|
+
const escapedValue = escapeSqlLiteral(value);
|
|
30
25
|
return /* SQL */ `set_config('${this.namespace}.${key}', '${escapedValue}', true)`;
|
|
31
26
|
})
|
|
32
27
|
.join(",");
|
|
@@ -36,5 +31,4 @@ class RowLevelSecurityContextBuilder {
|
|
|
36
31
|
return /* SQL */ `SELECT ${statements};`;
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
|
-
exports.RowLevelSecurityContextBuilder = RowLevelSecurityContextBuilder;
|
|
40
34
|
//# sourceMappingURL=row-level-security-context-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-level-security-context-builder.js","sourceRoot":"","sources":["../../src/utils/row-level-security-context-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"row-level-security-context-builder.js","sourceRoot":"","sources":["../../src/utils/row-level-security-context-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,sFAAsF;AACtF,MAAM,OAAO,8BAA8B;IACxB,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChC,SAAS,GAAG,KAAK,CAAC;IAEnC,6DAA6D;IAC7D,GAAG,CACD,GAAiB,EACjB,KAAmC;QAEnC,eAAe,CAAC,GAAG,EAAE,gCAAgC,CAAC,CAAC;QAEvD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+DAA+D;IAC/D,OAAO;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,8EAA8E;IAC9E,KAAK;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE;aAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACpB,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAC7C,OAAO,SAAS,CAAC,eAAe,IAAI,CAAC,SAAS,IAAI,GAAG,OAAO,YAAY,UAAU,CAAC;QACrF,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,OAAO,SAAS,CAAC,UAAU,UAAU,GAAG,CAAC;IAC3C,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-boot/row-level-security",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nest-boot/nest-boot.git",
|
|
@@ -23,34 +23,35 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@mikro-orm/migrations": "^
|
|
27
|
-
"@mikro-orm/postgresql": "^
|
|
28
|
-
"@
|
|
29
|
-
"reflect-metadata": "^0.2.2"
|
|
26
|
+
"@mikro-orm/migrations": "^7.0.0",
|
|
27
|
+
"@mikro-orm/postgresql": "^7.0.0",
|
|
28
|
+
"@mikro-orm/sql": "^7.0.0",
|
|
29
|
+
"reflect-metadata": "^0.2.2",
|
|
30
|
+
"@nest-boot/request-context": "^8.0.0-beta.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@mikro-orm/core": "
|
|
33
|
-
"@mikro-orm/
|
|
34
|
-
"@mikro-orm/
|
|
35
|
-
"@mikro-orm/
|
|
36
|
-
"@mikro-orm/
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@nestjs/
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
33
|
+
"@mikro-orm/core": "7.1.4",
|
|
34
|
+
"@mikro-orm/decorators": "7.1.4",
|
|
35
|
+
"@mikro-orm/migrations": "7.1.4",
|
|
36
|
+
"@mikro-orm/nestjs": "^7.0.2",
|
|
37
|
+
"@mikro-orm/postgresql": "7.1.4",
|
|
38
|
+
"@mikro-orm/reflection": "7.1.4",
|
|
39
|
+
"@mikro-orm/sql": "7.1.4",
|
|
40
|
+
"@nestjs/common": "next",
|
|
41
|
+
"@nestjs/core": "next",
|
|
42
|
+
"@nestjs/testing": "next",
|
|
43
|
+
"@types/node": "^26.0.0",
|
|
44
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
43
45
|
"eslint": "^9.39.3",
|
|
44
|
-
"jest": "^29.7.0",
|
|
45
46
|
"reflect-metadata": "^0.2.2",
|
|
46
47
|
"rxjs": "^7.8.2",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"@nest-boot/eslint-config": "^
|
|
50
|
-
"@nest-boot/
|
|
51
|
-
"@nest-boot/
|
|
52
|
-
"@nest-boot/
|
|
53
|
-
"@nest-boot/
|
|
48
|
+
"typescript": "^6.0.3",
|
|
49
|
+
"vitest": "^4.1.2",
|
|
50
|
+
"@nest-boot/eslint-config": "^8.0.0-beta.0",
|
|
51
|
+
"@nest-boot/request-context": "^8.0.0-beta.0",
|
|
52
|
+
"@nest-boot/eslint-plugin": "^8.0.0-beta.0",
|
|
53
|
+
"@nest-boot/tsconfig": "^8.0.0-beta.0",
|
|
54
|
+
"@nest-boot/mikro-orm": "^8.0.0-beta.0"
|
|
54
55
|
},
|
|
55
56
|
"publishConfig": {
|
|
56
57
|
"access": "public"
|
|
@@ -61,21 +62,20 @@
|
|
|
61
62
|
"eslint --fix"
|
|
62
63
|
]
|
|
63
64
|
},
|
|
64
|
-
"volta": {
|
|
65
|
-
"extends": "../../package.json"
|
|
66
|
-
},
|
|
67
65
|
"dependencies": {
|
|
68
66
|
"pgsql-ast-parser": "^12.0.2"
|
|
69
67
|
},
|
|
68
|
+
"type": "module",
|
|
70
69
|
"scripts": {
|
|
71
70
|
"build": "tsc -p tsconfig.build.json",
|
|
72
71
|
"clean": "rm -rf .nx && rm -rf node_modules && rm -rf dist",
|
|
73
72
|
"dev": "tsc -w -p tsconfig.build.json",
|
|
74
73
|
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
75
74
|
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
76
|
-
"test": "
|
|
77
|
-
"test:cov": "
|
|
78
|
-
"test:watch": "
|
|
79
|
-
"test:debug": "
|
|
75
|
+
"test": "vitest run",
|
|
76
|
+
"test:cov": "vitest run --coverage",
|
|
77
|
+
"test:watch": "vitest",
|
|
78
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism",
|
|
79
|
+
"test:e2e": "vitest run --config ./vitest.config.e2e.ts"
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|