@rebasepro/client-postgresql 0.0.1-canary.4f204c2 → 0.0.1-canary.626e45b
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/client/src/auth.d.ts +6 -1
- package/dist/client/src/collection.d.ts +2 -1
- package/dist/client/src/functions.d.ts +49 -0
- package/dist/client/src/index.d.ts +3 -0
- package/dist/types/src/controllers/auth.d.ts +8 -2
- package/dist/types/src/controllers/client.d.ts +13 -0
- package/dist/types/src/controllers/collection_registry.d.ts +2 -1
- package/dist/types/src/controllers/data_driver.d.ts +36 -1
- package/dist/types/src/controllers/navigation.d.ts +18 -6
- package/dist/types/src/controllers/registry.d.ts +9 -1
- package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
- package/dist/types/src/rebase_context.d.ts +17 -0
- package/dist/types/src/types/backend_hooks.d.ts +187 -0
- package/dist/types/src/types/collections.d.ts +31 -11
- package/dist/types/src/types/component_ref.d.ts +47 -0
- package/dist/types/src/types/cron.d.ts +1 -1
- package/dist/types/src/types/entity_views.d.ts +6 -7
- package/dist/types/src/types/formex.d.ts +40 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/plugins.d.ts +6 -3
- package/dist/types/src/types/properties.d.ts +72 -88
- package/dist/types/src/types/slots.d.ts +20 -10
- package/dist/types/src/types/translations.d.ts +6 -0
- package/package.json +3 -3
|
@@ -50,7 +50,12 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
|
|
|
50
50
|
accessToken: string;
|
|
51
51
|
refreshToken: string;
|
|
52
52
|
}>;
|
|
53
|
-
signInWithGoogle: (
|
|
53
|
+
signInWithGoogle: (tokenOrPayload: string | {
|
|
54
|
+
idToken?: string;
|
|
55
|
+
accessToken?: string;
|
|
56
|
+
code?: string;
|
|
57
|
+
redirectUri?: string;
|
|
58
|
+
}) => Promise<{
|
|
54
59
|
user: RebaseUser;
|
|
55
60
|
accessToken: string;
|
|
56
61
|
refreshToken: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transport } from "./transport";
|
|
1
|
+
import { Transport, FindParams } from "./transport";
|
|
2
2
|
import { RebaseWebSocketClient } from "./websocket";
|
|
3
3
|
import { CollectionAccessor } from "@rebasepro/types";
|
|
4
4
|
import { FilterOperator, QueryBuilder } from "./query_builder";
|
|
@@ -15,5 +15,6 @@ export interface CollectionClient<M extends Record<string, unknown> = Record<str
|
|
|
15
15
|
offset(count: number): QueryBuilder<M>;
|
|
16
16
|
search(searchString: string): QueryBuilder<M>;
|
|
17
17
|
include(...relations: string[]): QueryBuilder<M>;
|
|
18
|
+
count(params?: FindParams): Promise<number>;
|
|
18
19
|
}
|
|
19
20
|
export declare function createCollectionClient<M extends Record<string, unknown> = Record<string, unknown>>(transport: Transport, slug: string, ws?: RebaseWebSocketClient): CollectionClient<M>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Transport } from "./transport";
|
|
2
|
+
/**
|
|
3
|
+
* Client interface for invoking custom backend functions.
|
|
4
|
+
*
|
|
5
|
+
* Custom functions are Hono route files auto-mounted by the Rebase backend
|
|
6
|
+
* at `/api/functions/{name}`. The `FunctionsClient` wraps the shared
|
|
7
|
+
* transport so callers never need to manually construct URLs or inject
|
|
8
|
+
* auth tokens.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const result = await client.functions.invoke<{ job: Job }>('extract-job', {
|
|
13
|
+
* url: 'https://example.com/posting',
|
|
14
|
+
* html: htmlContent,
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface FunctionsClient {
|
|
19
|
+
/**
|
|
20
|
+
* Invoke a custom backend function by name.
|
|
21
|
+
*
|
|
22
|
+
* @typeParam T - Expected shape of the response payload.
|
|
23
|
+
* @param name - Function name (the filename without extension, e.g. `"extract-job"`).
|
|
24
|
+
* @param payload - Optional JSON-serialisable body sent as `POST`.
|
|
25
|
+
* @param options - Optional overrides (HTTP method, sub-path, extra headers).
|
|
26
|
+
* @returns The parsed JSON response from the function.
|
|
27
|
+
*/
|
|
28
|
+
invoke<T = unknown>(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise<T>;
|
|
29
|
+
}
|
|
30
|
+
export interface FunctionInvokeOptions {
|
|
31
|
+
/** HTTP method — defaults to `"POST"`. */
|
|
32
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
33
|
+
/** Sub-path appended after the function name, e.g. `"status/123"`. */
|
|
34
|
+
path?: string;
|
|
35
|
+
/** Extra headers merged into the request (auth is still injected automatically). */
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a `FunctionsClient` backed by the given transport.
|
|
40
|
+
*
|
|
41
|
+
* The transport already handles:
|
|
42
|
+
* - Base URL resolution
|
|
43
|
+
* - JWT injection via `Authorization: Bearer`
|
|
44
|
+
* - 401 retry / `onUnauthorized` flow
|
|
45
|
+
* - Consistent error throwing via `RebaseApiError`
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare function createFunctionsClient(transport: Transport): FunctionsClient;
|
|
@@ -3,6 +3,7 @@ import { createAuth, CreateAuthOptions } from "./auth";
|
|
|
3
3
|
import { createAdmin, CreateAdminOptions } from "./admin";
|
|
4
4
|
import { createCron, CreateCronOptions } from "./cron";
|
|
5
5
|
import { CollectionClient } from "./collection";
|
|
6
|
+
import type { FunctionsClient } from "./functions";
|
|
6
7
|
export * from "./transport";
|
|
7
8
|
export * from "./auth";
|
|
8
9
|
export * from "./admin";
|
|
@@ -11,6 +12,7 @@ export * from "./collection";
|
|
|
11
12
|
export * from "./websocket";
|
|
12
13
|
export * from "./storage";
|
|
13
14
|
export * from "./reviver";
|
|
15
|
+
export * from "./functions";
|
|
14
16
|
export interface CreateRebaseClientOptions extends RebaseClientConfig {
|
|
15
17
|
auth?: CreateAuthOptions;
|
|
16
18
|
admin?: CreateAdminOptions;
|
|
@@ -26,6 +28,7 @@ export type RebaseClient<DB = Record<string, unknown>> = BaseRebaseClient<DB> &
|
|
|
26
28
|
auth: ReturnType<typeof createAuth>;
|
|
27
29
|
admin: ReturnType<typeof createAdmin>;
|
|
28
30
|
cron: ReturnType<typeof createCron>;
|
|
31
|
+
functions: FunctionsClient;
|
|
29
32
|
ws?: RebaseWebSocketClient;
|
|
30
33
|
storage?: StorageSource;
|
|
31
34
|
call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
|
|
@@ -80,8 +80,14 @@ export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
|
80
80
|
export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
|
|
81
81
|
/** Login with email and password */
|
|
82
82
|
emailPasswordLogin?(email: string, password: string): Promise<void>;
|
|
83
|
-
/** Login with a Google
|
|
84
|
-
googleLogin
|
|
83
|
+
/** Login with a Google token or authorization code */
|
|
84
|
+
googleLogin?: {
|
|
85
|
+
(token: string, tokenType?: "idToken" | "accessToken"): Promise<void>;
|
|
86
|
+
(payload: {
|
|
87
|
+
code: string;
|
|
88
|
+
redirectUri: string;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
};
|
|
85
91
|
/** Register a new user */
|
|
86
92
|
register?(email: string, password: string, displayName?: string): Promise<void>;
|
|
87
93
|
/** Skip login (for anonymous access if enabled) */
|
|
@@ -167,4 +167,17 @@ export interface RebaseClient<DB = unknown> {
|
|
|
167
167
|
email?: EmailService;
|
|
168
168
|
/** Admin API for user and role management */
|
|
169
169
|
admin?: AdminAPI;
|
|
170
|
+
/**
|
|
171
|
+
* The base HTTP URL of the backend server.
|
|
172
|
+
* Exposed by the SDK client (`@rebasepro/client`) and used to auto-derive
|
|
173
|
+
* the `ApiConfigProvider` URL.
|
|
174
|
+
*/
|
|
175
|
+
baseUrl?: string;
|
|
176
|
+
/**
|
|
177
|
+
* WebSocket client for realtime subscriptions and admin capabilities.
|
|
178
|
+
* Exposed by the SDK client (`@rebasepro/client`). The shape is intentionally
|
|
179
|
+
* left as `unknown` in the base interface — callers should narrow via feature
|
|
180
|
+
* detection (e.g. `typeof ws.executeSql === "function"`).
|
|
181
|
+
*/
|
|
182
|
+
ws?: unknown;
|
|
170
183
|
}
|
|
@@ -36,7 +36,8 @@ export type CollectionRegistryController<DB = Record<string, unknown>, EC extend
|
|
|
36
36
|
* Retrieve all the related parent collection ids for a given path
|
|
37
37
|
* @param path
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
getParentCollectionSlugs: (path: string) => string[];
|
|
40
|
+
getParentEntityIds: (path: string) => string[];
|
|
40
41
|
/**
|
|
41
42
|
* Resolve paths from a list of ids
|
|
42
43
|
* @param ids
|
|
@@ -144,12 +144,19 @@ export interface DataDriver {
|
|
|
144
144
|
path: string;
|
|
145
145
|
databaseId?: string;
|
|
146
146
|
collection: EntityCollection;
|
|
147
|
-
|
|
147
|
+
parentCollectionSlugs?: string[];
|
|
148
|
+
parentEntityIds?: string[];
|
|
148
149
|
}) => Promise<boolean>;
|
|
149
150
|
/**
|
|
150
151
|
* Flag to indicate if the driver has requested the initialization of the text search index
|
|
151
152
|
*/
|
|
152
153
|
needsInitTextSearch?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Optional REST-optimised fetch service. When present, the REST API
|
|
156
|
+
* generator uses these methods instead of the generic `fetchEntity` /
|
|
157
|
+
* `fetchCollection` pipeline, enabling include-aware eager-loading.
|
|
158
|
+
*/
|
|
159
|
+
restFetchService?: RestFetchService;
|
|
153
160
|
/**
|
|
154
161
|
* Return the admin capabilities of this driver.
|
|
155
162
|
* @see SQLAdmin
|
|
@@ -158,3 +165,31 @@ export interface DataDriver {
|
|
|
158
165
|
*/
|
|
159
166
|
admin?: import("../types/backend").DatabaseAdmin;
|
|
160
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* REST-optimised fetch service exposed by drivers that support
|
|
170
|
+
* eager-loading of relations via `include`.
|
|
171
|
+
*
|
|
172
|
+
* The methods return flattened rows (`{ id, ...columns }`) rather
|
|
173
|
+
* than the `Entity<M>` wrapper used by the generic DataDriver API.
|
|
174
|
+
*
|
|
175
|
+
* @group DataDriver
|
|
176
|
+
*/
|
|
177
|
+
export interface RestFetchService {
|
|
178
|
+
/**
|
|
179
|
+
* Fetch a collection of flattened entities with optional relation includes.
|
|
180
|
+
*/
|
|
181
|
+
fetchCollectionForRest(collectionPath: string, options?: {
|
|
182
|
+
filter?: FilterValues<string>;
|
|
183
|
+
orderBy?: string;
|
|
184
|
+
order?: "desc" | "asc";
|
|
185
|
+
limit?: number;
|
|
186
|
+
offset?: number;
|
|
187
|
+
startAfter?: Record<string, unknown>;
|
|
188
|
+
searchString?: string;
|
|
189
|
+
databaseId?: string;
|
|
190
|
+
}, include?: string[]): Promise<Record<string, unknown>[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Fetch a single flattened entity with optional relation includes.
|
|
193
|
+
*/
|
|
194
|
+
fetchEntityForRest(collectionPath: string, entityId: string | number, include?: string[], databaseId?: string): Promise<Record<string, unknown> | null>;
|
|
195
|
+
}
|
|
@@ -144,17 +144,18 @@ export interface AppView {
|
|
|
144
144
|
* It will still be accessible if you reach the specified path
|
|
145
145
|
*/
|
|
146
146
|
hideFromNavigation?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Navigation group for this view.
|
|
149
|
+
* Views sharing the same group name will be visually grouped
|
|
150
|
+
* together in the drawer and home page. If not set, the view
|
|
151
|
+
* falls into the default "Views" group.
|
|
152
|
+
*/
|
|
153
|
+
group?: string;
|
|
147
154
|
/**
|
|
148
155
|
* Component to be rendered. This can be any React component, and can use
|
|
149
156
|
* any of the provided hooks
|
|
150
157
|
*/
|
|
151
158
|
view: React.ReactNode;
|
|
152
|
-
/**
|
|
153
|
-
* Optional field used to group top level navigation entries under a
|
|
154
|
-
* navigation view.
|
|
155
|
-
* This prop is ignored for admin views.
|
|
156
|
-
*/
|
|
157
|
-
group?: string;
|
|
158
159
|
/**
|
|
159
160
|
* If true, a wildcard route (slug/*) is automatically registered
|
|
160
161
|
* alongside the base route, enabling nested navigation within this view.
|
|
@@ -193,6 +194,17 @@ export interface NavigationGroupMapping {
|
|
|
193
194
|
* List of collection ids or view paths that belong to this group.
|
|
194
195
|
*/
|
|
195
196
|
entries: string[];
|
|
197
|
+
/**
|
|
198
|
+
* Configure which groups start collapsed.
|
|
199
|
+
* Set to `true` to collapse in both drawer and home page,
|
|
200
|
+
* or use an object to control each independently.
|
|
201
|
+
*
|
|
202
|
+
* @defaultValue false (expanded)
|
|
203
|
+
*/
|
|
204
|
+
collapsedByDefault?: boolean | {
|
|
205
|
+
drawer?: boolean;
|
|
206
|
+
home?: boolean;
|
|
207
|
+
};
|
|
196
208
|
}
|
|
197
209
|
export interface NavigationEntry {
|
|
198
210
|
id: string;
|
|
@@ -3,7 +3,7 @@ import type { EntityCollection } from "../types/collections";
|
|
|
3
3
|
import type { EntityCollectionsBuilder } from "../types/builders";
|
|
4
4
|
import type { EntityCustomView } from "../types/entity_views";
|
|
5
5
|
import type { EntityAction } from "../types/entity_actions";
|
|
6
|
-
import type { AppView } from "./navigation";
|
|
6
|
+
import type { AppView, NavigationGroupMapping } from "./navigation";
|
|
7
7
|
/**
|
|
8
8
|
* Options to enable the built-in collection editor.
|
|
9
9
|
* When provided to `<RebaseCMS>`, the editor is auto-wired as a native feature.
|
|
@@ -25,6 +25,14 @@ export interface RebaseCMSConfig<EC extends EntityCollection = any> {
|
|
|
25
25
|
entityViews?: EntityCustomView<any>[];
|
|
26
26
|
entityActions?: EntityAction[];
|
|
27
27
|
plugins?: any[];
|
|
28
|
+
/**
|
|
29
|
+
* Centralized configuration for how collections and views are grouped
|
|
30
|
+
* in the navigation sidebar and home page.
|
|
31
|
+
* Each mapping defines a named group and the collection/view slugs
|
|
32
|
+
* that belong to it. The array order determines group display order.
|
|
33
|
+
* Entry order within each group determines card order.
|
|
34
|
+
*/
|
|
35
|
+
navigationGroupMappings?: NavigationGroupMapping[];
|
|
28
36
|
/**
|
|
29
37
|
* Enable the built-in visual collection/schema editor.
|
|
30
38
|
* Pass `true` for zero-config, or an options object for fine-grained control.
|
|
@@ -62,6 +62,13 @@ export interface EntitySidePanelProps<M extends Record<string, unknown> = Record
|
|
|
62
62
|
* Allow the user to open the entity fullscreen
|
|
63
63
|
*/
|
|
64
64
|
allowFullScreen?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Pre-populate the form with these values when creating a new entity.
|
|
67
|
+
* Only applied when `entityId` is not set (i.e. the form is in "new" mode).
|
|
68
|
+
* Useful for actions that fetch data from an external source (e.g. a URL)
|
|
69
|
+
* and want to pre-fill the document before the user saves.
|
|
70
|
+
*/
|
|
71
|
+
defaultValues?: Partial<M>;
|
|
65
72
|
}
|
|
66
73
|
/**
|
|
67
74
|
* Controller to open the side dialog displaying entity forms
|
|
@@ -3,6 +3,7 @@ import type { AuthController } from "./controllers/auth";
|
|
|
3
3
|
import type { StorageSource } from "./controllers/storage";
|
|
4
4
|
import type { UserConfigurationPersistence } from "./controllers/local_config_persistence";
|
|
5
5
|
import type { DatabaseAdmin } from "./types/backend";
|
|
6
|
+
import type { RebaseClient } from "./controllers/client";
|
|
6
7
|
import type { RebaseData } from "./controllers/data";
|
|
7
8
|
import type { User } from "./users";
|
|
8
9
|
import type { UserManagementDelegate } from "./types/user_management_delegate";
|
|
@@ -12,6 +13,22 @@ import type { UserManagementDelegate } from "./types/user_management_delegate";
|
|
|
12
13
|
* @group Hooks and utilities
|
|
13
14
|
*/
|
|
14
15
|
export type RebaseCallContext<USER extends User = User> = {
|
|
16
|
+
/**
|
|
17
|
+
* The Rebase client instance.
|
|
18
|
+
* Available in all entity callbacks (beforeSave, afterSave, afterRead,
|
|
19
|
+
* beforeDelete, afterDelete) and in CollectionActionsProps via context.
|
|
20
|
+
* Use it to call backend functions, access data, storage, etc.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // In a beforeSave callback:
|
|
24
|
+
* const result = await context.client.functions.invoke('my-function', { ... });
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // In a CollectionAction component:
|
|
28
|
+
* const { client } = props.context;
|
|
29
|
+
* const result = await client.functions.invoke('extract-job', { url });
|
|
30
|
+
*/
|
|
31
|
+
client: RebaseClient<any>;
|
|
15
32
|
/**
|
|
16
33
|
* Unified data access — `context.data.products.create(...)`.
|
|
17
34
|
* Access any collection as a dynamic property.
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { AdminUser, AdminRole } from "../controllers/client";
|
|
2
|
+
/**
|
|
3
|
+
* Context passed to every backend hook.
|
|
4
|
+
* Provides information about the request that triggered the hook.
|
|
5
|
+
* @group Backend Hooks
|
|
6
|
+
*/
|
|
7
|
+
export interface BackendHookContext {
|
|
8
|
+
/** The currently authenticated user making the request (if any) */
|
|
9
|
+
requestUser?: {
|
|
10
|
+
userId: string;
|
|
11
|
+
roles: string[];
|
|
12
|
+
};
|
|
13
|
+
/** The HTTP method of the request */
|
|
14
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Hooks for intercepting Admin User data at the API boundary.
|
|
18
|
+
*
|
|
19
|
+
* These hooks run on the server after the database operation completes
|
|
20
|
+
* but before the response is sent to the client.
|
|
21
|
+
*
|
|
22
|
+
* @group Backend Hooks
|
|
23
|
+
*/
|
|
24
|
+
export interface UserHooks {
|
|
25
|
+
/**
|
|
26
|
+
* Transform a user record after it's read from the database,
|
|
27
|
+
* before it's returned to the client.
|
|
28
|
+
*
|
|
29
|
+
* Return the modified user, or `null` to filter it out entirely
|
|
30
|
+
* (the user won't appear in listings or individual fetches).
|
|
31
|
+
*/
|
|
32
|
+
afterRead?(user: AdminUser, context: BackendHookContext): AdminUser | null | Promise<AdminUser | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Transform user data before it's written to the database.
|
|
35
|
+
* Runs on POST (create) and PUT (update).
|
|
36
|
+
*
|
|
37
|
+
* Return the (possibly modified) data to proceed with the save.
|
|
38
|
+
* Throw an error to abort the operation.
|
|
39
|
+
*/
|
|
40
|
+
beforeSave?(data: {
|
|
41
|
+
email?: string;
|
|
42
|
+
displayName?: string;
|
|
43
|
+
roles?: string[];
|
|
44
|
+
}, context: BackendHookContext): {
|
|
45
|
+
email?: string;
|
|
46
|
+
displayName?: string;
|
|
47
|
+
roles?: string[];
|
|
48
|
+
} | Promise<{
|
|
49
|
+
email?: string;
|
|
50
|
+
displayName?: string;
|
|
51
|
+
roles?: string[];
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Called after a user is successfully created or updated.
|
|
55
|
+
* Useful for side-effects like sending notifications.
|
|
56
|
+
*/
|
|
57
|
+
afterSave?(user: AdminUser, context: BackendHookContext): void | Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Called before a user is deleted. Throw to prevent deletion.
|
|
60
|
+
*/
|
|
61
|
+
beforeDelete?(userId: string, context: BackendHookContext): void | Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Called after a user is successfully deleted.
|
|
64
|
+
*/
|
|
65
|
+
afterDelete?(userId: string, context: BackendHookContext): void | Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Hooks for intercepting Admin Role data at the API boundary.
|
|
69
|
+
* @group Backend Hooks
|
|
70
|
+
*/
|
|
71
|
+
export interface RoleHooks {
|
|
72
|
+
/**
|
|
73
|
+
* Transform a role record after it's read from the database,
|
|
74
|
+
* before it's returned to the client.
|
|
75
|
+
*
|
|
76
|
+
* Return the modified role, or `null` to filter it out entirely.
|
|
77
|
+
*/
|
|
78
|
+
afterRead?(role: AdminRole, context: BackendHookContext): AdminRole | null | Promise<AdminRole | null>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Hooks for intercepting collection entity data at the REST API boundary.
|
|
82
|
+
*
|
|
83
|
+
* These run **after** per-collection `EntityCallbacks` (which execute inside
|
|
84
|
+
* the DataDriver) and provide a single cross-cutting interception point for
|
|
85
|
+
* ALL collections flowing through the REST API.
|
|
86
|
+
*
|
|
87
|
+
* Every callback receives the collection `slug` so you can target specific
|
|
88
|
+
* collections or apply logic globally.
|
|
89
|
+
*
|
|
90
|
+
* @group Backend Hooks
|
|
91
|
+
*/
|
|
92
|
+
export interface DataHooks {
|
|
93
|
+
/**
|
|
94
|
+
* Transform an entity after it's read from the database,
|
|
95
|
+
* before it's returned to the client.
|
|
96
|
+
*
|
|
97
|
+
* Runs for both list (GET /:slug) and single (GET /:slug/:id) fetches.
|
|
98
|
+
* Return the modified entity, or `null` to filter it out.
|
|
99
|
+
*
|
|
100
|
+
* @param slug - The collection slug (e.g. "orders", "products")
|
|
101
|
+
* @param entity - The flattened entity object (id + values merged)
|
|
102
|
+
* @param context - Request context (authenticated user, HTTP method)
|
|
103
|
+
*/
|
|
104
|
+
afterRead?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): Record<string, unknown> | null | Promise<Record<string, unknown> | null>;
|
|
105
|
+
/**
|
|
106
|
+
* Transform entity values before they are written to the database.
|
|
107
|
+
* Runs on POST (create) and PUT (update).
|
|
108
|
+
*
|
|
109
|
+
* Return the (possibly modified) values. Throw to abort the save.
|
|
110
|
+
*
|
|
111
|
+
* @param slug - The collection slug
|
|
112
|
+
* @param values - The raw request body values
|
|
113
|
+
* @param entityId - The entity ID (only present on updates)
|
|
114
|
+
* @param context - Request context
|
|
115
|
+
*/
|
|
116
|
+
beforeSave?(slug: string, values: Record<string, unknown>, entityId: string | undefined, context: BackendHookContext): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
117
|
+
/**
|
|
118
|
+
* Called after an entity is successfully saved (created or updated).
|
|
119
|
+
* Useful for side-effects like syncing to external systems.
|
|
120
|
+
*
|
|
121
|
+
* @param slug - The collection slug
|
|
122
|
+
* @param entity - The saved entity (flattened)
|
|
123
|
+
* @param context - Request context
|
|
124
|
+
*/
|
|
125
|
+
afterSave?(slug: string, entity: Record<string, unknown>, context: BackendHookContext): void | Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Called before an entity is deleted. Throw to prevent deletion.
|
|
128
|
+
*
|
|
129
|
+
* @param slug - The collection slug
|
|
130
|
+
* @param entityId - The entity ID being deleted
|
|
131
|
+
* @param context - Request context
|
|
132
|
+
*/
|
|
133
|
+
beforeDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Called after an entity is successfully deleted.
|
|
136
|
+
*
|
|
137
|
+
* @param slug - The collection slug
|
|
138
|
+
* @param entityId - The deleted entity ID
|
|
139
|
+
* @param context - Request context
|
|
140
|
+
*/
|
|
141
|
+
afterDelete?(slug: string, entityId: string, context: BackendHookContext): void | Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Backend-level hooks for intercepting data at the API boundary.
|
|
145
|
+
*
|
|
146
|
+
* These hooks run server-side after database operations complete and before
|
|
147
|
+
* API responses are sent.
|
|
148
|
+
*
|
|
149
|
+
* - `users` / `roles` — intercept admin user and role management endpoints
|
|
150
|
+
* - `data` — intercept ALL collection entity data flowing through the REST API
|
|
151
|
+
*
|
|
152
|
+
* `data` hooks complement per-collection `EntityCallbacks`. Entity callbacks
|
|
153
|
+
* run inside the DataDriver (close to the DB); data hooks run at the HTTP
|
|
154
|
+
* boundary (close to the client). Use data hooks for cross-cutting concerns
|
|
155
|
+
* like audit logging, response enrichment, or field masking.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const hooks: BackendHooks = {
|
|
160
|
+
* data: {
|
|
161
|
+
* afterRead(slug, entity, ctx) {
|
|
162
|
+
* // Mask PII for non-admin users across all collections
|
|
163
|
+
* if (!ctx.requestUser?.roles.includes("admin") && entity.email) {
|
|
164
|
+
* return { ...entity, email: "***" };
|
|
165
|
+
* }
|
|
166
|
+
* return entity;
|
|
167
|
+
* }
|
|
168
|
+
* },
|
|
169
|
+
* users: {
|
|
170
|
+
* afterRead(user, ctx) {
|
|
171
|
+
* if (user.email.endsWith("@system.internal")) return null;
|
|
172
|
+
* return user;
|
|
173
|
+
* }
|
|
174
|
+
* }
|
|
175
|
+
* };
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @group Backend Hooks
|
|
179
|
+
*/
|
|
180
|
+
export interface BackendHooks {
|
|
181
|
+
/** Hooks for intercepting user management data */
|
|
182
|
+
users?: UserHooks;
|
|
183
|
+
/** Hooks for intercepting role management data */
|
|
184
|
+
roles?: RoleHooks;
|
|
185
|
+
/** Hooks for intercepting ALL collection entity data via the REST API */
|
|
186
|
+
data?: DataHooks;
|
|
187
|
+
}
|
|
@@ -9,6 +9,7 @@ import type { RebaseContext } from "../rebase_context";
|
|
|
9
9
|
import type { Relation } from "./relations";
|
|
10
10
|
import type { EntityCustomView } from "./entity_views";
|
|
11
11
|
import type { EntityAction } from "./entity_actions";
|
|
12
|
+
import type { ComponentRef } from "./component_ref";
|
|
12
13
|
/**
|
|
13
14
|
* Base interface containing all driver-agnostic collection properties.
|
|
14
15
|
* Use {@link PostgresCollection} or {@link FirebaseCollection} for
|
|
@@ -19,9 +20,8 @@ import type { EntityAction } from "./entity_actions";
|
|
|
19
20
|
*/
|
|
20
21
|
export interface BaseEntityCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
21
22
|
/**
|
|
22
|
-
* You can set an alias that will be used internally instead of the
|
|
23
|
-
* The `
|
|
24
|
-
* while `path` will still be used in the driver.
|
|
23
|
+
* You can set an alias that will be used internally instead of the collection name.
|
|
24
|
+
* The `slug` value will be used to determine the URL of the collection.
|
|
25
25
|
* Note that you can use this value in reference properties too.
|
|
26
26
|
*/
|
|
27
27
|
slug: string;
|
|
@@ -87,6 +87,9 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
87
87
|
icon?: string | React.ReactNode;
|
|
88
88
|
/**
|
|
89
89
|
* Navigation group for this collection.
|
|
90
|
+
* Collections sharing the same group name will be visually grouped
|
|
91
|
+
* together in the drawer and home page. If not set, the collection
|
|
92
|
+
* falls into the default "Views" group.
|
|
90
93
|
*/
|
|
91
94
|
group?: string;
|
|
92
95
|
/**
|
|
@@ -158,17 +161,17 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
158
161
|
/**
|
|
159
162
|
* Force a filter in this view. If applied, the rest of the filters will
|
|
160
163
|
* be disabled. Filters applied with this prop cannot be changed.
|
|
161
|
-
* e.g. `
|
|
162
|
-
* e.g. `
|
|
164
|
+
* e.g. `fixedFilter: { age: [">", 18] }`
|
|
165
|
+
* e.g. `fixedFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
|
|
163
166
|
*/
|
|
164
|
-
readonly
|
|
167
|
+
readonly fixedFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
|
|
165
168
|
/**
|
|
166
169
|
* Initial filters applied to the collection this collection is related to.
|
|
167
170
|
* Defaults to none. Filters applied with this prop can be changed.
|
|
168
|
-
* e.g. `
|
|
169
|
-
* e.g. `
|
|
171
|
+
* e.g. `defaultFilter: { age: [">", 18] }`
|
|
172
|
+
* e.g. `defaultFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
|
|
170
173
|
*/
|
|
171
|
-
readonly
|
|
174
|
+
readonly defaultFilter?: FilterValues<Extract<keyof M, string> | (string & {})>;
|
|
172
175
|
/**
|
|
173
176
|
* Default sort applied to this collection.
|
|
174
177
|
* When setting this prop, entities will have a default order
|
|
@@ -302,7 +305,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
302
305
|
/**
|
|
303
306
|
* Builder for the collection actions rendered in the toolbar
|
|
304
307
|
*/
|
|
305
|
-
Actions?:
|
|
308
|
+
Actions?: ComponentRef<CollectionActionsProps>[];
|
|
306
309
|
}
|
|
307
310
|
/**
|
|
308
311
|
* A collection backed by PostgreSQL (or any SQL database).
|
|
@@ -314,6 +317,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
314
317
|
* @group Models
|
|
315
318
|
*/
|
|
316
319
|
export interface PostgresCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
|
|
320
|
+
properties: Properties;
|
|
317
321
|
/**
|
|
318
322
|
* The driver for this collection. For Postgres collections this
|
|
319
323
|
* can be omitted (Postgres is the default) or set to `"postgres"`.
|
|
@@ -457,7 +461,8 @@ export interface CollectionActionsProps<M extends Record<string, unknown> = Reco
|
|
|
457
461
|
/**
|
|
458
462
|
* Array of the parent path segments like `['users']`
|
|
459
463
|
*/
|
|
460
|
-
|
|
464
|
+
parentCollectionSlugs: string[];
|
|
465
|
+
parentEntityIds: string[];
|
|
461
466
|
/**
|
|
462
467
|
* The collection configuration
|
|
463
468
|
*/
|
|
@@ -481,6 +486,21 @@ export interface CollectionActionsProps<M extends Record<string, unknown> = Reco
|
|
|
481
486
|
* undefined means the count is still loading.
|
|
482
487
|
*/
|
|
483
488
|
collectionEntitiesCount?: number;
|
|
489
|
+
/**
|
|
490
|
+
* Programmatically open the new-document form for this collection,
|
|
491
|
+
* optionally pre-populating it with initial field values.
|
|
492
|
+
* The form opens in the same mode configured for the collection
|
|
493
|
+
* (side panel, full screen, or split).
|
|
494
|
+
*
|
|
495
|
+
* This is the primary hook for workflows that need to create a document
|
|
496
|
+
* from external data — e.g. fetching content from a URL, importing from
|
|
497
|
+
* a third-party API, or duplicating from another system.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* // Inside a custom CollectionAction component:
|
|
501
|
+
* openNewDocument({ title: "Fetched title", body: "..." });
|
|
502
|
+
*/
|
|
503
|
+
openNewDocument: (defaultValues?: Record<string, unknown>) => void;
|
|
484
504
|
}
|
|
485
505
|
/**
|
|
486
506
|
* Use this controller to retrieve the selected entities or modify them in
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Internal marker for a lazily-loaded component reference.
|
|
4
|
+
* Created by the Vite transform plugin when converting string paths
|
|
5
|
+
* to deferred `import()` calls. Users should NOT create these manually.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export interface LazyComponentRef<P = unknown> {
|
|
10
|
+
readonly __rebaseLazy: true;
|
|
11
|
+
readonly load: () => Promise<{
|
|
12
|
+
default: React.ComponentType<P>;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A reference to a React component that can be provided in three forms:
|
|
17
|
+
*
|
|
18
|
+
* 1. **String path** (recommended for collection configs):
|
|
19
|
+
* ```ts
|
|
20
|
+
* Field: "../../frontend/src/components/MyField"
|
|
21
|
+
* ```
|
|
22
|
+
* The Vite plugin transforms this into a `LazyComponentRef` at build time.
|
|
23
|
+
* On the backend, the string stays inert and is never evaluated.
|
|
24
|
+
*
|
|
25
|
+
* 2. **Lazy import function**:
|
|
26
|
+
* ```ts
|
|
27
|
+
* Field: () => import("../../frontend/src/components/MyField")
|
|
28
|
+
* ```
|
|
29
|
+
* Standard ES dynamic import. Backend never calls the function.
|
|
30
|
+
*
|
|
31
|
+
* 3. **Direct component reference** (use only in frontend-only code):
|
|
32
|
+
* ```ts
|
|
33
|
+
* Field: MyFieldComponent
|
|
34
|
+
* ```
|
|
35
|
+
* Importing a component at the top level will pull React into the
|
|
36
|
+
* backend runtime — only safe in code that the backend never imports.
|
|
37
|
+
*
|
|
38
|
+
* @group Types
|
|
39
|
+
*/
|
|
40
|
+
export type ComponentRef<P = unknown> = React.ComponentType<P> | LazyComponentRef<P> | (() => Promise<{
|
|
41
|
+
default: React.ComponentType<P>;
|
|
42
|
+
}>) | string;
|
|
43
|
+
/**
|
|
44
|
+
* Type guard: checks if a value is a `LazyComponentRef` produced by the
|
|
45
|
+
* Vite transform plugin.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isLazyComponentRef<P = unknown>(ref: unknown): ref is LazyComponentRef<P>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RebaseClient } from "../controllers/client";
|
|
1
2
|
/**
|
|
2
3
|
* Cron Job type definitions for Rebase.
|
|
3
4
|
*
|
|
@@ -32,7 +33,6 @@ export interface CronJobDefinition {
|
|
|
32
33
|
*/
|
|
33
34
|
handler: (ctx: CronJobContext) => Promise<unknown> | unknown;
|
|
34
35
|
}
|
|
35
|
-
import type { RebaseClient } from "../controllers/client";
|
|
36
36
|
/**
|
|
37
37
|
* Context passed to each cron handler invocation.
|
|
38
38
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Entity, EntityValues } from "./entities";
|
|
3
3
|
import type { EntityCollection } from "./collections";
|
|
4
|
+
import type { FormexController } from "./formex";
|
|
5
|
+
import type { ComponentRef } from "./component_ref";
|
|
4
6
|
/**
|
|
5
7
|
* Context passed to custom fields and entity views.
|
|
6
|
-
* This is the base definition — `@rebasepro/admin` re-exports a
|
|
7
|
-
* fully-typed version that narrows the `formex` field.
|
|
8
8
|
* @group Form custom fields
|
|
9
9
|
*/
|
|
10
10
|
export interface FormContext<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -38,10 +38,8 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
38
38
|
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
39
39
|
/**
|
|
40
40
|
* The underlying formex controller that powers the form.
|
|
41
|
-
* Prefer importing `FormContext` from `@rebasepro/admin` for the
|
|
42
|
-
* fully-typed `FormexController<M>` version.
|
|
43
41
|
*/
|
|
44
|
-
formex:
|
|
42
|
+
formex: FormexController<M>;
|
|
45
43
|
disabled: boolean;
|
|
46
44
|
}
|
|
47
45
|
export type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
@@ -49,7 +47,7 @@ export type EntityCustomView<M extends Record<string, unknown> = Record<string,
|
|
|
49
47
|
name: string;
|
|
50
48
|
tabComponent?: React.ReactNode;
|
|
51
49
|
includeActions?: boolean | "bottom";
|
|
52
|
-
Builder?:
|
|
50
|
+
Builder?: ComponentRef<EntityCustomViewParams<M>>;
|
|
53
51
|
position?: "start" | "end";
|
|
54
52
|
};
|
|
55
53
|
export interface EntityCustomViewParams<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -57,5 +55,6 @@ export interface EntityCustomViewParams<M extends Record<string, unknown> = Reco
|
|
|
57
55
|
entity?: Entity<M>;
|
|
58
56
|
modifiedValues?: EntityValues<M>;
|
|
59
57
|
formContext: FormContext<M>;
|
|
60
|
-
|
|
58
|
+
parentCollectionSlugs?: string[];
|
|
59
|
+
parentEntityIds?: string[];
|
|
61
60
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { FormEvent } from "react";
|
|
2
|
+
export type FormexController<T = any> = {
|
|
3
|
+
values: T;
|
|
4
|
+
initialValues: T;
|
|
5
|
+
setValues: (values: T) => void;
|
|
6
|
+
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
7
|
+
touched: Record<string, boolean>;
|
|
8
|
+
setFieldTouched: (key: string, touched: boolean, shouldValidate?: boolean) => void;
|
|
9
|
+
setTouched: (touched: Record<string, boolean>) => void;
|
|
10
|
+
dirty: boolean;
|
|
11
|
+
setDirty: (dirty: boolean) => void;
|
|
12
|
+
setSubmitCount: (submitCount: number) => void;
|
|
13
|
+
errors: Record<string, string>;
|
|
14
|
+
setFieldError: (key: string, error?: string) => void;
|
|
15
|
+
handleChange: (event: React.SyntheticEvent) => void;
|
|
16
|
+
handleBlur: (event: React.FocusEvent) => void;
|
|
17
|
+
handleSubmit: (event?: FormEvent<HTMLFormElement>) => void;
|
|
18
|
+
validate: () => void;
|
|
19
|
+
resetForm: (props?: FormexResetProps<T>) => void;
|
|
20
|
+
submitCount: number;
|
|
21
|
+
isSubmitting: boolean;
|
|
22
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
23
|
+
isValidating: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The version of the form. This is incremented every time the form is reset
|
|
26
|
+
* or the form is submitted.
|
|
27
|
+
*/
|
|
28
|
+
version: number;
|
|
29
|
+
debugId?: string;
|
|
30
|
+
undo: () => void;
|
|
31
|
+
redo: () => void;
|
|
32
|
+
canUndo: boolean;
|
|
33
|
+
canRedo: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type FormexResetProps<T = any> = {
|
|
36
|
+
values?: T;
|
|
37
|
+
submitCount?: number;
|
|
38
|
+
errors?: Record<string, string>;
|
|
39
|
+
touched?: Record<string, boolean>;
|
|
40
|
+
};
|
|
@@ -10,6 +10,7 @@ export * from "./entity_callbacks";
|
|
|
10
10
|
export * from "./entity_overrides";
|
|
11
11
|
export * from "./export_import";
|
|
12
12
|
export * from "./modify_collections";
|
|
13
|
+
export * from "./formex";
|
|
13
14
|
export * from "./websockets";
|
|
14
15
|
export * from "./backend";
|
|
15
16
|
export * from "./translations";
|
|
@@ -21,3 +22,5 @@ export * from "./property_config";
|
|
|
21
22
|
export * from "./entity_views";
|
|
22
23
|
export * from "./data_source";
|
|
23
24
|
export * from "./cron";
|
|
25
|
+
export * from "./backend_hooks";
|
|
26
|
+
export * from "./component_ref";
|
|
@@ -157,7 +157,8 @@ export interface PluginHooks {
|
|
|
157
157
|
*/
|
|
158
158
|
onColumnsReorder?: (props: {
|
|
159
159
|
fullPath: string;
|
|
160
|
-
|
|
160
|
+
parentCollectionSlugs: string[];
|
|
161
|
+
parentEntityIds: string[];
|
|
161
162
|
collection: EntityCollection;
|
|
162
163
|
newPropertiesOrder: string[];
|
|
163
164
|
}) => void;
|
|
@@ -166,7 +167,8 @@ export interface PluginHooks {
|
|
|
166
167
|
*/
|
|
167
168
|
onKanbanColumnsReorder?: (props: {
|
|
168
169
|
fullPath: string;
|
|
169
|
-
|
|
170
|
+
parentCollectionSlugs: string[];
|
|
171
|
+
parentEntityIds: string[];
|
|
170
172
|
collection: EntityCollection;
|
|
171
173
|
kanbanColumnProperty: string;
|
|
172
174
|
newColumnsOrder: string[];
|
|
@@ -241,7 +243,8 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
|
|
|
241
243
|
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
242
244
|
entityId?: string | number;
|
|
243
245
|
path: string;
|
|
244
|
-
|
|
246
|
+
parentCollectionSlugs: string[];
|
|
247
|
+
parentEntityIds: string[];
|
|
245
248
|
status: EntityStatus;
|
|
246
249
|
collection: EC;
|
|
247
250
|
disabled: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ComponentRef } from "./component_ref";
|
|
2
2
|
import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
|
|
3
3
|
import type { Relation, JoinStep, OnAction } from "./relations";
|
|
4
4
|
import type { EntityCollection, FilterValues } from "./collections";
|
|
@@ -36,6 +36,14 @@ export type Property = StringProperty | NumberProperty | BooleanProperty | DateP
|
|
|
36
36
|
export type Properties = {
|
|
37
37
|
[key: string]: Property;
|
|
38
38
|
};
|
|
39
|
+
export type PostgresProperty = Exclude<Property, ReferenceProperty>;
|
|
40
|
+
export type PostgresProperties = {
|
|
41
|
+
[key: string]: PostgresProperty;
|
|
42
|
+
};
|
|
43
|
+
export type FirebaseProperty = Exclude<Property, RelationProperty>;
|
|
44
|
+
export type FirebaseProperties = {
|
|
45
|
+
[key: string]: FirebaseProperty;
|
|
46
|
+
};
|
|
39
47
|
/**
|
|
40
48
|
* A helper type to infer the underlying data type from a Property definition.
|
|
41
49
|
* This is the core of the type inference system.
|
|
@@ -89,7 +97,18 @@ export type InferEntityType<P extends Properties> = {
|
|
|
89
97
|
* Interface including all common properties of a CMS property.
|
|
90
98
|
* @group Entity properties
|
|
91
99
|
*/
|
|
100
|
+
export interface BaseUIConfig<CustomProps = unknown> {
|
|
101
|
+
columnWidth?: number;
|
|
102
|
+
hideFromCollection?: boolean;
|
|
103
|
+
readOnly?: boolean;
|
|
104
|
+
disabled?: boolean | PropertyDisabledConfig;
|
|
105
|
+
widthPercentage?: number;
|
|
106
|
+
customProps?: CustomProps;
|
|
107
|
+
Field?: ComponentRef<any>;
|
|
108
|
+
Preview?: ComponentRef<any>;
|
|
109
|
+
}
|
|
92
110
|
export interface BaseProperty<CustomProps = unknown> {
|
|
111
|
+
ui?: BaseUIConfig<CustomProps>;
|
|
93
112
|
/**
|
|
94
113
|
* Property name (e.g. Product)
|
|
95
114
|
*/
|
|
@@ -106,27 +125,17 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
106
125
|
*/
|
|
107
126
|
propertyConfig?: string;
|
|
108
127
|
/**
|
|
109
|
-
*
|
|
110
|
-
* the
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
* Is this a read only property. When set to true, it gets rendered as a
|
|
119
|
-
* preview.
|
|
120
|
-
*/
|
|
121
|
-
readOnly?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Is this field disabled.
|
|
124
|
-
* When set to true, it gets rendered as a
|
|
125
|
-
* disabled field. You can also specify a configuration for defining the
|
|
126
|
-
* behaviour of disabled properties (including custom messages, clear value on
|
|
127
|
-
* disabled or hide the field completely)
|
|
128
|
+
* Explicit database column name. When set, this value is used as-is
|
|
129
|
+
* for the SQL column name, bypassing any snake_case conversion of
|
|
130
|
+
* the property key.
|
|
131
|
+
*
|
|
132
|
+
* This is automatically populated by `rebase schema introspect`
|
|
133
|
+
* to guarantee an exact match with the live database schema.
|
|
134
|
+
*
|
|
135
|
+
* For manually-authored collections you can omit this — the framework
|
|
136
|
+
* will derive the column name from the property key via `toSnakeCase()`.
|
|
128
137
|
*/
|
|
129
|
-
|
|
138
|
+
columnName?: string;
|
|
130
139
|
/**
|
|
131
140
|
* Rules for validating this property
|
|
132
141
|
*/
|
|
@@ -135,16 +144,6 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
135
144
|
* This value will be set by default for new entities.
|
|
136
145
|
*/
|
|
137
146
|
defaultValue?: unknown;
|
|
138
|
-
/**
|
|
139
|
-
* A number between 0 and 100 that indicates the width of the field in the form view.
|
|
140
|
-
* It defaults to 100, but you can set it to 50 to have two fields in the same row.
|
|
141
|
-
*/
|
|
142
|
-
widthPercentage?: number;
|
|
143
|
-
/**
|
|
144
|
-
* Additional props that are passed to the components defined in `field`
|
|
145
|
-
* or in `preview`.
|
|
146
|
-
*/
|
|
147
|
-
customProps?: CustomProps;
|
|
148
147
|
/**
|
|
149
148
|
* Use this to define dynamic properties that change based on certain conditions
|
|
150
149
|
* or on the entity's values. For example, you can make a field read-only if
|
|
@@ -168,21 +167,19 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
168
167
|
* Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
|
|
169
168
|
*/
|
|
170
169
|
callbacks?: PropertyCallbacks;
|
|
171
|
-
/**
|
|
172
|
-
* Custom field component to render this property in forms.
|
|
173
|
-
* Used by the CMS layer.
|
|
174
|
-
*/
|
|
175
|
-
Field?: React.ComponentType<any>;
|
|
176
|
-
/**
|
|
177
|
-
* Custom preview component to render this property in previews/tables.
|
|
178
|
-
* Used by the CMS layer.
|
|
179
|
-
*/
|
|
180
|
-
Preview?: React.ComponentType<any>;
|
|
181
170
|
}
|
|
182
171
|
/**
|
|
183
172
|
* @group Entity properties
|
|
184
173
|
*/
|
|
174
|
+
export interface StringUIConfig extends BaseUIConfig {
|
|
175
|
+
multiline?: boolean;
|
|
176
|
+
markdown?: boolean;
|
|
177
|
+
previewAsTag?: boolean;
|
|
178
|
+
clearable?: boolean;
|
|
179
|
+
url?: boolean | PreviewType;
|
|
180
|
+
}
|
|
185
181
|
export interface StringProperty extends BaseProperty {
|
|
182
|
+
ui?: StringUIConfig;
|
|
186
183
|
type: "string";
|
|
187
184
|
/**
|
|
188
185
|
* Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
|
|
@@ -257,10 +254,6 @@ export interface StringProperty extends BaseProperty {
|
|
|
257
254
|
* Should this string be rendered as a tag instead of just text.
|
|
258
255
|
*/
|
|
259
256
|
previewAsTag?: boolean;
|
|
260
|
-
/**
|
|
261
|
-
* Add an icon to clear the value and set it to `null`. Defaults to `false`
|
|
262
|
-
*/
|
|
263
|
-
clearable?: boolean;
|
|
264
257
|
/**
|
|
265
258
|
* You can use this property (a string) to behave as a reference to another
|
|
266
259
|
* collection. The stored value is the ID of the entity in the
|
|
@@ -272,7 +265,11 @@ export interface StringProperty extends BaseProperty {
|
|
|
272
265
|
/**
|
|
273
266
|
* @group Entity properties
|
|
274
267
|
*/
|
|
268
|
+
export interface NumberUIConfig extends BaseUIConfig {
|
|
269
|
+
clearable?: boolean;
|
|
270
|
+
}
|
|
275
271
|
export interface NumberProperty extends BaseProperty {
|
|
272
|
+
ui?: NumberUIConfig;
|
|
276
273
|
type: "number";
|
|
277
274
|
/**
|
|
278
275
|
* Optional database column type. Allows specifying exact database numeric types.
|
|
@@ -300,15 +297,12 @@ export interface NumberProperty extends BaseProperty {
|
|
|
300
297
|
* displayed in the dropdown.
|
|
301
298
|
*/
|
|
302
299
|
enum?: EnumValues;
|
|
303
|
-
/**
|
|
304
|
-
* Add an icon to clear the value and set it to `null`. Defaults to `false`
|
|
305
|
-
*/
|
|
306
|
-
clearable?: boolean;
|
|
307
300
|
}
|
|
308
301
|
/**
|
|
309
302
|
* @group Entity properties
|
|
310
303
|
*/
|
|
311
304
|
export interface BooleanProperty extends BaseProperty {
|
|
305
|
+
ui?: BaseUIConfig;
|
|
312
306
|
type: "boolean";
|
|
313
307
|
/**
|
|
314
308
|
* Rules for validating this property
|
|
@@ -318,7 +312,11 @@ export interface BooleanProperty extends BaseProperty {
|
|
|
318
312
|
/**
|
|
319
313
|
* @group Entity properties
|
|
320
314
|
*/
|
|
315
|
+
export interface DateUIConfig extends BaseUIConfig {
|
|
316
|
+
clearable?: boolean;
|
|
317
|
+
}
|
|
321
318
|
export interface DateProperty extends BaseProperty {
|
|
319
|
+
ui?: DateUIConfig;
|
|
322
320
|
type: "date";
|
|
323
321
|
/**
|
|
324
322
|
* Optional database column type. If not set, defaults to `timestamp` with timezone.
|
|
@@ -354,6 +352,7 @@ export interface DateProperty extends BaseProperty {
|
|
|
354
352
|
* @group Entity properties
|
|
355
353
|
*/
|
|
356
354
|
export interface GeopointProperty extends BaseProperty {
|
|
355
|
+
ui?: BaseUIConfig;
|
|
357
356
|
type: "geopoint";
|
|
358
357
|
/**
|
|
359
358
|
* Rules for validating this property
|
|
@@ -363,7 +362,11 @@ export interface GeopointProperty extends BaseProperty {
|
|
|
363
362
|
/**
|
|
364
363
|
* @group Entity properties
|
|
365
364
|
*/
|
|
365
|
+
export interface ReferenceUIConfig extends BaseUIConfig {
|
|
366
|
+
previewProperties?: string[];
|
|
367
|
+
}
|
|
366
368
|
export interface ReferenceProperty extends BaseProperty {
|
|
369
|
+
ui?: ReferenceUIConfig;
|
|
367
370
|
type: "reference";
|
|
368
371
|
/**
|
|
369
372
|
* Marks this field as a Primary Key / Unique Identifier.
|
|
@@ -384,15 +387,9 @@ export interface ReferenceProperty extends BaseProperty {
|
|
|
384
387
|
path?: string;
|
|
385
388
|
/**
|
|
386
389
|
* Allow selection of entities that pass the given filter only.
|
|
387
|
-
* e.g. `
|
|
390
|
+
* e.g. `fixedFilter: { age: [">=", 18] }`
|
|
388
391
|
*/
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Properties that need to be rendered when displaying a preview of this
|
|
392
|
-
* reference. If not specified the first 3 are used. Only the first 3
|
|
393
|
-
* specified values are considered.
|
|
394
|
-
*/
|
|
395
|
-
previewProperties?: string[];
|
|
392
|
+
fixedFilter?: FilterValues<string>;
|
|
396
393
|
/**
|
|
397
394
|
* Should the reference include the ID of the entity. Defaults to `true`
|
|
398
395
|
*/
|
|
@@ -405,7 +402,12 @@ export interface ReferenceProperty extends BaseProperty {
|
|
|
405
402
|
/**
|
|
406
403
|
* @group Entity properties
|
|
407
404
|
*/
|
|
405
|
+
export interface RelationUIConfig extends BaseUIConfig {
|
|
406
|
+
previewProperties?: string[];
|
|
407
|
+
widget?: "select" | "dialog";
|
|
408
|
+
}
|
|
408
409
|
export interface RelationProperty extends BaseProperty {
|
|
410
|
+
ui?: RelationUIConfig;
|
|
409
411
|
type: "relation";
|
|
410
412
|
/**
|
|
411
413
|
* Marks this field as a Primary Key / Unique Identifier.
|
|
@@ -492,15 +494,9 @@ export interface RelationProperty extends BaseProperty {
|
|
|
492
494
|
relation?: Relation;
|
|
493
495
|
/**
|
|
494
496
|
* Allow selection of entities that pass the given filter only.
|
|
495
|
-
* e.g. `
|
|
497
|
+
* e.g. `fixedFilter: { age: [">=", 18] }`
|
|
496
498
|
*/
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Properties that need to be rendered when displaying a preview of this
|
|
500
|
-
* reference. If not specified the first 3 are used. Only the first 3
|
|
501
|
-
* specified values are considered.
|
|
502
|
-
*/
|
|
503
|
-
previewProperties?: string[];
|
|
499
|
+
fixedFilter?: FilterValues<string>;
|
|
504
500
|
/**
|
|
505
501
|
* Should the reference include the ID of the entity. Defaults to `true`
|
|
506
502
|
*/
|
|
@@ -518,7 +514,12 @@ export interface RelationProperty extends BaseProperty {
|
|
|
518
514
|
/**
|
|
519
515
|
* @group Entity properties
|
|
520
516
|
*/
|
|
517
|
+
export interface ArrayUIConfig extends BaseUIConfig {
|
|
518
|
+
expanded?: boolean;
|
|
519
|
+
minimalistView?: boolean;
|
|
520
|
+
}
|
|
521
521
|
export interface ArrayProperty extends BaseProperty {
|
|
522
|
+
ui?: ArrayUIConfig;
|
|
522
523
|
type: "array";
|
|
523
524
|
/**
|
|
524
525
|
* Optional database column type. Defaults to `jsonb`.
|
|
@@ -573,15 +574,6 @@ export interface ArrayProperty extends BaseProperty {
|
|
|
573
574
|
* Rules for validating this property
|
|
574
575
|
*/
|
|
575
576
|
validation?: ArrayPropertyValidationSchema;
|
|
576
|
-
/**
|
|
577
|
-
* Should the field be initially expanded. Defaults to `true`
|
|
578
|
-
*/
|
|
579
|
-
expanded?: boolean;
|
|
580
|
-
/**
|
|
581
|
-
* Display the child properties directly, without being wrapped in an
|
|
582
|
-
* extendable panel.
|
|
583
|
-
*/
|
|
584
|
-
minimalistView?: boolean;
|
|
585
577
|
/**
|
|
586
578
|
* Can the elements in this array be reordered. Defaults to `true`.
|
|
587
579
|
* This prop has no effect if `disabled` is set to true.
|
|
@@ -596,7 +588,13 @@ export interface ArrayProperty extends BaseProperty {
|
|
|
596
588
|
/**
|
|
597
589
|
* @group Entity properties
|
|
598
590
|
*/
|
|
591
|
+
export interface MapUIConfig extends BaseUIConfig {
|
|
592
|
+
expanded?: boolean;
|
|
593
|
+
minimalistView?: boolean;
|
|
594
|
+
spreadChildren?: boolean;
|
|
595
|
+
}
|
|
599
596
|
export interface MapProperty extends BaseProperty {
|
|
597
|
+
ui?: MapUIConfig;
|
|
600
598
|
type: "map";
|
|
601
599
|
/**
|
|
602
600
|
* Optional database column type. Defaults to `jsonb`.
|
|
@@ -630,20 +628,6 @@ export interface MapProperty extends BaseProperty {
|
|
|
630
628
|
* needed
|
|
631
629
|
*/
|
|
632
630
|
pickOnlySomeKeys?: boolean;
|
|
633
|
-
/**
|
|
634
|
-
* Display the child properties as independent columns in the collection
|
|
635
|
-
* view
|
|
636
|
-
*/
|
|
637
|
-
spreadChildren?: boolean;
|
|
638
|
-
/**
|
|
639
|
-
* Display the child properties directly, without being wrapped in an
|
|
640
|
-
* extendable panel. Note that this will also hide the title of this property.
|
|
641
|
-
*/
|
|
642
|
-
minimalistView?: boolean;
|
|
643
|
-
/**
|
|
644
|
-
* Should the field be initially expanded. Defaults to `true`
|
|
645
|
-
*/
|
|
646
|
-
expanded?: boolean;
|
|
647
631
|
/**
|
|
648
632
|
* Render this map as a key-value table that allows to use
|
|
649
633
|
* arbitrary keys. You don't need to define the properties in this case.
|
|
@@ -100,7 +100,8 @@ export interface NavigationSlotProps {
|
|
|
100
100
|
export interface CollectionToolbarProps {
|
|
101
101
|
path: string;
|
|
102
102
|
collection: EntityCollection;
|
|
103
|
-
|
|
103
|
+
parentCollectionSlugs: string[];
|
|
104
|
+
parentEntityIds: string[];
|
|
104
105
|
tableController: EntityTableController;
|
|
105
106
|
selectionController: SelectionController;
|
|
106
107
|
}
|
|
@@ -111,7 +112,8 @@ export interface CollectionToolbarProps {
|
|
|
111
112
|
export interface CollectionEmptyStateProps {
|
|
112
113
|
path: string;
|
|
113
114
|
collection: EntityCollection;
|
|
114
|
-
|
|
115
|
+
parentCollectionSlugs: string[];
|
|
116
|
+
parentEntityIds: string[];
|
|
115
117
|
canCreate: boolean;
|
|
116
118
|
onNewClick?: () => void;
|
|
117
119
|
}
|
|
@@ -123,7 +125,8 @@ export interface CollectionHeaderActionProps {
|
|
|
123
125
|
property: Property;
|
|
124
126
|
propertyKey: string;
|
|
125
127
|
path: string;
|
|
126
|
-
|
|
128
|
+
parentCollectionSlugs: string[];
|
|
129
|
+
parentEntityIds: string[];
|
|
127
130
|
onHover: boolean;
|
|
128
131
|
collection: EntityCollection;
|
|
129
132
|
tableController: EntityTableController;
|
|
@@ -134,7 +137,8 @@ export interface CollectionHeaderActionProps {
|
|
|
134
137
|
*/
|
|
135
138
|
export interface CollectionAddColumnProps {
|
|
136
139
|
path: string;
|
|
137
|
-
|
|
140
|
+
parentCollectionSlugs: string[];
|
|
141
|
+
parentEntityIds: string[];
|
|
138
142
|
collection: EntityCollection;
|
|
139
143
|
tableController: EntityTableController;
|
|
140
144
|
}
|
|
@@ -145,7 +149,8 @@ export interface CollectionAddColumnProps {
|
|
|
145
149
|
export interface CollectionErrorProps {
|
|
146
150
|
path: string;
|
|
147
151
|
collection: EntityCollection;
|
|
148
|
-
|
|
152
|
+
parentCollectionSlugs?: string[];
|
|
153
|
+
parentEntityIds?: string[];
|
|
149
154
|
error: Error;
|
|
150
155
|
}
|
|
151
156
|
/**
|
|
@@ -155,7 +160,8 @@ export interface CollectionErrorProps {
|
|
|
155
160
|
export interface KanbanSetupProps {
|
|
156
161
|
collection: EntityCollection;
|
|
157
162
|
fullPath: string;
|
|
158
|
-
|
|
163
|
+
parentCollectionSlugs: string[];
|
|
164
|
+
parentEntityIds: string[];
|
|
159
165
|
}
|
|
160
166
|
/**
|
|
161
167
|
* Props for the `kanban.add-column` slot.
|
|
@@ -164,7 +170,8 @@ export interface KanbanSetupProps {
|
|
|
164
170
|
export interface KanbanAddColumnProps {
|
|
165
171
|
collection: EntityCollection;
|
|
166
172
|
fullPath: string;
|
|
167
|
-
|
|
173
|
+
parentCollectionSlugs: string[];
|
|
174
|
+
parentEntityIds: string[];
|
|
168
175
|
columnProperty: string;
|
|
169
176
|
}
|
|
170
177
|
/**
|
|
@@ -177,7 +184,8 @@ export interface EntityRowActionsProps {
|
|
|
177
184
|
entityId: string;
|
|
178
185
|
path: string;
|
|
179
186
|
collection: EntityCollection;
|
|
180
|
-
|
|
187
|
+
parentCollectionSlugs: string[];
|
|
188
|
+
parentEntityIds: string[];
|
|
181
189
|
selectionController: SelectionController;
|
|
182
190
|
context: RebaseContext;
|
|
183
191
|
}
|
|
@@ -202,7 +210,8 @@ export interface EntityFieldSlotProps {
|
|
|
202
210
|
export interface CollectionFilterPanelProps {
|
|
203
211
|
path: string;
|
|
204
212
|
collection: EntityCollection;
|
|
205
|
-
|
|
213
|
+
parentCollectionSlugs: string[];
|
|
214
|
+
parentEntityIds: string[];
|
|
206
215
|
tableController: EntityTableController;
|
|
207
216
|
context: RebaseContext;
|
|
208
217
|
}
|
|
@@ -238,7 +247,8 @@ export interface ShellToolbarProps {
|
|
|
238
247
|
export interface CollectionInsightsSlotProps {
|
|
239
248
|
path: string;
|
|
240
249
|
collection: EntityCollection;
|
|
241
|
-
|
|
250
|
+
parentCollectionSlugs: string[];
|
|
251
|
+
parentEntityIds: string[];
|
|
242
252
|
}
|
|
243
253
|
/**
|
|
244
254
|
* Props for `home.card.insight` slot.
|
|
@@ -51,6 +51,8 @@ export interface RebaseTranslations {
|
|
|
51
51
|
all_entries_loaded: string;
|
|
52
52
|
create_your_first_entry: string;
|
|
53
53
|
no_results_filter_sort: string;
|
|
54
|
+
/** Shown when a text search yields no results. Supports `{{search}}` interpolation. */
|
|
55
|
+
no_results_search?: string;
|
|
54
56
|
add: string;
|
|
55
57
|
remove: string;
|
|
56
58
|
copy_id: string;
|
|
@@ -461,6 +463,10 @@ export interface RebaseTranslations {
|
|
|
461
463
|
reset_password_success?: string;
|
|
462
464
|
reset_password_confirmation?: string;
|
|
463
465
|
error_resetting_password?: string;
|
|
466
|
+
/** Permission-denied empty states */
|
|
467
|
+
no_permission_to_view_users?: string;
|
|
468
|
+
no_permission_to_view_roles?: string;
|
|
469
|
+
no_permission_description?: string;
|
|
464
470
|
/** Editor table-bubble */
|
|
465
471
|
add_row_before: string;
|
|
466
472
|
add_row_after: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/client-postgresql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.1-canary.
|
|
4
|
+
"version": "0.0.1-canary.626e45b",
|
|
5
5
|
"description": "PostgreSQL data source client for Rebase",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"./package.json": "./package.json"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@rebasepro/
|
|
61
|
-
"@rebasepro/
|
|
60
|
+
"@rebasepro/types": "0.0.1-canary.626e45b",
|
|
61
|
+
"@rebasepro/client": "0.0.1-canary.626e45b"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"react": ">=19.0.0",
|