@rebasepro/types 0.4.0 → 0.6.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/README.md +83 -232
- package/dist/controllers/client.d.ts +79 -32
- package/dist/controllers/customization_controller.d.ts +10 -9
- package/dist/index.es.js +249 -197
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +294 -224
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +0 -16
- package/dist/types/auth_adapter.d.ts +59 -4
- package/dist/types/backend.d.ts +36 -1
- package/dist/types/backend_hooks.d.ts +0 -63
- package/dist/types/breadcrumbs.d.ts +26 -0
- package/dist/types/collections.d.ts +162 -1
- package/dist/types/component_overrides.d.ts +138 -0
- package/dist/types/entity_views.d.ts +9 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/plugins.d.ts +0 -5
- package/dist/types/properties.d.ts +0 -8
- package/dist/types/translations.d.ts +3 -0
- package/dist/types/user_management_delegate.d.ts +0 -70
- package/package.json +10 -10
- package/src/controllers/client.ts +85 -33
- package/src/controllers/customization_controller.tsx +11 -11
- package/src/rebase_context.tsx +0 -16
- package/src/types/auth_adapter.ts +70 -4
- package/src/types/backend.ts +39 -1
- package/src/types/backend_hooks.ts +0 -55
- package/src/types/breadcrumbs.ts +27 -0
- package/src/types/collections.ts +172 -2
- package/src/types/component_overrides.ts +177 -0
- package/src/types/database_adapter.ts +1 -1
- package/src/types/entity_views.tsx +10 -1
- package/src/types/index.ts +2 -0
- package/src/types/plugins.tsx +1 -5
- package/src/types/properties.ts +0 -9
- package/src/types/translations.ts +3 -0
- package/src/types/user_management_delegate.ts +0 -77
package/README.md
CHANGED
|
@@ -1,242 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
<a href="https://rebase.pro">
|
|
3
|
-
<img src="https://rebase.pro/img/logo_small.png" width="240px" alt="Rebase logo" />
|
|
4
|
-
</a>
|
|
5
|
-
</p>
|
|
1
|
+
# @rebasepro/types
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
<h3 align="center">The Open-Source Headless CMS & Admin Panel for Postgres</h3>
|
|
9
|
-
<p align="center">
|
|
10
|
-
<strong>Ship production-ready backends and radically extensible back-office apps in minutes.</strong><br/>
|
|
11
|
-
Own your data, own your code. The absolute easiest way to build on PostgreSQL.
|
|
12
|
-
</p>
|
|
3
|
+
Shared TypeScript type definitions and interfaces for the Rebase ecosystem.
|
|
13
4
|
|
|
14
|
-
|
|
15
|
-
<a href="https://demo.rebase.pro">Live Demo</a> •
|
|
16
|
-
<a href="https://rebase.pro/docs">Documentation</a> •
|
|
17
|
-
<a href="https://rebase.pro/features">Features</a> •
|
|
18
|
-
<a href="https://github.com/rebasepro/rebase">GitHub</a> •
|
|
19
|
-
<a href="https://discord.gg/fxy7xsQm3m">Discord</a>
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
<p align="center">
|
|
23
|
-
<a href="https://www.npmjs.com/package/@rebasepro/core"><img src="https://img.shields.io/npm/v/@rebasepro/core.svg?style=flat-square&color=orange" alt="NPM Version" /></a>
|
|
24
|
-
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-purple.svg?style=flat-square" alt="License: MIT" /></a>
|
|
25
|
-
<a href="https://www.npmjs.com/package/@rebasepro/core"><img src="https://img.shields.io/npm/dw/@rebasepro/core?style=flat-square&color=blue" alt="NPM Downloads" /></a>
|
|
26
|
-
<a href="https://discord.gg/fxy7xsQm3m"><img src="https://img.shields.io/discord/1013768502458470442?style=flat-square&logo=discord&logoColor=white&label=Discord" alt="Discord" /></a>
|
|
27
|
-
</p>
|
|
28
|
-
|
|
29
|
-
<br/>
|
|
30
|
-
|
|
31
|
-
<p align="center">
|
|
32
|
-
<img src="https://rebase.pro/img/demo_products.png" width="800px" alt="Rebase Dashboard" />
|
|
33
|
-
</p>
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## What is Rebase?
|
|
38
|
-
|
|
39
|
-
Rebase is a **developer-first**, open-source headless CMS and admin panel framework built with **React** and **TypeScript**. It gives you a complete backend-as-a-service layer on top of PostgreSQL — including authentication, S3-compatible storage, a full admin UI, and auto-generated APIs — while letting you extend every layer with custom React components, serverless functions, and scripts.
|
|
40
|
-
|
|
41
|
-
### ✨ Key Highlights
|
|
42
|
-
|
|
43
|
-
- 🔓 **No Vendor Lock-in** — Self-host anywhere. Full control over your infrastructure, code, and database.
|
|
44
|
-
- ⚡ **Instant Setup** — `npx @rebasepro/cli init` scaffolds a production-ready project in seconds.
|
|
45
|
-
- 🗄️ **PostgreSQL First** — First-class Postgres support with Drizzle ORM, schema introspection, and automatic migrations.
|
|
46
|
-
- 🧩 **Radical Extensibility** — Not constrained to pre-built widgets. If you can build it in React, you can build it in Rebase.
|
|
47
|
-
- 🎨 **Premium UI** — Fast, accessible design system built on Tailwind CSS v4 and Radix UI.
|
|
48
|
-
- 🤖 **AI-Ready** — MCP server for AI-assisted database management, plus data enhancement and insights plugins.
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## ⚡ Quick Start
|
|
53
|
-
|
|
54
|
-
Scaffold a complete, self-hosted Rebase application connected to your database:
|
|
5
|
+
## Installation
|
|
55
6
|
|
|
56
7
|
```bash
|
|
57
|
-
|
|
8
|
+
pnpm add @rebasepro/types
|
|
58
9
|
```
|
|
59
10
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
11
|
+
## What This Package Does
|
|
12
|
+
|
|
13
|
+
Provides the canonical type definitions used across all Rebase packages — both client-side and server-side. This is a **types-only** package with no runtime dependencies. Every other `@rebasepro/*` package depends on it.
|
|
14
|
+
|
|
15
|
+
## Key Exports
|
|
16
|
+
|
|
17
|
+
### Collection & Entity Types
|
|
18
|
+
|
|
19
|
+
| Export | Description |
|
|
20
|
+
|--------|-------------|
|
|
21
|
+
| `EntityCollection` | Full collection definition (name, slug, properties, callbacks, security rules, views) |
|
|
22
|
+
| `Property` | Union type for all property configurations (text, number, date, reference, array, map, etc.) |
|
|
23
|
+
| `Entity` | Generic entity record type |
|
|
24
|
+
| `EntityCallbacks` | Lifecycle hooks (`onPreSave`, `onSaveSuccess`, `onDelete`, etc.) |
|
|
25
|
+
| `EntityValues` | Record of property values for an entity |
|
|
26
|
+
| `SecurityRule` | RLS-style access control rule for a collection |
|
|
27
|
+
|
|
28
|
+
### Backend & Driver Interfaces
|
|
29
|
+
|
|
30
|
+
| Export | Description |
|
|
31
|
+
|--------|-------------|
|
|
32
|
+
| `DataDriver` | Abstract interface for database drivers (`fetchCollection`, `saveEntity`, `deleteEntity`, etc.) |
|
|
33
|
+
| `DatabaseAdapter` | Pluggable database adapter interface (used by `server-core`) |
|
|
34
|
+
| `BackendBootstrapper` | Lifecycle interface for initializing database drivers, auth, history, and realtime |
|
|
35
|
+
| `DatabaseAdmin` | Admin operations interface (SQL execution, collection stats, table metadata) |
|
|
36
|
+
| `RealtimeProvider` | Interface for realtime subscription providers |
|
|
37
|
+
| `BackendConfig` / `BackendInstance` | Abstract backend configuration and instance types |
|
|
38
|
+
| `HealthCheckResult` | Return type for health check operations |
|
|
39
|
+
| `InitializedDriver` | Result of driver initialization (driver, realtime, registry, internals) |
|
|
40
|
+
| `BootstrappedAuth` | Result of auth initialization (user service, role service, email service) |
|
|
41
|
+
|
|
42
|
+
### Auth & User Types
|
|
43
|
+
|
|
44
|
+
| Export | Description |
|
|
45
|
+
|--------|-------------|
|
|
46
|
+
| `AuthAdapter` | Pluggable auth adapter interface (for Clerk, Auth0, custom auth) |
|
|
47
|
+
| `AuthController` | Client-side auth controller interface |
|
|
48
|
+
| `RebaseUser` | User record type |
|
|
49
|
+
| `Role` | Role definition type |
|
|
50
|
+
|
|
51
|
+
### Controller Interfaces
|
|
52
|
+
|
|
53
|
+
| Export | Description |
|
|
54
|
+
|--------|-------------|
|
|
55
|
+
| `RebaseClient` | Top-level client interface (data, auth, storage, email) |
|
|
56
|
+
| `DataSourceDelegate` | Data operations interface for client-side data sources |
|
|
57
|
+
| `StorageSource` | File storage interface |
|
|
58
|
+
| `CollectionRegistryInterface` | Collection lookup and registration |
|
|
59
|
+
| `NavigationController` | App navigation interface |
|
|
60
|
+
|
|
61
|
+
### Other
|
|
62
|
+
|
|
63
|
+
| Export | Description |
|
|
64
|
+
|--------|-------------|
|
|
65
|
+
| `CronJobDefinition` | Cron job configuration type |
|
|
66
|
+
| `BackendHooks` | Server-side hooks for intercepting admin data |
|
|
67
|
+
| `PluginConfig` | Plugin system types |
|
|
68
|
+
| `WebSocketMessage` | WebSocket protocol message types |
|
|
69
|
+
| `Locale` | Localization types |
|
|
70
|
+
|
|
71
|
+
## Quick Start
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import type {
|
|
75
|
+
EntityCollection,
|
|
76
|
+
DataDriver,
|
|
77
|
+
DatabaseAdapter,
|
|
78
|
+
RebaseUser,
|
|
79
|
+
Property,
|
|
80
|
+
} from "@rebasepro/types";
|
|
65
81
|
```
|
|
66
82
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## Features
|
|
72
|
-
|
|
73
|
-
### 🏓 Full Admin Panel & CMS
|
|
74
|
-
|
|
75
|
-
An incredibly fast, windowed spreadsheet view to manage your database with inline editing, real-time updates, filtering, sorting, and text search. Switch between multiple view modes:
|
|
76
|
-
|
|
77
|
-
- **Spreadsheet table** — Inline editing, column reordering, drag-and-drop
|
|
78
|
-
- **Card grid** — Visual overview with image previews
|
|
79
|
-
- **List view** — Compact, scannable layout
|
|
80
|
-
- **Custom views** — Build any React component as a collection view
|
|
81
|
-
|
|
82
|
-
### 🔒 Typed Schema & Database Migrations
|
|
83
|
-
|
|
84
|
-
Define your data models using pure TypeScript collections. Rebase automatically generates your Drizzle ORM schema, handles PostgreSQL migrations, and keeps your live database perfectly in sync using built-in tooling like `rebase doctor`.
|
|
85
|
-
|
|
86
|
-
### 🔐 Authentication & Access Control
|
|
87
|
-
|
|
88
|
-
Built-in authentication with multiple providers:
|
|
89
|
-
|
|
90
|
-
- **Email/Password** — With password reset flow
|
|
91
|
-
- **Google OAuth** — One-click sign-in
|
|
92
|
-
- **Anonymous** — For guest access
|
|
93
|
-
|
|
94
|
-
Granular **role-based access control (RBAC)** with customizable permissions per collection, field, and action.
|
|
95
|
-
|
|
96
|
-
### 📦 S3-Compatible Storage
|
|
97
|
-
|
|
98
|
-
Native S3-compatible file storage with:
|
|
99
|
-
|
|
100
|
-
- Drag-and-drop uploads with progress tracking
|
|
101
|
-
- Automatic image resizing and optimization
|
|
102
|
-
- File metadata management
|
|
103
|
-
- Storage browser in Studio
|
|
104
|
-
|
|
105
|
-
### 🛠️ Studio — Developer Toolbox
|
|
106
|
-
|
|
107
|
-
A full developer environment built into the admin panel:
|
|
108
|
-
|
|
109
|
-
| Tool | Description |
|
|
110
|
-
|---|---|
|
|
111
|
-
| **SQL Editor** | Write and execute SQL queries directly against your database with schema-aware autocomplete |
|
|
112
|
-
| **RLS Policy Editor** | Visual editor for PostgreSQL Row-Level Security policies |
|
|
113
|
-
| **Schema Visualizer** | Interactive ER diagram of your database with relationship mapping |
|
|
114
|
-
| **JS/TS Editor** | In-browser code editor for scripts and functions |
|
|
115
|
-
| **API Explorer** | Browse and test your auto-generated REST API endpoints |
|
|
116
|
-
| **Cron Jobs** | Schedule and monitor recurring tasks |
|
|
117
|
-
| **Storage Browser** | Browse and manage files in your S3-compatible storage |
|
|
118
|
-
|
|
119
|
-
### ⚡ Extensible API & Edge Functions
|
|
120
|
-
|
|
121
|
-
Drop custom Hono routes or scheduled tasks into the `functions/` and `crons/` directories. Rebase auto-loads them with database access and JWT authentication middleware injected automatically.
|
|
122
|
-
|
|
123
|
-
### 🧬 SDK Generator
|
|
124
|
-
|
|
125
|
-
Auto-generate fully typed **TypeScript SDKs** from your collection definitions. Use them in any frontend, script, or service to interact with your Rebase backend with complete type safety.
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
npx @rebasepro/cli generate-sdk
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 🤖 MCP Server
|
|
132
|
-
|
|
133
|
-
A built-in **Model Context Protocol** server that enables AI assistants to:
|
|
134
|
-
|
|
135
|
-
- Query and manage your database schema
|
|
136
|
-
- Create, read, update, and delete documents
|
|
137
|
-
- Manage users and roles
|
|
138
|
-
- Introspect your data model
|
|
139
|
-
|
|
140
|
-
### 🔍 Schema Inference & Introspection
|
|
141
|
-
|
|
142
|
-
Point Rebase at an existing PostgreSQL database and automatically generate collection definitions from your tables — including types, relations, validation constraints, and more.
|
|
143
|
-
|
|
144
|
-
### 📥📤 Import & Export
|
|
145
|
-
|
|
146
|
-
Import data from **CSV, JSON, and Excel** with an intuitive field mapper. Export your data in multiple formats with configurable column selection.
|
|
147
|
-
|
|
148
|
-
### 🧩 Plugins
|
|
149
|
-
|
|
150
|
-
Extend the admin experience with first-party plugins:
|
|
151
|
-
|
|
152
|
-
- **Data Enhancement** — AI-powered field suggestions and auto-fill
|
|
153
|
-
- **Insights** — Analytics dashboards and usage metrics
|
|
154
|
-
|
|
155
|
-
### 📜 Standalone Scripting
|
|
156
|
-
|
|
157
|
-
Write standalone data manipulation scripts that connect directly to your running backend using the `@rebasepro/client` SDK. The CLI persists the dev server URL to `.rebase-dev-url` for zero-config local development.
|
|
158
|
-
|
|
159
|
-
### 🧩 Custom Views & React Extensibility
|
|
160
|
-
|
|
161
|
-
Build entirely custom views — dashboards, previews, charts — and drop them into the main navigation or as entity-level tabs. Use built-in hooks to interact with Rebase's internal state.
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## 🛠️ Core Technologies
|
|
166
|
-
|
|
167
|
-
Built entirely on modern, battle-tested web standards:
|
|
168
|
-
|
|
169
|
-
| Technology | What we use it for |
|
|
170
|
-
|---|---|
|
|
171
|
-
| 💙 **TypeScript 5.x** | End-to-end type safety |
|
|
172
|
-
| ⚛️ **React 19** | Component-driven UI |
|
|
173
|
-
| 🌊 **Tailwind CSS v4** | Utility-first styling |
|
|
174
|
-
| 🔌 **WebSockets** | Real-time synchronization |
|
|
175
|
-
| 🗄️ **Drizzle ORM** | Type-safe SQL migrations and queries |
|
|
176
|
-
| 🧱 **Radix UI** | Accessible UI primitives |
|
|
177
|
-
| 📝 **TipTap v3** | Rich text editing |
|
|
178
|
-
| 🌐 **Hono** | Ultrafast HTTP server framework |
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## 📦 Packages
|
|
183
|
-
|
|
184
|
-
Rebase is structured as a modular monorepo — install only the layers you need:
|
|
185
|
-
|
|
186
|
-
| Package | Description |
|
|
187
|
-
|---|---|
|
|
188
|
-
| `@rebasepro/types` | Core TypeScript type definitions |
|
|
189
|
-
| `@rebasepro/utils` | Shared utility functions |
|
|
190
|
-
| `@rebasepro/common` | Common modules shared across packages |
|
|
191
|
-
| `@rebasepro/formex` | Lightweight form management library |
|
|
192
|
-
| `@rebasepro/ui` | Standalone React component library (Tailwind + Radix) |
|
|
193
|
-
| `@rebasepro/core` | Core CMS logic and controllers |
|
|
194
|
-
| `@rebasepro/client` | Client-side data access layer |
|
|
195
|
-
| `@rebasepro/client-postgresql` | PostgreSQL client adapter |
|
|
196
|
-
| `@rebasepro/client-firebase` | Firebase/Firestore client adapter |
|
|
197
|
-
| `@rebasepro/server-core` | Server framework and middleware (Hono) |
|
|
198
|
-
| `@rebasepro/server-postgresql` | PostgreSQL server adapter with Drizzle |
|
|
199
|
-
| `@rebasepro/server-mongodb` | MongoDB server adapter |
|
|
200
|
-
| `@rebasepro/auth` | Authentication controllers and login views |
|
|
201
|
-
| `@rebasepro/admin` | Full admin panel interface |
|
|
202
|
-
| `@rebasepro/studio` | SQL editor, RLS editor, schema visualizer, API explorer |
|
|
203
|
-
| `@rebasepro/cli` | CLI for project scaffolding and management |
|
|
204
|
-
| `@rebasepro/sdk-generator` | TypeScript SDK code generation |
|
|
205
|
-
| `@rebasepro/mcp-server` | MCP server for AI integrations |
|
|
206
|
-
| `@rebasepro/schema-inference` | Database schema introspection and inference |
|
|
207
|
-
| `@rebasepro/plugin-data-enhancement` | AI-powered data enhancement plugin |
|
|
208
|
-
| `@rebasepro/plugin-insights` | Analytics and insights plugin |
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## 🎨 Standalone UI Library
|
|
213
|
-
|
|
214
|
-
Rebase exposes its design system as a completely independent library. Fully typed, accessible, and customizable via Tailwind CSS v4:
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
npm install @rebasepro/ui
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
## Demo
|
|
223
|
-
|
|
224
|
-
Explore a live interactive sandbox with all features — data resets periodically:
|
|
225
|
-
|
|
226
|
-
**👉 [demo.rebase.pro](https://demo.rebase.pro)**
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Support & Community
|
|
231
|
-
|
|
232
|
-
- 📖 [Documentation](https://rebase.pro/docs)
|
|
233
|
-
- 💬 [Discord Community](https://discord.gg/fxy7xsQm3m)
|
|
234
|
-
- 🐛 [GitHub Issues](https://github.com/rebasepro/rebase/issues)
|
|
235
|
-
- 📝 [Changelog](./CHANGELOG.md)
|
|
236
|
-
|
|
237
|
-
---
|
|
83
|
+
## Related Packages
|
|
238
84
|
|
|
239
|
-
|
|
85
|
+
Every `@rebasepro/*` package depends on this one. Key consumers:
|
|
240
86
|
|
|
241
|
-
|
|
242
|
-
|
|
87
|
+
| Package | Uses |
|
|
88
|
+
|---------|------|
|
|
89
|
+
| `@rebasepro/server-core` | `DataDriver`, `DatabaseAdapter`, `BackendBootstrapper`, `AuthAdapter` |
|
|
90
|
+
| `@rebasepro/server-postgresql` | `BackendBootstrapper`, `InitializedDriver`, `RealtimeProvider` |
|
|
91
|
+
| `@rebasepro/server-mongodb` | `BackendBootstrapper`, `DataDriver`, `EntityCollection` |
|
|
92
|
+
| `@rebasepro/client` | `RebaseClient`, `DataSourceDelegate`, `StorageSource` |
|
|
93
|
+
| `@rebasepro/admin` | `EntityCollection`, `Property`, `PluginConfig`, controller interfaces |
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { User } from "../users";
|
|
2
2
|
import type { RebaseData } from "./data";
|
|
3
3
|
import type { EmailService } from "./email";
|
|
4
|
+
import type { StorageSource } from "./storage";
|
|
5
|
+
import type { CronJobStatus, CronJobLogEntry } from "../types/cron";
|
|
4
6
|
/**
|
|
5
7
|
* Event type for authentication state changes
|
|
6
8
|
*/
|
|
@@ -14,7 +16,6 @@ export interface RebaseSession {
|
|
|
14
16
|
expiresAt: number;
|
|
15
17
|
user: User;
|
|
16
18
|
}
|
|
17
|
-
import type { StorageSource } from "./storage";
|
|
18
19
|
/**
|
|
19
20
|
* Unified Authentication Client Interface
|
|
20
21
|
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
@@ -111,8 +112,65 @@ export interface AdminAPI {
|
|
|
111
112
|
}>;
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
115
|
+
* Client-side Cron job management interface.
|
|
116
|
+
* @group Cron
|
|
117
|
+
*/
|
|
118
|
+
export interface CronAPI {
|
|
119
|
+
listJobs(): Promise<{
|
|
120
|
+
jobs: CronJobStatus[];
|
|
121
|
+
}>;
|
|
122
|
+
getJob(jobId: string): Promise<{
|
|
123
|
+
job: CronJobStatus;
|
|
124
|
+
}>;
|
|
125
|
+
triggerJob(jobId: string): Promise<{
|
|
126
|
+
log: CronJobLogEntry;
|
|
127
|
+
job: CronJobStatus;
|
|
128
|
+
}>;
|
|
129
|
+
getJobLogs(jobId: string, options?: {
|
|
130
|
+
limit?: number;
|
|
131
|
+
}): Promise<{
|
|
132
|
+
logs: CronJobLogEntry[];
|
|
133
|
+
}>;
|
|
134
|
+
toggleJob(jobId: string, enabled: boolean): Promise<{
|
|
135
|
+
job: CronJobStatus;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Options for invoking a custom backend function.
|
|
140
|
+
* @group Functions
|
|
141
|
+
*/
|
|
142
|
+
export interface FunctionInvokeOptions {
|
|
143
|
+
/** HTTP method — defaults to `"POST"`. */
|
|
144
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
145
|
+
/** Sub-path appended after the function name. */
|
|
146
|
+
path?: string;
|
|
147
|
+
/** Extra headers merged into the request. */
|
|
148
|
+
headers?: Record<string, string>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Client interface for invoking custom backend functions.
|
|
152
|
+
* @group Functions
|
|
153
|
+
*/
|
|
154
|
+
export interface FunctionsAPI {
|
|
155
|
+
/**
|
|
156
|
+
* Invoke a custom backend function by name.
|
|
157
|
+
*
|
|
158
|
+
* @typeParam T - Expected shape of the response payload.
|
|
159
|
+
* @param name - Function name (filename without extension, e.g. `"extract-job"`).
|
|
160
|
+
* @param payload - Optional JSON-serialisable body sent as POST.
|
|
161
|
+
* @param options - Optional overrides (method, sub-path, headers).
|
|
162
|
+
*/
|
|
163
|
+
invoke<T = unknown>(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise<T>;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The single, canonical Rebase client interface.
|
|
167
|
+
*
|
|
168
|
+
* Used everywhere: the server-side `rebase` singleton, the SDK's
|
|
169
|
+
* `createRebaseClient()`, React context, cron job context, etc.
|
|
170
|
+
*
|
|
171
|
+
* Core fields (`data`, `auth`) are always present. Everything else
|
|
172
|
+
* is optional — which capabilities are populated depends on the
|
|
173
|
+
* runtime environment and adapter.
|
|
116
174
|
*/
|
|
117
175
|
export interface RebaseClient<DB = unknown> {
|
|
118
176
|
/** Unified Data access layer */
|
|
@@ -123,43 +181,32 @@ export interface RebaseClient<DB = unknown> {
|
|
|
123
181
|
storage?: StorageSource;
|
|
124
182
|
/**
|
|
125
183
|
* Server-side email service.
|
|
126
|
-
*
|
|
127
|
-
* Available when SMTP (or a custom `sendEmail` function) is configured
|
|
128
|
-
* in the backend auth config. `undefined` when email is not configured.
|
|
129
|
-
*
|
|
130
|
-
* > **Note:** This is only available on the server-side `rebase` singleton.
|
|
131
|
-
* > The client-side SDK does not include an email service.
|
|
184
|
+
* Available when SMTP or a custom `sendEmail` function is configured.
|
|
132
185
|
*/
|
|
133
186
|
email?: EmailService;
|
|
134
187
|
/** Admin API for user management */
|
|
135
188
|
admin?: AdminAPI;
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
189
|
+
/** Cron job management API */
|
|
190
|
+
cron?: CronAPI;
|
|
191
|
+
/** Custom backend functions API */
|
|
192
|
+
functions?: FunctionsAPI;
|
|
193
|
+
/** Base HTTP URL of the backend server */
|
|
141
194
|
baseUrl?: string;
|
|
142
|
-
/**
|
|
143
|
-
* WebSocket client for realtime subscriptions and admin capabilities.
|
|
144
|
-
* Exposed by the SDK client (`@rebasepro/client`). The shape is intentionally
|
|
145
|
-
* left as `unknown` in the base interface — callers should narrow via feature
|
|
146
|
-
* detection (e.g. `typeof ws.executeSql === "function"`).
|
|
147
|
-
*/
|
|
195
|
+
/** WebSocket client for realtime subscriptions */
|
|
148
196
|
ws?: unknown;
|
|
197
|
+
/** Set the auth token for subsequent requests */
|
|
198
|
+
setToken?(token: string | null): void;
|
|
199
|
+
/** Set a function that lazily resolves the auth token */
|
|
200
|
+
setAuthTokenGetter?(getter: () => Promise<string | null>): void;
|
|
201
|
+
/** Set handler called when a request returns 401 */
|
|
202
|
+
setOnUnauthorized?(handler: () => Promise<boolean>): void;
|
|
203
|
+
/** Resolve the current auth token */
|
|
204
|
+
resolveToken?(): Promise<string | null>;
|
|
205
|
+
/** Make a raw HTTP call to the backend */
|
|
206
|
+
call?<T = unknown>(endpoint: string, payload?: unknown): Promise<T>;
|
|
149
207
|
/**
|
|
150
208
|
* Execute raw SQL against the database.
|
|
151
|
-
*
|
|
152
|
-
* Only available server-side when the backend uses a SQL database
|
|
153
|
-
* (PostgreSQL, MySQL, etc.). `undefined` for document databases
|
|
154
|
-
* (MongoDB, Firestore) and on the client-side SDK.
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```typescript
|
|
158
|
-
* // In a cron job or custom function:
|
|
159
|
-
* if (ctx.client.sql) {
|
|
160
|
-
* const rows = await ctx.client.sql("SELECT count(*) FROM orders");
|
|
161
|
-
* }
|
|
162
|
-
* ```
|
|
209
|
+
* Only available server-side with a SQL database.
|
|
163
210
|
*/
|
|
164
211
|
sql?(query: string, options?: {
|
|
165
212
|
database?: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import type { EntityLinkBuilder } from "../types/entity_link_builder";
|
|
3
2
|
import type { Locale } from "../types/locales";
|
|
4
3
|
import type { EntityAction } from "../types/entity_actions";
|
|
@@ -6,6 +5,7 @@ import type { EntityCustomView } from "../types/entity_views";
|
|
|
6
5
|
import type { RebasePlugin } from "../types/plugins";
|
|
7
6
|
import type { PropertyConfig } from "../types/property_config";
|
|
8
7
|
import type { SlotContribution } from "../types/slots";
|
|
8
|
+
import type { ComponentOverrideMap } from "../types/component_overrides";
|
|
9
9
|
export type CustomizationController = {
|
|
10
10
|
/**
|
|
11
11
|
* Builder for generating utility links for entities
|
|
@@ -49,12 +49,13 @@ export type CustomizationController = {
|
|
|
49
49
|
* the `propertyConfig` prop of a property in a collection.
|
|
50
50
|
*/
|
|
51
51
|
propertyConfigs: Record<string, PropertyConfig>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Global component overrides. Keys are component names from
|
|
54
|
+
* {@link OverridableComponentName}. Values replace the default
|
|
55
|
+
* implementation everywhere in the app.
|
|
56
|
+
*
|
|
57
|
+
* Collection-scoped overrides (set on individual collections)
|
|
58
|
+
* take precedence over global overrides.
|
|
59
|
+
*/
|
|
60
|
+
components?: ComponentOverrideMap;
|
|
60
61
|
};
|