@rebasepro/types 0.7.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 (88) hide show
  1. package/README.md +10 -10
  2. package/dist/controllers/auth.d.ts +1 -1
  3. package/dist/controllers/client.d.ts +237 -7
  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 +285 -81
  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 -6
  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 +290 -16
  17. package/dist/index.es.js.map +1 -1
  18. package/dist/index.umd.js +305 -18
  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 +9 -6
  22. package/dist/types/backend.d.ts +30 -26
  23. package/dist/types/builders.d.ts +2 -2
  24. package/dist/types/collections.d.ts +211 -136
  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 +18 -5
  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 +55 -43
  32. package/dist/types/entity_views.d.ts +3 -3
  33. package/dist/types/filter-operators.d.ts +153 -0
  34. package/dist/types/index.d.ts +3 -2
  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 +191 -0
  38. package/dist/types/properties.d.ts +153 -43
  39. package/dist/types/property_config.d.ts +1 -1
  40. package/dist/types/relations.d.ts +3 -3
  41. package/dist/types/slots.d.ts +14 -14
  42. package/dist/types/storage_source.d.ts +83 -0
  43. package/dist/types/websockets.d.ts +12 -13
  44. package/dist/users/user.d.ts +21 -9
  45. package/package.json +1 -1
  46. package/src/controllers/auth.tsx +1 -1
  47. package/src/controllers/client.ts +275 -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 +309 -97
  51. package/src/controllers/data_driver.ts +49 -40
  52. package/src/controllers/index.ts +1 -1
  53. package/src/controllers/local_config_persistence.tsx +4 -4
  54. package/src/controllers/navigation.ts +2 -2
  55. package/src/controllers/registry.ts +18 -6
  56. package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
  57. package/src/controllers/storage.ts +60 -1
  58. package/src/errors.ts +80 -0
  59. package/src/index.ts +1 -0
  60. package/src/rebase_context.tsx +8 -4
  61. package/src/types/auth_adapter.ts +9 -6
  62. package/src/types/backend.ts +41 -36
  63. package/src/types/builders.ts +2 -2
  64. package/src/types/collections.ts +256 -172
  65. package/src/types/component_overrides.ts +72 -5
  66. package/src/types/cron.ts +10 -1
  67. package/src/types/data_source.ts +29 -7
  68. package/src/types/database_adapter.ts +4 -3
  69. package/src/types/entities.ts +7 -7
  70. package/src/types/entity_actions.tsx +7 -7
  71. package/src/types/entity_callbacks.ts +58 -47
  72. package/src/types/entity_views.tsx +3 -3
  73. package/src/types/filter-operators.ts +240 -0
  74. package/src/types/index.ts +3 -2
  75. package/src/types/modify_collections.tsx +2 -2
  76. package/src/types/plugins.tsx +9 -9
  77. package/src/types/policy.ts +229 -0
  78. package/src/types/properties.ts +164 -44
  79. package/src/types/property_config.tsx +0 -1
  80. package/src/types/relations.ts +3 -3
  81. package/src/types/slots.tsx +14 -14
  82. package/src/types/storage_source.ts +90 -0
  83. package/src/types/websockets.ts +12 -14
  84. package/src/users/user.ts +22 -9
  85. package/dist/types/backend_hooks.d.ts +0 -109
  86. package/dist/types/entity_overrides.d.ts +0 -10
  87. package/src/types/backend_hooks.ts +0 -114
  88. package/src/types/entity_overrides.tsx +0 -11
@@ -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,22 @@ 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
+
329
+ /**
330
+ * Get the currently registered global callbacks, if any.
331
+ */
332
+ getGlobalCallbacks(): any | undefined;
328
333
  }
329
334
 
330
335
  // =============================================================================
@@ -341,7 +346,7 @@ export interface DataTransformer {
341
346
  */
342
347
  serializeToDatabase<M extends Record<string, unknown>>(
343
348
  entity: M,
344
- collection: EntityCollection
349
+ collection: CollectionConfig
345
350
  ): Record<string, unknown>;
346
351
 
347
352
  /**
@@ -349,7 +354,7 @@ export interface DataTransformer {
349
354
  */
350
355
  deserializeFromDatabase<M extends Record<string, unknown>>(
351
356
  data: Record<string, unknown>,
352
- collection: EntityCollection
357
+ collection: CollectionConfig
353
358
  ): Promise<M>;
354
359
  }
355
360
 
@@ -584,7 +589,7 @@ export interface BackendInstance extends BackendLifecycle {
584
589
  /**
585
590
  * Entity repository for CRUD operations
586
591
  */
587
- entityRepository: EntityRepository;
592
+ entityRepository: DataRepository;
588
593
 
589
594
  /**
590
595
  * Realtime provider for subscriptions
@@ -692,7 +697,7 @@ export interface BackendBootstrapper {
692
697
  * Initialize history tables / services if this driver supports them.
693
698
  * Return undefined if history is not supported by this backend.
694
699
  */
695
- initializeHistory?(config: unknown, driverResult: InitializedDriver): Promise<{ historyService: unknown } | undefined>;
700
+ initializeHistory?(config: HistoryConfig, driverResult: InitializedDriver): Promise<{ historyService: unknown } | undefined>;
696
701
 
697
702
  /**
698
703
  * Create a realtime provider for this driver.
@@ -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