@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,10 +1,10 @@
1
1
  import type { ComponentRef } from "./component_ref";
2
2
  import type { Entity, EntityReference, EntityRelation, EntityValues, GeoPoint, Vector } from "./entities";
3
3
  import type { JoinStep, OnAction, Relation } from "./relations";
4
- import type { EntityCollection, FilterValues } from "./collections";
4
+ import type { CollectionConfig, FilterValues, WhereFilterOp } from "./collections";
5
5
  import type { ColorKey, ColorScheme } from "./chips";
6
6
  import type { AuthController } from "../controllers/auth";
7
- import type { EntityAfterReadProps, EntityBeforeSaveProps } from "./entity_callbacks";
7
+ import type { AfterReadProps, BeforeSaveProps } from "./entity_callbacks";
8
8
  import type { User } from "../users";
9
9
  /**
10
10
  * Callbacks/Hooks for individual property fields
@@ -14,7 +14,7 @@ export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = R
14
14
  /**
15
15
  * Callback used after fetching data, to transform the value before rendering
16
16
  */
17
- afterRead?(props: Omit<EntityAfterReadProps<M, USER>, "entity"> & {
17
+ afterRead?(props: Omit<AfterReadProps<M, USER>, "entity"> & {
18
18
  value: T;
19
19
  entity: Entity<M> | undefined;
20
20
  }): Promise<T> | T;
@@ -22,7 +22,7 @@ export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = R
22
22
  * Callback used before saving, after validation.
23
23
  * You can modify the value before it's saved.
24
24
  */
25
- beforeSave?(props: Omit<EntityBeforeSaveProps<M, USER>, "values"> & {
25
+ beforeSave?(props: Omit<BeforeSaveProps<M, USER>, "values"> & {
26
26
  value: T;
27
27
  previousValue: T | undefined;
28
28
  values: Partial<M>;
@@ -44,6 +44,16 @@ export type FirebaseProperty = Exclude<Property, RelationProperty>;
44
44
  export type FirebaseProperties = {
45
45
  [key: string]: FirebaseProperty;
46
46
  };
47
+ export type MongoProperty = Exclude<Property, RelationProperty>;
48
+ export type MongoProperties = {
49
+ [key: string]: MongoProperty;
50
+ };
51
+ /**
52
+ * Union of all engine-specific property maps. Use this at engine-agnostic
53
+ * boundaries (collection editor, normalization) where the concrete engine is
54
+ * unknown but the narrowed property constraint must be satisfied.
55
+ */
56
+ export type EngineProperties = PostgresProperties | FirebaseProperties | MongoProperties;
47
57
  /**
48
58
  * A helper type to infer the underlying data type from a Property definition.
49
59
  * This is the core of the type inference system.
@@ -106,6 +116,31 @@ export interface BaseUIConfig<CustomProps = unknown> {
106
116
  customProps?: CustomProps;
107
117
  Field?: ComponentRef<any>;
108
118
  Preview?: ComponentRef<any>;
119
+ /**
120
+ * Narrow the filter operators offered for this property in collection
121
+ * filter UIs (table header filters and the Filters dialog).
122
+ *
123
+ * The final offered set is the **intersection** of the engine's
124
+ * capabilities, the property-type defaults, and this list — you can only
125
+ * *restrict*, never enable an operator the underlying engine cannot run.
126
+ *
127
+ * Pass an empty array to disable filtering on this property entirely.
128
+ *
129
+ * @example
130
+ * // Email column: exact match, contains, and null check only
131
+ * ui: { filterOperators: ["==", "ilike", "is-null"] }
132
+ */
133
+ filterOperators?: readonly WhereFilterOp[];
134
+ /**
135
+ * Replace the filter field rendered for this property in collection
136
+ * filter UIs. The component receives `FilterFieldBindingProps`
137
+ * (property, resolved `operators`, `value`, `setValue`, …).
138
+ *
139
+ * Takes precedence over the collection-level
140
+ * `components["Collection.FilterField"]` override and the built-in
141
+ * per-type filter fields.
142
+ */
143
+ Filter?: ComponentRef<any>;
109
144
  }
110
145
  export interface BaseProperty<CustomProps = unknown> {
111
146
  ui?: BaseUIConfig<CustomProps>;
@@ -140,10 +175,6 @@ export interface BaseProperty<CustomProps = unknown> {
140
175
  * Rules for validating this property
141
176
  */
142
177
  validation?: PropertyValidationSchema;
143
- /**
144
- * This value will be set by default for new entities.
145
- */
146
- defaultValue?: unknown;
147
178
  /**
148
179
  * Use this to define dynamic properties that change based on certain conditions
149
180
  * or on the entity's values. For example, you can make a field read-only if
@@ -179,15 +210,36 @@ export interface BaseProperty<CustomProps = unknown> {
179
210
  * @group Entity properties
180
211
  */
181
212
  export interface StringUIConfig extends BaseUIConfig {
213
+ /**
214
+ * Is this string property long enough so it should be displayed in
215
+ * a multiple line field. Defaults to false. If set to true,
216
+ * the number of lines adapts to the content
217
+ */
182
218
  multiline?: boolean;
219
+ /**
220
+ * Should this string property be displayed as a markdown field. If true,
221
+ * the field is rendered as a text editor that supports markdown highlight
222
+ * syntax. It also includes a preview of the result.
223
+ */
183
224
  markdown?: boolean;
225
+ /**
226
+ * Should this string be rendered as a tag instead of just text.
227
+ */
184
228
  previewAsTag?: boolean;
185
229
  clearable?: boolean;
230
+ /**
231
+ * If the value of this property is a URL, you can set this flag to true
232
+ * to add a link, or one of the supported media types to render a preview
233
+ */
186
234
  url?: boolean | PreviewType;
187
235
  }
188
236
  export interface StringProperty extends BaseProperty {
189
237
  ui?: StringUIConfig;
190
238
  type: "string";
239
+ /**
240
+ * Default value for new entities. Must be a string.
241
+ */
242
+ defaultValue?: string;
191
243
  /**
192
244
  * Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
193
245
  * Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
@@ -222,18 +274,6 @@ export interface StringProperty extends BaseProperty {
222
274
  *
223
275
  */
224
276
  enum?: EnumValues;
225
- /**
226
- * Is this string property long enough so it should be displayed in
227
- * a multiple line field. Defaults to false. If set to true,
228
- * the number of lines adapts to the content
229
- */
230
- multiline?: boolean;
231
- /**
232
- * Should this string property be displayed as a markdown field. If true,
233
- * the field is rendered as a text editors that supports markdown highlight
234
- * syntax. It also includes a preview of the result.
235
- */
236
- markdown?: boolean;
237
277
  /**
238
278
  * You can specify a `Storage` configuration. It is used to
239
279
  * indicate that this string refers to a path in your storage provider.
@@ -243,31 +283,15 @@ export interface StringProperty extends BaseProperty {
243
283
  * This property is used to indicate that the string is a user ID, and
244
284
  * it will be rendered as a user picker.
245
285
  * Note that the user ID needs to be the one used in your authentication
246
- * provider, e.g. Firebase Auth.
286
+ * provider (e.g. the ID in your `users` table).
247
287
  * You can also use a property builder to specify the user path dynamically
248
288
  * based on other values of the entity.
249
289
  */
250
290
  userSelect?: boolean;
251
- /**
252
- * If the value of this property is a URL, you can set this flag to true
253
- * to add a link, or one of the supported media types to render a preview
254
- */
255
- url?: boolean | PreviewType;
256
291
  /**
257
292
  * Does this field include an email
258
293
  */
259
294
  email?: boolean;
260
- /**
261
- * Should this string be rendered as a tag instead of just text.
262
- */
263
- previewAsTag?: boolean;
264
- /**
265
- * You can use this property (a string) to behave as a reference to another
266
- * collection. The stored value is the ID of the entity in the
267
- * collection, and the `path` prop is used to
268
- * define the collection this reference points to.
269
- */
270
- reference?: ReferenceProperty;
271
295
  }
272
296
  /**
273
297
  * @group Entity properties
@@ -278,6 +302,10 @@ export interface NumberUIConfig extends BaseUIConfig {
278
302
  export interface NumberProperty extends BaseProperty {
279
303
  ui?: NumberUIConfig;
280
304
  type: "number";
305
+ /**
306
+ * Default value for new entities. Must be a number.
307
+ */
308
+ defaultValue?: number;
281
309
  /**
282
310
  * Optional database column type. Allows specifying exact database numeric types.
283
311
  * If not provided, integer fields (where validation.integer is true or isId is true) default to `integer`, others to `numeric`.
@@ -311,6 +339,10 @@ export interface NumberProperty extends BaseProperty {
311
339
  export interface BooleanProperty extends BaseProperty {
312
340
  ui?: BaseUIConfig;
313
341
  type: "boolean";
342
+ /**
343
+ * Default value for new entities. Must be a boolean.
344
+ */
345
+ defaultValue?: boolean;
314
346
  /**
315
347
  * Rules for validating this property
316
348
  */
@@ -325,6 +357,10 @@ export interface VectorUIConfig extends BaseUIConfig {
325
357
  export interface VectorProperty extends BaseProperty {
326
358
  ui?: VectorUIConfig;
327
359
  type: "vector";
360
+ /**
361
+ * Default value for new entities.
362
+ */
363
+ defaultValue?: Vector;
328
364
  dimensions: number;
329
365
  validation?: PropertyValidationSchema;
330
366
  }
@@ -333,17 +369,28 @@ export interface VectorProperty extends BaseProperty {
333
369
  */
334
370
  export interface BinaryProperty extends BaseProperty {
335
371
  type: "binary";
372
+ /**
373
+ * Default value for new entities. Must be a base64-encoded string.
374
+ */
375
+ defaultValue?: string;
336
376
  validation?: PropertyValidationSchema;
337
377
  }
338
378
  /**
339
379
  * @group Entity properties
340
380
  */
341
381
  export interface DateUIConfig extends BaseUIConfig {
382
+ /**
383
+ * Add an icon to clear the value and set it to `null`. Defaults to `false`
384
+ */
342
385
  clearable?: boolean;
343
386
  }
344
387
  export interface DateProperty extends BaseProperty {
345
388
  ui?: DateUIConfig;
346
389
  type: "date";
390
+ /**
391
+ * Default value for new entities. Must be a Date.
392
+ */
393
+ defaultValue?: Date;
347
394
  /**
348
395
  * Optional database column type. If not set, defaults to `timestamp` with timezone.
349
396
  */
@@ -369,10 +416,6 @@ export interface DateProperty extends BaseProperty {
369
416
  * `updated_on` fields
370
417
  */
371
418
  autoValue?: "on_create" | "on_update";
372
- /**
373
- * Add an icon to clear the value and set it to `null`. Defaults to `false`
374
- */
375
- clearable?: boolean;
376
419
  }
377
420
  /**
378
421
  * @group Entity properties
@@ -380,6 +423,10 @@ export interface DateProperty extends BaseProperty {
380
423
  export interface GeopointProperty extends BaseProperty {
381
424
  ui?: BaseUIConfig;
382
425
  type: "geopoint";
426
+ /**
427
+ * Default value for new entities. Must be a GeoPoint.
428
+ */
429
+ defaultValue?: GeoPoint;
383
430
  /**
384
431
  * Rules for validating this property
385
432
  */
@@ -391,9 +438,29 @@ export interface GeopointProperty extends BaseProperty {
391
438
  export interface ReferenceUIConfig extends BaseUIConfig {
392
439
  previewProperties?: string[];
393
440
  }
441
+ /**
442
+ * A pointer to a entity, stored **as a value** on the row (id + path, and
443
+ * optionally a `driver`/`databaseId` for cross-datasource pointers).
444
+ *
445
+ * This is the native primitive of **document databases** — it maps 1:1 to a
446
+ * Firestore `DocumentReference`, and is persisted by the MongoDB driver as a
447
+ * tagged sub-document. It carries no schema-level relationship (no foreign key,
448
+ * no join, no cascade) and is resolved on demand.
449
+ *
450
+ * **Which to use:**
451
+ * - Firestore / MongoDB collection → use `reference`.
452
+ * - Postgres collection → use {@link RelationProperty} (`type: "relation"`),
453
+ * which models a real foreign key / join with prefetch and cascade.
454
+ *
455
+ * @group Entity properties
456
+ */
394
457
  export interface ReferenceProperty extends BaseProperty {
395
458
  ui?: ReferenceUIConfig;
396
459
  type: "reference";
460
+ /**
461
+ * Default value for new entities. Must be a EntityReference.
462
+ */
463
+ defaultValue?: EntityReference;
397
464
  /**
398
465
  * Marks this field as a Primary Key / Unique Identifier.
399
466
  * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
@@ -432,9 +499,29 @@ export interface RelationUIConfig extends BaseUIConfig {
432
499
  previewProperties?: string[];
433
500
  widget?: "select" | "dialog";
434
501
  }
502
+ /**
503
+ * A schema-level relationship between collections **within a single
504
+ * datasource** — backed by a foreign key, junction table, or explicit join
505
+ * path. The resolved value (an `EntityRelation`) can carry a prefetched entity
506
+ * payload to eliminate N+1 queries, and supports `onUpdate`/`onDelete` cascade.
507
+ *
508
+ * This is the native primitive of **relational databases** (Postgres). It is
509
+ * the SQL counterpart to {@link ReferenceProperty}.
510
+ *
511
+ * **Which to use:**
512
+ * - Postgres collection → use `relation`.
513
+ * - Firestore / MongoDB collection → use {@link ReferenceProperty}
514
+ * (`type: "reference"`), a stored pointer with no join engine.
515
+ *
516
+ * @group Entity properties
517
+ */
435
518
  export interface RelationProperty extends BaseProperty {
436
519
  ui?: RelationUIConfig;
437
520
  type: "relation";
521
+ /**
522
+ * Default value for new entities. Must be a EntityRelation or array of EntityRelation.
523
+ */
524
+ defaultValue?: EntityRelation | EntityRelation[];
438
525
  /**
439
526
  * Marks this field as a Primary Key / Unique Identifier.
440
527
  * Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
@@ -447,7 +534,7 @@ export interface RelationProperty extends BaseProperty {
447
534
  * When set, the framework treats this property as a self-contained relation
448
535
  * definition and no separate `relations[]` entry is needed.
449
536
  */
450
- target?: string | (() => EntityCollection | string);
537
+ target?: string | (() => CollectionConfig | string);
451
538
  /**
452
539
  * Whether this property references one or many records.
453
540
  * Defaults to `"one"`.
@@ -505,7 +592,7 @@ export interface RelationProperty extends BaseProperty {
505
592
  /**
506
593
  * Overrides applied to the target collection when rendered as a subcollection tab.
507
594
  */
508
- overrides?: Partial<EntityCollection>;
595
+ overrides?: Partial<CollectionConfig>;
509
596
  /**
510
597
  * Optional name for this relation. Defaults to the property key at runtime.
511
598
  * Only needed when the relation name should differ from the property key,
@@ -547,6 +634,10 @@ export interface ArrayUIConfig extends BaseUIConfig {
547
634
  export interface ArrayProperty extends BaseProperty {
548
635
  ui?: ArrayUIConfig;
549
636
  type: "array";
637
+ /**
638
+ * Default value for new entities. Must be an array.
639
+ */
640
+ defaultValue?: unknown[];
550
641
  /**
551
642
  * Optional database column type. By default, maps to a native Postgres array
552
643
  * (e.g. `text[]`, `integer[]`/`numeric[]`, `boolean[]`) if the element type
@@ -624,6 +715,10 @@ export interface MapUIConfig extends BaseUIConfig {
624
715
  export interface MapProperty extends BaseProperty {
625
716
  ui?: MapUIConfig;
626
717
  type: "map";
718
+ /**
719
+ * Default value for new entities. Must be a record/object.
720
+ */
721
+ defaultValue?: Record<string, unknown>;
627
722
  /**
628
723
  * Optional database column type. Defaults to `jsonb`.
629
724
  */
@@ -801,6 +896,21 @@ export interface ArrayPropertyValidationSchema extends PropertyValidationSchema
801
896
  * @group Entity properties
802
897
  */
803
898
  export type StorageConfig = {
899
+ /**
900
+ * Key referencing a named storage backend from the StorageRegistry.
901
+ * Must match a `StorageSourceDefinition.key` or a key registered
902
+ * in `initializeRebaseBackend({ storage: { ... } })`.
903
+ *
904
+ * When omitted, the default storage source is used.
905
+ */
906
+ storageSource?: string;
907
+ /**
908
+ * Store files for this property as **public**: they are placed under the
909
+ * public prefix and served via stable, token-less, permanent, CDN-cacheable
910
+ * URLs (safe to persist and hotlink). Use for public assets like avatars or
911
+ * storefront images. Defaults to `false` (private, short-lived signed URLs).
912
+ */
913
+ public?: boolean;
804
914
  /**
805
915
  * File MIME types that can be uploaded to this reference. Don't specify for
806
916
  * all.
@@ -70,5 +70,5 @@ export type PropertyConfig = {
70
70
  */
71
71
  description?: string;
72
72
  };
73
- export type PropertyConfigId = "text_field" | "multiline" | "markdown" | "url" | "email" | "user_select" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference" | "reference_as_string" | "multi_references" | "relation" | "switch" | "date_time" | "repeat" | "custom_array" | "block" | "vector_input";
73
+ export type PropertyConfigId = "text_field" | "multiline" | "markdown" | "url" | "email" | "user_select" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference" | "multi_references" | "relation" | "switch" | "date_time" | "repeat" | "custom_array" | "block" | "vector_input";
74
74
  export {};
@@ -1,4 +1,4 @@
1
- import type { EntityCollection } from "./collections";
1
+ import type { CollectionConfig } from "./collections";
2
2
  /**
3
3
  * @group Models
4
4
  */
@@ -17,7 +17,7 @@ export interface Relation {
17
17
  /**
18
18
  * The final collection you want to retrieve records from.
19
19
  */
20
- target: (() => EntityCollection) | any;
20
+ target: (() => CollectionConfig) | any;
21
21
  /**
22
22
  * The nature of the relationship, determining if one or many records are returned.
23
23
  */
@@ -270,7 +270,7 @@ export interface Relation {
270
270
  * Action to perform on delete.
271
271
  */
272
272
  onDelete?: OnAction;
273
- overrides?: Partial<EntityCollection>;
273
+ overrides?: Partial<CollectionConfig>;
274
274
  validation?: {
275
275
  required?: boolean;
276
276
  };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import type { CollectionActionsProps, EntityTableController, SelectionController, EntityCollection } from "./collections";
2
+ import type { CollectionActionsProps, EntityTableController, SelectionController, CollectionConfig } from "./collections";
3
3
  import type { Entity } from "./entities";
4
4
  import type { PluginFormActionProps, PluginGenericProps, PluginHomePageActionsProps, PluginHomePageAdditionalCardsProps } from "./plugins";
5
5
  import type { Property } from "./properties";
@@ -99,7 +99,7 @@ export interface NavigationSlotProps {
99
99
  */
100
100
  export interface CollectionToolbarProps {
101
101
  path: string;
102
- collection: EntityCollection;
102
+ collection: CollectionConfig;
103
103
  parentCollectionSlugs: string[];
104
104
  parentEntityIds: string[];
105
105
  tableController: EntityTableController;
@@ -111,7 +111,7 @@ export interface CollectionToolbarProps {
111
111
  */
112
112
  export interface CollectionEmptyStateProps {
113
113
  path: string;
114
- collection: EntityCollection;
114
+ collection: CollectionConfig;
115
115
  parentCollectionSlugs: string[];
116
116
  parentEntityIds: string[];
117
117
  canCreate: boolean;
@@ -128,7 +128,7 @@ export interface CollectionHeaderActionProps {
128
128
  parentCollectionSlugs: string[];
129
129
  parentEntityIds: string[];
130
130
  onHover: boolean;
131
- collection: EntityCollection;
131
+ collection: CollectionConfig;
132
132
  tableController: EntityTableController;
133
133
  }
134
134
  /**
@@ -139,7 +139,7 @@ export interface CollectionAddColumnProps {
139
139
  path: string;
140
140
  parentCollectionSlugs: string[];
141
141
  parentEntityIds: string[];
142
- collection: EntityCollection;
142
+ collection: CollectionConfig;
143
143
  tableController: EntityTableController;
144
144
  }
145
145
  /**
@@ -148,7 +148,7 @@ export interface CollectionAddColumnProps {
148
148
  */
149
149
  export interface CollectionErrorProps {
150
150
  path: string;
151
- collection: EntityCollection;
151
+ collection: CollectionConfig;
152
152
  parentCollectionSlugs?: string[];
153
153
  parentEntityIds?: string[];
154
154
  error: Error;
@@ -158,7 +158,7 @@ export interface CollectionErrorProps {
158
158
  * @group Plugins
159
159
  */
160
160
  export interface KanbanSetupProps {
161
- collection: EntityCollection;
161
+ collection: CollectionConfig;
162
162
  fullPath: string;
163
163
  parentCollectionSlugs: string[];
164
164
  parentEntityIds: string[];
@@ -168,7 +168,7 @@ export interface KanbanSetupProps {
168
168
  * @group Plugins
169
169
  */
170
170
  export interface KanbanAddColumnProps {
171
- collection: EntityCollection;
171
+ collection: CollectionConfig;
172
172
  fullPath: string;
173
173
  parentCollectionSlugs: string[];
174
174
  parentEntityIds: string[];
@@ -176,14 +176,14 @@ export interface KanbanAddColumnProps {
176
176
  }
177
177
  /**
178
178
  * Props for `entity.row.actions` slot.
179
- * Rendered for each row in an entity collection table.
179
+ * Rendered for each row in a entity collection table.
180
180
  * @group Plugins
181
181
  */
182
182
  export interface EntityRowActionsProps {
183
183
  entity: Entity;
184
184
  entityId: string;
185
185
  path: string;
186
- collection: EntityCollection;
186
+ collection: CollectionConfig;
187
187
  parentCollectionSlugs: string[];
188
188
  parentEntityIds: string[];
189
189
  selectionController: SelectionController;
@@ -199,7 +199,7 @@ export interface EntityFieldSlotProps {
199
199
  property: Property;
200
200
  path: string;
201
201
  entityId?: string | number;
202
- collection: EntityCollection;
202
+ collection: CollectionConfig;
203
203
  context: RebaseContext;
204
204
  }
205
205
  /**
@@ -209,7 +209,7 @@ export interface EntityFieldSlotProps {
209
209
  */
210
210
  export interface CollectionFilterPanelProps {
211
211
  path: string;
212
- collection: EntityCollection;
212
+ collection: CollectionConfig;
213
213
  parentCollectionSlugs: string[];
214
214
  parentEntityIds: string[];
215
215
  tableController: EntityTableController;
@@ -246,7 +246,7 @@ export interface ShellToolbarProps {
246
246
  */
247
247
  export interface CollectionInsightsSlotProps {
248
248
  path: string;
249
- collection: EntityCollection;
249
+ collection: CollectionConfig;
250
250
  parentCollectionSlugs: string[];
251
251
  parentEntityIds: string[];
252
252
  }
@@ -257,6 +257,6 @@ export interface CollectionInsightsSlotProps {
257
257
  */
258
258
  export interface HomeCardInsightSlotProps {
259
259
  slug: string;
260
- collection: EntityCollection;
260
+ collection: CollectionConfig;
261
261
  context: RebaseContext;
262
262
  }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Describes a named storage backend — a place files live.
3
+ *
4
+ * Declared once and shared front + back: the frontend uses it to decide
5
+ * transport (HTTP proxy vs direct SDK), the backend uses the same `key`
6
+ * to resolve a StorageController, and collection properties reference
7
+ * a definition by its `key` via `StorageConfig.storageSource`.
8
+ *
9
+ * This mirrors the {@link DataSourceDefinition} pattern used for databases.
10
+ *
11
+ * @group Models
12
+ */
13
+ /**
14
+ * The default storage source key, used when a property does not specify
15
+ * a `storageSource`. Shared by the frontend and backend registries so
16
+ * both agree on "the default storage backend".
17
+ * @group Models
18
+ */
19
+ export declare const DEFAULT_STORAGE_SOURCE_KEY = "(default)";
20
+ /**
21
+ * How the *frontend* reaches a storage backend.
22
+ *
23
+ * - `"server"` — through the Rebase backend REST API (`/api/storage`).
24
+ * The backend holds the actual `StorageController` and routes by
25
+ * storage-source key. This is the default and covers Local, S3, GCS,
26
+ * and any other server-mediated engine.
27
+ * - `"direct"` — straight from the client to the external backend via
28
+ * its own SDK (e.g. Firebase Storage via `@firebase/storage`).
29
+ * The Rebase backend is **not** in the upload/download path.
30
+ *
31
+ * @group Models
32
+ */
33
+ export type StorageSourceTransport = "server" | "direct";
34
+ /**
35
+ * Declarative definition of a storage source — a named place files live.
36
+ *
37
+ * Declared once and shared front and back: the frontend uses it to decide
38
+ * transport (client HTTP proxy vs direct provider SDK), the backend uses
39
+ * the same `key` to resolve a `StorageController`, and collection
40
+ * properties reference a definition by its `key` via
41
+ * `StorageConfig.storageSource`.
42
+ *
43
+ * @group Models
44
+ */
45
+ export interface StorageSourceDefinition {
46
+ /**
47
+ * Unique identifier for this storage source. Collection properties
48
+ * point at it via `StorageConfig.storageSource`.
49
+ * Defaults to {@link DEFAULT_STORAGE_SOURCE_KEY}.
50
+ */
51
+ key: string;
52
+ /**
53
+ * The engine backing this storage source (e.g. `"local"`, `"s3"`,
54
+ * `"gcs"`, `"firebase"`, `"azure"`, or a custom id).
55
+ */
56
+ engine: string;
57
+ /**
58
+ * How the frontend reaches this storage. Defaults to `"server"`.
59
+ *
60
+ * When `"direct"`, the client uses a provider-specific SDK
61
+ * (e.g. `@firebase/storage`) and the backend does not proxy
62
+ * upload/download traffic for this source.
63
+ */
64
+ transport: StorageSourceTransport;
65
+ /** Human-readable label for the UI (e.g. "Firebase Storage", "S3 Media"). */
66
+ label?: string;
67
+ }
68
+ /**
69
+ * A resolved storage source: the single source of truth that the frontend
70
+ * router and backend registry both derive from.
71
+ *
72
+ * @group Models
73
+ */
74
+ export interface ResolvedStorageSource {
75
+ /** Storage source key (routing key, shared front + back). */
76
+ key: string;
77
+ /** Engine backing the source. */
78
+ engine: string;
79
+ /** Frontend transport. */
80
+ transport: StorageSourceTransport;
81
+ /** Human-readable label. */
82
+ label?: string;
83
+ }
@@ -1,4 +1,3 @@
1
- import { Entity } from "./entities";
2
1
  export interface WebSocketErrorPayload {
3
2
  error?: string | {
4
3
  message: string;
@@ -12,32 +11,32 @@ export interface WebSocketMessage {
12
11
  payload?: unknown;
13
12
  subscriptionId?: string;
14
13
  requestId?: string;
15
- entities?: Entity<Record<string, unknown>>[];
16
- entity?: Entity<Record<string, unknown>> | null;
14
+ rows?: Record<string, unknown>[];
15
+ row?: Record<string, unknown> | null;
17
16
  error?: string;
18
17
  }
19
18
  export interface CollectionUpdateMessage extends WebSocketMessage {
20
19
  type: "collection_update";
21
20
  subscriptionId: string;
22
- entities: Entity<Record<string, unknown>>[];
21
+ rows: Record<string, unknown>[];
23
22
  }
24
- export interface EntityUpdateMessage extends WebSocketMessage {
25
- type: "entity_update";
23
+ export interface SingleUpdateMessage extends WebSocketMessage {
24
+ type: "single_update";
26
25
  subscriptionId: string;
27
- entity: Entity<Record<string, unknown>> | null;
26
+ row: Record<string, unknown> | null;
28
27
  }
29
28
  /**
30
29
  * Lightweight patch message sent to collection subscribers when a single
31
- * entity is created, updated, or deleted. The client can merge this into
30
+ * row is created, updated, or deleted. The client can merge this into
32
31
  * its cached collection data for near-instant cross-tab updates without
33
32
  * waiting for a full collection refetch.
34
33
  */
35
- export interface CollectionEntityPatchMessage extends WebSocketMessage {
36
- type: "collection_entity_patch";
34
+ export interface CollectionPatchMessage extends WebSocketMessage {
35
+ type: "collection_patch";
37
36
  subscriptionId: string;
38
- entityId: string;
39
- /** The updated entity, or null if deleted */
40
- entity: Entity<Record<string, unknown>> | null;
37
+ id: string;
38
+ /** The updated row, or null if deleted */
39
+ row: Record<string, unknown> | null;
41
40
  }
42
41
  /**
43
42
  * Column metadata returned by table introspection.