@rebasepro/types 0.0.1-canary.2 → 0.0.1-canary.4d4fb3e
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 +1 -1
- package/dist/controllers/analytics_controller.d.ts +2 -2
- package/dist/controllers/auth.d.ts +50 -6
- package/dist/controllers/client.d.ts +58 -0
- package/dist/controllers/collection_registry.d.ts +44 -0
- package/dist/controllers/customization_controller.d.ts +5 -1
- package/dist/controllers/data.d.ts +141 -0
- package/dist/controllers/{datasource.d.ts → data_driver.d.ts} +25 -36
- package/dist/controllers/database_admin.d.ts +11 -0
- package/dist/controllers/effective_role.d.ts +4 -0
- package/dist/controllers/index.d.ts +11 -5
- package/dist/controllers/navigation.d.ts +9 -58
- package/dist/controllers/registry.d.ts +51 -0
- package/dist/controllers/side_entity_controller.d.ts +1 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +113 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +112 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +35 -25
- package/dist/types/backend.d.ts +296 -17
- package/dist/types/builders.d.ts +14 -0
- package/dist/types/collections.d.ts +166 -241
- package/dist/types/data_source.d.ts +64 -0
- package/dist/types/entities.d.ts +29 -24
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +4 -4
- package/dist/types/entity_overrides.d.ts +6 -2
- package/dist/types/entity_views.d.ts +61 -0
- package/dist/types/index.d.ts +8 -5
- package/dist/types/plugins.d.ts +170 -221
- package/dist/types/properties.d.ts +17 -29
- package/dist/types/property_config.d.ts +13 -11
- package/dist/types/slots.d.ts +228 -0
- package/dist/types/translations.d.ts +826 -0
- package/dist/types/user_management_delegate.d.ts +42 -0
- package/dist/types/websockets.d.ts +45 -0
- package/dist/users/user.d.ts +4 -0
- package/package.json +7 -39
- package/src/controllers/analytics_controller.tsx +2 -2
- package/src/controllers/auth.tsx +53 -6
- package/src/controllers/client.ts +74 -0
- package/src/controllers/collection_registry.ts +53 -0
- package/src/controllers/customization_controller.tsx +6 -1
- package/src/controllers/data.ts +153 -0
- package/src/controllers/{datasource.ts → data_driver.ts} +41 -37
- package/src/controllers/database_admin.ts +22 -0
- package/src/controllers/effective_role.ts +4 -0
- package/src/controllers/index.ts +14 -5
- package/src/controllers/navigation.ts +9 -73
- package/src/controllers/registry.ts +62 -0
- package/src/controllers/side_entity_controller.tsx +1 -2
- package/src/index.ts +0 -1
- package/src/rebase_context.tsx +37 -33
- package/src/types/backend.ts +351 -19
- package/src/types/builders.ts +16 -0
- package/src/types/collections.ts +196 -259
- package/src/types/data_source.ts +156 -0
- package/src/types/entities.ts +35 -28
- package/src/types/entity_actions.tsx +6 -6
- package/src/types/entity_callbacks.ts +4 -4
- package/src/types/entity_overrides.tsx +6 -2
- package/src/types/entity_views.tsx +77 -0
- package/src/types/index.ts +9 -5
- package/src/types/plugins.tsx +198 -256
- package/src/types/properties.ts +22 -31
- package/src/types/property_config.tsx +11 -11
- package/src/types/slots.tsx +271 -0
- package/src/types/translations.ts +923 -0
- package/src/types/user_management_delegate.ts +43 -0
- package/src/types/websockets.ts +48 -0
- package/src/users/user.ts +5 -0
- package/dist/components/EntityFormActionsProps.d.ts +0 -17
- package/dist/components/EntityFormProps.d.ts +0 -46
- package/dist/components/PropertyPreviewProps.d.ts +0 -50
- package/dist/components/formex.d.ts +0 -40
- package/dist/components/index.d.ts +0 -3
- package/dist/types/fields.d.ts +0 -221
- package/dist/types/rebase.d.ts +0 -180
- package/src/components/EntityFormActionsProps.tsx +0 -18
- package/src/components/EntityFormProps.tsx +0 -52
- package/src/components/PropertyPreviewProps.tsx +0 -61
- package/src/components/formex.tsx +0 -46
- package/src/components/index.ts +0 -3
- package/src/types/fields.tsx +0 -298
- package/src/types/rebase.tsx +0 -211
package/README.md
CHANGED
|
@@ -138,7 +138,7 @@ You can replace the Firebase Storage implementation with your own.
|
|
|
138
138
|
## Included example
|
|
139
139
|
|
|
140
140
|
You can access the code for the demo project under
|
|
141
|
-
[`example`](https://github.com/
|
|
141
|
+
[`example`](https://github.com/rebasepro/rebase/tree/master/example). It includes
|
|
142
142
|
every feature provided by this CMS.
|
|
143
143
|
|
|
144
144
|
Keep in mind you need to update the dependencies in that project if you want to
|
|
@@ -2,6 +2,6 @@ export type AnalyticsController = {
|
|
|
2
2
|
/**
|
|
3
3
|
* Callback used to get analytics events from the CMS
|
|
4
4
|
*/
|
|
5
|
-
onAnalyticsEvent?: (event:
|
|
5
|
+
onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
7
|
+
export type AnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "home_move_card" | "home_move_group" | "home_drop_new_group" | "collection_inline_editing" | "view_mode_changed" | "kanban_card_moved" | "kanban_column_reorder" | "kanban_property_changed" | "kanban_new_entity_in_column" | "kanban_backfill_order" | "card_view_entity_click" | "unmapped_event";
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
import { DataSource } from "./datasource";
|
|
2
1
|
import { StorageSource } from "./storage";
|
|
3
2
|
import { Role, User } from "../users";
|
|
3
|
+
import { RebaseData } from "./data";
|
|
4
|
+
/**
|
|
5
|
+
* Capabilities advertised by an auth provider.
|
|
6
|
+
* UI components use this to show/hide features dynamically
|
|
7
|
+
* (e.g. password reset, registration, session management).
|
|
8
|
+
* @group Hooks and utilities
|
|
9
|
+
*/
|
|
10
|
+
export interface AuthCapabilities {
|
|
11
|
+
emailPasswordLogin?: boolean;
|
|
12
|
+
googleLogin?: boolean;
|
|
13
|
+
registration?: boolean;
|
|
14
|
+
passwordReset?: boolean;
|
|
15
|
+
sessionManagement?: boolean;
|
|
16
|
+
profileUpdate?: boolean;
|
|
17
|
+
emailVerification?: boolean;
|
|
18
|
+
}
|
|
4
19
|
/**
|
|
5
20
|
* Controller for retrieving the logged user or performing auth related operations.
|
|
6
21
|
* Note that if you are implementing your AuthController, you probably will want
|
|
7
22
|
* to do it as the result of a hook.
|
|
8
23
|
* @group Hooks and utilities
|
|
9
24
|
*/
|
|
10
|
-
export type AuthController<USER extends User =
|
|
25
|
+
export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
11
26
|
/**
|
|
12
27
|
* The user currently logged in
|
|
13
28
|
* The values can be: the user object, null if they skipped login
|
|
@@ -46,9 +61,38 @@ export type AuthController<USER extends User = any, ExtraData = unknown> = {
|
|
|
46
61
|
loginSkipped: boolean;
|
|
47
62
|
extra: ExtraData;
|
|
48
63
|
setExtra: (extra: ExtraData) => void;
|
|
49
|
-
setUser
|
|
50
|
-
setUserRoles
|
|
64
|
+
setUser?(user: USER | null): void;
|
|
65
|
+
setUserRoles?(roles: Role[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* Capabilities advertised by the auth provider.
|
|
68
|
+
* UI components use this to feature-detect what the backend supports.
|
|
69
|
+
*/
|
|
70
|
+
capabilities?: AuthCapabilities;
|
|
51
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Extended auth controller with common optional auth methods.
|
|
74
|
+
* Backend implementations (Rebase backend, Firebase, Supabase, etc.)
|
|
75
|
+
* extend this with their own backend-specific extras.
|
|
76
|
+
* @group Hooks and utilities
|
|
77
|
+
*/
|
|
78
|
+
export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
|
|
79
|
+
/** Login with email and password */
|
|
80
|
+
emailPasswordLogin?(email: string, password: string): Promise<void>;
|
|
81
|
+
/** Login with a Google ID token or trigger Google popup */
|
|
82
|
+
googleLogin?(idToken: string): Promise<void>;
|
|
83
|
+
/** Register a new user */
|
|
84
|
+
register?(email: string, password: string, displayName?: string): Promise<void>;
|
|
85
|
+
/** Skip login (for anonymous access if enabled) */
|
|
86
|
+
skipLogin?(): void;
|
|
87
|
+
/** Request password reset email */
|
|
88
|
+
forgotPassword?(email: string): Promise<void>;
|
|
89
|
+
/** Reset password using a token */
|
|
90
|
+
resetPassword?(token: string, password: string): Promise<void>;
|
|
91
|
+
/** Change password for the authenticated user */
|
|
92
|
+
changePassword?(oldPassword: string, newPassword: string): Promise<void>;
|
|
93
|
+
/** Update user profile */
|
|
94
|
+
updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
|
|
95
|
+
}
|
|
52
96
|
/**
|
|
53
97
|
* Implement this function to allow access to specific users.
|
|
54
98
|
* @group Hooks and utilities
|
|
@@ -63,9 +107,9 @@ export type Authenticator<USER extends User = User> = (props: {
|
|
|
63
107
|
*/
|
|
64
108
|
authController: AuthController<USER>;
|
|
65
109
|
/**
|
|
66
|
-
*
|
|
110
|
+
* Unified data access API
|
|
67
111
|
*/
|
|
68
|
-
|
|
112
|
+
data: RebaseData;
|
|
69
113
|
/**
|
|
70
114
|
* Used storage implementation
|
|
71
115
|
*/
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { User } from "../users";
|
|
2
|
+
import { RebaseData } from "./data";
|
|
3
|
+
/**
|
|
4
|
+
* Event type for authentication state changes
|
|
5
|
+
*/
|
|
6
|
+
export type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED';
|
|
7
|
+
/**
|
|
8
|
+
* Standard session interface representing an authenticated state
|
|
9
|
+
*/
|
|
10
|
+
export interface RebaseSession {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
user: User;
|
|
15
|
+
}
|
|
16
|
+
import { StorageSource } from "./storage";
|
|
17
|
+
/**
|
|
18
|
+
* Unified Authentication Client Interface
|
|
19
|
+
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
20
|
+
*/
|
|
21
|
+
export interface AuthClient {
|
|
22
|
+
/**
|
|
23
|
+
* Get the current user from the server or cache
|
|
24
|
+
*/
|
|
25
|
+
getUser(): Promise<User | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the currently active session
|
|
28
|
+
*/
|
|
29
|
+
getSession(): RebaseSession | null;
|
|
30
|
+
/**
|
|
31
|
+
* Sign out the current user and clear local session
|
|
32
|
+
*/
|
|
33
|
+
signOut(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Subscribe to authentication state changes
|
|
36
|
+
*/
|
|
37
|
+
onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Manually refresh the session token
|
|
40
|
+
*/
|
|
41
|
+
refreshSession(): Promise<RebaseSession>;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Overarching abstraction that unites Data, Auth, and Storage.
|
|
46
|
+
* Adapters for Supabase or Firebase simply need to implement this interface.
|
|
47
|
+
*/
|
|
48
|
+
export interface RebaseClient<DB = any> {
|
|
49
|
+
/** Unified Data access layer */
|
|
50
|
+
data: RebaseData;
|
|
51
|
+
/** Unified Authentication layer */
|
|
52
|
+
auth: AuthClient;
|
|
53
|
+
/** Unified Storage layer */
|
|
54
|
+
storage?: StorageSource;
|
|
55
|
+
/** Optional admin panel specific tasks */
|
|
56
|
+
admin?: any;
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EntityCollection, EntityReference } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Controller that provides access to the registered entity collections.
|
|
4
|
+
* @group Models
|
|
5
|
+
*/
|
|
6
|
+
export type CollectionRegistryController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
7
|
+
/**
|
|
8
|
+
* List of the mapped collections in the CMS.
|
|
9
|
+
* Each entry relates to a collection in the root database.
|
|
10
|
+
* Each of the navigation entries in this field
|
|
11
|
+
* generates an entry in the main menu.
|
|
12
|
+
*/
|
|
13
|
+
collections?: EntityCollection[];
|
|
14
|
+
/**
|
|
15
|
+
* Is the registry ready to be used
|
|
16
|
+
*/
|
|
17
|
+
initialised: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get the collection configuration for a given path.
|
|
20
|
+
* The collection is resolved from the given path or alias.
|
|
21
|
+
*/
|
|
22
|
+
getCollection: (slugOrPath: string, includeUserOverride?: boolean) => EC | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get the raw, un-normalized collection configuration.
|
|
25
|
+
* This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
|
|
26
|
+
* This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
|
|
27
|
+
*/
|
|
28
|
+
getRawCollection: (slugOrPath: string) => EC | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve all the related parent references for a given path
|
|
31
|
+
* @param path
|
|
32
|
+
*/
|
|
33
|
+
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
34
|
+
/**
|
|
35
|
+
* Retrieve all the related parent collection ids for a given path
|
|
36
|
+
* @param path
|
|
37
|
+
*/
|
|
38
|
+
getParentCollectionIds: (path: string) => string[];
|
|
39
|
+
/**
|
|
40
|
+
* Resolve paths from a list of ids
|
|
41
|
+
* @param ids
|
|
42
|
+
*/
|
|
43
|
+
convertIdsToPaths: (ids: string[]) => string[];
|
|
44
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { EntityLinkBuilder, Locale, EntityAction, EntityCustomView, RebasePlugin, PropertyConfig, SlotContribution } from "../types";
|
|
3
3
|
export type CustomizationController = {
|
|
4
4
|
/**
|
|
5
5
|
* Builder for generating utility links for entities
|
|
@@ -9,6 +9,10 @@ export type CustomizationController = {
|
|
|
9
9
|
* Use plugins to modify the behaviour of the CMS.
|
|
10
10
|
*/
|
|
11
11
|
plugins?: RebasePlugin[];
|
|
12
|
+
/**
|
|
13
|
+
* Pre-merged slots from plugins + direct slot contributions.
|
|
14
|
+
*/
|
|
15
|
+
resolvedSlots: SlotContribution[];
|
|
12
16
|
/**
|
|
13
17
|
* List of additional custom views for entities.
|
|
14
18
|
* You can use the key to reference the custom view in
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Entity, EntityValues } from "../types/entities";
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for querying a collection.
|
|
4
|
+
* Uses PostgREST-style filter syntax for consistency between
|
|
5
|
+
* the SDK (HTTP) and framework (in-process) contexts.
|
|
6
|
+
*
|
|
7
|
+
* @group Data
|
|
8
|
+
*/
|
|
9
|
+
export interface FindParams {
|
|
10
|
+
/** Maximum number of items to return (default: 20) */
|
|
11
|
+
limit?: number;
|
|
12
|
+
/** Number of items to skip */
|
|
13
|
+
offset?: number;
|
|
14
|
+
/** Page number (1-indexed), alternative to offset */
|
|
15
|
+
page?: number;
|
|
16
|
+
/**
|
|
17
|
+
* PostgREST-style filter object.
|
|
18
|
+
* Keys are field names, values use "operator.value" format.
|
|
19
|
+
* Operators: eq, neq, gt, gte, lt, lte, in, nin, cs (array-contains), csa (array-contains-any)
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* { status: "eq.published" }
|
|
23
|
+
* { age: "gte.18" }
|
|
24
|
+
* { role: "in.(admin,editor)" }
|
|
25
|
+
*/
|
|
26
|
+
where?: Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Sort order. Format: "field:direction".
|
|
29
|
+
* @example "created_at:desc", "name:asc"
|
|
30
|
+
*/
|
|
31
|
+
orderBy?: string;
|
|
32
|
+
/** Relations to include in the response */
|
|
33
|
+
include?: string[];
|
|
34
|
+
/** Full-text search string */
|
|
35
|
+
searchString?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Paginated response from a collection query.
|
|
39
|
+
* @group Data
|
|
40
|
+
*/
|
|
41
|
+
export interface FindResponse<M extends Record<string, any> = any> {
|
|
42
|
+
/** Array of entities matching the query */
|
|
43
|
+
data: Entity<M>[];
|
|
44
|
+
/** Pagination metadata */
|
|
45
|
+
meta: {
|
|
46
|
+
total: number;
|
|
47
|
+
limit: number;
|
|
48
|
+
offset: number;
|
|
49
|
+
hasMore: boolean;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A single collection's CRUD accessor.
|
|
54
|
+
*
|
|
55
|
+
* This is the unified API surface used in both:
|
|
56
|
+
* - The generated SDK (`client.data.products.create(...)`)
|
|
57
|
+
* - Framework callbacks (`context.data.products.create(...)`)
|
|
58
|
+
*
|
|
59
|
+
* @group Data
|
|
60
|
+
*/
|
|
61
|
+
export interface CollectionAccessor<M extends Record<string, any> = any> {
|
|
62
|
+
/**
|
|
63
|
+
* Find multiple records with optional filtering, pagination, and sorting.
|
|
64
|
+
*/
|
|
65
|
+
find(params?: FindParams): Promise<FindResponse<M>>;
|
|
66
|
+
/**
|
|
67
|
+
* Find a single record by its ID.
|
|
68
|
+
*/
|
|
69
|
+
findById(id: string | number): Promise<Entity<M> | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a new record.
|
|
72
|
+
* @param data The entity data to create.
|
|
73
|
+
* @param id Optional specific ID to use for the new record.
|
|
74
|
+
* @returns The created entity
|
|
75
|
+
*/
|
|
76
|
+
create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
|
|
77
|
+
/**
|
|
78
|
+
* Update an existing record by ID.
|
|
79
|
+
* @returns The updated entity
|
|
80
|
+
*/
|
|
81
|
+
update(id: string | number, data: Partial<EntityValues<M>>): Promise<Entity<M>>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete a record by ID.
|
|
84
|
+
*/
|
|
85
|
+
delete(id: string | number): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Subscribe to a collection for real-time updates.
|
|
88
|
+
* Optional method, may not be supported by all implementations (like stateless HTTP clients).
|
|
89
|
+
*/
|
|
90
|
+
listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
|
|
91
|
+
/**
|
|
92
|
+
* Subscribe to a single record for real-time updates.
|
|
93
|
+
* Optional method.
|
|
94
|
+
*/
|
|
95
|
+
listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void): () => void;
|
|
96
|
+
/**
|
|
97
|
+
* Count the number of records matching the given filter.
|
|
98
|
+
*/
|
|
99
|
+
count?(params?: FindParams): Promise<number>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The unified data access object.
|
|
103
|
+
*
|
|
104
|
+
* Access collections as dynamic properties: `data.products.find(...)`.
|
|
105
|
+
* In the SDK this is backed by HTTP transport (typed, generated per-project).
|
|
106
|
+
* In the framework this is backed by a Proxy + in-process database driver (dynamic).
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* // SDK
|
|
110
|
+
* const client = createRebaseClient({ baseUrl: "..." });
|
|
111
|
+
* await client.data.products.create({ name: "Camera", price: 299 });
|
|
112
|
+
*
|
|
113
|
+
* // Framework callback
|
|
114
|
+
* callbacks: {
|
|
115
|
+
* afterSave({ context }) {
|
|
116
|
+
* await context.data.logs.create({ action: "saved", timestamp: new Date() });
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* @group Data
|
|
121
|
+
*/
|
|
122
|
+
export interface RebaseData {
|
|
123
|
+
/**
|
|
124
|
+
* Get a collection accessor by slug.
|
|
125
|
+
* Alternative to dynamic property access for cases where
|
|
126
|
+
* the collection name is a variable.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* const accessor = data.collection("products");
|
|
130
|
+
* await accessor.find({ limit: 10 });
|
|
131
|
+
*/
|
|
132
|
+
collection(slug: string): CollectionAccessor;
|
|
133
|
+
/**
|
|
134
|
+
* Dynamic collection accessor.
|
|
135
|
+
* Access any collection by its slug as a property.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* data.products.find({ where: { status: "eq.published" } })
|
|
139
|
+
*/
|
|
140
|
+
[collectionSlug: string]: CollectionAccessor | ((slug: string) => CollectionAccessor);
|
|
141
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Entity, EntityCollection, EntityStatus, EntityValues, FilterValues
|
|
1
|
+
import { Entity, EntityCollection, EntityStatus, EntityValues, FilterValues } from "../types";
|
|
2
2
|
import { RebaseContext } from "../rebase_context";
|
|
3
|
+
import { TableMetadata } from "../types/websockets";
|
|
3
4
|
/**
|
|
4
|
-
* @
|
|
5
|
+
* @internal
|
|
5
6
|
*/
|
|
6
7
|
export interface FetchEntityProps<M extends Record<string, any> = any> {
|
|
7
8
|
path: string;
|
|
@@ -10,14 +11,14 @@ export interface FetchEntityProps<M extends Record<string, any> = any> {
|
|
|
10
11
|
collection?: EntityCollection<M, any>;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
|
-
* @
|
|
14
|
+
* @internal
|
|
14
15
|
*/
|
|
15
16
|
export type ListenEntityProps<M extends Record<string, any> = any> = FetchEntityProps<M> & {
|
|
16
17
|
onUpdate: (entity: Entity<M> | null) => void;
|
|
17
18
|
onError?: (error: Error) => void;
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
|
-
* @
|
|
21
|
+
* @internal
|
|
21
22
|
*/
|
|
22
23
|
export interface FetchCollectionProps<M extends Record<string, any> = any> {
|
|
23
24
|
path: string;
|
|
@@ -30,14 +31,14 @@ export interface FetchCollectionProps<M extends Record<string, any> = any> {
|
|
|
30
31
|
order?: "desc" | "asc";
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
|
-
* @
|
|
34
|
+
* @internal
|
|
34
35
|
*/
|
|
35
36
|
export type ListenCollectionProps<M extends Record<string, any> = any> = FetchCollectionProps<M> & {
|
|
36
37
|
onUpdate: (entities: Entity<M>[]) => void;
|
|
37
38
|
onError?: (error: Error) => void;
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
|
-
* @
|
|
41
|
+
* @internal
|
|
41
42
|
*/
|
|
42
43
|
export interface SaveEntityProps<M extends Record<string, any> = any> {
|
|
43
44
|
path: string;
|
|
@@ -48,7 +49,7 @@ export interface SaveEntityProps<M extends Record<string, any> = any> {
|
|
|
48
49
|
status: EntityStatus;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
|
-
* @
|
|
52
|
+
* @internal
|
|
52
53
|
*/
|
|
53
54
|
export interface DeleteEntityProps<M extends Record<string, any> = any> {
|
|
54
55
|
entity: Entity<M>;
|
|
@@ -62,23 +63,23 @@ export type FilterCombinationValidProps = {
|
|
|
62
63
|
sortBy?: [string, "asc" | "desc"];
|
|
63
64
|
};
|
|
64
65
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
66
|
+
* Internal driver interface for communicating with the data layer.
|
|
67
|
+
* This is NOT the public API — use `RebaseData` / `context.data` instead.
|
|
68
|
+
* @internal
|
|
67
69
|
*/
|
|
68
|
-
export interface
|
|
70
|
+
export interface DataDriver {
|
|
69
71
|
/**
|
|
70
|
-
* Key that identifies this
|
|
72
|
+
* Key that identifies this driver
|
|
71
73
|
*/
|
|
72
74
|
key?: string;
|
|
73
75
|
/**
|
|
74
|
-
* If the
|
|
76
|
+
* If the driver has been initialised
|
|
75
77
|
*/
|
|
76
78
|
initialised?: boolean;
|
|
77
79
|
/**
|
|
78
80
|
* Fetch data from a collection
|
|
79
81
|
* @param props
|
|
80
82
|
* @return Promise of entities
|
|
81
|
-
* @see useCollectionFetch if you need this functionality implemented as a hook
|
|
82
83
|
*/
|
|
83
84
|
fetchCollection<M extends Record<string, any> = any>(props: FetchCollectionProps<M>): Promise<Entity<M>[]>;
|
|
84
85
|
/**
|
|
@@ -86,7 +87,6 @@ export interface DataSource {
|
|
|
86
87
|
* `fetchCollection` will be used instead, with no real time updates.
|
|
87
88
|
* @param props
|
|
88
89
|
* @return Function to cancel subscription
|
|
89
|
-
* @see useCollectionFetch if you need this functionality implemented as a hook
|
|
90
90
|
*/
|
|
91
91
|
listenCollection?<M extends Record<string, any> = any>(props: ListenCollectionProps<M>): () => void;
|
|
92
92
|
/**
|
|
@@ -133,7 +133,7 @@ export interface DataSource {
|
|
|
133
133
|
databaseId?: string;
|
|
134
134
|
}): boolean;
|
|
135
135
|
/**
|
|
136
|
-
* Get the object to generate the current time in the
|
|
136
|
+
* Get the object to generate the current time in the driver
|
|
137
137
|
*/
|
|
138
138
|
currentTime?: () => unknown;
|
|
139
139
|
delegateToCMSModel?: (data: unknown) => unknown;
|
|
@@ -146,34 +146,23 @@ export interface DataSource {
|
|
|
146
146
|
parentCollectionIds?: string[];
|
|
147
147
|
}) => Promise<boolean>;
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
149
|
+
* Flag to indicate if the driver has requested the initialization of the text search index
|
|
150
150
|
*/
|
|
151
|
+
needsInitTextSearch?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Return the admin capabilities of this driver.
|
|
154
|
+
* @see SQLAdmin
|
|
155
|
+
* @see DocumentAdmin
|
|
156
|
+
* @see SchemaAdmin
|
|
157
|
+
*/
|
|
158
|
+
admin?: import("../types/backend").DatabaseAdmin;
|
|
151
159
|
executeSql?(sql: string, options?: {
|
|
152
160
|
database?: string;
|
|
153
161
|
role?: string;
|
|
154
162
|
}): Promise<Record<string, unknown>[]>;
|
|
155
|
-
/**
|
|
156
|
-
* Fetch the available databases (if supported by the datasource)
|
|
157
|
-
*/
|
|
158
163
|
fetchAvailableDatabases?(): Promise<string[]>;
|
|
159
|
-
/**
|
|
160
|
-
* Fetch the available roles (if supported by the datasource)
|
|
161
|
-
*/
|
|
162
164
|
fetchAvailableRoles?(): Promise<string[]>;
|
|
163
|
-
/**
|
|
164
|
-
* Fetch the current database name (if supported by the datasource)
|
|
165
|
-
*/
|
|
166
165
|
fetchCurrentDatabase?(): Promise<string | undefined>;
|
|
167
|
-
/**
|
|
168
|
-
* Fetch database tables not yet mapped to a collection (if supported)
|
|
169
|
-
*/
|
|
170
166
|
fetchUnmappedTables?(mappedPaths?: string[]): Promise<string[]>;
|
|
171
|
-
|
|
172
|
-
* Fetch column metadata for a given table (if supported)
|
|
173
|
-
*/
|
|
174
|
-
fetchTableColumns?(tableName: string): Promise<TableColumnInfo[]>;
|
|
175
|
-
/**
|
|
176
|
-
* Flag to indicate if the datasource delegate has requested the initialization of the text search index
|
|
177
|
-
*/
|
|
178
|
-
needsInitTextSearch?: boolean;
|
|
167
|
+
fetchTableMetadata?(tableName: string): Promise<TableMetadata>;
|
|
179
168
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module database_admin
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the capability-specific admin interfaces from `@rebasepro/types/backend`.
|
|
5
|
+
* This file is kept for backwards compatibility — new code should import from
|
|
6
|
+
* `@rebasepro/types` directly.
|
|
7
|
+
*
|
|
8
|
+
* @group Admin
|
|
9
|
+
*/
|
|
10
|
+
export type { SQLAdmin, DocumentAdmin, SchemaAdmin, DatabaseAdmin, HealthCheckResult, } from "../types/backend";
|
|
11
|
+
export { isSQLAdmin, isDocumentAdmin, isSchemaAdmin, } from "../types/backend";
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
export * from "./collection_registry";
|
|
1
2
|
export * from "./analytics_controller";
|
|
2
3
|
export * from "./auth";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
4
|
+
export * from "./data";
|
|
5
|
+
export * from "./database_admin";
|
|
6
|
+
export * from "./data_driver";
|
|
6
7
|
export * from "./local_config_persistence";
|
|
7
8
|
export * from "./navigation";
|
|
8
|
-
export * from "./
|
|
9
|
+
export * from "./effective_role";
|
|
10
|
+
export * from "./storage";
|
|
11
|
+
export * from "./client";
|
|
12
|
+
export * from "./customization_controller";
|
|
9
13
|
export * from "./side_entity_controller";
|
|
14
|
+
export * from "./side_dialogs_controller";
|
|
15
|
+
export * from "./dialogs_controller";
|
|
10
16
|
export * from "./snackbar";
|
|
11
|
-
export * from "./
|
|
17
|
+
export * from "./registry";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { EntityCollection
|
|
2
|
+
import { EntityCollection } from "../types/collections";
|
|
3
|
+
import { RebasePlugin } from "../types/plugins";
|
|
3
4
|
/**
|
|
4
5
|
* Controller that handles URL path building and resolution.
|
|
5
6
|
* @group Models
|
|
6
7
|
*/
|
|
7
|
-
export type
|
|
8
|
+
export type UrlController = {
|
|
8
9
|
/**
|
|
9
10
|
* Default path under the navigation routes of the CMS will be created.
|
|
10
11
|
* Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
|
|
@@ -43,7 +44,7 @@ export type CMSUrlController = {
|
|
|
43
44
|
* Build a URL path for the CMS (e.g. for custom views)
|
|
44
45
|
* @param path
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
buildAppUrlPath: (path: string) => string;
|
|
47
48
|
/**
|
|
48
49
|
* Turn a path with collection ids into a resolved path.
|
|
49
50
|
* The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
|
|
@@ -68,12 +69,12 @@ export type NavigationStateController = {
|
|
|
68
69
|
* Custom additional views created by the developer, added to the main
|
|
69
70
|
* navigation
|
|
70
71
|
*/
|
|
71
|
-
views?:
|
|
72
|
+
views?: AppView[];
|
|
72
73
|
/**
|
|
73
74
|
* Custom additional views created by the developer, added to the admin
|
|
74
75
|
* navigation
|
|
75
76
|
*/
|
|
76
|
-
adminViews?:
|
|
77
|
+
adminViews?: AppView[];
|
|
77
78
|
/**
|
|
78
79
|
* Configuration for the views that should be displayed at the top
|
|
79
80
|
* level of the navigation (e.g. in the home page or the navigation
|
|
@@ -96,58 +97,8 @@ export type NavigationStateController = {
|
|
|
96
97
|
/**
|
|
97
98
|
* Plugin system allowing to extend the CMS functionality.
|
|
98
99
|
*/
|
|
99
|
-
plugins?: RebasePlugin
|
|
100
|
+
plugins?: RebasePlugin[];
|
|
100
101
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Controller that provides access to the registered entity collections.
|
|
103
|
-
* @group Models
|
|
104
|
-
*/
|
|
105
|
-
export type CollectionRegistryController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
106
|
-
/**
|
|
107
|
-
* List of the mapped collections in the CMS.
|
|
108
|
-
* Each entry relates to a collection in the root database.
|
|
109
|
-
* Each of the navigation entries in this field
|
|
110
|
-
* generates an entry in the main menu.
|
|
111
|
-
*/
|
|
112
|
-
collections?: EntityCollection[];
|
|
113
|
-
/**
|
|
114
|
-
* Is the registry ready to be used
|
|
115
|
-
*/
|
|
116
|
-
initialised: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Get the collection configuration for a given path.
|
|
119
|
-
* The collection is resolved from the given path or alias.
|
|
120
|
-
*/
|
|
121
|
-
getCollection: (slugOrPath: string, includeUserOverride?: boolean) => EC | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* Get the raw, un-normalized collection configuration.
|
|
124
|
-
* This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
|
|
125
|
-
* This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
|
|
126
|
-
*/
|
|
127
|
-
getRawCollection: (slugOrPath: string) => EC | undefined;
|
|
128
|
-
/**
|
|
129
|
-
* Retrieve all the related parent references for a given path
|
|
130
|
-
* @param path
|
|
131
|
-
*/
|
|
132
|
-
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
133
|
-
/**
|
|
134
|
-
* Retrieve all the related parent collection ids for a given path
|
|
135
|
-
* @param path
|
|
136
|
-
*/
|
|
137
|
-
getParentCollectionIds: (path: string) => string[];
|
|
138
|
-
/**
|
|
139
|
-
* Resolve paths from a list of ids
|
|
140
|
-
* @param ids
|
|
141
|
-
*/
|
|
142
|
-
convertIdsToPaths: (ids: string[]) => string[];
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Legacy monolithic controller that includes the resolved navigation and utility methods and attributes.
|
|
146
|
-
* It is a combination of CMSUrlController, NavigationStateController, and CollectionRegistryController.
|
|
147
|
-
* @group Models
|
|
148
|
-
* @deprecated Use the specific controllers instead.
|
|
149
|
-
*/
|
|
150
|
-
export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = CMSUrlController & NavigationStateController & CollectionRegistryController<EC>;
|
|
151
102
|
export interface NavigateOptions {
|
|
152
103
|
replace?: boolean;
|
|
153
104
|
state?: unknown;
|
|
@@ -167,7 +118,7 @@ export type NavigationBlocker = {
|
|
|
167
118
|
* navigation.
|
|
168
119
|
* @group Models
|
|
169
120
|
*/
|
|
170
|
-
export interface
|
|
121
|
+
export interface AppView {
|
|
171
122
|
/**
|
|
172
123
|
* CMS Path you can reach this view from.
|
|
173
124
|
*/
|
|
@@ -250,7 +201,7 @@ export interface NavigationEntry {
|
|
|
250
201
|
slug: string;
|
|
251
202
|
type: "collection" | "view" | "admin";
|
|
252
203
|
collection?: EntityCollection;
|
|
253
|
-
view?:
|
|
204
|
+
view?: AppView;
|
|
254
205
|
description?: string;
|
|
255
206
|
group: string;
|
|
256
207
|
}
|