@rebasepro/types 0.28.2 → 0.29.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/controllers/aggregates.d.ts +26 -0
- package/dist/controllers/data.d.ts +76 -11
- package/dist/controllers/data_driver.d.ts +64 -9
- package/dist/controllers/index.d.ts +1 -0
- package/dist/index.es.js +150 -3
- package/dist/index.es.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +18 -0
- package/dist/types/backend.d.ts +46 -0
- package/dist/types/collections.d.ts +43 -0
- package/dist/types/filter-operators.d.ts +4 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/mcp_app_modules.d.ts +28 -0
- package/dist/types/properties.d.ts +10 -10
- package/dist/types/schema_editing.d.ts +7 -1
- package/package.json +1 -1
|
@@ -65,6 +65,24 @@ export interface MountableRouter {
|
|
|
65
65
|
* @group Auth
|
|
66
66
|
*/
|
|
67
67
|
export declare const IMPERSONATE_HEADER = "x-rebase-impersonate";
|
|
68
|
+
/**
|
|
69
|
+
* The request header a client sends to the auth routes to say where it keeps
|
|
70
|
+
* its refresh token. `json` asks for the token in the response body, and has
|
|
71
|
+
* the token it presents read from the request body.
|
|
72
|
+
*
|
|
73
|
+
* It matters only on a server with `cookieAuth`, which otherwise puts the
|
|
74
|
+
* token in an HttpOnly cookie and answers the body's with `""`, so a client
|
|
75
|
+
* with no cookie jar (Node, React Native), or one that keeps its own sign-in
|
|
76
|
+
* apart from the page's cookie session, held nothing to renew with. A request
|
|
77
|
+
* that sends it is answered as a server without `cookieAuth` answers: the
|
|
78
|
+
* cookie is neither read nor set. So it can never turn a cookie the page's
|
|
79
|
+
* script cannot read into a token it can.
|
|
80
|
+
*
|
|
81
|
+
* `@rebasepro/client` sends it on every auth request in `authFlowMode: "json"`.
|
|
82
|
+
*
|
|
83
|
+
* @group Auth
|
|
84
|
+
*/
|
|
85
|
+
export declare const AUTH_FLOW_HEADER = "x-rebase-auth-flow";
|
|
68
86
|
/**
|
|
69
87
|
* The request header that asks for a data-plane request to run as a role —
|
|
70
88
|
* the RLS simulator's "view as". Alone it runs as a signed-in holder of that
|
package/dist/types/backend.d.ts
CHANGED
|
@@ -561,6 +561,39 @@ export interface SqlCursor {
|
|
|
561
561
|
/** End the read and give the session back. Safe to call more than once. */
|
|
562
562
|
close(): Promise<void>;
|
|
563
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* One connection pool a driver holds, as `/metrics` reports it — see
|
|
566
|
+
* {@link SQLAdmin.poolStats}.
|
|
567
|
+
*
|
|
568
|
+
* @group Admin
|
|
569
|
+
*/
|
|
570
|
+
export interface DatabasePoolStats {
|
|
571
|
+
/** Which pool: `primary`, `read` (the replica), `session` (the direct pool for the SQL console). */
|
|
572
|
+
pool: string;
|
|
573
|
+
/** Connections open, busy or idle. */
|
|
574
|
+
total: number;
|
|
575
|
+
/** Open connections nobody holds. */
|
|
576
|
+
idle: number;
|
|
577
|
+
/** Callers queued for a connection. Above zero for long is a pool too small for its load. */
|
|
578
|
+
waiting: number;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* A sample of the database server behind a source — see
|
|
582
|
+
* {@link SQLAdmin.sampleHealth}. A field is absent when it could not be read
|
|
583
|
+
* (a role without the privilege, an engine without the notion), never zero.
|
|
584
|
+
*
|
|
585
|
+
* @group Admin
|
|
586
|
+
*/
|
|
587
|
+
export interface DatabaseHealthSample {
|
|
588
|
+
/** Client connections on the server, by state (`active`, `idle`, `idle in transaction`, …). */
|
|
589
|
+
connections?: Record<string, number>;
|
|
590
|
+
/** The server's `max_connections`. */
|
|
591
|
+
maxConnections?: number;
|
|
592
|
+
/** The size of this source's database, in bytes. */
|
|
593
|
+
sizeBytes?: number;
|
|
594
|
+
/** How far the read replica is behind the primary, in seconds, when the source has one. */
|
|
595
|
+
replicaLagSeconds?: number;
|
|
596
|
+
}
|
|
564
597
|
/**
|
|
565
598
|
* Administrative operations for SQL-based databases (PostgreSQL, MySQL, etc.).
|
|
566
599
|
* Used by the SQL Editor, RLS Editor, and schema browser.
|
|
@@ -603,6 +636,19 @@ export interface SQLAdmin {
|
|
|
603
636
|
* through `executeSql` as before.
|
|
604
637
|
*/
|
|
605
638
|
probe?(timeoutMs: number): Promise<void>;
|
|
639
|
+
/**
|
|
640
|
+
* The connection pools this source holds besides the one the server
|
|
641
|
+
* opened for it — the read replica's, the SQL console's direct one —
|
|
642
|
+
* for `/metrics`. Synchronous and free: counts the pools already keep.
|
|
643
|
+
*/
|
|
644
|
+
poolStats?(): DatabasePoolStats[];
|
|
645
|
+
/**
|
|
646
|
+
* Sample the server behind this source: connections against
|
|
647
|
+
* `max_connections`, the database's size, the replica's lag. Run every 30
|
|
648
|
+
* seconds by the metrics probe, so the control plane can watch a database
|
|
649
|
+
* it may not be able to reach.
|
|
650
|
+
*/
|
|
651
|
+
sampleHealth?(): Promise<DatabaseHealthSample>;
|
|
606
652
|
/**
|
|
607
653
|
* Run a script a person wrote — the Studio SQL console — and describe what
|
|
608
654
|
* it returned.
|
|
@@ -187,6 +187,27 @@ export interface BaseCollectionConfig<M extends Record<string, unknown> = Record
|
|
|
187
187
|
*/
|
|
188
188
|
strictWrites?: boolean;
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* The SQL view a collection serves. See {@link PostgresCollectionConfig.view}.
|
|
192
|
+
*
|
|
193
|
+
* @group Models
|
|
194
|
+
*/
|
|
195
|
+
export interface CollectionView {
|
|
196
|
+
/** The view's `SELECT`, as SQL. Its columns are the collection's properties. */
|
|
197
|
+
query: string;
|
|
198
|
+
/**
|
|
199
|
+
* Store the rows (`CREATE MATERIALIZED VIEW`) rather than run the query on
|
|
200
|
+
* every read. Refresh them with the collection's `refresh()`.
|
|
201
|
+
*/
|
|
202
|
+
materialized?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Who may read a materialized view: callers holding one of these roles.
|
|
205
|
+
* Defaults to `["admin"]`, which `dataAsAdmin` and the server's own work
|
|
206
|
+
* hold. Ignored for a plain view, whose rows the base tables' policies
|
|
207
|
+
* decide.
|
|
208
|
+
*/
|
|
209
|
+
roles?: string[];
|
|
210
|
+
}
|
|
190
211
|
/**
|
|
191
212
|
* A collection backed by PostgreSQL (or any SQL database).
|
|
192
213
|
* Adds support for SQL-style relations (JOINs) and Row Level Security.
|
|
@@ -228,6 +249,28 @@ export interface PostgresCollectionConfig<M extends Record<string, unknown> = Re
|
|
|
228
249
|
* If not specified, "public" is used (or the default search path).
|
|
229
250
|
*/
|
|
230
251
|
schema?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Serve a SQL view instead of a table: the collection is read-only, and
|
|
254
|
+
* `db push` (and a managed boot) creates the view under `table` from
|
|
255
|
+
* `query`, recreating it when the query changes.
|
|
256
|
+
*
|
|
257
|
+
* The properties describe the view's columns, and one of them must be
|
|
258
|
+
* `isId`: a view has no primary key of its own.
|
|
259
|
+
*
|
|
260
|
+
* A plain view runs as the caller (`security_invoker`), so the policies of
|
|
261
|
+
* the tables it reads decide which rows each caller sees; `securityRules`
|
|
262
|
+
* do not apply to it. A materialized view stores its rows and has no
|
|
263
|
+
* row-level security at all, so it is served whole, and only to callers
|
|
264
|
+
* holding one of `roles`.
|
|
265
|
+
*
|
|
266
|
+
* ```ts
|
|
267
|
+
* view: {
|
|
268
|
+
* query: "SELECT lower(artist) AS artist, count(*)::int AS songs FROM songs GROUP BY 1",
|
|
269
|
+
* materialized: true
|
|
270
|
+
* }
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
view?: CollectionView;
|
|
231
274
|
/**
|
|
232
275
|
* For SQL databases, you can define the relations between collections here.
|
|
233
276
|
* Relations describe JOINs, foreign keys, and junction tables.
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* │ "not-in" │ "nin" │ Value not in list │
|
|
22
22
|
* │ "array-contains" │ "cs" │ Array contains element │
|
|
23
23
|
* │ "array-contains-any" │ "csa" │ Array contains any of │
|
|
24
|
+
* │ "array-contains-all" │ "csall" │ Array contains all of │
|
|
25
|
+
* │ "array-contained-by" │ "cd" │ Array holds only elements of │
|
|
24
26
|
* │ "like" │ "like" │ SQL LIKE (case-sensitive) │
|
|
25
27
|
* │ "ilike" │ "ilike" │ SQL ILIKE (case-insensitive) │
|
|
26
28
|
* │ "not-like" │ "nlike" │ NOT LIKE (case-sensitive) │
|
|
@@ -195,7 +197,7 @@ export declare function sortKeyToString(key: SortKey): string;
|
|
|
195
197
|
*
|
|
196
198
|
* @group Models
|
|
197
199
|
*/
|
|
198
|
-
export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any" | "like" | "ilike" | "not-like" | "not-ilike" | "is-null" | "is-not-null";
|
|
200
|
+
export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any" | "array-contains-all" | "array-contained-by" | "like" | "ilike" | "not-like" | "not-ilike" | "is-null" | "is-not-null";
|
|
199
201
|
/**
|
|
200
202
|
* Used to define filters applied in collections.
|
|
201
203
|
*
|
|
@@ -317,7 +319,7 @@ export interface FilterPreset<Key extends string = string> {
|
|
|
317
319
|
* in application code. Used by `serializeFilter`/`deserializeFilter`
|
|
318
320
|
* in `@rebasepro/common`.
|
|
319
321
|
*/
|
|
320
|
-
export type RestFilterOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "cs" | "csa" | "like" | "ilike" | "nlike" | "nilike" | "isnull" | "notnull";
|
|
322
|
+
export type RestFilterOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "cs" | "csa" | "csall" | "cd" | "like" | "ilike" | "nlike" | "nilike" | "isnull" | "notnull";
|
|
321
323
|
/** Maps canonical operators to their REST short-code equivalents. */
|
|
322
324
|
export declare const CANONICAL_TO_REST: Readonly<Record<WhereFilterOp, RestFilterOp>>;
|
|
323
325
|
/** Maps REST short-code operators to their canonical equivalents. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The modules an app Claude writes for show_app may import, and from each the
|
|
3
|
+
* names the MCP view serves.
|
|
4
|
+
*
|
|
5
|
+
* An app imports the real package names, so the code reads — and pastes into
|
|
6
|
+
* a project — like every other piece of Rebase code. Inside the view each
|
|
7
|
+
* name is the package's own part: `"*"` serves the whole module, a list
|
|
8
|
+
* serves exactly those exports. The one list three readers share, so none
|
|
9
|
+
* can drift from the others:
|
|
10
|
+
*
|
|
11
|
+
* - the view's module registry (`@rebasepro/cms/mcp-view`), which hands an
|
|
12
|
+
* app these exports and no others;
|
|
13
|
+
* - the server's compiler for show_app, which refuses any other import
|
|
14
|
+
* before the app opens, naming it;
|
|
15
|
+
* - show_app's guide (`SHOW_APP_CODE_GUIDE` in `@rebasepro/server`), which a
|
|
16
|
+
* test holds to this list.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MCP_APP_MODULES: {
|
|
19
|
+
readonly react: "*";
|
|
20
|
+
readonly "react/jsx-runtime": "*";
|
|
21
|
+
readonly "@rebasepro/ui": "*";
|
|
22
|
+
readonly "@rebasepro/app": readonly ["useRows", "useRow", "useRowCount", "useAggregate", "useRowWrites"];
|
|
23
|
+
readonly "@rebasepro/cms": readonly ["CollectionPanel", "CollectionToolbar", "CollectionSearchBar", "CollectionFiltersButton", "CollectionViewModeToggle", "CollectionAddButton", "RecordForm", "RecordDetail", "FormField", "FieldValue", "useSidePanel"];
|
|
24
|
+
};
|
|
25
|
+
/** A module an app may import. */
|
|
26
|
+
export type McpAppModule = keyof typeof MCP_APP_MODULES;
|
|
27
|
+
/** The names a module with a served list hands out. */
|
|
28
|
+
export type McpAppModuleExport<M extends McpAppModule> = (typeof MCP_APP_MODULES)[M] extends readonly (infer N extends string)[] ? N : string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResourceRef } from "./resources.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Vector } from "./entities.js";
|
|
3
3
|
import type { Relation, ResolvedRelation } from "./relations.js";
|
|
4
4
|
import type { ColorKey, ColorScheme } from "./chips.js";
|
|
5
5
|
import type { AuthState } from "../controllers/auth_state.js";
|
|
@@ -17,11 +17,11 @@ export type SqlExpression = `sql\`${string}\``;
|
|
|
17
17
|
*/
|
|
18
18
|
export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
|
|
19
19
|
/**
|
|
20
|
-
* Callback used after fetching data, to transform the value before
|
|
20
|
+
* Callback used after fetching data, to transform the value before
|
|
21
|
+
* rendering. `row` is the whole row it was read in, as the server sends it.
|
|
21
22
|
*/
|
|
22
|
-
afterRead?(props:
|
|
23
|
+
afterRead?(props: AfterReadProps<M, USER> & {
|
|
23
24
|
value: T;
|
|
24
|
-
entity: Entity<M> | undefined;
|
|
25
25
|
}): Promise<T> | T;
|
|
26
26
|
/**
|
|
27
27
|
* Callback used before saving, after validation.
|
|
@@ -1015,8 +1015,8 @@ export type PropertyBuilderProps<M extends Record<string, unknown> = Record<stri
|
|
|
1015
1015
|
index?: number;
|
|
1016
1016
|
/** The collection path this entity belongs to. */
|
|
1017
1017
|
path: string;
|
|
1018
|
-
/** The
|
|
1019
|
-
|
|
1018
|
+
/** The record's id, or `undefined` while it is being created. */
|
|
1019
|
+
id?: string | number;
|
|
1020
1020
|
/** Who is editing — the signed-in user and their roles. */
|
|
1021
1021
|
authController: AuthState;
|
|
1022
1022
|
};
|
|
@@ -1241,7 +1241,7 @@ export type StorageConfig = {
|
|
|
1241
1241
|
* - `{file.name}` - Name of the file without extension
|
|
1242
1242
|
* - `{file.ext}` - Extension of the file
|
|
1243
1243
|
* - `{rand}` - Random value used to avoid name collisions
|
|
1244
|
-
* - `{
|
|
1244
|
+
* - `{id}` - The record's id (`{entityId}` is read the same)
|
|
1245
1245
|
* - `{propertyKey}` - ID of this property
|
|
1246
1246
|
* - `{path}` - Path of this entity
|
|
1247
1247
|
*
|
|
@@ -1260,7 +1260,7 @@ export type StorageConfig = {
|
|
|
1260
1260
|
* - `{file.name}` - Name of the file without extension
|
|
1261
1261
|
* - `{file.ext}` - Extension of the file
|
|
1262
1262
|
* - `{rand}` - Random value used to avoid name collisions
|
|
1263
|
-
* - `{
|
|
1263
|
+
* - `{id}` - The record's id (`{entityId}` is read the same)
|
|
1264
1264
|
* - `{propertyKey}` - ID of this property
|
|
1265
1265
|
* - `{path}` - Path of this entity
|
|
1266
1266
|
*
|
|
@@ -1338,9 +1338,9 @@ export interface UploadedFileContext {
|
|
|
1338
1338
|
*/
|
|
1339
1339
|
property: StringProperty | ArrayProperty;
|
|
1340
1340
|
/**
|
|
1341
|
-
*
|
|
1341
|
+
* The record's id; absent for one being created.
|
|
1342
1342
|
*/
|
|
1343
|
-
|
|
1343
|
+
id?: string | number;
|
|
1344
1344
|
/**
|
|
1345
1345
|
* Entity path. E.g. `products/PID/locales`
|
|
1346
1346
|
*/
|
|
@@ -196,11 +196,17 @@ export interface SchemaReconcileColumn {
|
|
|
196
196
|
* read, and a database that changed in between is planned and shown again.
|
|
197
197
|
*/
|
|
198
198
|
export interface SchemaReconcilePlan {
|
|
199
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Columns whose NOT NULL this plan drops: those declared optional that the
|
|
201
|
+
* database still requires, and those no property declares that block
|
|
202
|
+
* every insert (`undeclared: true`) and are not being dropped. Their data
|
|
203
|
+
* stays.
|
|
204
|
+
*/
|
|
200
205
|
relaxed: Array<{
|
|
201
206
|
collection: string;
|
|
202
207
|
table: string;
|
|
203
208
|
column: string;
|
|
209
|
+
undeclared?: boolean;
|
|
204
210
|
}>;
|
|
205
211
|
/** Every column no collection declares, dropped or not. */
|
|
206
212
|
undeclared: SchemaReconcileColumn[];
|