@rebasepro/types 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/controllers/auth.d.ts +1 -1
- package/dist/controllers/client.d.ts +184 -6
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +267 -35
- package/dist/controllers/data_driver.d.ts +50 -37
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +2 -2
- package/dist/controllers/registry.d.ts +17 -4
- package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
- package/dist/controllers/storage.d.ts +39 -0
- package/dist/errors.d.ts +64 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +142 -15
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +150 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +4 -1
- package/dist/types/backend.d.ts +26 -26
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +62 -63
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +10 -1
- package/dist/types/data_source.d.ts +15 -2
- package/dist/types/database_adapter.d.ts +4 -3
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +39 -39
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +62 -17
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +64 -10
- package/dist/types/properties.d.ts +41 -9
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/websockets.d.ts +12 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +1 -1
- package/src/controllers/auth.tsx +1 -1
- package/src/controllers/client.ts +214 -6
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +290 -39
- package/src/controllers/data_driver.ts +49 -40
- package/src/controllers/index.ts +1 -1
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +2 -2
- package/src/controllers/registry.ts +18 -4
- package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
- package/src/controllers/storage.ts +60 -1
- package/src/errors.ts +80 -0
- package/src/index.ts +1 -0
- package/src/rebase_context.tsx +8 -4
- package/src/types/auth_adapter.ts +4 -1
- package/src/types/backend.ts +36 -36
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +78 -79
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +10 -1
- package/src/types/data_source.ts +24 -2
- package/src/types/database_adapter.ts +4 -3
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +42 -42
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +96 -23
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +64 -8
- package/src/types/properties.ts +44 -9
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/websockets.ts +12 -14
- package/src/users/user.ts +22 -9
package/dist/rebase_context.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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
6
|
import type { RebaseClient } from "./controllers/client";
|
|
7
|
-
import type {
|
|
7
|
+
import type { RebaseSdkData } from "./controllers/data";
|
|
8
8
|
import type { User } from "./users";
|
|
9
9
|
/**
|
|
10
10
|
* Context that is provided to entity callbacks (hooks).
|
|
@@ -31,8 +31,12 @@ export type RebaseCallContext<USER extends User = User> = {
|
|
|
31
31
|
/**
|
|
32
32
|
* Unified data access — `context.data.products.create(...)`.
|
|
33
33
|
* Access any collection as a dynamic property.
|
|
34
|
+
*
|
|
35
|
+
* Returns flat rows (`{ id, ...columns }`), identical to the frontend SDK
|
|
36
|
+
* client — so `context.data` in a backend callback and `client.data` in the
|
|
37
|
+
* frontend behave the same way (`row.title`, never `row.values.title`).
|
|
34
38
|
*/
|
|
35
|
-
data:
|
|
39
|
+
data: RebaseSdkData;
|
|
36
40
|
/**
|
|
37
41
|
* Used storage implementation
|
|
38
42
|
*/
|
|
@@ -64,9 +68,9 @@ export type RebaseContext<USER extends User = User, AuthControllerType extends A
|
|
|
64
68
|
*/
|
|
65
69
|
sideDialogsController?: import("./controllers/side_dialogs_controller").SideDialogsController;
|
|
66
70
|
/**
|
|
67
|
-
* Controller to open the side
|
|
71
|
+
* Controller to open the side panel displaying entity forms
|
|
68
72
|
*/
|
|
69
|
-
|
|
73
|
+
sidePanelController?: import("./controllers/side_panel_controller").SidePanelController;
|
|
70
74
|
/**
|
|
71
75
|
* Controller resolving URLs in the CMS
|
|
72
76
|
*/
|
|
@@ -212,6 +212,9 @@ export interface AuthResponsePayload {
|
|
|
212
212
|
email: string;
|
|
213
213
|
displayName: string | null;
|
|
214
214
|
photoURL: string | null;
|
|
215
|
+
providerId?: string;
|
|
216
|
+
isAnonymous?: boolean;
|
|
217
|
+
emailVerified?: boolean;
|
|
215
218
|
roles: string[];
|
|
216
219
|
metadata: Record<string, unknown>;
|
|
217
220
|
};
|
|
@@ -343,7 +346,7 @@ export interface AuthAdapter {
|
|
|
343
346
|
*
|
|
344
347
|
* @param values - Raw request body from the client.
|
|
345
348
|
* @param collectionAuth - The parsed `AuthCollectionConfig` from the collection (if `auth` is an object).
|
|
346
|
-
* @returns Processed values ready for `driver.
|
|
349
|
+
* @returns Processed values ready for `driver.save()`, plus metadata for the post-save step.
|
|
347
350
|
*/
|
|
348
351
|
prepareUserCreation?(values: Record<string, unknown>, collectionAuth?: unknown): Promise<UserCreationPrepareResult>;
|
|
349
352
|
/**
|
package/dist/types/backend.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { EntityCollection, FilterValues, WhereFilterOp } from "./collections";
|
|
1
|
+
import type { CollectionConfig, FilterValues, WhereFilterOp } from "./collections";
|
|
3
2
|
import type { AuthAdapter } from "./auth_adapter";
|
|
3
|
+
import type { HistoryConfig } from "../controllers/client";
|
|
4
4
|
/**
|
|
5
5
|
* Abstract database connection interface.
|
|
6
6
|
* Represents a connection to any database system.
|
|
@@ -39,7 +39,7 @@ export interface FetchCollectionOptions<M extends Record<string, unknown> = Reco
|
|
|
39
39
|
startAfter?: unknown;
|
|
40
40
|
searchString?: string;
|
|
41
41
|
databaseId?: string;
|
|
42
|
-
collection?:
|
|
42
|
+
collection?: CollectionConfig;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Options for searching entities
|
|
@@ -50,7 +50,7 @@ export interface SearchOptions<M extends Record<string, unknown> = Record<string
|
|
|
50
50
|
order?: "desc" | "asc";
|
|
51
51
|
limit?: number;
|
|
52
52
|
databaseId?: string;
|
|
53
|
-
collection?:
|
|
53
|
+
collection?: CollectionConfig;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Options for counting entities
|
|
@@ -110,31 +110,31 @@ export type ConditionBuilderStatic<T = unknown> = {
|
|
|
110
110
|
* - Relation resolution
|
|
111
111
|
* - ID generation and conversion
|
|
112
112
|
*/
|
|
113
|
-
export interface
|
|
113
|
+
export interface DataRepository {
|
|
114
114
|
/**
|
|
115
115
|
* Fetch a single entity by ID
|
|
116
116
|
*/
|
|
117
|
-
|
|
117
|
+
fetchOne<M extends Record<string, unknown>>(collectionPath: string, id: string | number, databaseId?: string): Promise<Record<string, unknown> | undefined>;
|
|
118
118
|
/**
|
|
119
119
|
* Fetch a collection of entities with optional filtering, ordering, and pagination
|
|
120
120
|
*/
|
|
121
|
-
fetchCollection<M extends Record<string, unknown>>(collectionPath: string, options?: FetchCollectionOptions<M>): Promise<
|
|
121
|
+
fetchCollection<M extends Record<string, unknown>>(collectionPath: string, options?: FetchCollectionOptions<M>): Promise<Record<string, unknown>[]>;
|
|
122
122
|
/**
|
|
123
123
|
* Search entities by text
|
|
124
124
|
*/
|
|
125
|
-
|
|
125
|
+
searchRows<M extends Record<string, unknown>>(collectionPath: string, searchString: string, options?: SearchOptions<M>): Promise<Record<string, unknown>[]>;
|
|
126
126
|
/**
|
|
127
127
|
* Count entities in a collection
|
|
128
128
|
*/
|
|
129
|
-
|
|
129
|
+
count<M extends Record<string, unknown>>(collectionPath: string, options?: CountOptions<M>): Promise<number>;
|
|
130
130
|
/**
|
|
131
|
-
* Save
|
|
131
|
+
* Save a entity (create or update)
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
save<M extends Record<string, unknown>>(collectionPath: string, values: Partial<M>, id?: string | number, databaseId?: string): Promise<Record<string, unknown>>;
|
|
134
134
|
/**
|
|
135
|
-
* Delete
|
|
135
|
+
* Delete a entity by ID
|
|
136
136
|
*/
|
|
137
|
-
|
|
137
|
+
delete(collectionPath: string, id: string | number, databaseId?: string): Promise<void>;
|
|
138
138
|
/**
|
|
139
139
|
* Check if a field value is unique in a collection
|
|
140
140
|
*/
|
|
@@ -157,10 +157,10 @@ export interface CollectionSubscriptionConfig {
|
|
|
157
157
|
/**
|
|
158
158
|
* Configuration for subscribing to a single entity
|
|
159
159
|
*/
|
|
160
|
-
export interface
|
|
160
|
+
export interface SingleSubscriptionConfig {
|
|
161
161
|
clientId: string;
|
|
162
162
|
path: string;
|
|
163
|
-
|
|
163
|
+
id: string | number;
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
166
166
|
* Abstract realtime provider interface.
|
|
@@ -170,19 +170,19 @@ export interface RealtimeProvider {
|
|
|
170
170
|
/**
|
|
171
171
|
* Subscribe to collection changes
|
|
172
172
|
*/
|
|
173
|
-
subscribeToCollection(subscriptionId: string, config: CollectionSubscriptionConfig, callback?: (
|
|
173
|
+
subscribeToCollection(subscriptionId: string, config: CollectionSubscriptionConfig, callback?: (rows: Record<string, unknown>[]) => void): void;
|
|
174
174
|
/**
|
|
175
175
|
* Subscribe to single entity changes
|
|
176
176
|
*/
|
|
177
|
-
|
|
177
|
+
subscribeToOne(subscriptionId: string, config: SingleSubscriptionConfig, callback?: (row: Record<string, unknown> | null) => void): void;
|
|
178
178
|
/**
|
|
179
179
|
* Unsubscribe from a subscription
|
|
180
180
|
*/
|
|
181
181
|
unsubscribe(subscriptionId: string): void;
|
|
182
182
|
/**
|
|
183
|
-
* Notify all relevant subscribers of
|
|
183
|
+
* Notify all relevant subscribers of a entity update
|
|
184
184
|
*/
|
|
185
|
-
|
|
185
|
+
notifyUpdate(path: string, id: string, row: Record<string, unknown> | null, databaseId?: string): Promise<void>;
|
|
186
186
|
/**
|
|
187
187
|
* Called when the HTTP server is ready and listening.
|
|
188
188
|
* Useful for providers that need the server address for callbacks.
|
|
@@ -210,15 +210,15 @@ export interface CollectionRegistryInterface {
|
|
|
210
210
|
/**
|
|
211
211
|
* Register a collection
|
|
212
212
|
*/
|
|
213
|
-
register(collection:
|
|
213
|
+
register(collection: CollectionConfig): void;
|
|
214
214
|
/**
|
|
215
215
|
* Get a collection by its path
|
|
216
216
|
*/
|
|
217
|
-
getCollectionByPath(path: string):
|
|
217
|
+
getCollectionByPath(path: string): CollectionConfig | undefined;
|
|
218
218
|
/**
|
|
219
219
|
* Get all registered collections
|
|
220
220
|
*/
|
|
221
|
-
getCollections():
|
|
221
|
+
getCollections(): CollectionConfig[];
|
|
222
222
|
/**
|
|
223
223
|
* Get the currently registered global callbacks, if any.
|
|
224
224
|
*/
|
|
@@ -232,11 +232,11 @@ export interface DataTransformer {
|
|
|
232
232
|
/**
|
|
233
233
|
* Transform entity data for storage in the database
|
|
234
234
|
*/
|
|
235
|
-
serializeToDatabase<M extends Record<string, unknown>>(entity: M, collection:
|
|
235
|
+
serializeToDatabase<M extends Record<string, unknown>>(entity: M, collection: CollectionConfig): Record<string, unknown>;
|
|
236
236
|
/**
|
|
237
237
|
* Transform database data back to entity format
|
|
238
238
|
*/
|
|
239
|
-
deserializeFromDatabase<M extends Record<string, unknown>>(data: Record<string, unknown>, collection:
|
|
239
|
+
deserializeFromDatabase<M extends Record<string, unknown>>(data: Record<string, unknown>, collection: CollectionConfig): Promise<M>;
|
|
240
240
|
}
|
|
241
241
|
/**
|
|
242
242
|
* Administrative operations for SQL-based databases (PostgreSQL, MySQL, etc.).
|
|
@@ -427,7 +427,7 @@ export interface BackendInstance extends BackendLifecycle {
|
|
|
427
427
|
/**
|
|
428
428
|
* Entity repository for CRUD operations
|
|
429
429
|
*/
|
|
430
|
-
entityRepository:
|
|
430
|
+
entityRepository: DataRepository;
|
|
431
431
|
/**
|
|
432
432
|
* Realtime provider for subscriptions
|
|
433
433
|
*/
|
|
@@ -518,7 +518,7 @@ export interface BackendBootstrapper {
|
|
|
518
518
|
* Initialize history tables / services if this driver supports them.
|
|
519
519
|
* Return undefined if history is not supported by this backend.
|
|
520
520
|
*/
|
|
521
|
-
initializeHistory?(config:
|
|
521
|
+
initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{
|
|
522
522
|
historyService: unknown;
|
|
523
523
|
} | undefined>;
|
|
524
524
|
/**
|
package/dist/types/builders.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AuthController } from "../controllers/auth";
|
|
2
2
|
import type { RebaseData } from "../controllers/data";
|
|
3
3
|
import type { User } from "../users";
|
|
4
|
-
import type {
|
|
4
|
+
import type { CollectionConfig } from "./collections";
|
|
5
5
|
import type { AppView } from "../controllers/navigation";
|
|
6
|
-
export type
|
|
6
|
+
export type CollectionConfigsBuilder<EC extends CollectionConfig = CollectionConfig> = (params: {
|
|
7
7
|
user: User | null;
|
|
8
8
|
authController: AuthController;
|
|
9
9
|
data: RebaseData;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Entity, EntityStatus } from "./entities";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CollectionCallbacks } from "./entity_callbacks";
|
|
4
4
|
import type { Properties, PostgresProperties, FirebaseProperties, MongoProperties } from "./properties";
|
|
5
5
|
import type { ExportConfig } from "./export_import";
|
|
6
6
|
import type { User } from "../users";
|
|
@@ -11,16 +11,16 @@ import type { EntityAction } from "./entity_actions";
|
|
|
11
11
|
import type { PolicyExpression } from "./policy";
|
|
12
12
|
import type { ComponentRef } from "./component_ref";
|
|
13
13
|
import type { CollectionComponentOverrideMap } from "./component_overrides";
|
|
14
|
-
import type { FilterValues, FilterPreset } from "./filter-operators";
|
|
14
|
+
import type { FilterValues, FilterPreset, OrderByTuple } from "./filter-operators";
|
|
15
15
|
/**
|
|
16
16
|
* Base interface containing all driver-agnostic collection properties.
|
|
17
|
-
* Use {@link
|
|
18
|
-
* driver-specific type safety, or {@link
|
|
17
|
+
* Use {@link PostgresCollectionConfig} or {@link FirebaseCollectionConfig} for
|
|
18
|
+
* driver-specific type safety, or {@link CollectionConfig} when you
|
|
19
19
|
* need to handle any collection regardless of backend.
|
|
20
20
|
*
|
|
21
21
|
* @group Models
|
|
22
22
|
*/
|
|
23
|
-
export interface
|
|
23
|
+
export interface BaseCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
24
24
|
/**
|
|
25
25
|
* You can set an alias that will be used internally instead of the collection name.
|
|
26
26
|
* The `slug` value will be used to determine the URL of the collection.
|
|
@@ -48,12 +48,12 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
48
48
|
*
|
|
49
49
|
* Custom drivers can set this directly to expose child collections to the UI.
|
|
50
50
|
*/
|
|
51
|
-
childCollections?: () =>
|
|
51
|
+
childCollections?: () => CollectionConfig<Record<string, unknown>>[];
|
|
52
52
|
/**
|
|
53
53
|
* The data source this collection belongs to — the routing key shared by
|
|
54
54
|
* the frontend router and the backend driver registry. It points at a
|
|
55
55
|
* {@link DataSourceDefinition} registered on `<Rebase dataSources>` (front)
|
|
56
|
-
* and `
|
|
56
|
+
* and `initializeRebaseBackend({ dataSources })` (back).
|
|
57
57
|
*
|
|
58
58
|
* If not specified, the default data source `"(default)"` is used, which
|
|
59
59
|
* for a standard Rebase app is the server-mediated Postgres backend.
|
|
@@ -70,8 +70,8 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
70
70
|
* The database engine backing this collection (`"postgres"`, `"firestore"`,
|
|
71
71
|
* `"mongodb"`, or a custom id).
|
|
72
72
|
*
|
|
73
|
-
* On concrete collection types ({@link
|
|
74
|
-
* {@link
|
|
73
|
+
* On concrete collection types ({@link PostgresCollectionConfig},
|
|
74
|
+
* {@link FirebaseCollectionConfig}, {@link MongoDBCollectionConfig}) this is a literal
|
|
75
75
|
* discriminant. On the base type it is optional and gets stamped
|
|
76
76
|
* automatically during collection normalization from the registered
|
|
77
77
|
* {@link DataSourceDefinition}.
|
|
@@ -90,7 +90,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
90
90
|
*/
|
|
91
91
|
databaseId?: string;
|
|
92
92
|
/**
|
|
93
|
-
* Set of properties that compose
|
|
93
|
+
* Set of properties that compose a entity
|
|
94
94
|
*/
|
|
95
95
|
properties: Properties;
|
|
96
96
|
/**
|
|
@@ -125,12 +125,12 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
125
125
|
*/
|
|
126
126
|
readonly titleProperty?: Extract<keyof M, string> | (string & {});
|
|
127
127
|
/**
|
|
128
|
-
* When editing
|
|
128
|
+
* When editing a entity, you can choose to open the entity in a side dialog
|
|
129
129
|
* or in a full screen dialog. Defaults to `full_screen`.
|
|
130
130
|
*/
|
|
131
131
|
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
132
132
|
/**
|
|
133
|
-
* Controls what happens when a user clicks on
|
|
133
|
+
* Controls what happens when a user clicks on a entity in the collection view.
|
|
134
134
|
* - `"edit"` (default): Opens the entity in the edit form.
|
|
135
135
|
* - `"view"`: Opens a read-only detail view with an "Edit" button.
|
|
136
136
|
*/
|
|
@@ -177,19 +177,18 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
177
177
|
* If you are specifying your collection as code, the order is the same as the
|
|
178
178
|
* one you define in `properties`. Additional columns are added at the
|
|
179
179
|
* end of the list, if the order is not specified.
|
|
180
|
+
*
|
|
180
181
|
* You can use this prop to hide some properties from the table view.
|
|
181
182
|
* Note that if you set this prop, other ways to hide fields, like
|
|
182
183
|
* `hidden` in the property definition, will be ignored.
|
|
183
184
|
* `propertiesOrder` has precedence over `hidden`.
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* -
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* `hidden` in the property definition,will be ignored.
|
|
192
|
-
* `propertiesOrder` has precedence over `hidden`.
|
|
185
|
+
*
|
|
186
|
+
* Supported entry formats:
|
|
187
|
+
* - For properties, use the property key.
|
|
188
|
+
* - For additional fields, use the field key.
|
|
189
|
+
* - Child collections (Firestore subcollections, or Postgres relations
|
|
190
|
+
* with `many` cardinality) each get a column with id
|
|
191
|
+
* `subcollection:<slug>`, e.g. `subcollection:orders`.
|
|
193
192
|
*/
|
|
194
193
|
propertiesOrder?: (Extract<keyof M, string> | (string & {}) | string | `subcollection:${string}`)[];
|
|
195
194
|
/**
|
|
@@ -202,11 +201,11 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
202
201
|
pagination?: boolean | number;
|
|
203
202
|
selectionEnabled?: boolean;
|
|
204
203
|
/**
|
|
205
|
-
* This interface defines all the callbacks that can be used when
|
|
204
|
+
* This interface defines all the callbacks that can be used when a entity
|
|
206
205
|
* is being created, updated or deleted.
|
|
207
206
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
208
207
|
*/
|
|
209
|
-
readonly callbacks?:
|
|
208
|
+
readonly callbacks?: CollectionCallbacks<M, USER>;
|
|
210
209
|
/**
|
|
211
210
|
* Pass your own selection controller if you want to control selected
|
|
212
211
|
* entities externally.
|
|
@@ -251,7 +250,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
251
250
|
* applied in the collection.
|
|
252
251
|
* e.g. `sort: ["order", "asc"]`
|
|
253
252
|
*/
|
|
254
|
-
readonly sort?:
|
|
253
|
+
readonly sort?: OrderByTuple<Extract<keyof M, string> | (string & {})>;
|
|
255
254
|
/**
|
|
256
255
|
* You can add additional fields to the collection view by implementing
|
|
257
256
|
* an additional field delegate.
|
|
@@ -277,7 +276,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
277
276
|
hideFromNavigation?: boolean;
|
|
278
277
|
/**
|
|
279
278
|
* If you want to open custom views or subcollections by default when opening the edit
|
|
280
|
-
* view of
|
|
279
|
+
* view of a entity, you can specify the path to the view here.
|
|
281
280
|
* The path is relative to the current collection. For example if you have a collection
|
|
282
281
|
* that has a custom view as well as a subcollection that refers to another entity, you can
|
|
283
282
|
* either specify the path to the custom view or the path to the subcollection.
|
|
@@ -314,7 +313,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
314
313
|
*/
|
|
315
314
|
metadata?: Record<string, unknown>;
|
|
316
315
|
/**
|
|
317
|
-
* Width of the side dialog (in pixels) when opening
|
|
316
|
+
* Width of the side dialog (in pixels) when opening a entity in this collection.
|
|
318
317
|
*/
|
|
319
318
|
sideDialogWidth?: number | string;
|
|
320
319
|
/**
|
|
@@ -335,9 +334,9 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
335
334
|
/**
|
|
336
335
|
* Should local changes be backed up in local storage, to prevent data loss on
|
|
337
336
|
* accidental navigations.
|
|
338
|
-
* - `manual_apply`: When the user navigates back to
|
|
337
|
+
* - `manual_apply`: When the user navigates back to a entity with local changes,
|
|
339
338
|
* they will be prompted to restore the changes.
|
|
340
|
-
* - `auto_apply`: When the user navigates back to
|
|
339
|
+
* - `auto_apply`: When the user navigates back to a entity with local changes,
|
|
341
340
|
* the changes will be automatically applied.
|
|
342
341
|
* - `false`: Local changes will not be backed up.
|
|
343
342
|
* Defaults to `manual_apply`.
|
|
@@ -397,7 +396,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
397
396
|
* Security rules for this collection (Row Level Security).
|
|
398
397
|
* When defined, the backend enforces access control policies.
|
|
399
398
|
*/
|
|
400
|
-
securityRules?: SecurityRule[];
|
|
399
|
+
securityRules?: readonly SecurityRule[];
|
|
401
400
|
/**
|
|
402
401
|
* Collection-scoped component overrides. These take precedence over
|
|
403
402
|
* global overrides set on `<Rebase>`, but only within this collection's
|
|
@@ -409,7 +408,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
409
408
|
*
|
|
410
409
|
* @example
|
|
411
410
|
* ```tsx
|
|
412
|
-
* const productsCollection:
|
|
411
|
+
* const productsCollection: PostgresCollectionConfig = {
|
|
413
412
|
* name: "Products",
|
|
414
413
|
* slug: "products",
|
|
415
414
|
* table: "products",
|
|
@@ -427,12 +426,12 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
427
426
|
* A collection backed by PostgreSQL (or any SQL database).
|
|
428
427
|
* Adds support for SQL-style relations (JOINs) and Row Level Security.
|
|
429
428
|
*
|
|
430
|
-
* Use this type instead of {@link
|
|
429
|
+
* Use this type instead of {@link CollectionConfig} when you want
|
|
431
430
|
* compile-time safety that only SQL-relevant fields appear.
|
|
432
431
|
*
|
|
433
432
|
* @group Models
|
|
434
433
|
*/
|
|
435
|
-
export interface
|
|
434
|
+
export interface PostgresCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseCollectionConfig<M, USER> {
|
|
436
435
|
properties: PostgresProperties;
|
|
437
436
|
/**
|
|
438
437
|
* The database engine for this collection. For Postgres collections this
|
|
@@ -455,7 +454,7 @@ export interface PostgresCollection<M extends Record<string, unknown> = Record<s
|
|
|
455
454
|
*/
|
|
456
455
|
relations?: Relation[];
|
|
457
456
|
/**
|
|
458
|
-
* Security rules for this collection (
|
|
457
|
+
* Security rules for this collection (PostgreSQL Row Level Security).
|
|
459
458
|
* When defined, the schema generator will enable RLS on the table and
|
|
460
459
|
* create the corresponding PostgreSQL policies.
|
|
461
460
|
*
|
|
@@ -469,24 +468,24 @@ export interface PostgresCollection<M extends Record<string, unknown> = Record<s
|
|
|
469
468
|
* - `auth.roles()` — comma-separated app role IDs
|
|
470
469
|
* - `auth.jwt()` — full JWT claims as JSONB
|
|
471
470
|
*/
|
|
472
|
-
securityRules?: SecurityRule[];
|
|
471
|
+
securityRules?: readonly SecurityRule[];
|
|
473
472
|
}
|
|
474
473
|
/**
|
|
475
474
|
* A collection backed by Firebase / Firestore.
|
|
476
475
|
* Adds support for subcollections (nested document collections).
|
|
477
476
|
*
|
|
478
|
-
* Use this type instead of {@link
|
|
477
|
+
* Use this type instead of {@link CollectionConfig} when you want
|
|
479
478
|
* compile-time safety that only Firestore-relevant fields appear.
|
|
480
479
|
*
|
|
481
480
|
* @group Models
|
|
482
481
|
*/
|
|
483
|
-
export interface
|
|
482
|
+
export interface FirebaseCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseCollectionConfig<M, USER> {
|
|
484
483
|
/**
|
|
485
484
|
* The database engine for this collection. Must be set to `"firestore"`.
|
|
486
485
|
*/
|
|
487
486
|
engine: "firestore";
|
|
488
487
|
/**
|
|
489
|
-
* Set of properties that compose
|
|
488
|
+
* Set of properties that compose a entity.
|
|
490
489
|
* Firestore collections support `reference` properties but not `relation`.
|
|
491
490
|
*/
|
|
492
491
|
properties: FirebaseProperties;
|
|
@@ -497,7 +496,7 @@ export interface FirebaseCollection<M extends Record<string, unknown> = Record<s
|
|
|
497
496
|
*
|
|
498
497
|
* @example
|
|
499
498
|
* ```typescript
|
|
500
|
-
* const fsCustomer:
|
|
499
|
+
* const fsCustomer: FirebaseCollectionConfig = {
|
|
501
500
|
* slug: "fs_customer", // URL: /c/fs_customer
|
|
502
501
|
* path: "customer", // Firestore path: customer
|
|
503
502
|
* name: "Customers (Firestore)",
|
|
@@ -510,25 +509,25 @@ export interface FirebaseCollection<M extends Record<string, unknown> = Record<s
|
|
|
510
509
|
/**
|
|
511
510
|
* You can add subcollections to your entity in the same way you define the root
|
|
512
511
|
* collections. The collections added here will be displayed when opening
|
|
513
|
-
* the side dialog of
|
|
512
|
+
* the side dialog of a entity.
|
|
514
513
|
*/
|
|
515
|
-
subcollections?: () =>
|
|
514
|
+
subcollections?: () => CollectionConfig<Record<string, unknown>>[];
|
|
516
515
|
}
|
|
517
516
|
/**
|
|
518
517
|
* A collection backed by MongoDB.
|
|
519
518
|
*
|
|
520
|
-
* Use this type instead of {@link
|
|
519
|
+
* Use this type instead of {@link CollectionConfig} when you want
|
|
521
520
|
* compile-time safety that only MongoDB-relevant fields appear.
|
|
522
521
|
*
|
|
523
522
|
* @group Models
|
|
524
523
|
*/
|
|
525
|
-
export interface
|
|
524
|
+
export interface MongoDBCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseCollectionConfig<M, USER> {
|
|
526
525
|
/**
|
|
527
526
|
* The database engine for this collection. Must be set to `"mongodb"`.
|
|
528
527
|
*/
|
|
529
528
|
engine: "mongodb";
|
|
530
529
|
/**
|
|
531
|
-
* Set of properties that compose
|
|
530
|
+
* Set of properties that compose a entity.
|
|
532
531
|
* MongoDB collections support `reference` properties but not `relation`.
|
|
533
532
|
*/
|
|
534
533
|
properties: MongoProperties;
|
|
@@ -539,7 +538,7 @@ export interface MongoDBCollection<M extends Record<string, unknown> = Record<st
|
|
|
539
538
|
*
|
|
540
539
|
* @example
|
|
541
540
|
* ```typescript
|
|
542
|
-
* const mongoCustomer:
|
|
541
|
+
* const mongoCustomer: MongoDBCollectionConfig = {
|
|
543
542
|
* slug: "mongo_customer", // URL: /c/mongo_customer
|
|
544
543
|
* path: "customer", // MongoDB collection: customer
|
|
545
544
|
* name: "Customers (MongoDB)",
|
|
@@ -552,35 +551,35 @@ export interface MongoDBCollection<M extends Record<string, unknown> = Record<st
|
|
|
552
551
|
}
|
|
553
552
|
/**
|
|
554
553
|
* A collection backed by any data source.
|
|
555
|
-
* This is a discriminated union — use {@link
|
|
556
|
-
* {@link
|
|
554
|
+
* This is a discriminated union — use {@link PostgresCollectionConfig},
|
|
555
|
+
* {@link FirebaseCollectionConfig}, or {@link MongoDBCollectionConfig} for
|
|
557
556
|
* driver-specific type safety.
|
|
558
557
|
*
|
|
559
558
|
* @group Models
|
|
560
559
|
*/
|
|
561
|
-
export type
|
|
560
|
+
export type CollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = PostgresCollectionConfig<M, USER> | FirebaseCollectionConfig<M, USER> | MongoDBCollectionConfig<M, USER>;
|
|
562
561
|
/**
|
|
563
562
|
* Type guard for PostgreSQL collections.
|
|
564
563
|
* Returns true if the collection uses the Postgres engine (or the default engine).
|
|
565
564
|
* @group Models
|
|
566
565
|
*/
|
|
567
|
-
export declare function
|
|
566
|
+
export declare function isPostgresCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): collection is PostgresCollectionConfig<M, USER>;
|
|
568
567
|
/**
|
|
569
568
|
* Type guard for Firebase / Firestore collections.
|
|
570
569
|
* @group Models
|
|
571
570
|
*/
|
|
572
|
-
export declare function
|
|
571
|
+
export declare function isFirebaseCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): collection is FirebaseCollectionConfig<M, USER>;
|
|
573
572
|
/**
|
|
574
573
|
* Type guard for MongoDB collections.
|
|
575
574
|
* @group Models
|
|
576
575
|
*/
|
|
577
|
-
export declare function
|
|
576
|
+
export declare function isMongoDBCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): collection is MongoDBCollectionConfig<M, USER>;
|
|
578
577
|
/**
|
|
579
578
|
* Returns the data path for a collection.
|
|
580
579
|
* For Firestore or MongoDB collections with a `path`, returns that value;
|
|
581
580
|
* otherwise falls back to `slug`.
|
|
582
581
|
*/
|
|
583
|
-
export declare function getCollectionDataPath<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection:
|
|
582
|
+
export declare function getCollectionDataPath<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): string;
|
|
584
583
|
/**
|
|
585
584
|
* Reads a collection's driver-declared subcollections thunk (the `subcollections`
|
|
586
585
|
* field) independent of engine identity, so engine-agnostic code doesn't have to
|
|
@@ -591,7 +590,7 @@ export declare function getCollectionDataPath<M extends Record<string, unknown>
|
|
|
591
590
|
* whether the engine honours subcollections at all before reading them.
|
|
592
591
|
* @group Models
|
|
593
592
|
*/
|
|
594
|
-
export declare function getDeclaredSubcollections<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection:
|
|
593
|
+
export declare function getDeclaredSubcollections<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): (() => CollectionConfig<Record<string, unknown>>[]) | undefined;
|
|
595
594
|
/**
|
|
596
595
|
* Configuration for Kanban board view mode.
|
|
597
596
|
* @group Collections
|
|
@@ -621,7 +620,7 @@ export type ViewMode = "list" | "table" | "cards" | "kanban";
|
|
|
621
620
|
*
|
|
622
621
|
* @group Models
|
|
623
622
|
*/
|
|
624
|
-
export interface CollectionActionsProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends
|
|
623
|
+
export interface CollectionActionsProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends CollectionConfig<M> = CollectionConfig<M>> {
|
|
625
624
|
/**
|
|
626
625
|
* Full collection path of this entity. This is the full path, like
|
|
627
626
|
* `users/1234/addresses`
|
|
@@ -677,7 +676,7 @@ export interface CollectionActionsProps<M extends Record<string, unknown> = Reco
|
|
|
677
676
|
}
|
|
678
677
|
/**
|
|
679
678
|
* Use this controller to retrieve the selected entities or modify them in
|
|
680
|
-
* an {@link
|
|
679
|
+
* an {@link CollectionConfig}
|
|
681
680
|
* @group Models
|
|
682
681
|
*/
|
|
683
682
|
export interface SelectionController<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -750,14 +749,14 @@ export interface AdditionalFieldDelegate<M extends Record<string, unknown> = Rec
|
|
|
750
749
|
context: RebaseContext;
|
|
751
750
|
}): string | number | Promise<string | number> | undefined;
|
|
752
751
|
}
|
|
753
|
-
export type
|
|
752
|
+
export type InferCollectionConfigType<S extends CollectionConfig> = S extends CollectionConfig<infer M> ? M : never;
|
|
754
753
|
/**
|
|
755
|
-
* Used in the {@link
|
|
754
|
+
* Used in the {@link CollectionConfig#defaultSelectedView} to define the default
|
|
756
755
|
* @group Models
|
|
757
756
|
*/
|
|
758
757
|
export type DefaultSelectedViewBuilder = (params: DefaultSelectedViewParams) => string | undefined;
|
|
759
758
|
/**
|
|
760
|
-
* Used in the {@link
|
|
759
|
+
* Used in the {@link CollectionConfig#defaultSelectedView} to define the default
|
|
761
760
|
* @group Models
|
|
762
761
|
*/
|
|
763
762
|
export type DefaultSelectedViewParams = {
|
|
@@ -810,7 +809,7 @@ export type SecurityOperation = "select" | "insert" | "update" | "delete" | "all
|
|
|
810
809
|
/**
|
|
811
810
|
* Flexible Row Level Security rule for a collection.
|
|
812
811
|
*
|
|
813
|
-
*
|
|
812
|
+
* Built on PostgreSQL Row Level Security. Rules can range from
|
|
814
813
|
* simple convenience shortcuts to fully custom SQL expressions, giving you the
|
|
815
814
|
* full power of PostgreSQL Row Level Security.
|
|
816
815
|
*
|
|
@@ -823,7 +822,7 @@ export type SecurityOperation = "select" | "insert" | "update" | "delete" | "all
|
|
|
823
822
|
*
|
|
824
823
|
* **How rules combine:** PostgreSQL evaluates all matching policies for an
|
|
825
824
|
* operation. Permissive rules are OR'd together (any one passing is enough).
|
|
826
|
-
* Restrictive rules are AND'd (all must pass). This
|
|
825
|
+
* Restrictive rules are AND'd (all must pass). This is standard PostgreSQL RLS behavior.
|
|
827
826
|
*
|
|
828
827
|
* **Mutual exclusivity:** `ownerField`, `access`, structured `condition`, and
|
|
829
828
|
* raw SQL (`using`/`withCheck`) cannot be combined. The type system enforces
|
|
@@ -882,7 +881,7 @@ export interface SecurityRuleBase {
|
|
|
882
881
|
* // Equivalent to operation: "all"
|
|
883
882
|
* { operations: ["all"], ownerField: "user_id" }
|
|
884
883
|
*/
|
|
885
|
-
operations?: SecurityOperation[];
|
|
884
|
+
operations?: readonly SecurityOperation[];
|
|
886
885
|
/**
|
|
887
886
|
* Whether this policy is `"permissive"` (default) or `"restrictive"`.
|
|
888
887
|
*
|
|
@@ -891,7 +890,7 @@ export interface SecurityRuleBase {
|
|
|
891
890
|
* - **restrictive**: Restrictive policies are AND'd with all permissive
|
|
892
891
|
* policies — they act as additional gates that *must* also pass.
|
|
893
892
|
*
|
|
894
|
-
* This is the
|
|
893
|
+
* This is the standard PostgreSQL RLS model.
|
|
895
894
|
*
|
|
896
895
|
* @default "permissive"
|
|
897
896
|
*/
|
|
@@ -923,7 +922,7 @@ export interface SecurityRuleBase {
|
|
|
923
922
|
* // Admins have unfiltered read access to all rows
|
|
924
923
|
* { operation: "select", roles: ["admin"], using: "true" }
|
|
925
924
|
*/
|
|
926
|
-
roles?: string[];
|
|
925
|
+
roles?: readonly string[];
|
|
927
926
|
/**
|
|
928
927
|
* **Advanced.** Native PostgreSQL database roles the policy applies to.
|
|
929
928
|
*
|
|
@@ -945,7 +944,7 @@ export interface SecurityRuleBase {
|
|
|
945
944
|
* // Only apply this policy when connected as `app_role`
|
|
946
945
|
* { operation: "select", access: "public", pgRoles: ["app_role"] }
|
|
947
946
|
*/
|
|
948
|
-
pgRoles?: string[];
|
|
947
|
+
pgRoles?: readonly string[];
|
|
949
948
|
}
|
|
950
949
|
/**
|
|
951
950
|
* Security rule that grants access based on row ownership.
|