@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
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import { Role, User } from "../users";
|
|
2
|
+
/**
|
|
3
|
+
* Result of creating a new user via admin flow.
|
|
4
|
+
* Contains the created user plus information about how credentials were delivered.
|
|
5
|
+
*/
|
|
6
|
+
export interface UserCreationResult<USER extends User = User> {
|
|
7
|
+
/** The created user */
|
|
8
|
+
user: USER;
|
|
9
|
+
/** Whether an invitation email was sent to the user */
|
|
10
|
+
invitationSent: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Temporary password (only present when email service is not configured).
|
|
13
|
+
* This is returned one-time and should be shown to the admin to share manually.
|
|
14
|
+
*/
|
|
15
|
+
temporaryPassword?: string;
|
|
16
|
+
}
|
|
2
17
|
/**
|
|
3
18
|
* Delegate to manage users, roles, and their permissions.
|
|
4
19
|
* This interface allows the CMS to be completely agnostic of the underlying
|
|
@@ -25,11 +40,38 @@ export interface UserManagementDelegate<USER extends User = User> {
|
|
|
25
40
|
* @param uid
|
|
26
41
|
*/
|
|
27
42
|
getUser: (uid: string) => USER | null;
|
|
43
|
+
/**
|
|
44
|
+
* Search users with server-side pagination.
|
|
45
|
+
* When provided, the CMS will use this for the users table
|
|
46
|
+
* instead of loading all users into memory.
|
|
47
|
+
*/
|
|
48
|
+
searchUsers?: (options: {
|
|
49
|
+
search?: string;
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
orderBy?: string;
|
|
53
|
+
orderDir?: "asc" | "desc";
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
users: USER[];
|
|
56
|
+
total: number;
|
|
57
|
+
}>;
|
|
28
58
|
/**
|
|
29
59
|
* Save a user (create or update)
|
|
30
60
|
* @param user
|
|
31
61
|
*/
|
|
32
62
|
saveUser?: (user: USER) => Promise<USER>;
|
|
63
|
+
/**
|
|
64
|
+
* Create a new user with invitation/password generation support.
|
|
65
|
+
* Returns additional info about how the credentials were delivered.
|
|
66
|
+
* Falls back to saveUser if not provided.
|
|
67
|
+
*/
|
|
68
|
+
createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
69
|
+
/**
|
|
70
|
+
* Reset the password for an existing user.
|
|
71
|
+
* Returns a temporary password if no email service is configured,
|
|
72
|
+
* or a flag indicating an email invitation was sent.
|
|
73
|
+
*/
|
|
74
|
+
resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
33
75
|
/**
|
|
34
76
|
* Delete a user
|
|
35
77
|
* @param user
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Entity } from "./entities";
|
|
2
|
+
export interface WebSocketErrorPayload {
|
|
3
|
+
error?: string | {
|
|
4
|
+
message: string;
|
|
5
|
+
code?: string;
|
|
6
|
+
};
|
|
7
|
+
message?: string;
|
|
8
|
+
code?: string;
|
|
9
|
+
}
|
|
2
10
|
export interface WebSocketMessage {
|
|
3
11
|
type: string;
|
|
4
12
|
payload?: unknown;
|
|
@@ -18,6 +26,19 @@ export interface EntityUpdateMessage extends WebSocketMessage {
|
|
|
18
26
|
subscriptionId: string;
|
|
19
27
|
entity: Entity<Record<string, unknown>> | null;
|
|
20
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Lightweight patch message sent to collection subscribers when a single
|
|
31
|
+
* entity is created, updated, or deleted. The client can merge this into
|
|
32
|
+
* its cached collection data for near-instant cross-tab updates without
|
|
33
|
+
* waiting for a full collection refetch.
|
|
34
|
+
*/
|
|
35
|
+
export interface CollectionEntityPatchMessage extends WebSocketMessage {
|
|
36
|
+
type: "collection_entity_patch";
|
|
37
|
+
subscriptionId: string;
|
|
38
|
+
entityId: string;
|
|
39
|
+
/** The updated entity, or null if deleted */
|
|
40
|
+
entity: Entity<Record<string, unknown>> | null;
|
|
41
|
+
}
|
|
21
42
|
/**
|
|
22
43
|
* Column metadata returned by table introspection.
|
|
23
44
|
*/
|
|
@@ -31,3 +52,27 @@ export interface TableColumnInfo {
|
|
|
31
52
|
/** Enum values, populated for USER-DEFINED (enum) columns */
|
|
32
53
|
enum_values?: string[];
|
|
33
54
|
}
|
|
55
|
+
export interface TableForeignKeyInfo {
|
|
56
|
+
column_name: string;
|
|
57
|
+
foreign_table_name: string;
|
|
58
|
+
foreign_column_name: string;
|
|
59
|
+
}
|
|
60
|
+
export interface TableJunctionInfo {
|
|
61
|
+
junction_table_name: string;
|
|
62
|
+
source_column_name: string;
|
|
63
|
+
target_table_name: string;
|
|
64
|
+
target_column_name: string;
|
|
65
|
+
}
|
|
66
|
+
export interface TablePolicyInfo {
|
|
67
|
+
policy_name: string;
|
|
68
|
+
roles: string[];
|
|
69
|
+
cmd: string;
|
|
70
|
+
qual?: string;
|
|
71
|
+
with_check?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface TableMetadata {
|
|
74
|
+
columns: TableColumnInfo[];
|
|
75
|
+
foreignKeys: TableForeignKeyInfo[];
|
|
76
|
+
junctions: TableJunctionInfo[];
|
|
77
|
+
policies: TablePolicyInfo[];
|
|
78
|
+
}
|
package/dist/users/user.d.ts
CHANGED
|
@@ -38,5 +38,9 @@ export type User = {
|
|
|
38
38
|
* These are plain string IDs — use the UserManagementDelegate to look up full Role objects.
|
|
39
39
|
*/
|
|
40
40
|
roles?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* The date and time when the user was created.
|
|
43
|
+
*/
|
|
44
|
+
createdAt?: Date | string | null;
|
|
41
45
|
getIdToken?: (forceRefresh?: boolean) => Promise<string>;
|
|
42
46
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/types",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.1-canary.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.0.1-canary.4d4fb3e",
|
|
5
|
+
"description": "Rebase type definitions — shared interfaces and controller types",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
8
8
|
},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/rebasepro/rebase.git",
|
|
14
14
|
"directory": "packages/types"
|
|
15
15
|
},
|
|
16
16
|
"main": "./dist/index.umd.js",
|
|
@@ -34,50 +34,20 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"watch": "vite build --watch",
|
|
36
36
|
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
37
|
-
"prepublishOnly": "run
|
|
37
|
+
"prepublishOnly": "pnpm run build",
|
|
38
38
|
"test:lint": "eslint \"src/**\" --quiet",
|
|
39
39
|
"test": "jest --passWithNoTests",
|
|
40
40
|
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
|
|
41
41
|
},
|
|
42
42
|
"exports": {
|
|
43
43
|
".": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
44
45
|
"development": "./src/index.ts",
|
|
45
46
|
"import": "./dist/index.es.js",
|
|
46
|
-
"require": "./dist/index.umd.js"
|
|
47
|
-
"types": "./dist/index.d.ts"
|
|
47
|
+
"require": "./dist/index.umd.js"
|
|
48
48
|
},
|
|
49
49
|
"./package.json": "./package.json"
|
|
50
50
|
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@dnd-kit/core": "^6.3.1",
|
|
53
|
-
"@dnd-kit/modifiers": "^9.0.0",
|
|
54
|
-
"@dnd-kit/sortable": "^10.0.0",
|
|
55
|
-
"@radix-ui/react-portal": "^1.1.5",
|
|
56
|
-
"@rebasepro/editor": "^0.0.1-canary.2",
|
|
57
|
-
"@rebasepro/formex": "^0.0.1-canary.2",
|
|
58
|
-
"@rebasepro/ui": "^0.0.1-canary.2",
|
|
59
|
-
"clsx": "^2.1.1",
|
|
60
|
-
"date-fns": "^3.6.0",
|
|
61
|
-
"fast-equals": "5.3.0",
|
|
62
|
-
"fuse.js": "^7.1.0",
|
|
63
|
-
"history": "^5.3.0",
|
|
64
|
-
"markdown-it": "^14.1.0",
|
|
65
|
-
"notistack": "^3.0.2",
|
|
66
|
-
"object-hash": "^3.0.0",
|
|
67
|
-
"prism-react-renderer": "^2.4.1",
|
|
68
|
-
"react-dropzone": "^14.3.8",
|
|
69
|
-
"react-image-file-resizer": "^0.4.8",
|
|
70
|
-
"react-transition-group": "^4.4.5",
|
|
71
|
-
"react-use-measure": "^2.1.7",
|
|
72
|
-
"react-window": "^1.8.11",
|
|
73
|
-
"yup": "^0.32.11"
|
|
74
|
-
},
|
|
75
|
-
"peerDependencies": {
|
|
76
|
-
"react": ">=19.0.0",
|
|
77
|
-
"react-dom": ">=19.0.0",
|
|
78
|
-
"react-router": "^6.28.0",
|
|
79
|
-
"react-router-dom": "^6.28.0"
|
|
80
|
-
},
|
|
81
51
|
"devDependencies": {
|
|
82
52
|
"@jest/globals": "^29.7.0",
|
|
83
53
|
"@testing-library/react": "^16.3.0",
|
|
@@ -94,8 +64,6 @@
|
|
|
94
64
|
"eslint-plugin-react-compiler": "beta",
|
|
95
65
|
"jest": "^29.7.0",
|
|
96
66
|
"npm-run-all": "^4.1.5",
|
|
97
|
-
"react-router": "^7.13.1",
|
|
98
|
-
"react-router-dom": "^7.13.1",
|
|
99
67
|
"ts-jest": "^29.3.1",
|
|
100
68
|
"ts-node": "^10.9.2",
|
|
101
69
|
"tsd": "^0.31.2",
|
|
@@ -106,7 +74,7 @@
|
|
|
106
74
|
"dist",
|
|
107
75
|
"src"
|
|
108
76
|
],
|
|
109
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "71bcef3c51a458cd054f7924cc18efbbe515dcc8",
|
|
110
78
|
"publishConfig": {
|
|
111
79
|
"access": "public"
|
|
112
80
|
},
|
|
@@ -3,11 +3,11 @@ export type AnalyticsController = {
|
|
|
3
3
|
/**
|
|
4
4
|
* Callback used to get analytics events from the CMS
|
|
5
5
|
*/
|
|
6
|
-
onAnalyticsEvent?: (event:
|
|
6
|
+
onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
|
|
7
7
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export type
|
|
10
|
+
export type AnalyticsEvent =
|
|
11
11
|
| "entity_click"
|
|
12
12
|
| "entity_click_from_reference"
|
|
13
13
|
|
package/src/controllers/auth.tsx
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Capabilities advertised by an auth provider.
|
|
7
|
+
* UI components use this to show/hide features dynamically
|
|
8
|
+
* (e.g. password reset, registration, session management).
|
|
9
|
+
* @group Hooks and utilities
|
|
10
|
+
*/
|
|
11
|
+
export interface AuthCapabilities {
|
|
12
|
+
emailPasswordLogin?: boolean;
|
|
13
|
+
googleLogin?: boolean;
|
|
14
|
+
registration?: boolean;
|
|
15
|
+
passwordReset?: boolean;
|
|
16
|
+
sessionManagement?: boolean;
|
|
17
|
+
profileUpdate?: boolean;
|
|
18
|
+
emailVerification?: boolean;
|
|
19
|
+
}
|
|
4
20
|
|
|
5
21
|
/**
|
|
6
22
|
* Controller for retrieving the logged user or performing auth related operations.
|
|
@@ -8,7 +24,7 @@ import { Role, User } from "../users";
|
|
|
8
24
|
* to do it as the result of a hook.
|
|
9
25
|
* @group Hooks and utilities
|
|
10
26
|
*/
|
|
11
|
-
export type AuthController<USER extends User =
|
|
27
|
+
export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
12
28
|
|
|
13
29
|
/**
|
|
14
30
|
* The user currently logged in
|
|
@@ -59,12 +75,43 @@ export type AuthController<USER extends User = any, ExtraData = unknown> = {
|
|
|
59
75
|
setExtra: (extra: ExtraData) => void;
|
|
60
76
|
|
|
61
77
|
|
|
62
|
-
setUser
|
|
78
|
+
setUser?(user: USER | null): void;
|
|
63
79
|
|
|
64
|
-
setUserRoles
|
|
80
|
+
setUserRoles?(roles: Role[]): void;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Capabilities advertised by the auth provider.
|
|
84
|
+
* UI components use this to feature-detect what the backend supports.
|
|
85
|
+
*/
|
|
86
|
+
capabilities?: AuthCapabilities;
|
|
65
87
|
|
|
66
88
|
};
|
|
67
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Extended auth controller with common optional auth methods.
|
|
92
|
+
* Backend implementations (Rebase backend, Firebase, Supabase, etc.)
|
|
93
|
+
* extend this with their own backend-specific extras.
|
|
94
|
+
* @group Hooks and utilities
|
|
95
|
+
*/
|
|
96
|
+
export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
|
|
97
|
+
/** Login with email and password */
|
|
98
|
+
emailPasswordLogin?(email: string, password: string): Promise<void>;
|
|
99
|
+
/** Login with a Google ID token or trigger Google popup */
|
|
100
|
+
googleLogin?(idToken: string): Promise<void>;
|
|
101
|
+
/** Register a new user */
|
|
102
|
+
register?(email: string, password: string, displayName?: string): Promise<void>;
|
|
103
|
+
/** Skip login (for anonymous access if enabled) */
|
|
104
|
+
skipLogin?(): void;
|
|
105
|
+
/** Request password reset email */
|
|
106
|
+
forgotPassword?(email: string): Promise<void>;
|
|
107
|
+
/** Reset password using a token */
|
|
108
|
+
resetPassword?(token: string, password: string): Promise<void>;
|
|
109
|
+
/** Change password for the authenticated user */
|
|
110
|
+
changePassword?(oldPassword: string, newPassword: string): Promise<void>;
|
|
111
|
+
/** Update user profile */
|
|
112
|
+
updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
|
|
113
|
+
}
|
|
114
|
+
|
|
68
115
|
/**
|
|
69
116
|
* Implement this function to allow access to specific users.
|
|
70
117
|
* @group Hooks and utilities
|
|
@@ -82,9 +129,9 @@ export type Authenticator<USER extends User = User> = (props: {
|
|
|
82
129
|
authController: AuthController<USER>;
|
|
83
130
|
|
|
84
131
|
/**
|
|
85
|
-
*
|
|
132
|
+
* Unified data access API
|
|
86
133
|
*/
|
|
87
|
-
|
|
134
|
+
data: RebaseData;
|
|
88
135
|
|
|
89
136
|
/**
|
|
90
137
|
* Used storage implementation
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { User } from "../users";
|
|
2
|
+
import { RebaseData } from "./data";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Event type for authentication state changes
|
|
6
|
+
*/
|
|
7
|
+
export type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Standard session interface representing an authenticated state
|
|
11
|
+
*/
|
|
12
|
+
export interface RebaseSession {
|
|
13
|
+
accessToken: string;
|
|
14
|
+
refreshToken: string;
|
|
15
|
+
expiresAt: number;
|
|
16
|
+
user: User;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
import { StorageSource } from "./storage";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Unified Authentication Client Interface
|
|
23
|
+
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
24
|
+
*/
|
|
25
|
+
export interface AuthClient {
|
|
26
|
+
/**
|
|
27
|
+
* Get the current user from the server or cache
|
|
28
|
+
*/
|
|
29
|
+
getUser(): Promise<User | null>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the currently active session
|
|
33
|
+
*/
|
|
34
|
+
getSession(): RebaseSession | null;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sign out the current user and clear local session
|
|
38
|
+
*/
|
|
39
|
+
signOut(): Promise<void>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Subscribe to authentication state changes
|
|
43
|
+
*/
|
|
44
|
+
onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Manually refresh the session token
|
|
48
|
+
*/
|
|
49
|
+
refreshSession(): Promise<RebaseSession>;
|
|
50
|
+
|
|
51
|
+
// Extensible for backend implementations
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Overarching abstraction that unites Data, Auth, and Storage.
|
|
57
|
+
* Adapters for Supabase or Firebase simply need to implement this interface.
|
|
58
|
+
*/
|
|
59
|
+
export interface RebaseClient<DB = any> {
|
|
60
|
+
/** Unified Data access layer */
|
|
61
|
+
data: RebaseData;
|
|
62
|
+
|
|
63
|
+
/** Unified Authentication layer */
|
|
64
|
+
auth: AuthClient;
|
|
65
|
+
|
|
66
|
+
/** Unified Storage layer */
|
|
67
|
+
storage?: StorageSource;
|
|
68
|
+
|
|
69
|
+
/** Optional admin panel specific tasks */
|
|
70
|
+
admin?: any;
|
|
71
|
+
|
|
72
|
+
// Generic extensibility
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EntityCollection, EntityReference } from "../types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Controller that provides access to the registered entity collections.
|
|
5
|
+
* @group Models
|
|
6
|
+
*/
|
|
7
|
+
export type CollectionRegistryController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* List of the mapped collections in the CMS.
|
|
11
|
+
* Each entry relates to a collection in the root database.
|
|
12
|
+
* Each of the navigation entries in this field
|
|
13
|
+
* generates an entry in the main menu.
|
|
14
|
+
*/
|
|
15
|
+
collections?: EntityCollection[];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Is the registry ready to be used
|
|
19
|
+
*/
|
|
20
|
+
initialised: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get the collection configuration for a given path.
|
|
24
|
+
* The collection is resolved from the given path or alias.
|
|
25
|
+
*/
|
|
26
|
+
getCollection: (slugOrPath: string, includeUserOverride?: boolean) => EC | undefined;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get the raw, un-normalized collection configuration.
|
|
30
|
+
* This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
|
|
31
|
+
* This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
|
|
32
|
+
*/
|
|
33
|
+
getRawCollection: (slugOrPath: string) => EC | undefined;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Retrieve all the related parent references for a given path
|
|
37
|
+
* @param path
|
|
38
|
+
*/
|
|
39
|
+
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve all the related parent collection ids for a given path
|
|
43
|
+
* @param path
|
|
44
|
+
*/
|
|
45
|
+
getParentCollectionIds: (path: string) => string[];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Resolve paths from a list of ids
|
|
49
|
+
* @param ids
|
|
50
|
+
*/
|
|
51
|
+
convertIdsToPaths: (ids: string[]) => string[];
|
|
52
|
+
|
|
53
|
+
};
|
|
@@ -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
|
|
|
4
4
|
export type CustomizationController = {
|
|
5
5
|
|
|
@@ -13,6 +13,11 @@ export type CustomizationController = {
|
|
|
13
13
|
*/
|
|
14
14
|
plugins?: RebasePlugin[];
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Pre-merged slots from plugins + direct slot contributions.
|
|
18
|
+
*/
|
|
19
|
+
resolvedSlots: SlotContribution[];
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* List of additional custom views for entities.
|
|
18
23
|
* You can use the key to reference the custom view in
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Entity, EntityValues } from "../types/entities";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for querying a collection.
|
|
5
|
+
* Uses PostgREST-style filter syntax for consistency between
|
|
6
|
+
* the SDK (HTTP) and framework (in-process) contexts.
|
|
7
|
+
*
|
|
8
|
+
* @group Data
|
|
9
|
+
*/
|
|
10
|
+
export interface FindParams {
|
|
11
|
+
/** Maximum number of items to return (default: 20) */
|
|
12
|
+
limit?: number;
|
|
13
|
+
/** Number of items to skip */
|
|
14
|
+
offset?: number;
|
|
15
|
+
/** Page number (1-indexed), alternative to offset */
|
|
16
|
+
page?: number;
|
|
17
|
+
/**
|
|
18
|
+
* PostgREST-style filter object.
|
|
19
|
+
* Keys are field names, values use "operator.value" format.
|
|
20
|
+
* Operators: eq, neq, gt, gte, lt, lte, in, nin, cs (array-contains), csa (array-contains-any)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* { status: "eq.published" }
|
|
24
|
+
* { age: "gte.18" }
|
|
25
|
+
* { role: "in.(admin,editor)" }
|
|
26
|
+
*/
|
|
27
|
+
where?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Sort order. Format: "field:direction".
|
|
30
|
+
* @example "created_at:desc", "name:asc"
|
|
31
|
+
*/
|
|
32
|
+
orderBy?: string;
|
|
33
|
+
/** Relations to include in the response */
|
|
34
|
+
include?: string[];
|
|
35
|
+
/** Full-text search string */
|
|
36
|
+
searchString?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Paginated response from a collection query.
|
|
41
|
+
* @group Data
|
|
42
|
+
*/
|
|
43
|
+
export interface FindResponse<M extends Record<string, any> = any> {
|
|
44
|
+
/** Array of entities matching the query */
|
|
45
|
+
data: Entity<M>[];
|
|
46
|
+
/** Pagination metadata */
|
|
47
|
+
meta: {
|
|
48
|
+
total: number;
|
|
49
|
+
limit: number;
|
|
50
|
+
offset: number;
|
|
51
|
+
hasMore: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A single collection's CRUD accessor.
|
|
57
|
+
*
|
|
58
|
+
* This is the unified API surface used in both:
|
|
59
|
+
* - The generated SDK (`client.data.products.create(...)`)
|
|
60
|
+
* - Framework callbacks (`context.data.products.create(...)`)
|
|
61
|
+
*
|
|
62
|
+
* @group Data
|
|
63
|
+
*/
|
|
64
|
+
export interface CollectionAccessor<M extends Record<string, any> = any> {
|
|
65
|
+
/**
|
|
66
|
+
* Find multiple records with optional filtering, pagination, and sorting.
|
|
67
|
+
*/
|
|
68
|
+
find(params?: FindParams): Promise<FindResponse<M>>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Find a single record by its ID.
|
|
72
|
+
*/
|
|
73
|
+
findById(id: string | number): Promise<Entity<M> | undefined>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Create a new record.
|
|
77
|
+
* @param data The entity data to create.
|
|
78
|
+
* @param id Optional specific ID to use for the new record.
|
|
79
|
+
* @returns The created entity
|
|
80
|
+
*/
|
|
81
|
+
create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Update an existing record by ID.
|
|
85
|
+
* @returns The updated entity
|
|
86
|
+
*/
|
|
87
|
+
update(id: string | number, data: Partial<EntityValues<M>>): Promise<Entity<M>>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Delete a record by ID.
|
|
91
|
+
*/
|
|
92
|
+
delete(id: string | number): Promise<void>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Subscribe to a collection for real-time updates.
|
|
96
|
+
* Optional method, may not be supported by all implementations (like stateless HTTP clients).
|
|
97
|
+
*/
|
|
98
|
+
listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Subscribe to a single record for real-time updates.
|
|
102
|
+
* Optional method.
|
|
103
|
+
*/
|
|
104
|
+
listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void): () => void;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Count the number of records matching the given filter.
|
|
108
|
+
*/
|
|
109
|
+
count?(params?: FindParams): Promise<number>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The unified data access object.
|
|
114
|
+
*
|
|
115
|
+
* Access collections as dynamic properties: `data.products.find(...)`.
|
|
116
|
+
* In the SDK this is backed by HTTP transport (typed, generated per-project).
|
|
117
|
+
* In the framework this is backed by a Proxy + in-process database driver (dynamic).
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* // SDK
|
|
121
|
+
* const client = createRebaseClient({ baseUrl: "..." });
|
|
122
|
+
* await client.data.products.create({ name: "Camera", price: 299 });
|
|
123
|
+
*
|
|
124
|
+
* // Framework callback
|
|
125
|
+
* callbacks: {
|
|
126
|
+
* afterSave({ context }) {
|
|
127
|
+
* await context.data.logs.create({ action: "saved", timestamp: new Date() });
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* @group Data
|
|
132
|
+
*/
|
|
133
|
+
export interface RebaseData {
|
|
134
|
+
/**
|
|
135
|
+
* Get a collection accessor by slug.
|
|
136
|
+
* Alternative to dynamic property access for cases where
|
|
137
|
+
* the collection name is a variable.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* const accessor = data.collection("products");
|
|
141
|
+
* await accessor.find({ limit: 10 });
|
|
142
|
+
*/
|
|
143
|
+
collection(slug: string): CollectionAccessor;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Dynamic collection accessor.
|
|
147
|
+
* Access any collection by its slug as a property.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* data.products.find({ where: { status: "eq.published" } })
|
|
151
|
+
*/
|
|
152
|
+
[collectionSlug: string]: CollectionAccessor | ((slug: string) => CollectionAccessor);
|
|
153
|
+
}
|