@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
@@ -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
  */
@@ -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({
@@ -77,8 +77,25 @@ export interface AuthAdapterCapabilities {
77
77
  emailPasswordLogin: boolean;
78
78
  /** Supports new user registration. */
79
79
  registration: boolean;
80
- /** Supports password reset flow. */
80
+ /**
81
+ * Supports the end-user password reset flow (emailing a reset link).
82
+ *
83
+ * This is about *self-service* reset, so it is typically tied to whether an
84
+ * email service is configured. It says nothing about whether an admin can
85
+ * reset someone else's password — see `adminPasswordReset`.
86
+ */
81
87
  passwordReset: boolean;
88
+ /**
89
+ * Whether the adapter exposes `POST /admin/users/:userId/reset-password`,
90
+ * letting an admin reset another user's password.
91
+ *
92
+ * Independent of `passwordReset`: the built-in adapter supports this even
93
+ * with no email service configured (it returns a one-time temporary
94
+ * password instead of sending a link). Adapters that mount their own admin
95
+ * routes must set this to `true` only once that route actually exists —
96
+ * the admin UI hides the "Reset Password" action when it is `false`.
97
+ */
98
+ adminPasswordReset: boolean;
82
99
  /** Supports session listing/revocation. */
83
100
  sessionManagement: boolean;
84
101
  /** Supports profile updates (display name, photo). */
@@ -196,6 +213,11 @@ export interface UserCreationFinalizeResult {
196
213
  temporaryPassword?: string;
197
214
  /** Whether an invitation email was sent. */
198
215
  invitationSent: boolean;
216
+ /**
217
+ * Whether an email service was configured but delivery failed, causing the
218
+ * fallback to `temporaryPassword`. Absent when no email service is configured.
219
+ */
220
+ emailDeliveryFailed?: boolean;
199
221
  }
200
222
  /**
201
223
  * The auth response payload shape that flows through `transformAuthResponse`.
@@ -212,6 +234,9 @@ export interface AuthResponsePayload {
212
234
  email: string;
213
235
  displayName: string | null;
214
236
  photoURL: string | null;
237
+ providerId?: string;
238
+ isAnonymous?: boolean;
239
+ emailVerified?: boolean;
215
240
  roles: string[];
216
241
  metadata: Record<string, unknown>;
217
242
  };
@@ -263,7 +288,7 @@ export interface AuthAdapter {
263
288
  /**
264
289
  * Verify an incoming request and extract the authenticated user.
265
290
  *
266
- * This replaces the hardcoded JWT verification in server-core's middleware.
291
+ * This replaces the hardcoded JWT verification in server's middleware.
267
292
  * Each adapter implements its own token verification strategy:
268
293
  * - Built-in: verify Rebase JWT
269
294
  * - Clerk: call Clerk's `verifyToken()`
@@ -343,7 +368,7 @@ export interface AuthAdapter {
343
368
  *
344
369
  * @param values - Raw request body from the client.
345
370
  * @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.
371
+ * @returns Processed values ready for `driver.save()`, plus metadata for the post-save step.
347
372
  */
348
373
  prepareUserCreation?(values: Record<string, unknown>, collectionAuth?: unknown): Promise<UserCreationPrepareResult>;
349
374
  /**
@@ -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
  /**
@@ -551,6 +551,13 @@ export interface InitializedDriver {
551
551
  realtimeProvider?: RealtimeProvider;
552
552
  /** A collection registry to register schema / tables into. */
553
553
  collectionRegistry?: CollectionRegistryInterface;
554
+ /**
555
+ * Collections the driver derived from the live database schema.
556
+ *
557
+ * Set by drivers that introspect in `baas` mode; the server serves these
558
+ * instead of collections loaded from config files.
559
+ */
560
+ collections?: import("./collections").CollectionConfig[];
554
561
  /** The underlying database connection (for lifecycle management). */
555
562
  connection?: DatabaseConnection;
556
563
  /**
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Backup type definitions shared across server, client, and studio.
3
+ */
4
+ /** Where a backup lives — a local path or an object-storage bucket. */
5
+ export type BackupDestinationKind = "local" | "s3" | "gcs";
6
+ /**
7
+ * A single backup as surfaced by the admin API / Studio Backups panel.
8
+ */
9
+ export interface BackupInfo {
10
+ /** Storage key (object storage) or absolute file path (local). */
11
+ key: string;
12
+ /** Display name — the file's basename. */
13
+ name: string;
14
+ /** Size in bytes, when known. */
15
+ sizeBytes?: number;
16
+ /** ISO timestamp the backup was created, when recoverable. */
17
+ createdAt?: string;
18
+ /** The kind of destination this backup was read from. */
19
+ destinationKind: BackupDestinationKind;
20
+ }
@@ -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;