@palbase/backend 15.0.0 → 16.0.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/{chunk-LUV36KQU.js → chunk-ZZZHVPOQ.js} +2 -2
- package/dist/chunk-ZZZHVPOQ.js.map +1 -0
- package/dist/db/index.cjs +1 -1
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.cts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -1
- package/dist/{index-DmkBkvP6.d.cts → index-Cww79LRh.d.cts} +14 -8
- package/dist/{index-B398u5B0.d.ts → index-IYODApZV.d.ts} +14 -8
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-LUV36KQU.js.map +0 -1
|
@@ -324,9 +324,12 @@ type ColumnMap = Record<string, ColumnBuilder>;
|
|
|
324
324
|
* `{ columns, rls?, policies? }`.
|
|
325
325
|
*
|
|
326
326
|
* - `columns`: the column map (required).
|
|
327
|
-
* - `rls`: enable + FORCE row-level security on this table.
|
|
328
|
-
* `policies` is non-empty
|
|
329
|
-
*
|
|
327
|
+
* - `rls`: enable + FORCE row-level security on this table. **Defaults to
|
|
328
|
+
* `true`**, and is forced on when `policies` is non-empty. A table with RLS
|
|
329
|
+
* and no policies is deny-all, which is the starting state: nothing reads it
|
|
330
|
+
* until a policy says who may. Set `rls: false` only for a genuinely public
|
|
331
|
+
* table — it is an explicit opt-out that a reviewer can grep for, not
|
|
332
|
+
* something you get by forgetting.
|
|
330
333
|
* - `policies`: the RLS policies for this table, authored with `policy(name)`.
|
|
331
334
|
* Each entry may be a {@link PolicyBuilder} (the normal `policy(...)` chain)
|
|
332
335
|
* or a raw {@link PolicyDef} object.
|
|
@@ -381,7 +384,7 @@ interface TableInput<C extends ColumnMap = ColumnMap> {
|
|
|
381
384
|
*
|
|
382
385
|
* `defineSchema` derives `name` from the object key, so authors never repeat
|
|
383
386
|
* the table name. `rls`/`policies` are always present after normalization
|
|
384
|
-
* (defaulted to `
|
|
387
|
+
* (defaulted to `true`/`[]`).
|
|
385
388
|
*
|
|
386
389
|
* The `C` type parameter preserves the precise per-column phantom types so that
|
|
387
390
|
* downstream mapped types (InsertShape, RowShape) can discriminate on them.
|
|
@@ -467,10 +470,13 @@ type TablesFromInput<T extends Record<string, TableInput>> = {
|
|
|
467
470
|
* the runtime schema extractor parses. Per-column phantom types are preserved
|
|
468
471
|
* so `Database.tables.todos.insert({...})` stays typed.
|
|
469
472
|
*
|
|
470
|
-
* RLS normalization: `rls` defaults to
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
473
|
+
* RLS normalization: `rls` defaults to **`true`**, `policies` to `[]`. A table
|
|
474
|
+
* that declares neither is therefore deny-all — nothing reads it until a policy
|
|
475
|
+
* says who may, which is the safe starting point rather than a bug. Declare
|
|
476
|
+
* `rls: false` for a genuinely public table; that is an explicit, greppable
|
|
477
|
+
* statement of intent instead of an omission. When `policies` is non-empty,
|
|
478
|
+
* `rls` is forced on (ENABLE + FORCE) regardless of the declared flag — a table
|
|
479
|
+
* with policies must have RLS enabled or the policies would be inert.
|
|
474
480
|
*/
|
|
475
481
|
declare function defineSchema<T extends Record<string, TableInput>>(input: SchemaInput<T>): SchemaDef<TablesFromInput<T>>;
|
|
476
482
|
|
package/dist/index.cjs
CHANGED
|
@@ -1002,7 +1002,7 @@ function defineSchema(input) {
|
|
|
1002
1002
|
const table = input.tables[name];
|
|
1003
1003
|
if (table === void 0) continue;
|
|
1004
1004
|
const policies = (table.policies ?? []).map(toPolicyDef);
|
|
1005
|
-
const rls =
|
|
1005
|
+
const rls = policies.length > 0 || table.rls !== false;
|
|
1006
1006
|
const tableDef = {
|
|
1007
1007
|
name,
|
|
1008
1008
|
columns: table.columns,
|