@rebasepro/common 0.22.0 → 0.23.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/collections/default-collections.d.ts +1 -1
- package/dist/collections/field-access.d.ts +5 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/soft-delete.d.ts +23 -0
- package/dist/data/filter-dialect.d.ts +13 -0
- package/dist/index.es.js +250 -46
- package/dist/index.es.js.map +1 -1
- package/dist/util/policy/index.d.ts +1 -0
- package/dist/util/policy/policyToSecurityRule.d.ts +27 -0
- package/package.json +3 -3
- package/dist/util/callback-errors.test.d.ts +0 -1
- package/dist/util/internal-tables.test.d.ts +0 -1
- package/dist/util/permissions.test.d.ts +0 -1
- package/dist/util/table-name.test.d.ts +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PostgresPolicy, SecurityRule } from "@rebasepro/types";
|
|
2
|
+
/**
|
|
3
|
+
* The rule a Postgres policy compiles back from — a `pg_policies` row, or what
|
|
4
|
+
* a policy editor produced in that shape.
|
|
5
|
+
*
|
|
6
|
+
* One definition for every place that turns a policy into a rule: Studio's RLS
|
|
7
|
+
* editor ("Save" and "Import to codebase"), the collection editor's RLS tab
|
|
8
|
+
* ("Import to codebase") and "Import from table"
|
|
9
|
+
* (`buildCollectionFromTableMetadata`). The rule is what `db push` compiles back
|
|
10
|
+
* into the database, so anything this gets wrong is a policy that changes on
|
|
11
|
+
* the way back:
|
|
12
|
+
*
|
|
13
|
+
* - The `TO` list names *database* roles, which is `pgRoles`. `roles` holds
|
|
14
|
+
* *application* roles and compiles to a `rebase.roles()` check: filed there,
|
|
15
|
+
* `TO public` is a check no user passes, and on a restrictive policy — which
|
|
16
|
+
* compiles to `NOT (roles) OR condition` — a gate every user passes.
|
|
17
|
+
* `pgRoles` is omitted at the `public` default, so a rule that targets every
|
|
18
|
+
* connection, nearly all of them, carries no advanced field it does not need.
|
|
19
|
+
* - The WITH CHECK is kept whether or not there is a USING beside it. Every
|
|
20
|
+
* INSERT policy has only a check, and a rule with neither clause compiles to
|
|
21
|
+
* `WITH CHECK (false)`, which stops every insert.
|
|
22
|
+
* - `mode` is written when the policy states one: a restrictive policy read
|
|
23
|
+
* back as permissive is OR'd with every grant beside it.
|
|
24
|
+
* - Retired RLS helpers (`auth.uid()`) are respelled, as `sqlToPolicy` does
|
|
25
|
+
* for what it reads, because this rule is written into the project's config.
|
|
26
|
+
*/
|
|
27
|
+
export declare function policyToSecurityRule(policy: Partial<PostgresPolicy>): SecurityRule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Rebase shared core — collection registry, data driver adapter and fluent query builder. No React dependency.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rebase",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"fast-equals": "6.0.2",
|
|
46
46
|
"json-logic-js": "^2.0.5",
|
|
47
|
-
"@rebasepro/
|
|
48
|
-
"@rebasepro/
|
|
47
|
+
"@rebasepro/types": "0.23.0",
|
|
48
|
+
"@rebasepro/utils": "0.23.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@jest/globals": "^30.4.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|