@rebasepro/types 0.30.0 → 0.31.0-canary.g59cd6fd
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/README.md +16 -18
- package/dist/call_context.d.ts +3 -3
- package/dist/controllers/client.d.ts +29 -0
- package/dist/controllers/data.d.ts +85 -332
- package/dist/controllers/data_driver.d.ts +47 -57
- package/dist/controllers/index.d.ts +0 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +2567 -1151
- package/dist/index.es.js.map +1 -1
- package/dist/schema/column_options.d.ts +336 -0
- package/dist/schema/column_type.d.ts +116 -0
- package/dist/schema/columns.d.ts +646 -0
- package/dist/schema/compiled.d.ts +114 -0
- package/dist/schema/descriptor.d.ts +349 -0
- package/dist/schema/hooks.d.ts +164 -0
- package/dist/schema/index.d.ts +13 -0
- package/dist/schema/infer.d.ts +340 -0
- package/dist/schema/json.d.ts +237 -0
- package/dist/schema/relations.d.ts +205 -0
- package/dist/schema/table.d.ts +304 -0
- package/dist/schema/table_options.d.ts +103 -0
- package/dist/schema/table_patch.d.ts +338 -0
- package/dist/types/auth_adapter.d.ts +12 -6
- package/dist/types/auth_hooks.d.ts +65 -0
- package/dist/types/backend.d.ts +85 -96
- package/dist/types/data_source.d.ts +4 -9
- package/dist/types/database_adapter.d.ts +30 -31
- package/dist/types/entities.d.ts +0 -162
- package/dist/types/filter-operators.d.ts +2 -26
- package/dist/types/history.d.ts +6 -9
- package/dist/types/index.d.ts +3 -9
- package/dist/types/mcp_app_modules.d.ts +0 -2
- package/dist/types/policy.d.ts +85 -10
- package/dist/types/project_manifest.d.ts +113 -46
- package/dist/types/read_query.d.ts +98 -0
- package/dist/types/register.d.ts +35 -5
- package/dist/types/relations.d.ts +0 -430
- package/dist/types/schema_editing.d.ts +54 -2
- package/dist/types/schema_version.d.ts +24 -4
- package/dist/types/security_rules.d.ts +225 -15
- package/dist/types/storage_authorize.d.ts +2 -2
- package/dist/types/tenancy.d.ts +3 -3
- package/dist/types/ui_preferences.d.ts +228 -0
- package/package.json +3 -2
- package/dist/controllers/auth_state.d.ts +0 -23
- package/dist/controllers/collection_registry.d.ts +0 -67
- package/dist/controllers/effective_role.d.ts +0 -4
- package/dist/types/admin_block.d.ts +0 -96
- package/dist/types/chips.d.ts +0 -16
- package/dist/types/collection_contract.d.ts +0 -43
- package/dist/types/collection_patch.d.ts +0 -74
- package/dist/types/collections.d.ts +0 -783
- package/dist/types/component_ref.d.ts +0 -81
- package/dist/types/conditions-contract.types.d.ts +0 -14
- package/dist/types/entity_callbacks.d.ts +0 -393
- package/dist/types/indexes.d.ts +0 -179
- package/dist/types/properties.d.ts +0 -1640
package/README.md
CHANGED
|
@@ -14,29 +14,31 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
|
|
|
14
14
|
|
|
15
15
|
## What This Package Does
|
|
16
16
|
|
|
17
|
-
Provides the canonical type definitions used across all Rebase packages — both client-side and server-side. It has no runtime dependencies, but it is not types-only: it also exports the constants and small runtime helpers those packages share (`
|
|
17
|
+
Provides the canonical type definitions used across all Rebase packages — both client-side and server-side. It has no runtime dependencies, but it is not types-only: it also exports the constants and small runtime helpers those packages share (`declaredDataSources`, `bucket`, …). Every other `@rebasepro/*` package depends on it.
|
|
18
18
|
|
|
19
19
|
## Key Exports
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### Tables
|
|
22
22
|
|
|
23
23
|
| Export | Description |
|
|
24
24
|
|--------|-------------|
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
25
|
+
| `defineTable`, `defineAuthTable`, `defineView` | Declare a table, the users table, or a SQL view. `rls` is required on every table. Re-exported by `@rebasepro/server/schema`, the entry a `backend/schema` file imports. New in 0.31. |
|
|
26
|
+
| `col`, `rel`, `json`, `policy` | The column, relation, JSON-shape and policy-expression builders. New in 0.31. |
|
|
27
|
+
| `TableDescriptor`, `ColumnDescriptor`, `RelationDescriptor`, `RlsDescriptor` | The compiled form of a table: what the backend serves at `GET /api/schema/tables` and the SDK generator reads. New in 0.31. |
|
|
28
|
+
| `TableHooks` | A table's lifecycle hooks (`beforeQuery`, `afterRead`, `beforeSave`, `afterSave`, `afterSaveError`, `beforeDelete`, `afterDelete`). New in 0.31. |
|
|
29
|
+
| `InferRow`, `InferInsert`, `InferUpdate`, `DatabaseOf` | Row types inferred from a table, and a typed `Database` from a schema module. New in 0.31. |
|
|
30
|
+
| `TablePatch` | The schema editor's edits, as a typed list of operations. New in 0.31. |
|
|
31
|
+
| `SecurityRule` | One rule of a table's `rls` |
|
|
32
|
+
| `Register` | Augmented by a project to type server-side data: `database` (generated) or `tables` (the schema module) |
|
|
31
33
|
|
|
32
34
|
### Backend & Driver Interfaces
|
|
33
35
|
|
|
34
36
|
| Export | Description |
|
|
35
37
|
|--------|-------------|
|
|
36
|
-
| `DataDriver` | Abstract interface for database drivers (`fetchCollection`, `fetchOne`, `save`, `delete`, etc.) |
|
|
38
|
+
| `DataDriver` | Abstract interface for database drivers (`fetchCollection`, `fetchOne`, `save`, `delete`, etc.). Reads return the row `GET /api/data/<table>` returns, with a relation only when `include` names it. |
|
|
37
39
|
| `DatabaseAdapter` | Pluggable database adapter interface (used by `server`) |
|
|
38
40
|
| `BackendBootstrapper` | Lifecycle interface for initializing database drivers, auth, history, and realtime |
|
|
39
|
-
| `DatabaseAdmin` | Admin operations interface (SQL execution,
|
|
41
|
+
| `DatabaseAdmin` | Admin operations interface (SQL execution, table stats, table metadata) |
|
|
40
42
|
| `RealtimeProvider` | Interface for realtime subscription providers |
|
|
41
43
|
| `BackendConfig` / `BackendInstance` | Abstract backend configuration and instance types |
|
|
42
44
|
| `HealthCheckResult` | Return type for health check operations |
|
|
@@ -57,27 +59,24 @@ Provides the canonical type definitions used across all Rebase packages — both
|
|
|
57
59
|
| `RebaseClient` | Top-level client interface (data, auth, storage, email) |
|
|
58
60
|
| `RebaseServerClient` | The server-side `rebase` singleton: `RebaseClient` without `data`, plus `dataAsAdmin` |
|
|
59
61
|
| `StorageSource` | File storage interface |
|
|
60
|
-
| `CollectionRegistryInterface` | Collection lookup and registration |
|
|
61
62
|
|
|
62
63
|
### Other
|
|
63
64
|
|
|
64
65
|
| Export | Description |
|
|
65
66
|
|--------|-------------|
|
|
66
67
|
| `CronJobDefinition` | Cron job configuration type |
|
|
67
|
-
| `CollectionCallbacks` | Lifecycle callbacks for entity CRUD operations |
|
|
68
68
|
| `WebSocketMessage` | WebSocket protocol message types |
|
|
69
69
|
|
|
70
|
-
The admin panel's own types — `AuthController`, the plugin type `RebasePlugin`, `Locale` — live in `@rebasepro/cms-types`.
|
|
70
|
+
The admin panel's own types — `AuthController`, the plugin type `RebasePlugin`, `Locale`, and the collection and property view model it draws (`CollectionConfig`, `StringProperty` and every `…Property`, `CollectionCallbacks`) — live in `@rebasepro/cms-types`.
|
|
71
71
|
|
|
72
72
|
## Quick Start
|
|
73
73
|
|
|
74
74
|
```typescript
|
|
75
75
|
import type {
|
|
76
|
-
|
|
76
|
+
TableDescriptor,
|
|
77
77
|
DataDriver,
|
|
78
78
|
DatabaseAdapter,
|
|
79
79
|
User,
|
|
80
|
-
Property,
|
|
81
80
|
} from "@rebasepro/types";
|
|
82
81
|
```
|
|
83
82
|
|
|
@@ -87,8 +86,7 @@ Every `@rebasepro/*` package depends on this one. Key consumers:
|
|
|
87
86
|
|
|
88
87
|
| Package | Uses |
|
|
89
88
|
|---------|------|
|
|
90
|
-
| `@rebasepro/server` | `DataDriver`, `DatabaseAdapter`, `BackendBootstrapper`, `AuthAdapter` |
|
|
89
|
+
| `@rebasepro/server` | the table builders, `DataDriver`, `DatabaseAdapter`, `BackendBootstrapper`, `AuthAdapter` |
|
|
91
90
|
| `@rebasepro/server-postgres` | `BackendBootstrapper`, `InitializedDriver`, `RealtimeProvider` |
|
|
92
|
-
| `@rebasepro/server-mongo` | `BackendBootstrapper`, `DataDriver`, `CollectionConfig` |
|
|
93
91
|
| `@rebasepro/client` | `RebaseClient`, `StorageSource` |
|
|
94
|
-
| `@rebasepro/cms` | `
|
|
92
|
+
| `@rebasepro/cms` | `TableDescriptor`, controller interfaces |
|
package/dist/call_context.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { CallerCredential } from "./types/api_keys.js";
|
|
|
16
16
|
* `data` is left off because server-side there is none. The object is the
|
|
17
17
|
* `rebase` singleton, which omits `data` so that its admin-scoped plane has
|
|
18
18
|
* exactly one name. This used to be declared as the full `RebaseClient`, so
|
|
19
|
-
* `context.client.data.
|
|
19
|
+
* `context.client.data.table(…)` compiled and then threw "Cannot read
|
|
20
20
|
* properties of undefined" in production. In the browser the panel's client
|
|
21
21
|
* does carry a `data`, but `context.data` is the accessor there too: one name
|
|
22
22
|
* for a callback's queries on both sides of the wire.
|
|
@@ -86,7 +86,7 @@ export type RebaseCallContext<USER extends User = User, DB = RegisteredDatabase>
|
|
|
86
86
|
client: RebaseCallbackClient<DB>;
|
|
87
87
|
/**
|
|
88
88
|
* Unified data access — `context.data.products.create(...)`.
|
|
89
|
-
* Access any
|
|
89
|
+
* Access any table as a dynamic property.
|
|
90
90
|
*
|
|
91
91
|
* **Inherits the privilege of whatever triggered the callback.** This is not
|
|
92
92
|
* a fixed trust level, and it is the one thing to know about this accessor:
|
|
@@ -108,7 +108,7 @@ export type RebaseCallContext<USER extends User = User, DB = RegisteredDatabase>
|
|
|
108
108
|
* that, or reach for {@link client}`.dataAsAdmin` deliberately when the
|
|
109
109
|
* callback genuinely has to see what an admin may see. Note what that does
|
|
110
110
|
* *not* buy you: `policy.serverContext()` (`rebase.uid() IS NULL`) is false
|
|
111
|
-
* for the service identity, so a
|
|
111
|
+
* for the service identity, so a table whose only rule is
|
|
112
112
|
* `serverContext()` stays closed to it.
|
|
113
113
|
*
|
|
114
114
|
* Verified end-to-end against Postgres rather than asserted — see
|
|
@@ -11,6 +11,7 @@ import type { RoleSummary } from "../types/scopes.js";
|
|
|
11
11
|
import type { StorageSourceDefinition } from "../types/storage_source.js";
|
|
12
12
|
import type { RegisteredDatabase } from "../types/register.js";
|
|
13
13
|
import type { AccessSimulation } from "../types/auth_adapter.js";
|
|
14
|
+
import type { TableDescriptor } from "../schema/descriptor.js";
|
|
14
15
|
/**
|
|
15
16
|
* Event type for authentication state changes
|
|
16
17
|
*/
|
|
@@ -319,6 +320,32 @@ export interface CronAPI {
|
|
|
319
320
|
job: CronJobStatus;
|
|
320
321
|
}>;
|
|
321
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Options of {@link SchemaAPI.tables}.
|
|
325
|
+
* @group Schema
|
|
326
|
+
*/
|
|
327
|
+
export interface SchemaTablesOptions {
|
|
328
|
+
/** Abandons the request. */
|
|
329
|
+
signal?: AbortSignal;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* The backend's tables, as `GET /api/schema/tables` serves them to the caller.
|
|
333
|
+
* @group Schema
|
|
334
|
+
*/
|
|
335
|
+
export interface SchemaAPI {
|
|
336
|
+
/**
|
|
337
|
+
* Every table the signed-in caller may see, redacted for them: what the
|
|
338
|
+
* admin panel renders with no frontend configuration.
|
|
339
|
+
*
|
|
340
|
+
* Asked again, the request carries the `ETag` of the last answer in
|
|
341
|
+
* `If-None-Match`, and a `304` hands back the tables that answer held.
|
|
342
|
+
*
|
|
343
|
+
* Rejects with a `RebaseApiError`: status `401` when nobody is signed in;
|
|
344
|
+
* code `SCHEMA_UNAVAILABLE` (status `404`) when the backend serves no
|
|
345
|
+
* tables — auth is not configured there, or it predates the route.
|
|
346
|
+
*/
|
|
347
|
+
tables(options?: SchemaTablesOptions): Promise<TableDescriptor[]>;
|
|
348
|
+
}
|
|
322
349
|
/**
|
|
323
350
|
* Client-side database-backup management interface.
|
|
324
351
|
* @group Backups
|
|
@@ -525,6 +552,8 @@ export interface RebaseClient<DB = unknown> {
|
|
|
525
552
|
cron?: CronAPI;
|
|
526
553
|
/** Database backup management API */
|
|
527
554
|
backups?: BackupsAPI;
|
|
555
|
+
/** The backend's tables, as served to the caller (`GET /api/schema/tables`). */
|
|
556
|
+
schema?: SchemaAPI;
|
|
528
557
|
/** Custom backend functions API */
|
|
529
558
|
functions?: FunctionsAPI;
|
|
530
559
|
/** The project's service keys. Requires `keys:read` / `keys:write`. */
|