@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.
- package/README.md +10 -10
- package/dist/controllers/auth.d.ts +1 -1
- package/dist/controllers/client.d.ts +237 -7
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +285 -81
- package/dist/controllers/data_driver.d.ts +50 -37
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +2 -2
- package/dist/controllers/registry.d.ts +17 -6
- package/dist/controllers/{side_entity_controller.d.ts → side_panel_controller.d.ts} +7 -7
- package/dist/controllers/storage.d.ts +39 -0
- package/dist/errors.d.ts +64 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +290 -16
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +305 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +9 -6
- package/dist/types/backend.d.ts +30 -26
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +211 -136
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +10 -1
- package/dist/types/data_source.d.ts +18 -5
- package/dist/types/database_adapter.d.ts +4 -3
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +55 -43
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +153 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +191 -0
- package/dist/types/properties.d.ts +153 -43
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/storage_source.d.ts +83 -0
- package/dist/types/websockets.d.ts +12 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +1 -1
- package/src/controllers/auth.tsx +1 -1
- package/src/controllers/client.ts +275 -7
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +309 -97
- package/src/controllers/data_driver.ts +49 -40
- package/src/controllers/index.ts +1 -1
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +2 -2
- package/src/controllers/registry.ts +18 -6
- package/src/controllers/{side_entity_controller.tsx → side_panel_controller.tsx} +7 -7
- package/src/controllers/storage.ts +60 -1
- package/src/errors.ts +80 -0
- package/src/index.ts +1 -0
- package/src/rebase_context.tsx +8 -4
- package/src/types/auth_adapter.ts +9 -6
- package/src/types/backend.ts +41 -36
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +256 -172
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +10 -1
- package/src/types/data_source.ts +29 -7
- package/src/types/database_adapter.ts +4 -3
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +58 -47
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +240 -0
- package/src/types/index.ts +3 -2
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +229 -0
- package/src/types/properties.ts +164 -44
- package/src/types/property_config.tsx +0 -1
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/storage_source.ts +90 -0
- package/src/types/websockets.ts +12 -14
- package/src/users/user.ts +22 -9
- package/dist/types/backend_hooks.d.ts +0 -109
- package/dist/types/entity_overrides.d.ts +0 -10
- package/src/types/backend_hooks.ts +0 -114
- package/src/types/entity_overrides.tsx +0 -11
package/src/types/properties.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { ComponentRef } from "./component_ref";
|
|
|
2
2
|
|
|
3
3
|
import type { Entity, EntityReference, EntityRelation, EntityValues, GeoPoint, Vector } from "./entities";
|
|
4
4
|
import type { JoinStep, OnAction, Relation } from "./relations";
|
|
5
|
-
import type {
|
|
5
|
+
import type { CollectionConfig, FilterValues, WhereFilterOp } from "./collections";
|
|
6
6
|
import type { ColorKey, ColorScheme } from "./chips";
|
|
7
7
|
import type { AuthController } from "../controllers/auth";
|
|
8
|
-
import type {
|
|
8
|
+
import type { AfterReadProps, BeforeSaveProps } from "./entity_callbacks";
|
|
9
9
|
import type { User } from "../users";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -16,7 +16,7 @@ export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = R
|
|
|
16
16
|
/**
|
|
17
17
|
* Callback used after fetching data, to transform the value before rendering
|
|
18
18
|
*/
|
|
19
|
-
afterRead?(props: Omit<
|
|
19
|
+
afterRead?(props: Omit<AfterReadProps<M, USER>, "entity"> & {
|
|
20
20
|
value: T;
|
|
21
21
|
entity: Entity<M> | undefined;
|
|
22
22
|
}): Promise<T> | T;
|
|
@@ -25,7 +25,7 @@ export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = R
|
|
|
25
25
|
* Callback used before saving, after validation.
|
|
26
26
|
* You can modify the value before it's saved.
|
|
27
27
|
*/
|
|
28
|
-
beforeSave?(props: Omit<
|
|
28
|
+
beforeSave?(props: Omit<BeforeSaveProps<M, USER>, "values"> & {
|
|
29
29
|
value: T;
|
|
30
30
|
previousValue: T | undefined;
|
|
31
31
|
values: Partial<M>;
|
|
@@ -75,6 +75,20 @@ export type FirebaseProperties = {
|
|
|
75
75
|
[key: string]: FirebaseProperty;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
// MongoDB is a document store: it uses references (stored pointers), not
|
|
79
|
+
// SQL-style relations/joins. Same gating as Firestore.
|
|
80
|
+
export type MongoProperty = Exclude<Property, RelationProperty>;
|
|
81
|
+
export type MongoProperties = {
|
|
82
|
+
[key: string]: MongoProperty;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Union of all engine-specific property maps. Use this at engine-agnostic
|
|
87
|
+
* boundaries (collection editor, normalization) where the concrete engine is
|
|
88
|
+
* unknown but the narrowed property constraint must be satisfied.
|
|
89
|
+
*/
|
|
90
|
+
export type EngineProperties = PostgresProperties | FirebaseProperties | MongoProperties;
|
|
91
|
+
|
|
78
92
|
/**
|
|
79
93
|
* A helper type to infer the underlying data type from a Property definition.
|
|
80
94
|
* This is the core of the type inference system.
|
|
@@ -150,6 +164,33 @@ export interface BaseUIConfig<CustomProps = unknown> {
|
|
|
150
164
|
customProps?: CustomProps;
|
|
151
165
|
Field?: ComponentRef<any>;
|
|
152
166
|
Preview?: ComponentRef<any>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Narrow the filter operators offered for this property in collection
|
|
170
|
+
* filter UIs (table header filters and the Filters dialog).
|
|
171
|
+
*
|
|
172
|
+
* The final offered set is the **intersection** of the engine's
|
|
173
|
+
* capabilities, the property-type defaults, and this list — you can only
|
|
174
|
+
* *restrict*, never enable an operator the underlying engine cannot run.
|
|
175
|
+
*
|
|
176
|
+
* Pass an empty array to disable filtering on this property entirely.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* // Email column: exact match, contains, and null check only
|
|
180
|
+
* ui: { filterOperators: ["==", "ilike", "is-null"] }
|
|
181
|
+
*/
|
|
182
|
+
filterOperators?: readonly WhereFilterOp[];
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Replace the filter field rendered for this property in collection
|
|
186
|
+
* filter UIs. The component receives `FilterFieldBindingProps`
|
|
187
|
+
* (property, resolved `operators`, `value`, `setValue`, …).
|
|
188
|
+
*
|
|
189
|
+
* Takes precedence over the collection-level
|
|
190
|
+
* `components["Collection.FilterField"]` override and the built-in
|
|
191
|
+
* per-type filter fields.
|
|
192
|
+
*/
|
|
193
|
+
Filter?: ComponentRef<any>;
|
|
153
194
|
}
|
|
154
195
|
|
|
155
196
|
export interface BaseProperty<CustomProps = unknown> {
|
|
@@ -190,10 +231,9 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
190
231
|
*/
|
|
191
232
|
validation?: PropertyValidationSchema;
|
|
192
233
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
defaultValue?: unknown;
|
|
234
|
+
// NOTE: `defaultValue` is intentionally NOT on BaseProperty.
|
|
235
|
+
// Each concrete property type (StringProperty, NumberProperty, etc.)
|
|
236
|
+
// defines its own typed `defaultValue` for compile-time safety.
|
|
197
237
|
|
|
198
238
|
/**
|
|
199
239
|
* Use this to define dynamic properties that change based on certain conditions
|
|
@@ -235,16 +275,37 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
235
275
|
* @group Entity properties
|
|
236
276
|
*/
|
|
237
277
|
export interface StringUIConfig extends BaseUIConfig {
|
|
278
|
+
/**
|
|
279
|
+
* Is this string property long enough so it should be displayed in
|
|
280
|
+
* a multiple line field. Defaults to false. If set to true,
|
|
281
|
+
* the number of lines adapts to the content
|
|
282
|
+
*/
|
|
238
283
|
multiline?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Should this string property be displayed as a markdown field. If true,
|
|
286
|
+
* the field is rendered as a text editor that supports markdown highlight
|
|
287
|
+
* syntax. It also includes a preview of the result.
|
|
288
|
+
*/
|
|
239
289
|
markdown?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Should this string be rendered as a tag instead of just text.
|
|
292
|
+
*/
|
|
240
293
|
previewAsTag?: boolean;
|
|
241
294
|
clearable?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* If the value of this property is a URL, you can set this flag to true
|
|
297
|
+
* to add a link, or one of the supported media types to render a preview
|
|
298
|
+
*/
|
|
242
299
|
url?: boolean | PreviewType;
|
|
243
300
|
}
|
|
244
301
|
|
|
245
302
|
export interface StringProperty extends BaseProperty {
|
|
246
303
|
ui?: StringUIConfig;
|
|
247
304
|
type: "string";
|
|
305
|
+
/**
|
|
306
|
+
* Default value for new entities. Must be a string.
|
|
307
|
+
*/
|
|
308
|
+
defaultValue?: string;
|
|
248
309
|
/**
|
|
249
310
|
* Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
|
|
250
311
|
* Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
|
|
@@ -279,18 +340,6 @@ export interface StringProperty extends BaseProperty {
|
|
|
279
340
|
*
|
|
280
341
|
*/
|
|
281
342
|
enum?: EnumValues;
|
|
282
|
-
/**
|
|
283
|
-
* Is this string property long enough so it should be displayed in
|
|
284
|
-
* a multiple line field. Defaults to false. If set to true,
|
|
285
|
-
* the number of lines adapts to the content
|
|
286
|
-
*/
|
|
287
|
-
multiline?: boolean;
|
|
288
|
-
/**
|
|
289
|
-
* Should this string property be displayed as a markdown field. If true,
|
|
290
|
-
* the field is rendered as a text editors that supports markdown highlight
|
|
291
|
-
* syntax. It also includes a preview of the result.
|
|
292
|
-
*/
|
|
293
|
-
markdown?: boolean;
|
|
294
343
|
/**
|
|
295
344
|
* You can specify a `Storage` configuration. It is used to
|
|
296
345
|
* indicate that this string refers to a path in your storage provider.
|
|
@@ -301,33 +350,16 @@ export interface StringProperty extends BaseProperty {
|
|
|
301
350
|
* This property is used to indicate that the string is a user ID, and
|
|
302
351
|
* it will be rendered as a user picker.
|
|
303
352
|
* Note that the user ID needs to be the one used in your authentication
|
|
304
|
-
* provider
|
|
353
|
+
* provider (e.g. the ID in your `users` table).
|
|
305
354
|
* You can also use a property builder to specify the user path dynamically
|
|
306
355
|
* based on other values of the entity.
|
|
307
356
|
*/
|
|
308
357
|
userSelect?: boolean;
|
|
309
358
|
|
|
310
|
-
/**
|
|
311
|
-
* If the value of this property is a URL, you can set this flag to true
|
|
312
|
-
* to add a link, or one of the supported media types to render a preview
|
|
313
|
-
*/
|
|
314
|
-
url?: boolean | PreviewType;
|
|
315
359
|
/**
|
|
316
360
|
* Does this field include an email
|
|
317
361
|
*/
|
|
318
362
|
email?: boolean;
|
|
319
|
-
/**
|
|
320
|
-
* Should this string be rendered as a tag instead of just text.
|
|
321
|
-
*/
|
|
322
|
-
previewAsTag?: boolean;
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* You can use this property (a string) to behave as a reference to another
|
|
326
|
-
* collection. The stored value is the ID of the entity in the
|
|
327
|
-
* collection, and the `path` prop is used to
|
|
328
|
-
* define the collection this reference points to.
|
|
329
|
-
*/
|
|
330
|
-
reference?: ReferenceProperty;
|
|
331
363
|
}
|
|
332
364
|
|
|
333
365
|
/**
|
|
@@ -340,6 +372,10 @@ export interface NumberUIConfig extends BaseUIConfig {
|
|
|
340
372
|
export interface NumberProperty extends BaseProperty {
|
|
341
373
|
ui?: NumberUIConfig;
|
|
342
374
|
type: "number";
|
|
375
|
+
/**
|
|
376
|
+
* Default value for new entities. Must be a number.
|
|
377
|
+
*/
|
|
378
|
+
defaultValue?: number;
|
|
343
379
|
/**
|
|
344
380
|
* Optional database column type. Allows specifying exact database numeric types.
|
|
345
381
|
* If not provided, integer fields (where validation.integer is true or isId is true) default to `integer`, others to `numeric`.
|
|
@@ -375,6 +411,10 @@ export interface NumberProperty extends BaseProperty {
|
|
|
375
411
|
export interface BooleanProperty extends BaseProperty {
|
|
376
412
|
ui?: BaseUIConfig;
|
|
377
413
|
type: "boolean";
|
|
414
|
+
/**
|
|
415
|
+
* Default value for new entities. Must be a boolean.
|
|
416
|
+
*/
|
|
417
|
+
defaultValue?: boolean;
|
|
378
418
|
/**
|
|
379
419
|
* Rules for validating this property
|
|
380
420
|
*/
|
|
@@ -391,6 +431,10 @@ export interface VectorUIConfig extends BaseUIConfig {
|
|
|
391
431
|
export interface VectorProperty extends BaseProperty {
|
|
392
432
|
ui?: VectorUIConfig;
|
|
393
433
|
type: "vector";
|
|
434
|
+
/**
|
|
435
|
+
* Default value for new entities.
|
|
436
|
+
*/
|
|
437
|
+
defaultValue?: Vector;
|
|
394
438
|
dimensions: number;
|
|
395
439
|
validation?: PropertyValidationSchema;
|
|
396
440
|
}
|
|
@@ -400,6 +444,10 @@ export interface VectorProperty extends BaseProperty {
|
|
|
400
444
|
*/
|
|
401
445
|
export interface BinaryProperty extends BaseProperty {
|
|
402
446
|
type: "binary";
|
|
447
|
+
/**
|
|
448
|
+
* Default value for new entities. Must be a base64-encoded string.
|
|
449
|
+
*/
|
|
450
|
+
defaultValue?: string;
|
|
403
451
|
validation?: PropertyValidationSchema;
|
|
404
452
|
}
|
|
405
453
|
|
|
@@ -407,12 +455,19 @@ export interface BinaryProperty extends BaseProperty {
|
|
|
407
455
|
* @group Entity properties
|
|
408
456
|
*/
|
|
409
457
|
export interface DateUIConfig extends BaseUIConfig {
|
|
458
|
+
/**
|
|
459
|
+
* Add an icon to clear the value and set it to `null`. Defaults to `false`
|
|
460
|
+
*/
|
|
410
461
|
clearable?: boolean;
|
|
411
462
|
}
|
|
412
463
|
|
|
413
464
|
export interface DateProperty extends BaseProperty {
|
|
414
465
|
ui?: DateUIConfig;
|
|
415
466
|
type: "date";
|
|
467
|
+
/**
|
|
468
|
+
* Default value for new entities. Must be a Date.
|
|
469
|
+
*/
|
|
470
|
+
defaultValue?: Date;
|
|
416
471
|
/**
|
|
417
472
|
* Optional database column type. If not set, defaults to `timestamp` with timezone.
|
|
418
473
|
*/
|
|
@@ -438,10 +493,6 @@ export interface DateProperty extends BaseProperty {
|
|
|
438
493
|
* `updated_on` fields
|
|
439
494
|
*/
|
|
440
495
|
autoValue?: "on_create" | "on_update";
|
|
441
|
-
/**
|
|
442
|
-
* Add an icon to clear the value and set it to `null`. Defaults to `false`
|
|
443
|
-
*/
|
|
444
|
-
clearable?: boolean;
|
|
445
496
|
}
|
|
446
497
|
|
|
447
498
|
/**
|
|
@@ -450,6 +501,10 @@ export interface DateProperty extends BaseProperty {
|
|
|
450
501
|
export interface GeopointProperty extends BaseProperty {
|
|
451
502
|
ui?: BaseUIConfig;
|
|
452
503
|
type: "geopoint";
|
|
504
|
+
/**
|
|
505
|
+
* Default value for new entities. Must be a GeoPoint.
|
|
506
|
+
*/
|
|
507
|
+
defaultValue?: GeoPoint;
|
|
453
508
|
/**
|
|
454
509
|
* Rules for validating this property
|
|
455
510
|
*/
|
|
@@ -463,9 +518,29 @@ export interface ReferenceUIConfig extends BaseUIConfig {
|
|
|
463
518
|
previewProperties?: string[];
|
|
464
519
|
}
|
|
465
520
|
|
|
521
|
+
/**
|
|
522
|
+
* A pointer to a entity, stored **as a value** on the row (id + path, and
|
|
523
|
+
* optionally a `driver`/`databaseId` for cross-datasource pointers).
|
|
524
|
+
*
|
|
525
|
+
* This is the native primitive of **document databases** — it maps 1:1 to a
|
|
526
|
+
* Firestore `DocumentReference`, and is persisted by the MongoDB driver as a
|
|
527
|
+
* tagged sub-document. It carries no schema-level relationship (no foreign key,
|
|
528
|
+
* no join, no cascade) and is resolved on demand.
|
|
529
|
+
*
|
|
530
|
+
* **Which to use:**
|
|
531
|
+
* - Firestore / MongoDB collection → use `reference`.
|
|
532
|
+
* - Postgres collection → use {@link RelationProperty} (`type: "relation"`),
|
|
533
|
+
* which models a real foreign key / join with prefetch and cascade.
|
|
534
|
+
*
|
|
535
|
+
* @group Entity properties
|
|
536
|
+
*/
|
|
466
537
|
export interface ReferenceProperty extends BaseProperty {
|
|
467
538
|
ui?: ReferenceUIConfig;
|
|
468
539
|
type: "reference";
|
|
540
|
+
/**
|
|
541
|
+
* Default value for new entities. Must be a EntityReference.
|
|
542
|
+
*/
|
|
543
|
+
defaultValue?: EntityReference;
|
|
469
544
|
/**
|
|
470
545
|
* Marks this field as a Primary Key / Unique Identifier.
|
|
471
546
|
* Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
|
|
@@ -507,9 +582,29 @@ export interface RelationUIConfig extends BaseUIConfig {
|
|
|
507
582
|
widget?: "select" | "dialog";
|
|
508
583
|
}
|
|
509
584
|
|
|
585
|
+
/**
|
|
586
|
+
* A schema-level relationship between collections **within a single
|
|
587
|
+
* datasource** — backed by a foreign key, junction table, or explicit join
|
|
588
|
+
* path. The resolved value (an `EntityRelation`) can carry a prefetched entity
|
|
589
|
+
* payload to eliminate N+1 queries, and supports `onUpdate`/`onDelete` cascade.
|
|
590
|
+
*
|
|
591
|
+
* This is the native primitive of **relational databases** (Postgres). It is
|
|
592
|
+
* the SQL counterpart to {@link ReferenceProperty}.
|
|
593
|
+
*
|
|
594
|
+
* **Which to use:**
|
|
595
|
+
* - Postgres collection → use `relation`.
|
|
596
|
+
* - Firestore / MongoDB collection → use {@link ReferenceProperty}
|
|
597
|
+
* (`type: "reference"`), a stored pointer with no join engine.
|
|
598
|
+
*
|
|
599
|
+
* @group Entity properties
|
|
600
|
+
*/
|
|
510
601
|
export interface RelationProperty extends BaseProperty {
|
|
511
602
|
ui?: RelationUIConfig;
|
|
512
603
|
type: "relation";
|
|
604
|
+
/**
|
|
605
|
+
* Default value for new entities. Must be a EntityRelation or array of EntityRelation.
|
|
606
|
+
*/
|
|
607
|
+
defaultValue?: EntityRelation | EntityRelation[];
|
|
513
608
|
/**
|
|
514
609
|
* Marks this field as a Primary Key / Unique Identifier.
|
|
515
610
|
* Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
|
|
@@ -528,7 +623,7 @@ export interface RelationProperty extends BaseProperty {
|
|
|
528
623
|
* When set, the framework treats this property as a self-contained relation
|
|
529
624
|
* definition and no separate `relations[]` entry is needed.
|
|
530
625
|
*/
|
|
531
|
-
target?: string | (() =>
|
|
626
|
+
target?: string | (() => CollectionConfig | string);
|
|
532
627
|
|
|
533
628
|
/**
|
|
534
629
|
* Whether this property references one or many records.
|
|
@@ -596,7 +691,7 @@ export interface RelationProperty extends BaseProperty {
|
|
|
596
691
|
/**
|
|
597
692
|
* Overrides applied to the target collection when rendered as a subcollection tab.
|
|
598
693
|
*/
|
|
599
|
-
overrides?: Partial<
|
|
694
|
+
overrides?: Partial<CollectionConfig>;
|
|
600
695
|
|
|
601
696
|
// ─── Framework-managed fields ───
|
|
602
697
|
|
|
@@ -649,6 +744,10 @@ export interface ArrayUIConfig extends BaseUIConfig {
|
|
|
649
744
|
export interface ArrayProperty extends BaseProperty {
|
|
650
745
|
ui?: ArrayUIConfig;
|
|
651
746
|
type: "array";
|
|
747
|
+
/**
|
|
748
|
+
* Default value for new entities. Must be an array.
|
|
749
|
+
*/
|
|
750
|
+
defaultValue?: unknown[];
|
|
652
751
|
/**
|
|
653
752
|
* Optional database column type. By default, maps to a native Postgres array
|
|
654
753
|
* (e.g. `text[]`, `integer[]`/`numeric[]`, `boolean[]`) if the element type
|
|
@@ -729,6 +828,10 @@ export interface MapUIConfig extends BaseUIConfig {
|
|
|
729
828
|
export interface MapProperty extends BaseProperty {
|
|
730
829
|
ui?: MapUIConfig;
|
|
731
830
|
type: "map";
|
|
831
|
+
/**
|
|
832
|
+
* Default value for new entities. Must be a record/object.
|
|
833
|
+
*/
|
|
834
|
+
defaultValue?: Record<string, unknown>;
|
|
732
835
|
/**
|
|
733
836
|
* Optional database column type. Defaults to `jsonb`.
|
|
734
837
|
*/
|
|
@@ -921,6 +1024,23 @@ export interface ArrayPropertyValidationSchema extends PropertyValidationSchema
|
|
|
921
1024
|
* @group Entity properties
|
|
922
1025
|
*/
|
|
923
1026
|
export type StorageConfig = {
|
|
1027
|
+
/**
|
|
1028
|
+
* Key referencing a named storage backend from the StorageRegistry.
|
|
1029
|
+
* Must match a `StorageSourceDefinition.key` or a key registered
|
|
1030
|
+
* in `initializeRebaseBackend({ storage: { ... } })`.
|
|
1031
|
+
*
|
|
1032
|
+
* When omitted, the default storage source is used.
|
|
1033
|
+
*/
|
|
1034
|
+
storageSource?: string;
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Store files for this property as **public**: they are placed under the
|
|
1038
|
+
* public prefix and served via stable, token-less, permanent, CDN-cacheable
|
|
1039
|
+
* URLs (safe to persist and hotlink). Use for public assets like avatars or
|
|
1040
|
+
* storefront images. Defaults to `false` (private, short-lived signed URLs).
|
|
1041
|
+
*/
|
|
1042
|
+
public?: boolean;
|
|
1043
|
+
|
|
924
1044
|
/**
|
|
925
1045
|
* File MIME types that can be uploaded to this reference. Don't specify for
|
|
926
1046
|
* all.
|
package/src/types/relations.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CollectionConfig } from "./collections";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @group Models
|
|
@@ -20,7 +20,7 @@ export interface Relation {
|
|
|
20
20
|
/**
|
|
21
21
|
* The final collection you want to retrieve records from.
|
|
22
22
|
*/
|
|
23
|
-
target: (() =>
|
|
23
|
+
target: (() => CollectionConfig) | any;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* The nature of the relationship, determining if one or many records are returned.
|
|
@@ -282,7 +282,7 @@ export interface Relation {
|
|
|
282
282
|
*/
|
|
283
283
|
onDelete?: OnAction;
|
|
284
284
|
|
|
285
|
-
overrides?: Partial<
|
|
285
|
+
overrides?: Partial<CollectionConfig>;
|
|
286
286
|
|
|
287
287
|
validation?: {
|
|
288
288
|
required?: boolean;
|
package/src/types/slots.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CollectionActionsProps, EntityTableController, SelectionController,
|
|
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";
|
|
@@ -128,7 +128,7 @@ export interface NavigationSlotProps {
|
|
|
128
128
|
*/
|
|
129
129
|
export interface CollectionToolbarProps {
|
|
130
130
|
path: string;
|
|
131
|
-
collection:
|
|
131
|
+
collection: CollectionConfig;
|
|
132
132
|
parentCollectionSlugs: string[];
|
|
133
133
|
parentEntityIds: string[];
|
|
134
134
|
tableController: EntityTableController;
|
|
@@ -141,7 +141,7 @@ export interface CollectionToolbarProps {
|
|
|
141
141
|
*/
|
|
142
142
|
export interface CollectionEmptyStateProps {
|
|
143
143
|
path: string;
|
|
144
|
-
collection:
|
|
144
|
+
collection: CollectionConfig;
|
|
145
145
|
parentCollectionSlugs: string[];
|
|
146
146
|
parentEntityIds: string[];
|
|
147
147
|
canCreate: boolean;
|
|
@@ -159,7 +159,7 @@ export interface CollectionHeaderActionProps {
|
|
|
159
159
|
parentCollectionSlugs: string[];
|
|
160
160
|
parentEntityIds: string[];
|
|
161
161
|
onHover: boolean;
|
|
162
|
-
collection:
|
|
162
|
+
collection: CollectionConfig;
|
|
163
163
|
tableController: EntityTableController;
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -171,7 +171,7 @@ export interface CollectionAddColumnProps {
|
|
|
171
171
|
path: string;
|
|
172
172
|
parentCollectionSlugs: string[];
|
|
173
173
|
parentEntityIds: string[];
|
|
174
|
-
collection:
|
|
174
|
+
collection: CollectionConfig;
|
|
175
175
|
tableController: EntityTableController;
|
|
176
176
|
}
|
|
177
177
|
|
|
@@ -181,7 +181,7 @@ export interface CollectionAddColumnProps {
|
|
|
181
181
|
*/
|
|
182
182
|
export interface CollectionErrorProps {
|
|
183
183
|
path: string;
|
|
184
|
-
collection:
|
|
184
|
+
collection: CollectionConfig;
|
|
185
185
|
parentCollectionSlugs?: string[];
|
|
186
186
|
parentEntityIds?: string[];
|
|
187
187
|
error: Error;
|
|
@@ -192,7 +192,7 @@ export interface CollectionErrorProps {
|
|
|
192
192
|
* @group Plugins
|
|
193
193
|
*/
|
|
194
194
|
export interface KanbanSetupProps {
|
|
195
|
-
collection:
|
|
195
|
+
collection: CollectionConfig;
|
|
196
196
|
fullPath: string;
|
|
197
197
|
parentCollectionSlugs: string[];
|
|
198
198
|
parentEntityIds: string[];
|
|
@@ -203,7 +203,7 @@ export interface KanbanSetupProps {
|
|
|
203
203
|
* @group Plugins
|
|
204
204
|
*/
|
|
205
205
|
export interface KanbanAddColumnProps {
|
|
206
|
-
collection:
|
|
206
|
+
collection: CollectionConfig;
|
|
207
207
|
fullPath: string;
|
|
208
208
|
parentCollectionSlugs: string[];
|
|
209
209
|
parentEntityIds: string[];
|
|
@@ -214,14 +214,14 @@ export interface KanbanAddColumnProps {
|
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
216
|
* Props for `entity.row.actions` slot.
|
|
217
|
-
* Rendered for each row in
|
|
217
|
+
* Rendered for each row in a entity collection table.
|
|
218
218
|
* @group Plugins
|
|
219
219
|
*/
|
|
220
220
|
export interface EntityRowActionsProps {
|
|
221
221
|
entity: Entity;
|
|
222
222
|
entityId: string;
|
|
223
223
|
path: string;
|
|
224
|
-
collection:
|
|
224
|
+
collection: CollectionConfig;
|
|
225
225
|
parentCollectionSlugs: string[];
|
|
226
226
|
parentEntityIds: string[];
|
|
227
227
|
selectionController: SelectionController;
|
|
@@ -238,7 +238,7 @@ export interface EntityFieldSlotProps {
|
|
|
238
238
|
property: Property;
|
|
239
239
|
path: string;
|
|
240
240
|
entityId?: string | number;
|
|
241
|
-
collection:
|
|
241
|
+
collection: CollectionConfig;
|
|
242
242
|
context: RebaseContext;
|
|
243
243
|
}
|
|
244
244
|
|
|
@@ -249,7 +249,7 @@ export interface EntityFieldSlotProps {
|
|
|
249
249
|
*/
|
|
250
250
|
export interface CollectionFilterPanelProps {
|
|
251
251
|
path: string;
|
|
252
|
-
collection:
|
|
252
|
+
collection: CollectionConfig;
|
|
253
253
|
parentCollectionSlugs: string[];
|
|
254
254
|
parentEntityIds: string[];
|
|
255
255
|
tableController: EntityTableController;
|
|
@@ -290,7 +290,7 @@ export interface ShellToolbarProps {
|
|
|
290
290
|
*/
|
|
291
291
|
export interface CollectionInsightsSlotProps {
|
|
292
292
|
path: string;
|
|
293
|
-
collection:
|
|
293
|
+
collection: CollectionConfig;
|
|
294
294
|
parentCollectionSlugs: string[];
|
|
295
295
|
parentEntityIds: string[];
|
|
296
296
|
}
|
|
@@ -302,6 +302,6 @@ export interface CollectionInsightsSlotProps {
|
|
|
302
302
|
*/
|
|
303
303
|
export interface HomeCardInsightSlotProps {
|
|
304
304
|
slug: string;
|
|
305
|
-
collection:
|
|
305
|
+
collection: CollectionConfig;
|
|
306
306
|
context: RebaseContext;
|
|
307
307
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
/**
|
|
15
|
+
* The default storage source key, used when a property does not specify
|
|
16
|
+
* a `storageSource`. Shared by the frontend and backend registries so
|
|
17
|
+
* both agree on "the default storage backend".
|
|
18
|
+
* @group Models
|
|
19
|
+
*/
|
|
20
|
+
export const DEFAULT_STORAGE_SOURCE_KEY = "(default)";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* How the *frontend* reaches a storage backend.
|
|
24
|
+
*
|
|
25
|
+
* - `"server"` — through the Rebase backend REST API (`/api/storage`).
|
|
26
|
+
* The backend holds the actual `StorageController` and routes by
|
|
27
|
+
* storage-source key. This is the default and covers Local, S3, GCS,
|
|
28
|
+
* and any other server-mediated engine.
|
|
29
|
+
* - `"direct"` — straight from the client to the external backend via
|
|
30
|
+
* its own SDK (e.g. Firebase Storage via `@firebase/storage`).
|
|
31
|
+
* The Rebase backend is **not** in the upload/download path.
|
|
32
|
+
*
|
|
33
|
+
* @group Models
|
|
34
|
+
*/
|
|
35
|
+
export type StorageSourceTransport = "server" | "direct";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Declarative definition of a storage source — a named place files live.
|
|
39
|
+
*
|
|
40
|
+
* Declared once and shared front and back: the frontend uses it to decide
|
|
41
|
+
* transport (client HTTP proxy vs direct provider SDK), the backend uses
|
|
42
|
+
* the same `key` to resolve a `StorageController`, and collection
|
|
43
|
+
* properties reference a definition by its `key` via
|
|
44
|
+
* `StorageConfig.storageSource`.
|
|
45
|
+
*
|
|
46
|
+
* @group Models
|
|
47
|
+
*/
|
|
48
|
+
export interface StorageSourceDefinition {
|
|
49
|
+
/**
|
|
50
|
+
* Unique identifier for this storage source. Collection properties
|
|
51
|
+
* point at it via `StorageConfig.storageSource`.
|
|
52
|
+
* Defaults to {@link DEFAULT_STORAGE_SOURCE_KEY}.
|
|
53
|
+
*/
|
|
54
|
+
key: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The engine backing this storage source (e.g. `"local"`, `"s3"`,
|
|
58
|
+
* `"gcs"`, `"firebase"`, `"azure"`, or a custom id).
|
|
59
|
+
*/
|
|
60
|
+
engine: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* How the frontend reaches this storage. Defaults to `"server"`.
|
|
64
|
+
*
|
|
65
|
+
* When `"direct"`, the client uses a provider-specific SDK
|
|
66
|
+
* (e.g. `@firebase/storage`) and the backend does not proxy
|
|
67
|
+
* upload/download traffic for this source.
|
|
68
|
+
*/
|
|
69
|
+
transport: StorageSourceTransport;
|
|
70
|
+
|
|
71
|
+
/** Human-readable label for the UI (e.g. "Firebase Storage", "S3 Media"). */
|
|
72
|
+
label?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A resolved storage source: the single source of truth that the frontend
|
|
77
|
+
* router and backend registry both derive from.
|
|
78
|
+
*
|
|
79
|
+
* @group Models
|
|
80
|
+
*/
|
|
81
|
+
export interface ResolvedStorageSource {
|
|
82
|
+
/** Storage source key (routing key, shared front + back). */
|
|
83
|
+
key: string;
|
|
84
|
+
/** Engine backing the source. */
|
|
85
|
+
engine: string;
|
|
86
|
+
/** Frontend transport. */
|
|
87
|
+
transport: StorageSourceTransport;
|
|
88
|
+
/** Human-readable label. */
|
|
89
|
+
label?: string;
|
|
90
|
+
}
|
package/src/types/websockets.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Entity } from "./entities";
|
|
2
|
-
|
|
3
1
|
export interface WebSocketErrorPayload {
|
|
4
2
|
error?: string | { message: string; code?: string };
|
|
5
3
|
message?: string;
|
|
@@ -11,35 +9,35 @@ export interface WebSocketMessage {
|
|
|
11
9
|
payload?: unknown;
|
|
12
10
|
subscriptionId?: string;
|
|
13
11
|
requestId?: string;
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
rows?: Record<string, unknown>[];
|
|
13
|
+
row?: Record<string, unknown> | null;
|
|
16
14
|
error?: string;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
export interface CollectionUpdateMessage extends WebSocketMessage {
|
|
20
18
|
type: "collection_update";
|
|
21
19
|
subscriptionId: string;
|
|
22
|
-
|
|
20
|
+
rows: Record<string, unknown>[];
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
export interface
|
|
26
|
-
type: "
|
|
23
|
+
export interface SingleUpdateMessage extends WebSocketMessage {
|
|
24
|
+
type: "single_update";
|
|
27
25
|
subscriptionId: string;
|
|
28
|
-
|
|
26
|
+
row: Record<string, unknown> | null;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
/**
|
|
32
30
|
* Lightweight patch message sent to collection subscribers when a single
|
|
33
|
-
*
|
|
31
|
+
* row is created, updated, or deleted. The client can merge this into
|
|
34
32
|
* its cached collection data for near-instant cross-tab updates without
|
|
35
33
|
* waiting for a full collection refetch.
|
|
36
34
|
*/
|
|
37
|
-
export interface
|
|
38
|
-
type: "
|
|
35
|
+
export interface CollectionPatchMessage extends WebSocketMessage {
|
|
36
|
+
type: "collection_patch";
|
|
39
37
|
subscriptionId: string;
|
|
40
|
-
|
|
41
|
-
/** The updated
|
|
42
|
-
|
|
38
|
+
id: string;
|
|
39
|
+
/** The updated row, or null if deleted */
|
|
40
|
+
row: Record<string, unknown> | null;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
/**
|