@rebasepro/types 0.28.2 → 0.29.0-canary.g0e3a0e7

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.
@@ -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
@@ -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.
@@ -37,3 +37,4 @@ export * from "./collection_contract.js";
37
37
  export * from "./schema_version.js";
38
38
  export * from "./storage_authorize.js";
39
39
  export * from "./register.js";
40
+ export * from "./mcp_app_modules.js";
@@ -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 { Entity, EntityReference, EntityRelation, EntityValues, GeoPoint, Vector } from "./entities.js";
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 rendering
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: Omit<AfterReadProps<M, USER>, "entity"> & {
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 entity's id, or `undefined` while it is being created. */
1019
- entityId?: string | number;
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
- * - `{entityId}` - ID of the entity
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
- * - `{entityId}` - ID of the entity
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
- * Entity ID
1341
+ * The record's id; absent for one being created.
1342
1342
  */
1343
- entityId?: string | number;
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
- /** Columns declared optional that the database still requires. */
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[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/types",
3
- "version": "0.28.2",
3
+ "version": "0.29.0-canary.g0e3a0e7",
4
4
  "description": "Rebase type definitions — shared interfaces and controller types",
5
5
  "keywords": [
6
6
  "rebase",