@rebasepro/types 0.6.1 → 0.8.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/dist/controllers/client.d.ts +69 -1
- package/dist/controllers/data.d.ts +19 -47
- package/dist/controllers/navigation.d.ts +14 -14
- package/dist/controllers/registry.d.ts +8 -4
- package/dist/index.es.js +164 -10
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +171 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/types/api_keys.d.ts +57 -0
- package/dist/types/auth_adapter.d.ts +66 -4
- package/dist/types/backend.d.ts +5 -0
- package/dist/types/collections.d.ts +200 -90
- package/dist/types/data_source.d.ts +79 -3
- package/dist/types/entity_actions.d.ts +2 -2
- package/dist/types/entity_callbacks.d.ts +18 -6
- package/dist/types/entity_views.d.ts +1 -1
- package/dist/types/filter-operators.d.ts +108 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/policy.d.ts +137 -0
- package/dist/types/properties.d.ts +122 -37
- package/dist/types/property_config.d.ts +1 -1
- package/dist/types/storage_source.d.ts +83 -0
- package/dist/types/translations.d.ts +8 -0
- package/package.json +1 -1
- package/src/controllers/client.ts +69 -1
- package/src/controllers/data.ts +20 -59
- package/src/controllers/navigation.ts +17 -16
- package/src/controllers/registry.ts +10 -4
- package/src/types/api_keys.ts +52 -0
- package/src/types/auth_adapter.ts +80 -4
- package/src/types/backend.ts +6 -1
- package/src/types/collections.ts +235 -113
- package/src/types/data_source.ts +89 -5
- package/src/types/entity_actions.tsx +2 -2
- package/src/types/entity_callbacks.ts +18 -7
- package/src/types/entity_views.tsx +1 -1
- package/src/types/filter-operators.ts +167 -0
- package/src/types/index.ts +5 -2
- package/src/types/plugins.tsx +1 -1
- package/src/types/policy.ts +173 -0
- package/src/types/properties.ts +132 -39
- package/src/types/property_config.tsx +0 -1
- package/src/types/storage_source.ts +90 -0
- package/src/types/translations.ts +8 -0
- 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
|
@@ -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.
|
|
@@ -140,10 +150,6 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
140
150
|
* Rules for validating this property
|
|
141
151
|
*/
|
|
142
152
|
validation?: PropertyValidationSchema;
|
|
143
|
-
/**
|
|
144
|
-
* This value will be set by default for new entities.
|
|
145
|
-
*/
|
|
146
|
-
defaultValue?: unknown;
|
|
147
153
|
/**
|
|
148
154
|
* Use this to define dynamic properties that change based on certain conditions
|
|
149
155
|
* or on the entity's values. For example, you can make a field read-only if
|
|
@@ -167,20 +173,48 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
167
173
|
* Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
|
|
168
174
|
*/
|
|
169
175
|
callbacks?: PropertyCallbacks;
|
|
176
|
+
/**
|
|
177
|
+
* Arbitrary key-value metadata for external consumers.
|
|
178
|
+
* Not interpreted by Rebase — passed through serialization unchanged.
|
|
179
|
+
* Used by domain apps to store custom per-property config
|
|
180
|
+
* (e.g. CRM visibility flags, display hints).
|
|
181
|
+
*/
|
|
182
|
+
metadata?: Record<string, unknown>;
|
|
170
183
|
}
|
|
171
184
|
/**
|
|
172
185
|
* @group Entity properties
|
|
173
186
|
*/
|
|
174
187
|
export interface StringUIConfig extends BaseUIConfig {
|
|
188
|
+
/**
|
|
189
|
+
* Is this string property long enough so it should be displayed in
|
|
190
|
+
* a multiple line field. Defaults to false. If set to true,
|
|
191
|
+
* the number of lines adapts to the content
|
|
192
|
+
*/
|
|
175
193
|
multiline?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Should this string property be displayed as a markdown field. If true,
|
|
196
|
+
* the field is rendered as a text editor that supports markdown highlight
|
|
197
|
+
* syntax. It also includes a preview of the result.
|
|
198
|
+
*/
|
|
176
199
|
markdown?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Should this string be rendered as a tag instead of just text.
|
|
202
|
+
*/
|
|
177
203
|
previewAsTag?: boolean;
|
|
178
204
|
clearable?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* If the value of this property is a URL, you can set this flag to true
|
|
207
|
+
* to add a link, or one of the supported media types to render a preview
|
|
208
|
+
*/
|
|
179
209
|
url?: boolean | PreviewType;
|
|
180
210
|
}
|
|
181
211
|
export interface StringProperty extends BaseProperty {
|
|
182
212
|
ui?: StringUIConfig;
|
|
183
213
|
type: "string";
|
|
214
|
+
/**
|
|
215
|
+
* Default value for new entities. Must be a string.
|
|
216
|
+
*/
|
|
217
|
+
defaultValue?: string;
|
|
184
218
|
/**
|
|
185
219
|
* Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
|
|
186
220
|
* Use `text` for strings with unbound length, `char` for fixed-length strings, or `varchar` for variable-length strings with a limit.
|
|
@@ -215,18 +249,6 @@ export interface StringProperty extends BaseProperty {
|
|
|
215
249
|
*
|
|
216
250
|
*/
|
|
217
251
|
enum?: EnumValues;
|
|
218
|
-
/**
|
|
219
|
-
* Is this string property long enough so it should be displayed in
|
|
220
|
-
* a multiple line field. Defaults to false. If set to true,
|
|
221
|
-
* the number of lines adapts to the content
|
|
222
|
-
*/
|
|
223
|
-
multiline?: boolean;
|
|
224
|
-
/**
|
|
225
|
-
* Should this string property be displayed as a markdown field. If true,
|
|
226
|
-
* the field is rendered as a text editors that supports markdown highlight
|
|
227
|
-
* syntax. It also includes a preview of the result.
|
|
228
|
-
*/
|
|
229
|
-
markdown?: boolean;
|
|
230
252
|
/**
|
|
231
253
|
* You can specify a `Storage` configuration. It is used to
|
|
232
254
|
* indicate that this string refers to a path in your storage provider.
|
|
@@ -236,31 +258,15 @@ export interface StringProperty extends BaseProperty {
|
|
|
236
258
|
* This property is used to indicate that the string is a user ID, and
|
|
237
259
|
* it will be rendered as a user picker.
|
|
238
260
|
* Note that the user ID needs to be the one used in your authentication
|
|
239
|
-
* provider
|
|
261
|
+
* provider (e.g. the ID in your `users` table).
|
|
240
262
|
* You can also use a property builder to specify the user path dynamically
|
|
241
263
|
* based on other values of the entity.
|
|
242
264
|
*/
|
|
243
265
|
userSelect?: boolean;
|
|
244
|
-
/**
|
|
245
|
-
* If the value of this property is a URL, you can set this flag to true
|
|
246
|
-
* to add a link, or one of the supported media types to render a preview
|
|
247
|
-
*/
|
|
248
|
-
url?: boolean | PreviewType;
|
|
249
266
|
/**
|
|
250
267
|
* Does this field include an email
|
|
251
268
|
*/
|
|
252
269
|
email?: boolean;
|
|
253
|
-
/**
|
|
254
|
-
* Should this string be rendered as a tag instead of just text.
|
|
255
|
-
*/
|
|
256
|
-
previewAsTag?: boolean;
|
|
257
|
-
/**
|
|
258
|
-
* You can use this property (a string) to behave as a reference to another
|
|
259
|
-
* collection. The stored value is the ID of the entity in the
|
|
260
|
-
* collection, and the `path` prop is used to
|
|
261
|
-
* define the collection this reference points to.
|
|
262
|
-
*/
|
|
263
|
-
reference?: ReferenceProperty;
|
|
264
270
|
}
|
|
265
271
|
/**
|
|
266
272
|
* @group Entity properties
|
|
@@ -271,6 +277,10 @@ export interface NumberUIConfig extends BaseUIConfig {
|
|
|
271
277
|
export interface NumberProperty extends BaseProperty {
|
|
272
278
|
ui?: NumberUIConfig;
|
|
273
279
|
type: "number";
|
|
280
|
+
/**
|
|
281
|
+
* Default value for new entities. Must be a number.
|
|
282
|
+
*/
|
|
283
|
+
defaultValue?: number;
|
|
274
284
|
/**
|
|
275
285
|
* Optional database column type. Allows specifying exact database numeric types.
|
|
276
286
|
* If not provided, integer fields (where validation.integer is true or isId is true) default to `integer`, others to `numeric`.
|
|
@@ -304,6 +314,10 @@ export interface NumberProperty extends BaseProperty {
|
|
|
304
314
|
export interface BooleanProperty extends BaseProperty {
|
|
305
315
|
ui?: BaseUIConfig;
|
|
306
316
|
type: "boolean";
|
|
317
|
+
/**
|
|
318
|
+
* Default value for new entities. Must be a boolean.
|
|
319
|
+
*/
|
|
320
|
+
defaultValue?: boolean;
|
|
307
321
|
/**
|
|
308
322
|
* Rules for validating this property
|
|
309
323
|
*/
|
|
@@ -318,6 +332,10 @@ export interface VectorUIConfig extends BaseUIConfig {
|
|
|
318
332
|
export interface VectorProperty extends BaseProperty {
|
|
319
333
|
ui?: VectorUIConfig;
|
|
320
334
|
type: "vector";
|
|
335
|
+
/**
|
|
336
|
+
* Default value for new entities.
|
|
337
|
+
*/
|
|
338
|
+
defaultValue?: Vector;
|
|
321
339
|
dimensions: number;
|
|
322
340
|
validation?: PropertyValidationSchema;
|
|
323
341
|
}
|
|
@@ -326,17 +344,28 @@ export interface VectorProperty extends BaseProperty {
|
|
|
326
344
|
*/
|
|
327
345
|
export interface BinaryProperty extends BaseProperty {
|
|
328
346
|
type: "binary";
|
|
347
|
+
/**
|
|
348
|
+
* Default value for new entities. Must be a base64-encoded string.
|
|
349
|
+
*/
|
|
350
|
+
defaultValue?: string;
|
|
329
351
|
validation?: PropertyValidationSchema;
|
|
330
352
|
}
|
|
331
353
|
/**
|
|
332
354
|
* @group Entity properties
|
|
333
355
|
*/
|
|
334
356
|
export interface DateUIConfig extends BaseUIConfig {
|
|
357
|
+
/**
|
|
358
|
+
* Add an icon to clear the value and set it to `null`. Defaults to `false`
|
|
359
|
+
*/
|
|
335
360
|
clearable?: boolean;
|
|
336
361
|
}
|
|
337
362
|
export interface DateProperty extends BaseProperty {
|
|
338
363
|
ui?: DateUIConfig;
|
|
339
364
|
type: "date";
|
|
365
|
+
/**
|
|
366
|
+
* Default value for new entities. Must be a Date.
|
|
367
|
+
*/
|
|
368
|
+
defaultValue?: Date;
|
|
340
369
|
/**
|
|
341
370
|
* Optional database column type. If not set, defaults to `timestamp` with timezone.
|
|
342
371
|
*/
|
|
@@ -362,10 +391,6 @@ export interface DateProperty extends BaseProperty {
|
|
|
362
391
|
* `updated_on` fields
|
|
363
392
|
*/
|
|
364
393
|
autoValue?: "on_create" | "on_update";
|
|
365
|
-
/**
|
|
366
|
-
* Add an icon to clear the value and set it to `null`. Defaults to `false`
|
|
367
|
-
*/
|
|
368
|
-
clearable?: boolean;
|
|
369
394
|
}
|
|
370
395
|
/**
|
|
371
396
|
* @group Entity properties
|
|
@@ -373,6 +398,10 @@ export interface DateProperty extends BaseProperty {
|
|
|
373
398
|
export interface GeopointProperty extends BaseProperty {
|
|
374
399
|
ui?: BaseUIConfig;
|
|
375
400
|
type: "geopoint";
|
|
401
|
+
/**
|
|
402
|
+
* Default value for new entities. Must be a GeoPoint.
|
|
403
|
+
*/
|
|
404
|
+
defaultValue?: GeoPoint;
|
|
376
405
|
/**
|
|
377
406
|
* Rules for validating this property
|
|
378
407
|
*/
|
|
@@ -384,9 +413,29 @@ export interface GeopointProperty extends BaseProperty {
|
|
|
384
413
|
export interface ReferenceUIConfig extends BaseUIConfig {
|
|
385
414
|
previewProperties?: string[];
|
|
386
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* A pointer to an entity, stored **as a value** on the row (id + path, and
|
|
418
|
+
* optionally a `driver`/`databaseId` for cross-datasource pointers).
|
|
419
|
+
*
|
|
420
|
+
* This is the native primitive of **document databases** — it maps 1:1 to a
|
|
421
|
+
* Firestore `DocumentReference`, and is persisted by the MongoDB driver as a
|
|
422
|
+
* tagged sub-document. It carries no schema-level relationship (no foreign key,
|
|
423
|
+
* no join, no cascade) and is resolved on demand.
|
|
424
|
+
*
|
|
425
|
+
* **Which to use:**
|
|
426
|
+
* - Firestore / MongoDB collection → use `reference`.
|
|
427
|
+
* - Postgres collection → use {@link RelationProperty} (`type: "relation"`),
|
|
428
|
+
* which models a real foreign key / join with prefetch and cascade.
|
|
429
|
+
*
|
|
430
|
+
* @group Entity properties
|
|
431
|
+
*/
|
|
387
432
|
export interface ReferenceProperty extends BaseProperty {
|
|
388
433
|
ui?: ReferenceUIConfig;
|
|
389
434
|
type: "reference";
|
|
435
|
+
/**
|
|
436
|
+
* Default value for new entities. Must be an EntityReference.
|
|
437
|
+
*/
|
|
438
|
+
defaultValue?: EntityReference;
|
|
390
439
|
/**
|
|
391
440
|
* Marks this field as a Primary Key / Unique Identifier.
|
|
392
441
|
* Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
|
|
@@ -425,9 +474,29 @@ export interface RelationUIConfig extends BaseUIConfig {
|
|
|
425
474
|
previewProperties?: string[];
|
|
426
475
|
widget?: "select" | "dialog";
|
|
427
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* A schema-level relationship between collections **within a single
|
|
479
|
+
* datasource** — backed by a foreign key, junction table, or explicit join
|
|
480
|
+
* path. The resolved value (an `EntityRelation`) can carry a prefetched entity
|
|
481
|
+
* payload to eliminate N+1 queries, and supports `onUpdate`/`onDelete` cascade.
|
|
482
|
+
*
|
|
483
|
+
* This is the native primitive of **relational databases** (Postgres). It is
|
|
484
|
+
* the SQL counterpart to {@link ReferenceProperty}.
|
|
485
|
+
*
|
|
486
|
+
* **Which to use:**
|
|
487
|
+
* - Postgres collection → use `relation`.
|
|
488
|
+
* - Firestore / MongoDB collection → use {@link ReferenceProperty}
|
|
489
|
+
* (`type: "reference"`), a stored pointer with no join engine.
|
|
490
|
+
*
|
|
491
|
+
* @group Entity properties
|
|
492
|
+
*/
|
|
428
493
|
export interface RelationProperty extends BaseProperty {
|
|
429
494
|
ui?: RelationUIConfig;
|
|
430
495
|
type: "relation";
|
|
496
|
+
/**
|
|
497
|
+
* Default value for new entities. Must be an EntityRelation or array of EntityRelation.
|
|
498
|
+
*/
|
|
499
|
+
defaultValue?: EntityRelation | EntityRelation[];
|
|
431
500
|
/**
|
|
432
501
|
* Marks this field as a Primary Key / Unique Identifier.
|
|
433
502
|
* Framework behavior: Auto-maps to `collection.primaryKeys` internally if not explicitly set.
|
|
@@ -540,6 +609,10 @@ export interface ArrayUIConfig extends BaseUIConfig {
|
|
|
540
609
|
export interface ArrayProperty extends BaseProperty {
|
|
541
610
|
ui?: ArrayUIConfig;
|
|
542
611
|
type: "array";
|
|
612
|
+
/**
|
|
613
|
+
* Default value for new entities. Must be an array.
|
|
614
|
+
*/
|
|
615
|
+
defaultValue?: unknown[];
|
|
543
616
|
/**
|
|
544
617
|
* Optional database column type. By default, maps to a native Postgres array
|
|
545
618
|
* (e.g. `text[]`, `integer[]`/`numeric[]`, `boolean[]`) if the element type
|
|
@@ -617,6 +690,10 @@ export interface MapUIConfig extends BaseUIConfig {
|
|
|
617
690
|
export interface MapProperty extends BaseProperty {
|
|
618
691
|
ui?: MapUIConfig;
|
|
619
692
|
type: "map";
|
|
693
|
+
/**
|
|
694
|
+
* Default value for new entities. Must be a record/object.
|
|
695
|
+
*/
|
|
696
|
+
defaultValue?: Record<string, unknown>;
|
|
620
697
|
/**
|
|
621
698
|
* Optional database column type. Defaults to `jsonb`.
|
|
622
699
|
*/
|
|
@@ -794,6 +871,14 @@ export interface ArrayPropertyValidationSchema extends PropertyValidationSchema
|
|
|
794
871
|
* @group Entity properties
|
|
795
872
|
*/
|
|
796
873
|
export type StorageConfig = {
|
|
874
|
+
/**
|
|
875
|
+
* Key referencing a named storage backend from the StorageRegistry.
|
|
876
|
+
* Must match a `StorageSourceDefinition.key` or a key registered
|
|
877
|
+
* in `initializeRebaseBackend({ storage: { ... } })`.
|
|
878
|
+
*
|
|
879
|
+
* When omitted, the default storage source is used.
|
|
880
|
+
*/
|
|
881
|
+
storageSource?: string;
|
|
797
882
|
/**
|
|
798
883
|
* File MIME types that can be uploaded to this reference. Don't specify for
|
|
799
884
|
* 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" | "
|
|
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 {};
|
|
@@ -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
|
+
}
|
|
@@ -39,6 +39,12 @@ export interface RebaseTranslations {
|
|
|
39
39
|
unsaved_changes_body: string;
|
|
40
40
|
discard_changes: string;
|
|
41
41
|
keep_editing: string;
|
|
42
|
+
/** Dialog title when clearing a new/copy form */
|
|
43
|
+
clear_form?: string;
|
|
44
|
+
/** Confirmation body when discarding changes on an existing entity */
|
|
45
|
+
discard_changes_confirmation?: string;
|
|
46
|
+
/** Confirmation body when clearing a new/copy form */
|
|
47
|
+
clear_form_confirmation?: string;
|
|
42
48
|
search: string;
|
|
43
49
|
find_by_id: string;
|
|
44
50
|
find_entity_by_id: string;
|
|
@@ -153,6 +159,8 @@ export interface RebaseTranslations {
|
|
|
153
159
|
form_modified: string;
|
|
154
160
|
/** Tooltip when the form is in sync with the database */
|
|
155
161
|
form_in_sync: string;
|
|
162
|
+
/** Tooltip/alert shown when form has validation errors */
|
|
163
|
+
fix_errors_before_saving?: string;
|
|
156
164
|
admin: string;
|
|
157
165
|
home: string;
|
|
158
166
|
this_form_has_errors: string;
|
package/package.json
CHANGED
|
@@ -3,6 +3,9 @@ import type { RebaseData } from "./data";
|
|
|
3
3
|
import type { EmailService } from "./email";
|
|
4
4
|
import type { StorageSource } from "./storage";
|
|
5
5
|
import type { CronJobStatus, CronJobLogEntry } from "../types/cron";
|
|
6
|
+
import type { ApiKeysAPI } from "../types/api_keys";
|
|
7
|
+
import type { StorageSourceDefinition } from "../types/storage_source";
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Event type for authentication state changes
|
|
@@ -86,6 +89,8 @@ export interface AdminAPI {
|
|
|
86
89
|
createUser(data: { email: string; displayName?: string; password?: string; roles?: string[]; metadata?: Record<string, any> }): Promise<{ user: AdminUser }>;
|
|
87
90
|
updateUser(userId: string, data: { email?: string; displayName?: string; password?: string; roles?: string[]; metadata?: Record<string, any> }): Promise<{ user: AdminUser }>;
|
|
88
91
|
deleteUser(userId: string): Promise<{ success: boolean }>;
|
|
92
|
+
resetPassword(userId: string, options?: { password?: string }): Promise<{ user: AdminUser; temporaryPassword?: string; invitationSent?: boolean }>;
|
|
93
|
+
listRoles(): Promise<{ roles: Array<{ id: string; name: string }> }>;
|
|
89
94
|
bootstrap(): Promise<{ success: boolean; message: string; user: { uid: string; roles: string[] } }>;
|
|
90
95
|
}
|
|
91
96
|
|
|
@@ -153,9 +158,30 @@ export interface RebaseClient<DB = unknown> {
|
|
|
153
158
|
/** Unified Authentication layer */
|
|
154
159
|
auth: AuthClient;
|
|
155
160
|
|
|
156
|
-
/** Unified Storage layer */
|
|
161
|
+
/** Unified Storage layer (default storage source, backward-compatible) */
|
|
157
162
|
storage?: StorageSource;
|
|
158
163
|
|
|
164
|
+
/** Registry of all named storage sources for multi-backend support */
|
|
165
|
+
storageRegistry?: StorageSourceRegistry;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Build a server-backed {@link StorageSource} for a named storage source.
|
|
169
|
+
* The returned source forwards `storageId` to the backend so requests are
|
|
170
|
+
* routed to the matching `StorageController`. Used to lazily wire
|
|
171
|
+
* `transport: "server"` sources on the frontend.
|
|
172
|
+
*/
|
|
173
|
+
createStorageSource?(storageId: string): StorageSource;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Discover the storage sources declared on the backend via
|
|
177
|
+
* `GET /api/storage/sources`. Server-transport sources are auto-registered
|
|
178
|
+
* into {@link storageRegistry}; `direct` sources are returned so the app
|
|
179
|
+
* can supply the live {@link StorageSource} instance. The result is cached
|
|
180
|
+
* (a failed call is retryable). This makes the backend the single source of
|
|
181
|
+
* truth for storage-source configuration.
|
|
182
|
+
*/
|
|
183
|
+
fetchStorageSources?(): Promise<StorageSourceDefinition[]>;
|
|
184
|
+
|
|
159
185
|
/**
|
|
160
186
|
* Server-side email service.
|
|
161
187
|
* Available when SMTP or a custom `sendEmail` function is configured.
|
|
@@ -171,6 +197,10 @@ export interface RebaseClient<DB = unknown> {
|
|
|
171
197
|
/** Custom backend functions API */
|
|
172
198
|
functions?: FunctionsAPI;
|
|
173
199
|
|
|
200
|
+
/** Service API keys management API */
|
|
201
|
+
apiKeys?: ApiKeysAPI;
|
|
202
|
+
|
|
203
|
+
|
|
174
204
|
/** Base HTTP URL of the backend server */
|
|
175
205
|
baseUrl?: string;
|
|
176
206
|
|
|
@@ -199,3 +229,41 @@ export interface RebaseClient<DB = unknown> {
|
|
|
199
229
|
sql?(query: string, options?: { database?: string; role?: string }): Promise<Record<string, unknown>[]>;
|
|
200
230
|
}
|
|
201
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Client-side registry for managing multiple storage sources.
|
|
234
|
+
*
|
|
235
|
+
* Mirrors the server-side `StorageRegistry` pattern. Allows collection
|
|
236
|
+
* properties to reference a named storage backend via
|
|
237
|
+
* `StorageConfig.storageSource`.
|
|
238
|
+
*
|
|
239
|
+
* @group Models
|
|
240
|
+
*/
|
|
241
|
+
export interface StorageSourceRegistry {
|
|
242
|
+
/**
|
|
243
|
+
* Get a storage source by key.
|
|
244
|
+
* @param key - Storage source key, or undefined/null for default
|
|
245
|
+
* @returns The StorageSource, or undefined if not found
|
|
246
|
+
*/
|
|
247
|
+
get(key: string | undefined | null): StorageSource | undefined;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Get the default storage source (key = "(default)").
|
|
251
|
+
* @throws Error if no default storage is registered
|
|
252
|
+
*/
|
|
253
|
+
getDefault(): StorageSource;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Get a storage source by key, with fallback to default.
|
|
257
|
+
* @param key - Storage source key, or undefined/null for default
|
|
258
|
+
* @returns The StorageSource (falls back to default if key not found)
|
|
259
|
+
* @throws Error if neither the specified nor default storage exists
|
|
260
|
+
*/
|
|
261
|
+
getOrDefault(key: string | undefined | null): StorageSource;
|
|
262
|
+
|
|
263
|
+
/** Check if a storage source with the given key exists */
|
|
264
|
+
has(key: string): boolean;
|
|
265
|
+
|
|
266
|
+
/** List all registered storage source keys */
|
|
267
|
+
list(): string[];
|
|
268
|
+
}
|
|
269
|
+
|
package/src/controllers/data.ts
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
1
|
import { Entity, EntityValues } from "../types/entities";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Parameters for querying a collection.
|
|
5
|
-
* Uses PostgREST-style filter syntax for consistency between
|
|
6
|
-
* the SDK (HTTP) and framework (in-process) contexts.
|
|
7
|
-
*
|
|
8
|
-
* @group Data
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* A where-clause value for a single field.
|
|
12
|
-
*
|
|
13
|
-
* Supports three syntaxes:
|
|
14
|
-
* 1. **Equality shorthand**: raw JS values — `null`, `"active"`, `42`, `true`
|
|
15
|
-
* 2. **Tuple syntax**: `[operator, value]` — `[">", 18]`, `["in", ["a","b"]]`
|
|
16
|
-
* 3. **PostgREST string**: `"eq.published"`, `"gte.18"`, `"in.(a,b)"`
|
|
17
|
-
*
|
|
18
|
-
* @group Data
|
|
19
|
-
*/
|
|
20
|
-
export type WhereFieldValue =
|
|
21
|
-
| string
|
|
22
|
-
| number
|
|
23
|
-
| boolean
|
|
24
|
-
| null
|
|
25
|
-
| [WhereFilterOpShort, any]
|
|
26
|
-
| [WhereFilterOpShort, any][];
|
|
2
|
+
import { WhereFilterOp, FilterValues } from "../types/filter-operators";
|
|
27
3
|
|
|
28
4
|
export type WhereValue<T> = T | T[] | null;
|
|
29
5
|
|
|
@@ -34,17 +10,15 @@ export interface LogicalCondition {
|
|
|
34
10
|
|
|
35
11
|
export interface FilterCondition {
|
|
36
12
|
column: string;
|
|
37
|
-
operator:
|
|
13
|
+
operator: WhereFilterOp;
|
|
38
14
|
value: unknown;
|
|
39
15
|
}
|
|
40
16
|
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
| "array-contains" | "array-contains-any" | "cs" | "csa";
|
|
47
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Parameters for querying a collection.
|
|
19
|
+
*
|
|
20
|
+
* @group Data
|
|
21
|
+
*/
|
|
48
22
|
export interface FindParams {
|
|
49
23
|
/** Maximum number of items to return (default: 20) */
|
|
50
24
|
limit?: number;
|
|
@@ -53,30 +27,17 @@ export interface FindParams {
|
|
|
53
27
|
/** Page number (1-indexed), alternative to offset */
|
|
54
28
|
page?: number;
|
|
55
29
|
/**
|
|
56
|
-
* Filter
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* ```ts
|
|
60
|
-
* { company_profile_id: null }
|
|
61
|
-
* { status: "active" }
|
|
62
|
-
* { age: 18 }
|
|
63
|
-
* ```
|
|
30
|
+
* Filter conditions keyed by field name.
|
|
31
|
+
* Each value is a `[WhereFilterOp, value]` tuple or an array of tuples
|
|
32
|
+
* for multiple conditions on the same field.
|
|
64
33
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
34
|
+
* @example
|
|
35
|
+
* { status: ["==", "active"] }
|
|
67
36
|
* { age: [">=", 18] }
|
|
68
37
|
* { role: ["in", ["admin", "editor"]] }
|
|
69
|
-
* {
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* **PostgREST string syntax** (original format):
|
|
73
|
-
* ```ts
|
|
74
|
-
* { status: "eq.published" }
|
|
75
|
-
* { age: "gte.18" }
|
|
76
|
-
* { role: "in.(admin,editor)" }
|
|
77
|
-
* ```
|
|
38
|
+
* { age: [[">=", 18], ["<", 65]] }
|
|
78
39
|
*/
|
|
79
|
-
where?:
|
|
40
|
+
where?: FilterValues<string>;
|
|
80
41
|
/** Logical grouping conditions (AND/OR) */
|
|
81
42
|
logical?: LogicalCondition;
|
|
82
43
|
/**
|
|
@@ -106,16 +67,16 @@ export interface FindResponse<M extends Record<string, unknown> = Record<string,
|
|
|
106
67
|
};
|
|
107
68
|
}
|
|
108
69
|
|
|
109
|
-
|
|
70
|
+
|
|
110
71
|
|
|
111
72
|
/**
|
|
112
73
|
* Fluent Query Builder Interface supported on both client and server accessors.
|
|
113
74
|
* @group Data
|
|
114
75
|
*/
|
|
115
76
|
export interface QueryBuilderInterface<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
116
|
-
where<K extends keyof M & string>(column: K, operator:
|
|
77
|
+
where<K extends keyof M & string>(column: K, operator: WhereFilterOp, value: WhereValue<M[K]>): this;
|
|
117
78
|
where(logicalCondition: LogicalCondition): this;
|
|
118
|
-
orderBy(column: keyof M & string,
|
|
79
|
+
orderBy(column: keyof M & string, direction?: "asc" | "desc"): this;
|
|
119
80
|
limit(count: number): this;
|
|
120
81
|
offset(count: number): this;
|
|
121
82
|
search(searchString: string): this;
|
|
@@ -186,9 +147,9 @@ export interface CollectionAccessor<M extends Record<string, unknown> = Record<s
|
|
|
186
147
|
count?(params?: FindParams): Promise<number>;
|
|
187
148
|
|
|
188
149
|
// Fluent Query Builder
|
|
189
|
-
where<K extends keyof M & string>(column: K, operator:
|
|
150
|
+
where<K extends keyof M & string>(column: K, operator: WhereFilterOp, value: WhereValue<M[K]>): QueryBuilderInterface<M>;
|
|
190
151
|
where(logicalCondition: LogicalCondition): QueryBuilderInterface<M>;
|
|
191
|
-
orderBy(column: keyof M & string,
|
|
152
|
+
orderBy(column: keyof M & string, direction?: "asc" | "desc"): QueryBuilderInterface<M>;
|
|
192
153
|
limit(count: number): QueryBuilderInterface<M>;
|
|
193
154
|
offset(count: number): QueryBuilderInterface<M>;
|
|
194
155
|
search(searchString: string): QueryBuilderInterface<M>;
|
|
@@ -226,7 +187,7 @@ export interface RebaseData {
|
|
|
226
187
|
* const accessor = data.collection("products");
|
|
227
188
|
* await accessor.find({ limit: 10 });
|
|
228
189
|
*/
|
|
229
|
-
collection(slug: string): CollectionAccessor
|
|
190
|
+
collection<M extends Record<string, unknown> = Record<string, unknown>>(slug: string): CollectionAccessor<M>;
|
|
230
191
|
|
|
231
192
|
/**
|
|
232
193
|
* Dynamic collection accessor.
|