@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.
Files changed (78) hide show
  1. package/README.md +10 -10
  2. package/dist/controllers/auth.d.ts +1 -1
  3. package/dist/controllers/client.d.ts +184 -6
  4. package/dist/controllers/collection_registry.d.ts +3 -3
  5. package/dist/controllers/customization_controller.d.ts +1 -1
  6. package/dist/controllers/data.d.ts +267 -35
  7. package/dist/controllers/data_driver.d.ts +50 -37
  8. package/dist/controllers/index.d.ts +1 -1
  9. package/dist/controllers/local_config_persistence.d.ts +4 -4
  10. package/dist/controllers/navigation.d.ts +2 -2
  11. package/dist/controllers/registry.d.ts +17 -4
  12. package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
  13. package/dist/controllers/storage.d.ts +39 -0
  14. package/dist/errors.d.ts +64 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.es.js +142 -15
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.umd.js +150 -17
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/rebase_context.d.ts +8 -4
  21. package/dist/types/auth_adapter.d.ts +4 -1
  22. package/dist/types/backend.d.ts +26 -26
  23. package/dist/types/builders.d.ts +2 -2
  24. package/dist/types/collections.d.ts +62 -63
  25. package/dist/types/component_overrides.d.ts +61 -3
  26. package/dist/types/cron.d.ts +10 -1
  27. package/dist/types/data_source.d.ts +15 -2
  28. package/dist/types/database_adapter.d.ts +4 -3
  29. package/dist/types/entities.d.ts +7 -7
  30. package/dist/types/entity_actions.d.ts +7 -7
  31. package/dist/types/entity_callbacks.d.ts +39 -39
  32. package/dist/types/entity_views.d.ts +3 -3
  33. package/dist/types/filter-operators.d.ts +62 -17
  34. package/dist/types/modify_collections.d.ts +2 -2
  35. package/dist/types/plugins.d.ts +9 -9
  36. package/dist/types/policy.d.ts +64 -10
  37. package/dist/types/properties.d.ts +41 -9
  38. package/dist/types/relations.d.ts +3 -3
  39. package/dist/types/slots.d.ts +14 -14
  40. package/dist/types/websockets.d.ts +12 -13
  41. package/dist/users/user.d.ts +21 -9
  42. package/package.json +1 -1
  43. package/src/controllers/auth.tsx +1 -1
  44. package/src/controllers/client.ts +214 -6
  45. package/src/controllers/collection_registry.ts +3 -3
  46. package/src/controllers/customization_controller.tsx +1 -1
  47. package/src/controllers/data.ts +290 -39
  48. package/src/controllers/data_driver.ts +49 -40
  49. package/src/controllers/index.ts +1 -1
  50. package/src/controllers/local_config_persistence.tsx +4 -4
  51. package/src/controllers/navigation.ts +2 -2
  52. package/src/controllers/registry.ts +18 -4
  53. package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
  54. package/src/controllers/storage.ts +60 -1
  55. package/src/errors.ts +80 -0
  56. package/src/index.ts +1 -0
  57. package/src/rebase_context.tsx +8 -4
  58. package/src/types/auth_adapter.ts +4 -1
  59. package/src/types/backend.ts +36 -36
  60. package/src/types/builders.ts +2 -2
  61. package/src/types/collections.ts +78 -79
  62. package/src/types/component_overrides.ts +72 -5
  63. package/src/types/cron.ts +10 -1
  64. package/src/types/data_source.ts +24 -2
  65. package/src/types/database_adapter.ts +4 -3
  66. package/src/types/entities.ts +7 -7
  67. package/src/types/entity_actions.tsx +7 -7
  68. package/src/types/entity_callbacks.ts +42 -42
  69. package/src/types/entity_views.tsx +3 -3
  70. package/src/types/filter-operators.ts +96 -23
  71. package/src/types/modify_collections.tsx +2 -2
  72. package/src/types/plugins.tsx +9 -9
  73. package/src/types/policy.ts +64 -8
  74. package/src/types/properties.ts +44 -9
  75. package/src/types/relations.ts +3 -3
  76. package/src/types/slots.tsx +14 -14
  77. package/src/types/websockets.ts +12 -14
  78. package/src/users/user.ts +22 -9
@@ -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 { RebaseData } from "./controllers/data";
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: RebaseData;
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 dialog displaying entity forms
71
+ * Controller to open the side panel displaying entity forms
68
72
  */
