@rebasepro/types 0.8.0 → 0.9.1-canary.09aaf62

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 (88) hide show
  1. package/README.md +13 -13
  2. package/dist/controllers/auth.d.ts +7 -1
  3. package/dist/controllers/client.d.ts +204 -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 +309 -35
  7. package/dist/controllers/data_driver.d.ts +92 -37
  8. package/dist/controllers/email.d.ts +2 -2
  9. package/dist/controllers/index.d.ts +1 -1
  10. package/dist/controllers/local_config_persistence.d.ts +4 -4
  11. package/dist/controllers/navigation.d.ts +2 -2
  12. package/dist/controllers/registry.d.ts +21 -8
  13. package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
  14. package/dist/controllers/storage.d.ts +39 -0
  15. package/dist/errors.d.ts +64 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.es.js +160 -15
  18. package/dist/index.es.js.map +1 -1
  19. package/dist/rebase_context.d.ts +8 -4
  20. package/dist/types/auth_adapter.d.ts +29 -4
  21. package/dist/types/backend.d.ts +33 -26
  22. package/dist/types/backup.d.ts +20 -0
  23. package/dist/types/builders.d.ts +2 -2
  24. package/dist/types/collections.d.ts +84 -75
  25. package/dist/types/component_overrides.d.ts +61 -3
  26. package/dist/types/cron.d.ts +11 -2
  27. package/dist/types/data_source.d.ts +15 -2
  28. package/dist/types/database_adapter.d.ts +21 -4
  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/index.d.ts +1 -0
  35. package/dist/types/modify_collections.d.ts +2 -2
  36. package/dist/types/plugins.d.ts +9 -9
  37. package/dist/types/policy.d.ts +111 -11
  38. package/dist/types/properties.d.ts +54 -9
  39. package/dist/types/relations.d.ts +3 -3
  40. package/dist/types/slots.d.ts +14 -14
  41. package/dist/types/translations.d.ts +5 -1
  42. package/dist/types/user_management_delegate.d.ts +8 -2
  43. package/dist/types/websockets.d.ts +46 -13
  44. package/dist/users/user.d.ts +21 -9
  45. package/package.json +5 -6
  46. package/src/controllers/auth.tsx +7 -1
  47. package/src/controllers/client.ts +235 -7
  48. package/src/controllers/collection_registry.ts +3 -3
  49. package/src/controllers/customization_controller.tsx +1 -1
  50. package/src/controllers/data.ts +330 -39
  51. package/src/controllers/data_driver.ts +93 -40
  52. package/src/controllers/email.ts +2 -2
  53. package/src/controllers/index.ts +1 -1
  54. package/src/controllers/local_config_persistence.tsx +4 -4
  55. package/src/controllers/navigation.ts +2 -2
  56. package/src/controllers/registry.ts +22 -8
  57. package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
  58. package/src/controllers/storage.ts +60 -1
  59. package/src/errors.ts +80 -0
  60. package/src/index.ts +1 -0
  61. package/src/rebase_context.tsx +8 -4
  62. package/src/types/auth_adapter.ts +29 -4
  63. package/src/types/backend.ts +44 -36
  64. package/src/types/backup.ts +26 -0
  65. package/src/types/builders.ts +2 -2
  66. package/src/types/collections.ts +101 -91
  67. package/src/types/component_overrides.ts +72 -5
  68. package/src/types/cron.ts +11 -2
  69. package/src/types/data_source.ts +24 -2
  70. package/src/types/database_adapter.ts +19 -4
  71. package/src/types/entities.ts +7 -7
  72. package/src/types/entity_actions.tsx +7 -7
  73. package/src/types/entity_callbacks.ts +42 -42
  74. package/src/types/entity_views.tsx +3 -3
  75. package/src/types/filter-operators.ts +96 -23
  76. package/src/types/index.ts +1 -0
  77. package/src/types/modify_collections.tsx +2 -2
  78. package/src/types/plugins.tsx +9 -9
  79. package/src/types/policy.ts +114 -9
  80. package/src/types/properties.ts +58 -9
  81. package/src/types/relations.ts +3 -3
  82. package/src/types/slots.tsx +14 -14
  83. package/src/types/translations.ts +5 -1
  84. package/src/types/user_management_delegate.ts +8 -2
  85. package/src/types/websockets.ts +43 -14
  86. package/src/users/user.ts +22 -9
  87. package/dist/index.umd.js +0 -458
  88. package/dist/index.umd.js.map +0 -1
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * @example Custom auth
19
19
  * ```ts
20
- * import { createCustomAuthAdapter } from "@rebasepro/server-core";
20
+ * import { createCustomAuthAdapter } from "@rebasepro/server";
21
21
  *
22
22
  * initializeRebaseBackend({
23
23
  * auth: createCustomAuthAdapter({
@@ -85,8 +85,25 @@ export interface AuthAdapterCapabilities {
85
85
  emailPasswordLogin: boolean;
86
86
  /** Supports new user registration. */
87
87
  registration: boolean;
88
- /** Supports password reset flow. */
88
+ /**
89
+ * Supports the end-user password reset flow (emailing a reset link).
90
+ *
91
+ * This is about *self-service* reset, so it is typically tied to whether an
92
+ * email service is configured. It says nothing about whether an admin can
93
+ * reset someone else's password — see `adminPasswordReset`.
94
+ */
89
95
  passwordReset: boolean;
96
+ /**
97
+ * Whether the adapter exposes `POST /admin/users/:userId/reset-password`,
98
+ * letting an admin reset another user's password.
99
+ *
100
+ * Independent of `passwordReset`: the built-in adapter supports this even
101
+ * with no email service configured (it returns a one-time temporary
102
+ * password instead of sending a link). Adapters that mount their own admin
103
+ * routes must set this to `true` only once that route actually exists —
104
+ * the admin UI hides the "Reset Password" action when it is `false`.
105
+ */
106
+ adminPasswordReset: boolean;
90
107
  /** Supports session listing/revocation. */
91
108
  sessionManagement: boolean;
92
109
  /** Supports profile updates (display name, photo). */
@@ -218,6 +235,11 @@ export interface UserCreationFinalizeResult {
218
235
  temporaryPassword?: string;
219
236
  /** Whether an invitation email was sent. */
220
237
  invitationSent: boolean;
238
+ /**
239
+ * Whether an email service was configured but delivery failed, causing the
240
+ * fallback to `temporaryPassword`. Absent when no email service is configured.
241
+ */
242
+ emailDeliveryFailed?: boolean;
221
243
  }
222
244
 
223
245
  // ─── Auth Response Transform ─────────────────────────────────────────────────
@@ -237,6 +259,9 @@ export interface AuthResponsePayload {
237
259
  email: string;
238
260
  displayName: string | null;
239
261
  photoURL: string | null;
262
+ providerId?: string;
263
+ isAnonymous?: boolean;
264
+ emailVerified?: boolean;
240
265
  roles: string[];
241
266
  metadata: Record<string, unknown>;
242
267
  };
@@ -295,7 +320,7 @@ export interface AuthAdapter {
295
320
  /**
296
321
  * Verify an incoming request and extract the authenticated user.
297
322
  *
298
- * This replaces the hardcoded JWT verification in server-core's middleware.
323
+ * This replaces the hardcoded JWT verification in server's middleware.
299
324
  * Each adapter implements its own token verification strategy:
300
325
  * - Built-in: verify Rebase JWT
301
326
  * - Clerk: call Clerk's `verifyToken()`
@@ -393,7 +418,7 @@ export interface AuthAdapter {
393
418
  *
394
419
  * @param values - Raw request body from the client.
395
420
  * @param collectionAuth - The parsed `AuthCollectionConfig` from the collection (if `auth` is an object).
396
- * @returns Processed values ready for `driver.saveEntity()`, plus metadata for the post-save step.
421
+ * @returns Processed values ready for `driver.save()`, plus metadata for the post-save step.
397
422
  */
398
423
  prepareUserCreation?(
399
424
  values: Record<string, unknown>,
@@ -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
  // =============================================================================
6
6
  // DATABASE CONNECTION INTERFACES
@@ -52,7 +52,7 @@ export interface FetchCollectionOptions<M extends Record<string, unknown> = Reco
52
52
  startAfter?: unknown;
53
53
  searchString?: string;
54
54
  databaseId?: string;
55
- collection?: EntityCollection;
55
+ collection?: CollectionConfig;
56
56
  }
57
57
 
58
58
  /**
@@ -64,7 +64,7 @@ export interface SearchOptions<M extends Record<string, unknown> = Record<string
64
64
  order?: "desc" | "asc";
65
65
  limit?: number;
66
66
  databaseId?: string;
67
- collection?: EntityCollection;
67
+ collection?: CollectionConfig;
68
68
  }
69
69
 
70
70
  /**
@@ -150,15 +150,15 @@ export type ConditionBuilderStatic<T = unknown> = {
150
150
  * - Relation resolution
151
151
  * - ID generation and conversion
152
152
  */
153
- export interface EntityRepository {
153
+ export interface DataRepository {
154
154
  /**
155
155
  * Fetch a single entity by ID
156
156
  */
157
- fetchEntity<M extends Record<string, unknown>>(
157
+ fetchOne<M extends Record<string, unknown>>(
158
158
  collectionPath: string,
159
- entityId: string | number,
159
+ id: string | number,
160
160
  databaseId?: string
161
- ): Promise<Entity<M> | undefined>;
161
+ ): Promise<Record<string, unknown> | undefined>;
162
162
 
163
163
  /**
164
164
  * Fetch a collection of entities with optional filtering, ordering, and pagination
@@ -166,41 +166,41 @@ export interface EntityRepository {
166
166
  fetchCollection<M extends Record<string, unknown>>(
167
167
  collectionPath: string,
168
168
  options?: FetchCollectionOptions<M>
169
- ): Promise<Entity<M>[]>;
169
+ ): Promise<Record<string, unknown>[]>;
170
170
 
171
171
  /**
172
172
  * Search entities by text
173
173
  */
174
- searchEntities<M extends Record<string, unknown>>(
174
+ searchRows<M extends Record<string, unknown>>(
175
175
  collectionPath: string,
176
176
  searchString: string,
177
177
  options?: SearchOptions<M>
178
- ): Promise<Entity<M>[]>;
178
+ ): Promise<Record<string, unknown>[]>;
179
179
 
180
180
  /**
181
181
  * Count entities in a collection
182
182
  */
183
- countEntities<M extends Record<string, unknown>>(
183
+ count<M extends Record<string, unknown>>(
184
184
  collectionPath: string,
185
185
  options?: CountOptions<M>
186
186
  ): Promise<number>;
187
187
 
188
188
  /**
189
- * Save an entity (create or update)
189
+ * Save a entity (create or update)
190
190
  */
191
- saveEntity<M extends Record<string, unknown>>(
191
+ save<M extends Record<string, unknown>>(
192
192
  collectionPath: string,
193
193
  values: Partial<M>,
194
- entityId?: string | number,
194
+ id?: string | number,
195
195
  databaseId?: string
196
- ): Promise<Entity<M>>;
196
+ ): Promise<Record<string, unknown>>;
197
197
 
198
198
  /**
199
- * Delete an entity by ID
199
+ * Delete a entity by ID
200
200
  */
201
- deleteEntity(
201
+ delete(
202
202
  collectionPath: string,
203
- entityId: string | number,
203
+ id: string | number,
204
204
  databaseId?: string
205
205
  ): Promise<void>;
206
206
 
@@ -239,10 +239,10 @@ export interface CollectionSubscriptionConfig {
239
239
  /**
240
240
  * Configuration for subscribing to a single entity
241
241
  */
242
- export interface EntitySubscriptionConfig {
242
+ export interface SingleSubscriptionConfig {
243
243
  clientId: string;
244
244
  path: string;
245
- entityId: string | number;
245
+ id: string | number;
246
246
  }
247
247
 
248
248
  /**
@@ -256,16 +256,16 @@ export interface RealtimeProvider {
256
256
  subscribeToCollection(
257
257
  subscriptionId: string,
258
258
  config: CollectionSubscriptionConfig,
259
- callback?: (entities: Entity[]) => void
259
+ callback?: (rows: Record<string, unknown>[]) => void
260
260
  ): void;
261
261
 
262
262
  /**
263
263
  * Subscribe to single entity changes
264
264
  */
265
- subscribeToEntity(
265
+ subscribeToOne(
266
266
  subscriptionId: string,
267
- config: EntitySubscriptionConfig,
268
- callback?: (entity: Entity | null) => void
267
+ config: SingleSubscriptionConfig,
268
+ callback?: (row: Record<string, unknown> | null) => void
269
269
  ): void;
270
270
 
271
271
  /**
@@ -274,12 +274,12 @@ export interface RealtimeProvider {
274
274
  unsubscribe(subscriptionId: string): void;
275
275
 
276
276
  /**
277
- * Notify all relevant subscribers of an entity update
277
+ * Notify all relevant subscribers of a entity update
278
278
  */
279
- notifyEntityUpdate(
279
+ notifyUpdate(
280
280
  path: string,
281
- entityId: string,
282
- entity: Entity | null,
281
+ id: string,
282
+ row: Record<string, unknown> | null,
283
283
  databaseId?: string
284
284
  ): Promise<void>;
285
285
 
@@ -314,17 +314,17 @@ export interface CollectionRegistryInterface {
314
314
  /**
315
315
  * Register a collection
316
316
  */
317
- register(collection: EntityCollection): void;
317
+ register(collection: CollectionConfig): void;
318
318
 
319
319
  /**
320
320
  * Get a collection by its path
321
321
  */
322
- getCollectionByPath(path: string): EntityCollection | undefined;
322
+ getCollectionByPath(path: string): CollectionConfig | undefined;
323
323
 
324
324
  /**
325
325
  * Get all registered collections
326
326
  */
327
- getCollections(): EntityCollection[];
327
+ getCollections(): CollectionConfig[];
328
328
 
329
329
  /**
330
330
  * Get the currently registered global callbacks, if any.
@@ -346,7 +346,7 @@ export interface DataTransformer {
346
346
  */
347
347
  serializeToDatabase<M extends Record<string, unknown>>(
348
348
  entity: M,
349
- collection: EntityCollection
349
+ collection: CollectionConfig
350
350
  ): Record<string, unknown>;
351
351
 
352
352
  /**
@@ -354,7 +354,7 @@ export interface DataTransformer {
354
354
  */
355
355
  deserializeFromDatabase<M extends Record<string, unknown>>(
356
356
  data: Record<string, unknown>,
357
- collection: EntityCollection
357
+ collection: CollectionConfig
358
358
  ): Promise<M>;
359
359
  }
360
360
 
@@ -589,7 +589,7 @@ export interface BackendInstance extends BackendLifecycle {
589
589
  /**
590
590
  * Entity repository for CRUD operations
591
591
  */
592
- entityRepository: EntityRepository;
592
+ entityRepository: DataRepository;
593
593
 
594
594
  /**
595
595
  * Realtime provider for subscriptions
@@ -697,7 +697,7 @@ export interface BackendBootstrapper {
697
697
  * Initialize history tables / services if this driver supports them.
698
698
  * Return undefined if history is not supported by this backend.
699
699
  */
700
- initializeHistory?(config: unknown, driverResult: InitializedDriver): Promise<{ historyService: unknown } | undefined>;
700
+ initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{ historyService: unknown } | undefined>;
701
701
 
702
702
  /**
703
703
  * Create a realtime provider for this driver.
@@ -736,6 +736,14 @@ export interface InitializedDriver {
736
736
  /** A collection registry to register schema / tables into. */
737
737
  collectionRegistry?: CollectionRegistryInterface;
738
738
 
739
+ /**
740
+ * Collections the driver derived from the live database schema.
741
+ *
742
+ * Set by drivers that introspect in `baas` mode; the server serves these
743
+ * instead of collections loaded from config files.
744
+ */
745
+ collections?: import("./collections").CollectionConfig[];
746
+
739
747
  /** The underlying database connection (for lifecycle management). */
740
748
  connection?: DatabaseConnection;
741
749
 
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Backup type definitions shared across server, client, and studio.
3
+ */
4
+
5
+ /** Where a backup lives — a local path or an object-storage bucket. */
6
+ export type BackupDestinationKind = "local" | "s3" | "gcs";
7
+
8
+ /**
9
+ * A single backup as surfaced by the admin API / Studio Backups panel.
10
+ */
11
+ export interface BackupInfo {
12
+ /** Storage key (object storage) or absolute file path (local). */
13
+ key: string;
14
+
15
+ /** Display name — the file's basename. */
16
+ name: string;
17
+
18
+ /** Size in bytes, when known. */
19
+ sizeBytes?: number;
20
+
21
+ /** ISO timestamp the backup was created, when recoverable. */
22
+ createdAt?: string;
23
+
24
+ /** The kind of destination this backup was read from. */
25
+ destinationKind: BackupDestinationKind;
26
+ }
@@ -1,10 +1,10 @@
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
6
 
7
- export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollection> = (params: {
7
+ export type CollectionConfigsBuilder<EC extends CollectionConfig = CollectionConfig> = (params: {
8
8
  user: User | null,
9
9
  authController: AuthController,
10
10
  data: RebaseData