@rebasepro/types 0.29.1 → 0.29.3
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/controllers/aggregates.d.ts +7 -1
- package/dist/controllers/client.d.ts +31 -3
- package/dist/controllers/data.d.ts +164 -29
- package/dist/controllers/data_driver.d.ts +63 -3
- package/dist/controllers/storage-references.d.ts +4 -3
- package/dist/controllers/storage.d.ts +3 -2
- package/dist/index.es.js +99 -5
- package/dist/index.es.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +1 -1
- package/dist/types/filter-operators.d.ts +23 -2
- package/dist/types/properties.d.ts +19 -3
- package/dist/types/resource_kinds.d.ts +5 -2
- package/dist/types/rls-functions.d.ts +59 -0
- package/package.json +1 -1
|
@@ -717,7 +717,7 @@ export interface AuthAdapter {
|
|
|
717
717
|
* refuse — for one that would leave the project without an administrator,
|
|
718
718
|
* among others.
|
|
719
719
|
*
|
|
720
|
-
* If not implemented, the rows are deleted
|
|
720
|
+
* If not implemented, the rows are deleted like any other.
|
|
721
721
|
*/
|
|
722
722
|
prepareUserDeletions?(uids: readonly string[]): Promise<void>;
|
|
723
723
|
/**
|
|
@@ -219,7 +219,8 @@ export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-conta
|
|
|
219
219
|
* { name: ["ilike", "%john%"] }
|
|
220
220
|
* { slug: ["like", "post-%"] }
|
|
221
221
|
*
|
|
222
|
-
* // Null checks (the value is ignored; `null` is conventional
|
|
222
|
+
* // Null checks (the value is ignored; `null` is conventional, and an
|
|
223
|
+
* // untyped caller may leave it out: `["is-null"]`)
|
|
223
224
|
* { deleted_at: ["is-null", null] }
|
|
224
225
|
* { published_at: ["is-not-null", null] }
|
|
225
226
|
*
|
|
@@ -279,7 +280,27 @@ export type FieldPath<M extends Record<string, unknown> = Record<string, unknown
|
|
|
279
280
|
*
|
|
280
281
|
* @group Models
|
|
281
282
|
*/
|
|
282
|
-
export type NonColumnFieldPath = `${string}.${string}` | `${string}->>${string}
|
|
283
|
+
export type NonColumnFieldPath = `${string}.${string}` | `${string}->>${string}` | CaseFoldedFieldPath;
|
|
284
|
+
/**
|
|
285
|
+
* A text column compared in one case: `lower(artist)` or `upper(code)`. Every
|
|
286
|
+
* operator applies to the folded value, so the values written beside it are
|
|
287
|
+
* written in that case — `{ "lower(artist)": ["in", ["abba", "queen"]] }`
|
|
288
|
+
* matches "ABBA" and "Queen". Compiled to `lower(artist)`, which an index on
|
|
289
|
+
* that expression serves. The same spelling an aggregate's `groupBy` uses.
|
|
290
|
+
*
|
|
291
|
+
* @group Models
|
|
292
|
+
*/
|
|
293
|
+
export type CaseFoldedFieldPath = `lower(${string})` | `upper(${string})`;
|
|
294
|
+
/**
|
|
295
|
+
* Read a {@link CaseFoldedFieldPath}: the function and the field it folds, or
|
|
296
|
+
* `undefined` for any other key.
|
|
297
|
+
*
|
|
298
|
+
* @group Models
|
|
299
|
+
*/
|
|
300
|
+
export declare function parseCaseFoldedFieldPath(key: string): {
|
|
301
|
+
fn: "lower" | "upper";
|
|
302
|
+
field: string;
|
|
303
|
+
} | undefined;
|
|
283
304
|
/**
|
|
284
305
|
* Relaxed filter type that also accepts pre-serialized PostgREST strings.
|
|
285
306
|
* **Internal only** — used at the wire-format boundary
|
|
@@ -771,6 +771,14 @@ export interface DateProperty extends BaseProperty {
|
|
|
771
771
|
* `updated_on` fields
|
|
772
772
|
*/
|
|
773
773
|
autoValue?: "on_create" | "on_update";
|
|
774
|
+
/**
|
|
775
|
+
* Makes this field (part of) the primary key — a calendar day in a key such
|
|
776
|
+
* as `(day, player)`. Only on `columnType: "date"`, whose value is a day and
|
|
777
|
+
* not an instant: it travels as `YYYY-MM-DD` in rows and in addresses
|
|
778
|
+
* (`2026-11-09:::p1`), never through a `Date`, so no time zone moves it.
|
|
779
|
+
* The day is the caller's (`"manual"`); the database assigns none.
|
|
780
|
+
*/
|
|
781
|
+
isId?: "manual" | true;
|
|
774
782
|
}
|
|
775
783
|
/**
|
|
776
784
|
* @group Entity properties
|
|
@@ -1017,6 +1025,8 @@ export type PropertyBuilderProps<M extends Record<string, unknown> = Record<stri
|
|
|
1017
1025
|
path: string;
|
|
1018
1026
|
/** The record's id, or `undefined` while it is being created. */
|
|
1019
1027
|
id?: string | number;
|
|
1028
|
+
/** @deprecated Use `id` instead. */
|
|
1029
|
+
entityId?: string | number;
|
|
1020
1030
|
/** Who is editing — the signed-in user and their roles. */
|
|
1021
1031
|
authController: AuthState;
|
|
1022
1032
|
};
|
|
@@ -1341,6 +1351,10 @@ export interface UploadedFileContext {
|
|
|
1341
1351
|
* The record's id; absent for one being created.
|
|
1342
1352
|
*/
|
|
1343
1353
|
id?: string | number;
|
|
1354
|
+
/**
|
|
1355
|
+
* @deprecated Use `id` instead.
|
|
1356
|
+
*/
|
|
1357
|
+
entityId?: string | number;
|
|
1344
1358
|
/**
|
|
1345
1359
|
* Entity path. E.g. `products/PID/locales`
|
|
1346
1360
|
*/
|
|
@@ -1494,8 +1508,10 @@ export interface PropertyConditions {
|
|
|
1494
1508
|
/**
|
|
1495
1509
|
* Make the field required when this condition evaluates to true.
|
|
1496
1510
|
* Overrides the static `validation.required` setting.
|
|
1511
|
+
*
|
|
1512
|
+
* A literal `true` makes it required unconditionally.
|
|
1497
1513
|
*/
|
|
1498
|
-
required?:
|
|
1514
|
+
required?: ConditionRule;
|
|
1499
1515
|
/**
|
|
1500
1516
|
* Custom message when conditional required validation fails.
|
|
1501
1517
|
*/
|
|
@@ -1566,9 +1582,9 @@ export interface PropertyConditions {
|
|
|
1566
1582
|
acceptedFiles?: JsonLogicRule;
|
|
1567
1583
|
/**
|
|
1568
1584
|
* Dynamic maximum file size in bytes.
|
|
1569
|
-
*
|
|
1585
|
+
* A number, or a rule that evaluates to one.
|
|
1570
1586
|
*/
|
|
1571
|
-
maxFileSize?: JsonLogicRule;
|
|
1587
|
+
maxFileSize?: number | JsonLogicRule;
|
|
1572
1588
|
}
|
|
1573
1589
|
/**
|
|
1574
1590
|
* Context available during JSON Logic condition evaluation.
|
|
@@ -80,6 +80,7 @@ export interface DatabaseRlsOptions {
|
|
|
80
80
|
provisionRole?: "auto" | "never";
|
|
81
81
|
grants?: "schema" | "managed" | "none";
|
|
82
82
|
policyTarget?: "public" | "requestRole";
|
|
83
|
+
adminPolicies?: "adminRole" | "public";
|
|
83
84
|
defaultPolicies?: boolean;
|
|
84
85
|
inheritRoles?: string[];
|
|
85
86
|
identity?: "rebase" | "supabase";
|
|
@@ -122,13 +123,15 @@ export declare function declaredDatabaseRls(key?: string): DatabaseRlsOptions;
|
|
|
122
123
|
* The policy settings every compile path must agree on — the boot's policy
|
|
123
124
|
* ensure, `rebase db generate`, the drift check — read from the one place all
|
|
124
125
|
* of them can see: the database declaration, with `REBASE_RLS_POLICY_TARGET` /
|
|
125
|
-
* `REBASE_RLS_DEFAULT_POLICIES` over it. Defaults
|
|
126
|
-
* before these existed
|
|
126
|
+
* `REBASE_RLS_ADMIN_POLICIES` / `REBASE_RLS_DEFAULT_POLICIES` over it. Defaults
|
|
127
|
+
* are what Rebase compiled before these existed, except `adminPolicies`, whose
|
|
128
|
+
* default (`"adminRole"`) changed what the server-or-admin policies are `TO`.
|
|
127
129
|
*
|
|
128
130
|
* Browser-safe: where there is no `process`, only the declaration counts.
|
|
129
131
|
*/
|
|
130
132
|
export declare function declaredRlsPolicyShape(dataSource?: string): {
|
|
131
133
|
policyTarget: "public" | "requestRole";
|
|
134
|
+
adminPolicies: "adminRole" | "public";
|
|
132
135
|
defaultPolicies: boolean;
|
|
133
136
|
};
|
|
134
137
|
/** Options a bucket accepts beyond the common ones. */
|
|
@@ -65,6 +65,65 @@ export declare const RLS_UID_SQL = "rebase.uid()";
|
|
|
65
65
|
export declare const RLS_IS_REQUEST_ROLE_SQL = "(SELECT rebase.is_request_role(current_user::text))";
|
|
66
66
|
/** The request's roles as a comma-separated string, for `string_to_array`. */
|
|
67
67
|
export declare const RLS_ROLES_SQL = "rebase.roles()";
|
|
68
|
+
/**
|
|
69
|
+
* The Postgres role that policies granting only the server context or admins
|
|
70
|
+
* are written `TO`: the injected `<table>_default_admin_*` baseline, and any
|
|
71
|
+
* permissive rule whose every clause requires one of the two (`roles: ["admin"]`).
|
|
72
|
+
*
|
|
73
|
+
* Postgres ORs the permissive policies that apply to the current role. Written
|
|
74
|
+
* `TO public`, the baseline applied to every signed-in user too, as
|
|
75
|
+
* `(InitPlan) OR owner_id = (InitPlan)` — and an OR with a per-statement
|
|
76
|
+
* constant arm cannot use the owner index, so a user's owner-scoped list or
|
|
77
|
+
* count scanned the whole table (78 ms against 2.8 ms at 1M rows). Written `TO`
|
|
78
|
+
* this role, the policy is not in a user's plan at all.
|
|
79
|
+
*
|
|
80
|
+
* It holds no privilege and cannot log in: being in it only decides which
|
|
81
|
+
* policies apply, and those still test `rebase.uid() IS NULL` or the `admin`
|
|
82
|
+
* role. Admin requests switch to a request role that inherits it
|
|
83
|
+
* ({@link adminRequestRoleFor}); a connection that is itself subject to RLS
|
|
84
|
+
* inherits it for the server context. One fixed name, so the policy text is the
|
|
85
|
+
* same in every deployment and every generated migration. FROZEN.
|
|
86
|
+
*/
|
|
87
|
+
export declare const REBASE_ADMIN_ROLE = "rebase_admin";
|
|
88
|
+
/**
|
|
89
|
+
* The role the admin request roles ({@link adminRequestRoleFor}) inherit and
|
|
90
|
+
* nothing else does, so an admin-only grant can apply to admin REQUESTS alone.
|
|
91
|
+
*
|
|
92
|
+
* {@link REBASE_ADMIN_ROLE} cannot do that job: the connection inherits it for
|
|
93
|
+
* the server context, and so would any process on it that does not switch
|
|
94
|
+
* roles. Its policies therefore keep their test (`rebase.uid() IS NULL` or the
|
|
95
|
+
* `admin` role) — and any policy expression that is not a constant is a
|
|
96
|
+
* security barrier, behind which Postgres will not evaluate a non-leakproof
|
|
97
|
+
* operator as an index condition. An admin's `tags && $1`, `name ~ $1` or
|
|
98
|
+
* jsonb filter scanned the whole table where the owner's used the index.
|
|
99
|
+
*
|
|
100
|
+
* Each admin-only grant gets a companion `TO` this role `USING (true)`.
|
|
101
|
+
* Postgres folds the OR of the permissive policies to `true` for a member, the
|
|
102
|
+
* barrier goes, and an admin request plans as the owner's does; restrictive
|
|
103
|
+
* policies still apply. Membership is the boundary: only the admin request
|
|
104
|
+
* roles hold it, granted `WITH INHERIT TRUE, SET FALSE`, and only from
|
|
105
|
+
* PostgreSQL 16, whose per-grant INHERIT keeps the connection (which holds
|
|
106
|
+
* those roles `WITH INHERIT FALSE`) out. A boot that finds the connection with
|
|
107
|
+
* its privileges revokes every membership, and the companions admit nobody.
|
|
108
|
+
* One fixed name, as {@link REBASE_ADMIN_ROLE}. FROZEN.
|
|
109
|
+
*/
|
|
110
|
+
export declare const REBASE_ADMIN_REQUEST_ROLE = "rebase_admin_request";
|
|
111
|
+
/**
|
|
112
|
+
* The role an admin request runs as, for a signed-in request role: it inherits
|
|
113
|
+
* that role (its grants and every policy written for it) and
|
|
114
|
+
* {@link REBASE_ADMIN_ROLE}. One per request role rather than the shared
|
|
115
|
+
* `rebase_admin` itself, because roles belong to the cluster: a project with a
|
|
116
|
+
* request role of its own (`rls.requestRole`) would otherwise share its admin
|
|
117
|
+
* access with every other project on the cluster. FROZEN derivation.
|
|
118
|
+
*/
|
|
119
|
+
export declare function adminRequestRoleFor(requestRole: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* Whether a request with these roles passes `rolesOverlap(["admin"])` — the
|
|
122
|
+
* test `string_to_array(rebase.roles(), ',') && ARRAY['admin']` makes of the
|
|
123
|
+
* comma-joined `app.user_roles`, so a role name with a comma in it is split
|
|
124
|
+
* exactly as Postgres splits it.
|
|
125
|
+
*/
|
|
126
|
+
export declare function holdsAdminRole(roles: readonly string[]): boolean;
|
|
68
127
|
/**
|
|
69
128
|
* Whether the caller is a GUEST — signed in through anonymous sign-in rather
|
|
70
129
|
* than with an account.
|