69
- sideEntityController?: import("./controllers/side_entity_controller").SideEntityController;
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.saveEntity()`, plus metadata for the post-save step.
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
  /**
@@ -1,6 +1,6 @@
1
- import type { Entity } from "./entities";
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?: EntityCollection;
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?: EntityCollection;
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 EntityRepository {
113
+ export interface DataRepository {
114
114
  /**
115
115
  * Fetch a single entity by ID
116
116
  */
117
- fetchEntity<M extends Record<string, unknown>>(collectionPath: string, entityId: string | number, databaseId?: string): Promise<Entity<M> | undefined>;
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<Entity<M>[]>;
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
- searchEntities<M extends Record<string, unknown>>(collectionPath: string, searchString: string, options?: SearchOptions<M>): Promise<Entity<M>[]>;
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
- countEntities<M extends Record<string, unknown>>(collectionPath: string, options?: CountOptions<M>): Promise<number>;
129
+ count<M extends Record<string, unknown>>(collectionPath: string, options?: CountOptions<M>): Promise<number>;
130
130
  /**
131
- * Save an entity (create or update)
131
+ * Save a entity (create or update)
132
132
  */
133
- saveEntity<M extends Record<string, unknown>>(collectionPath: string, values: Partial<M>, entityId?: string | number, databaseId?: string): Promise<Entity<M>>;
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 an entity by ID
135
+ * Delete a entity by ID
136
136
  */
137
- deleteEntity(collectionPath: string, entityId: string | number, databaseId?: string): Promise<void>;
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 EntitySubscriptionConfig {
160
+ export interface SingleSubscriptionConfig {
161
161
  clientId: string;
162
162
  path: string;
163
- entityId: string | number;
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?: (entities: Entity[]) => void): void;
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
- subscribeToEntity(subscriptionId: string, config: EntitySubscriptionConfig, callback?: (entity: Entity | null) => void): void;
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 an entity update
183
+ * Notify all relevant subscribers of a entity update
184
184
  */
185
- notifyEntityUpdate(path: string, entityId: string, entity: Entity | null, databaseId?: string): Promise<void>;
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: EntityCollection): void;
213
+ register(collection: CollectionConfig): void;
214
214
  /**
215
215
  * Get a collection by its path
216
216
  */
217
- getCollectionByPath(path: string): EntityCollection | undefined;
217
+ getCollectionByPath(path: string): CollectionConfig | undefined;
218
218
  /**
219
219
  * Get all registered collections
220
220
  */
221
- getCollections(): EntityCollection[];
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: EntityCollection): Record<string, unknown>;
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: EntityCollection): Promise<M>;
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: 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: unknown, driverResult: InitializedDriver): Promise<{
521
+ initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{
522
522
  historyService: unknown;
523
523
  } | undefined>;
524
524
  /**
@@ -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 { EntityCollection } from "./collections";
4
+ import type { CollectionConfig } from "./collections";
5
5
  import type { AppView } from "../controllers/navigation";
6
- export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollection> = (params: {
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 { EntityCallbacks } from "./entity_callbacks";
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 PostgresCollection} or {@link FirebaseCollection} for
18
- * driver-specific type safety, or {@link EntityCollection} when you
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 BaseEntityCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
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?: () => EntityCollection<Record<string, unknown>>[];
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 `initRebase({ dataSources })` (back).
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 PostgresCollection},
74
- * {@link FirebaseCollection}, {@link MongoDBCollection}) this is a literal
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 an entity
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 an entity, you can choose to open the entity in a side dialog
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 an entity in the collection view.
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
- * - For properties use the property key.
185
- * - For additional fields use the field key.
186
- * - If you have subcollections, you get a column for each subcollection,
187
- * with the path (or alias) as the subcollection, prefixed with
188
- * `subcollection:`. e.g. `subcollection:orders`.
189
- * You can use this prop to hide some properties from the table view.
190
- * Note that if you set this prop, other ways to hide fields, like
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 an entity
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?: EntityCallbacks<M, USER>;
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?: [Extract<keyof M, string> | (string & {}), "asc" | "desc"];
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 an entity, you can specify the path to the view here.
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 an entity in this collection.
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 an entity with local changes,
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 an entity with local changes,
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: PostgresCollection = {
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 EntityCollection} when you want
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 PostgresCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
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 (Supabase-style Row Level Security).
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 EntityCollection} when you want
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 FirebaseCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
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 an entity.
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: FirebaseCollection = {
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 an entity.
512
+ * the side dialog of a entity.
514
513
  */
515
- subcollections?: () => EntityCollection<Record<string, unknown>>[];
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 EntityCollection} when you want
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 MongoDBCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseEntityCollection<M, USER> {
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 an entity.
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: MongoDBCollection = {
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 PostgresCollection},
556
- * {@link FirebaseCollection}, or {@link MongoDBCollection} for
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 EntityCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = PostgresCollection<M, USER> | FirebaseCollection<M, USER> | MongoDBCollection<M, USER>;
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 isPostgresCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: EntityCollection<M, USER>): collection is PostgresCollection<M, USER>;
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 isFirebaseCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: EntityCollection<M, USER>): collection is FirebaseCollection<M, USER>;
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 isMongoDBCollection<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: EntityCollection<M, USER>): collection is MongoDBCollection<M, USER>;
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: EntityCollection<M, USER>): string;
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: EntityCollection<M, USER>): (() => EntityCollection<Record<string, unknown>>[]) | undefined;
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 EntityCollection<M> = EntityCollection<M>> {
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 EntityCollection}
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 InferCollectionType<S extends EntityCollection> = S extends EntityCollection<infer M> ? M : never;
752
+ export type InferCollectionConfigType<S extends CollectionConfig> = S extends CollectionConfig<infer M> ? M : never;
754
753
  /**
755
- * Used in the {@link EntityCollection#defaultSelectedView} to define the default
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 EntityCollection#defaultSelectedView} to define the default
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
- * Inspired by Supabase's approach to PostgreSQL RLS. Rules can range from
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 mirrors Supabase behavior.
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 same model as PostgreSQL / Supabase.
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.