@rebasepro/types 0.2.3 → 0.2.5
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/controllers/auth.d.ts +4 -26
- package/dist/controllers/client.d.ts +25 -43
- package/dist/controllers/collection_registry.d.ts +1 -1
- package/dist/controllers/data.d.ts +4 -0
- package/dist/controllers/data_driver.d.ts +23 -0
- package/dist/controllers/registry.d.ts +5 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +1 -1
- package/dist/types/auth_adapter.d.ts +5 -60
- package/dist/types/backend.d.ts +2 -2
- package/dist/types/backend_hooks.d.ts +2 -17
- package/dist/types/collections.d.ts +0 -4
- package/dist/types/component_ref.d.ts +1 -1
- package/dist/types/cron.d.ts +1 -1
- package/dist/types/entity_views.d.ts +1 -0
- package/dist/types/export_import.d.ts +1 -1
- package/dist/types/formex.d.ts +2 -2
- package/dist/types/properties.d.ts +9 -7
- package/dist/types/translations.d.ts +28 -12
- package/dist/types/user_management_delegate.d.ts +22 -57
- package/dist/users/index.d.ts +0 -1
- package/dist/users/user.d.ts +0 -1
- package/package.json +1 -1
- package/src/controllers/auth.tsx +4 -32
- package/src/controllers/client.ts +23 -23
- package/src/controllers/collection_registry.ts +1 -1
- package/src/controllers/data.ts +5 -0
- package/src/controllers/data_driver.ts +25 -0
- package/src/controllers/registry.ts +5 -4
- package/src/rebase_context.tsx +1 -1
- package/src/types/auth_adapter.ts +7 -67
- package/src/types/backend.ts +2 -2
- package/src/types/backend_hooks.ts +2 -18
- package/src/types/collections.ts +1 -4
- package/src/types/component_ref.ts +1 -1
- package/src/types/cron.ts +1 -1
- package/src/types/entity_views.tsx +1 -0
- package/src/types/export_import.ts +1 -1
- package/src/types/formex.ts +2 -2
- package/src/types/properties.ts +20 -31
- package/src/types/translations.ts +28 -12
- package/src/types/user_management_delegate.ts +22 -69
- package/src/users/index.ts +1 -1
- package/src/users/user.ts +0 -1
- package/dist/users/roles.d.ts +0 -22
- package/src/users/roles.ts +0 -32
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Role, User } from "../users";
|
|
3
|
-
import { RebaseData } from "./data";
|
|
1
|
+
import type { User } from "../users";
|
|
4
2
|
/**
|
|
5
3
|
* Capabilities advertised by an auth provider.
|
|
6
4
|
* UI components use this to show/hide features dynamically
|
|
@@ -64,7 +62,7 @@ export type AuthController<USER extends User = User, ExtraData = unknown> = {
|
|
|
64
62
|
extra: ExtraData;
|
|
65
63
|
setExtra: (extra: ExtraData) => void;
|
|
66
64
|
setUser?(user: USER | null): void;
|
|
67
|
-
setUserRoles?(roles:
|
|
65
|
+
setUserRoles?(roles: string[]): void;
|
|
68
66
|
/**
|
|
69
67
|
* Capabilities advertised by the auth provider.
|
|
70
68
|
* UI components use this to feature-detect what the backend supports.
|
|
@@ -89,6 +87,8 @@ export interface AuthControllerExtended<USER extends User = User, ExtraData = un
|
|
|
89
87
|
code: string;
|
|
90
88
|
redirectUri: string;
|
|
91
89
|
}) => Promise<void>;
|
|
90
|
+
/** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
|
|
91
|
+
oauthLogin?: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
|
|
92
92
|
/** Register a new user */
|
|
93
93
|
register?(email: string, password: string, displayName?: string): Promise<void>;
|
|
94
94
|
/** Skip login (for anonymous access if enabled) */
|
|
@@ -102,25 +102,3 @@ export interface AuthControllerExtended<USER extends User = User, ExtraData = un
|
|
|
102
102
|
/** Update user profile */
|
|
103
103
|
updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
|
|
104
104
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Implement this function to allow access to specific users.
|
|
107
|
-
* @group Hooks and utilities
|
|
108
|
-
*/
|
|
109
|
-
export type Authenticator<USER extends User = User> = (props: {
|
|
110
|
-
/**
|
|
111
|
-
* Logged-in user or null
|
|
112
|
-
*/
|
|
113
|
-
user: USER | null;
|
|
114
|
-
/**
|
|
115
|
-
* AuthController
|
|
116
|
-
*/
|
|
117
|
-
authController: AuthController<USER>;
|
|
118
|
-
/**
|
|
119
|
-
* Unified data access API
|
|
120
|
-
*/
|
|
121
|
-
data: RebaseData;
|
|
122
|
-
/**
|
|
123
|
-
* Used storage implementation
|
|
124
|
-
*/
|
|
125
|
-
storageSource: StorageSource;
|
|
126
|
-
}) => boolean | Promise<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { User } from "../users";
|
|
2
|
-
import { RebaseData } from "./data";
|
|
3
|
-
import { EmailService } from "./email";
|
|
1
|
+
import type { User } from "../users";
|
|
2
|
+
import type { RebaseData } from "./data";
|
|
3
|
+
import type { EmailService } from "./email";
|
|
4
4
|
/**
|
|
5
5
|
* Event type for authentication state changes
|
|
6
6
|
*/
|
|
@@ -14,7 +14,7 @@ export interface RebaseSession {
|
|
|
14
14
|
expiresAt: number;
|
|
15
15
|
user: User;
|
|
16
16
|
}
|
|
17
|
-
import { StorageSource } from "./storage";
|
|
17
|
+
import type { StorageSource } from "./storage";
|
|
18
18
|
/**
|
|
19
19
|
* Unified Authentication Client Interface
|
|
20
20
|
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
@@ -56,20 +56,9 @@ export interface AdminUser {
|
|
|
56
56
|
createdAt: string;
|
|
57
57
|
updatedAt: string;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Role record as returned by the Admin API.
|
|
61
|
-
* @group Admin
|
|
62
|
-
*/
|
|
63
|
-
export interface AdminRole {
|
|
64
|
-
id: string;
|
|
65
|
-
name: string;
|
|
66
|
-
isAdmin: boolean;
|
|
67
|
-
defaultPermissions: Record<string, unknown> | null;
|
|
68
|
-
config: Record<string, unknown> | null;
|
|
69
|
-
}
|
|
70
59
|
/**
|
|
71
60
|
* Client-side Admin API interface.
|
|
72
|
-
* Provides user
|
|
61
|
+
* Provides user management operations.
|
|
73
62
|
* @group Admin
|
|
74
63
|
*/
|
|
75
64
|
export interface AdminAPI {
|
|
@@ -112,32 +101,6 @@ export interface AdminAPI {
|
|
|
112
101
|
deleteUser(userId: string): Promise<{
|
|
113
102
|
success: boolean;
|
|
114
103
|
}>;
|
|
115
|
-
listRoles(): Promise<{
|
|
116
|
-
roles: AdminRole[];
|
|
117
|
-
}>;
|
|
118
|
-
getRole(roleId: string): Promise<{
|
|
119
|
-
role: AdminRole;
|
|
120
|
-
}>;
|
|
121
|
-
createRole(data: {
|
|
122
|
-
id: string;
|
|
123
|
-
name: string;
|
|
124
|
-
isAdmin?: boolean;
|
|
125
|
-
defaultPermissions?: Record<string, unknown>;
|
|
126
|
-
config?: Record<string, unknown>;
|
|
127
|
-
}): Promise<{
|
|
128
|
-
role: AdminRole;
|
|
129
|
-
}>;
|
|
130
|
-
updateRole(roleId: string, data: {
|
|
131
|
-
name?: string;
|
|
132
|
-
isAdmin?: boolean;
|
|
133
|
-
defaultPermissions?: Record<string, unknown>;
|
|
134
|
-
config?: Record<string, unknown>;
|
|
135
|
-
}): Promise<{
|
|
136
|
-
role: AdminRole;
|
|
137
|
-
}>;
|
|
138
|
-
deleteRole(roleId: string): Promise<{
|
|
139
|
-
success: boolean;
|
|
140
|
-
}>;
|
|
141
104
|
bootstrap(): Promise<{
|
|
142
105
|
success: boolean;
|
|
143
106
|
message: string;
|
|
@@ -168,7 +131,7 @@ export interface RebaseClient<DB = unknown> {
|
|
|
168
131
|
* > The client-side SDK does not include an email service.
|
|
169
132
|
*/
|
|
170
133
|
email?: EmailService;
|
|
171
|
-
/** Admin API for user
|
|
134
|
+
/** Admin API for user management */
|
|
172
135
|
admin?: AdminAPI;
|
|
173
136
|
/**
|
|
174
137
|
* The base HTTP URL of the backend server.
|
|
@@ -183,4 +146,23 @@ export interface RebaseClient<DB = unknown> {
|
|
|
183
146
|
* detection (e.g. `typeof ws.executeSql === "function"`).
|
|
184
147
|
*/
|
|
185
148
|
ws?: unknown;
|
|
149
|
+
/**
|
|
150
|
+
* Execute raw SQL against the database.
|
|
151
|
+
*
|
|
152
|
+
* Only available server-side when the backend uses a SQL database
|
|
153
|
+
* (PostgreSQL, MySQL, etc.). `undefined` for document databases
|
|
154
|
+
* (MongoDB, Firestore) and on the client-side SDK.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // In a cron job or custom function:
|
|
159
|
+
* if (ctx.client.sql) {
|
|
160
|
+
* const rows = await ctx.client.sql("SELECT count(*) FROM orders");
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
sql?(query: string, options?: {
|
|
165
|
+
database?: string;
|
|
166
|
+
role?: string;
|
|
167
|
+
}): Promise<Record<string, unknown>[]>;
|
|
186
168
|
}
|
|
@@ -4,7 +4,7 @@ import type { EntityReference } from "../types/entities";
|
|
|
4
4
|
* Controller that provides access to the registered entity collections.
|
|
5
5
|
* @group Models
|
|
6
6
|
*/
|
|
7
|
-
export type CollectionRegistryController<DB = Record<string, unknown>, EC extends EntityCollection = EntityCollection
|
|
7
|
+
export type CollectionRegistryController<DB = Record<string, unknown>, EC extends EntityCollection = EntityCollection> = {
|
|
8
8
|
/**
|
|
9
9
|
* List of the mapped collections in the CMS.
|
|
10
10
|
* Each entry relates to a collection in the root database.
|
|
@@ -125,6 +125,10 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
125
125
|
* Delete a record by ID.
|
|
126
126
|
*/
|
|
127
127
|
delete(id: string | number): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Delete all records in this collection.
|
|
130
|
+
*/
|
|
131
|
+
deleteAll?(): Promise<void>;
|
|
128
132
|
/**
|
|
129
133
|
* Subscribe to a collection for real-time updates.
|
|
130
134
|
* Optional method, may not be supported by all implementations (like stateless HTTP clients).
|
|
@@ -17,6 +17,21 @@ export type ListenEntityProps<M extends Record<string, unknown> = Record<string,
|
|
|
17
17
|
onUpdate: (entity: Entity<M> | null) => void;
|
|
18
18
|
onError?: (error: Error) => void;
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for vector similarity search queries.
|
|
22
|
+
* Vector search applies an ORDER BY distance expression and optionally
|
|
23
|
+
* filters results by a distance threshold.
|
|
24
|
+
*/
|
|
25
|
+
export interface VectorSearchParams {
|
|
26
|
+
/** Property name containing the vector column */
|
|
27
|
+
property: string;
|
|
28
|
+
/** Query vector to compare against */
|
|
29
|
+
vector: number[];
|
|
30
|
+
/** Distance function (default: "cosine") */
|
|
31
|
+
distance?: "cosine" | "l2" | "inner_product";
|
|
32
|
+
/** Only return results within this distance threshold */
|
|
33
|
+
threshold?: number;
|
|
34
|
+
}
|
|
20
35
|
/**
|
|
21
36
|
* @internal
|
|
22
37
|
*/
|
|
@@ -30,6 +45,8 @@ export interface FetchCollectionProps<M extends Record<string, unknown> = Record
|
|
|
30
45
|
orderBy?: string;
|
|
31
46
|
searchString?: string;
|
|
32
47
|
order?: "desc" | "asc";
|
|
48
|
+
/** Vector similarity search configuration */
|
|
49
|
+
vectorSearch?: VectorSearchParams;
|
|
33
50
|
}
|
|
34
51
|
/**
|
|
35
52
|
* @internal
|
|
@@ -112,6 +129,11 @@ export interface DataDriver {
|
|
|
112
129
|
* @return was the whole deletion flow successful
|
|
113
130
|
*/
|
|
114
131
|
deleteEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: DeleteEntityProps<M>): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Delete all entities from a collection.
|
|
134
|
+
* @param path Collection path
|
|
135
|
+
*/
|
|
136
|
+
deleteAll?(path: string): Promise<void>;
|
|
115
137
|
/**
|
|
116
138
|
* Check if the given property is unique in the given collection
|
|
117
139
|
* @param path Collection path
|
|
@@ -187,6 +209,7 @@ export interface RestFetchService {
|
|
|
187
209
|
startAfter?: Record<string, unknown>;
|
|
188
210
|
searchString?: string;
|
|
189
211
|
databaseId?: string;
|
|
212
|
+
vectorSearch?: VectorSearchParams;
|
|
190
213
|
}, include?: string[]): Promise<Record<string, unknown>[]>;
|
|
191
214
|
/**
|
|
192
215
|
* Fetch a single flattened entity with optional relation includes.
|
|
@@ -4,6 +4,7 @@ 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
6
|
import type { AppView, NavigationGroupMapping } from "./navigation";
|
|
7
|
+
import type { RebasePlugin } from "../types/plugins";
|
|
7
8
|
/**
|
|
8
9
|
* Options to enable the built-in collection editor.
|
|
9
10
|
* When provided to `<RebaseCMS>`, the editor is auto-wired as a native feature.
|
|
@@ -19,12 +20,12 @@ export interface CollectionEditorOptions {
|
|
|
19
20
|
/** Suggested base paths shown when creating new collections. */
|
|
20
21
|
pathSuggestions?: string[];
|
|
21
22
|
}
|
|
22
|
-
export interface RebaseCMSConfig<EC extends EntityCollection =
|
|
23
|
+
export interface RebaseCMSConfig<EC extends EntityCollection = EntityCollection> {
|
|
23
24
|
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
24
25
|
homePage?: ReactNode;
|
|
25
|
-
entityViews?: EntityCustomView
|
|
26
|
+
entityViews?: EntityCustomView[];
|
|
26
27
|
entityActions?: EntityAction[];
|
|
27
|
-
plugins?:
|
|
28
|
+
plugins?: RebasePlugin[];
|
|
28
29
|
/**
|
|
29
30
|
* Centralized configuration for how collections and views are grouped
|
|
30
31
|
* in the navigation sidebar and home page.
|
|
@@ -42,7 +43,7 @@ export interface RebaseCMSConfig<EC extends EntityCollection = any> {
|
|
|
42
43
|
collectionEditor?: boolean | CollectionEditorOptions;
|
|
43
44
|
}
|
|
44
45
|
export interface RebaseStudioConfig {
|
|
45
|
-
tools?: ("sql" | "js" | "rls" | "schema" | "storage" | "cron" | "schema-visualizer" | "branches" | "api")[];
|
|
46
|
+
tools?: ("sql" | "js" | "rls" | "schema" | "storage" | "cron" | "schema-visualizer" | "branches" | "api" | "logs")[];
|
|
46
47
|
homePage?: ReactNode;
|
|
47
48
|
devViews?: AppView[];
|
|
48
49
|
}
|