@rebasepro/types 0.8.0 → 0.9.1-canary.09aaf62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/dist/controllers/auth.d.ts +7 -1
- package/dist/controllers/client.d.ts +204 -6
- package/dist/controllers/collection_registry.d.ts +3 -3
- package/dist/controllers/customization_controller.d.ts +1 -1
- package/dist/controllers/data.d.ts +309 -35
- package/dist/controllers/data_driver.d.ts +92 -37
- package/dist/controllers/email.d.ts +2 -2
- 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 +21 -8
- 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 +160 -15
- package/dist/index.es.js.map +1 -1
- package/dist/rebase_context.d.ts +8 -4
- package/dist/types/auth_adapter.d.ts +29 -4
- package/dist/types/backend.d.ts +33 -26
- package/dist/types/backup.d.ts +20 -0
- package/dist/types/builders.d.ts +2 -2
- package/dist/types/collections.d.ts +84 -75
- package/dist/types/component_overrides.d.ts +61 -3
- package/dist/types/cron.d.ts +11 -2
- package/dist/types/data_source.d.ts +15 -2
- package/dist/types/database_adapter.d.ts +21 -4
- package/dist/types/entities.d.ts +7 -7
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +39 -39
- package/dist/types/entity_views.d.ts +3 -3
- package/dist/types/filter-operators.d.ts +62 -17
- package/dist/types/index.d.ts +1 -0
- package/dist/types/modify_collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +9 -9
- package/dist/types/policy.d.ts +111 -11
- package/dist/types/properties.d.ts +54 -9
- package/dist/types/relations.d.ts +3 -3
- package/dist/types/slots.d.ts +14 -14
- package/dist/types/translations.d.ts +5 -1
- package/dist/types/user_management_delegate.d.ts +8 -2
- package/dist/types/websockets.d.ts +46 -13
- package/dist/users/user.d.ts +21 -9
- package/package.json +5 -6
- package/src/controllers/auth.tsx +7 -1
- package/src/controllers/client.ts +235 -7
- package/src/controllers/collection_registry.ts +3 -3
- package/src/controllers/customization_controller.tsx +1 -1
- package/src/controllers/data.ts +330 -39
- package/src/controllers/data_driver.ts +93 -40
- package/src/controllers/email.ts +2 -2
- 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 +22 -8
- 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 +29 -4
- package/src/types/backend.ts +44 -36
- package/src/types/backup.ts +26 -0
- package/src/types/builders.ts +2 -2
- package/src/types/collections.ts +101 -91
- package/src/types/component_overrides.ts +72 -5
- package/src/types/cron.ts +11 -2
- package/src/types/data_source.ts +24 -2
- package/src/types/database_adapter.ts +19 -4
- package/src/types/entities.ts +7 -7
- package/src/types/entity_actions.tsx +7 -7
- package/src/types/entity_callbacks.ts +42 -42
- package/src/types/entity_views.tsx +3 -3
- package/src/types/filter-operators.ts +96 -23
- package/src/types/index.ts +1 -0
- package/src/types/modify_collections.tsx +2 -2
- package/src/types/plugins.tsx +9 -9
- package/src/types/policy.ts +114 -9
- package/src/types/properties.ts +58 -9
- package/src/types/relations.ts +3 -3
- package/src/types/slots.tsx +14 -14
- package/src/types/translations.ts +5 -1
- package/src/types/user_management_delegate.ts +8 -2
- package/src/types/websockets.ts +43 -14
- package/src/users/user.ts +22 -9
- package/dist/index.umd.js +0 -458
- package/dist/index.umd.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Entity, EntityStatus } from "./entities";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CollectionCallbacks } from "./entity_callbacks";
|
|
4
4
|
import type { Properties, PostgresProperties, FirebaseProperties, MongoProperties } from "./properties";
|
|
5
5
|
import type { ExportConfig } from "./export_import";
|
|
6
6
|
import type { User } from "../users";
|
|
@@ -11,16 +11,16 @@ import type { EntityAction } from "./entity_actions";
|
|
|
11
11
|
import type { PolicyExpression } from "./policy";
|
|
12
12
|
import type { ComponentRef } from "./component_ref";
|
|
13
13
|
import type { CollectionComponentOverrideMap } from "./component_overrides";
|
|
14
|
-
import type { FilterValues, FilterPreset } from "./filter-operators";
|
|
14
|
+
import type { FilterValues, FilterPreset, OrderByTuple } from "./filter-operators";
|
|
15
15
|
/**
|
|
16
16
|
* Base interface containing all driver-agnostic collection properties.
|
|
17
|
-
* Use {@link
|
|
18
|
-
* driver-specific type safety, or {@link
|
|
17
|
+
* Use {@link PostgresCollectionConfig} or {@link FirebaseCollectionConfig} for
|
|
18
|
+
* driver-specific type safety, or {@link CollectionConfig} when you
|
|
19
19
|
* need to handle any collection regardless of backend.
|
|
20
20
|
*
|
|
21
21
|
* @group Models
|
|
22
22
|
*/
|
|
23
|
-
export interface
|
|
23
|
+
export interface BaseCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
24
24
|
/**
|
|
25
25
|
* You can set an alias that will be used internally instead of the collection name.
|
|
26
26
|
* The `slug` value will be used to determine the URL of the collection.
|
|
@@ -48,12 +48,12 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
48
48
|
*
|
|
49
49
|
* Custom drivers can set this directly to expose child collections to the UI.
|
|
50
50
|
*/
|
|
51
|
-
childCollections?: () =>
|
|
51
|
+
childCollections?: () => CollectionConfig<Record<string, unknown>>[];
|
|
52
52
|
/**
|
|
53
53
|
* The data source this collection belongs to — the routing key shared by
|
|
54
54
|
* the frontend router and the backend driver registry. It points at a
|
|
55
55
|
* {@link DataSourceDefinition} registered on `<Rebase dataSources>` (front)
|
|
56
|
-
* and `
|
|
56
|
+
* and `initializeRebaseBackend({ dataSources })` (back).
|
|
57
57
|
*
|
|
58
58
|
* If not specified, the default data source `"(default)"` is used, which
|
|
59
59
|
* for a standard Rebase app is the server-mediated Postgres backend.
|
|
@@ -70,8 +70,8 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
70
70
|
* The database engine backing this collection (`"postgres"`, `"firestore"`,
|
|
71
71
|
* `"mongodb"`, or a custom id).
|
|
72
72
|
*
|
|
73
|
-
* On concrete collection types ({@link
|
|
74
|
-
* {@link
|
|
73
|
+
* On concrete collection types ({@link PostgresCollectionConfig},
|
|
74
|
+
* {@link FirebaseCollectionConfig}, {@link MongoDBCollectionConfig}) this is a literal
|
|
75
75
|
* discriminant. On the base type it is optional and gets stamped
|
|
76
76
|
* automatically during collection normalization from the registered
|
|
77
77
|
* {@link DataSourceDefinition}.
|
|
@@ -90,7 +90,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
90
90
|
*/
|
|
91
91
|
databaseId?: string;
|
|
92
92
|
/**
|
|
93
|
-
* Set of properties that compose
|
|
93
|
+
* Set of properties that compose a entity
|
|
94
94
|
*/
|
|
95
95
|
properties: Properties;
|
|
96
96
|
/**
|
|
@@ -125,12 +125,12 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
125
125
|
*/
|
|
126
126
|
readonly titleProperty?: Extract<keyof M, string> | (string & {});
|
|
127
127
|
/**
|
|
128
|
-
* When editing
|
|
128
|
+
* When editing a entity, you can choose to open the entity in a side dialog
|
|
129
129
|
* or in a full screen dialog. Defaults to `full_screen`.
|
|
130
130
|
*/
|
|
131
131
|
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
132
132
|
/**
|
|
133
|
-
* Controls what happens when a user clicks on
|
|
133
|
+
* Controls what happens when a user clicks on a entity in the collection view.
|
|
134
134
|
* - `"edit"` (default): Opens the entity in the edit form.
|
|
135
135
|
* - `"view"`: Opens a read-only detail view with an "Edit" button.
|
|
136
136
|
*/
|
|
@@ -154,42 +154,40 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
154
154
|
*/
|
|
155
155
|
auth?: boolean | AuthCollectionConfig;
|
|
156
156
|
/**
|
|
157
|
-
* Opt out of the framework's default Row Level Security policies
|
|
158
|
-
* authentication collections.
|
|
157
|
+
* Opt out of the framework's default Row Level Security policies.
|
|
159
158
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* `admin` role
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
159
|
+
* The schema generator automatically injects, for every collection, a
|
|
160
|
+
* baseline SELECT policy granting the trusted server context and the
|
|
161
|
+
* `admin` role read access (reads run under a restricted role, so RLS
|
|
162
|
+
* default-denies without it). For auth collections it additionally injects
|
|
163
|
+
* a self-read policy (`id = auth.uid()`) and an admin-only write gate
|
|
164
|
+
* (INSERT/UPDATE/DELETE require the `admin` role or the trusted server
|
|
165
|
+
* context), making privileged columns such as `roles` safe by default.
|
|
167
166
|
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
167
|
+
* Author-defined `securityRules` are permissive and broaden access on top
|
|
168
|
+
* of these defaults. Set this flag to `true` to remove the defaults
|
|
170
169
|
* entirely and take full responsibility for the collection's RLS.
|
|
171
170
|
*
|
|
172
171
|
* @default false
|
|
173
172
|
*/
|
|
174
|
-
|
|
173
|
+
disableDefaultPolicies?: boolean;
|
|
175
174
|
/**
|
|
176
175
|
* Order in which the properties are displayed.
|
|
177
176
|
* If you are specifying your collection as code, the order is the same as the
|
|
178
177
|
* one you define in `properties`. Additional columns are added at the
|
|
179
178
|
* end of the list, if the order is not specified.
|
|
179
|
+
*
|
|
180
180
|
* You can use this prop to hide some properties from the table view.
|
|
181
181
|
* Note that if you set this prop, other ways to hide fields, like
|
|
182
182
|
* `hidden` in the property definition, will be ignored.
|
|
183
183
|
* `propertiesOrder` has precedence over `hidden`.
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* -
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* `hidden` in the property definition,will be ignored.
|
|
192
|
-
* `propertiesOrder` has precedence over `hidden`.
|
|
184
|
+
*
|
|
185
|
+
* Supported entry formats:
|
|
186
|
+
* - For properties, use the property key.
|
|
187
|
+
* - For additional fields, use the field key.
|
|
188
|
+
* - Child collections (Firestore subcollections, or Postgres relations
|
|
189
|
+
* with `many` cardinality) each get a column with id
|
|
190
|
+
* `subcollection:<slug>`, e.g. `subcollection:orders`.
|
|
193
191
|
*/
|
|
194
192
|
propertiesOrder?: (Extract<keyof M, string> | (string & {}) | string | `subcollection:${string}`)[];
|
|
195
193
|
/**
|
|
@@ -202,11 +200,11 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
202
200
|
pagination?: boolean | number;
|
|
203
201
|
selectionEnabled?: boolean;
|
|
204
202
|
/**
|
|
205
|
-
* This interface defines all the callbacks that can be used when
|
|
203
|
+
* This interface defines all the callbacks that can be used when a entity
|
|
206
204
|
* is being created, updated or deleted.
|
|
207
205
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
208
206
|
*/
|
|
209
|
-
readonly callbacks?:
|
|
207
|
+
readonly callbacks?: CollectionCallbacks<M, USER>;
|
|
210
208
|
/**
|
|
211
209
|
* Pass your own selection controller if you want to control selected
|
|
212
210
|
* entities externally.
|
|
@@ -251,7 +249,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
251
249
|
* applied in the collection.
|
|
252
250
|
* e.g. `sort: ["order", "asc"]`
|
|
253
251
|
*/
|
|
254
|
-
readonly sort?:
|
|
252
|
+
readonly sort?: OrderByTuple<Extract<keyof M, string> | (string & {})>;
|
|
255
253
|
/**
|
|
256
254
|
* You can add additional fields to the collection view by implementing
|
|
257
255
|
* an additional field delegate.
|
|
@@ -277,7 +275,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
277
275
|
hideFromNavigation?: boolean;
|
|
278
276
|
/**
|
|
279
277
|
* If you want to open custom views or subcollections by default when opening the edit
|
|
280
|
-
* view of
|
|
278
|
+
* view of a entity, you can specify the path to the view here.
|
|
281
279
|
* The path is relative to the current collection. For example if you have a collection
|
|
282
280
|
* that has a custom view as well as a subcollection that refers to another entity, you can
|
|
283
281
|
* either specify the path to the custom view or the path to the subcollection.
|
|
@@ -314,7 +312,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
314
312
|
*/
|
|
315
313
|
metadata?: Record<string, unknown>;
|
|
316
314
|
/**
|
|
317
|
-
* Width of the side dialog (in pixels) when opening
|
|
315
|
+
* Width of the side dialog (in pixels) when opening a entity in this collection.
|
|
318
316
|
*/
|
|
319
317
|
sideDialogWidth?: number | string;
|
|
320
318
|
/**
|
|
@@ -332,12 +330,23 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
332
330
|
* This prop has no effect if the history plugin is not enabled
|
|
333
331
|
*/
|
|
334
332
|
history?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Whether a write naming a field this collection does not declare is
|
|
335
|
+
* rejected with a 400. Defaults to `true`.
|
|
336
|
+
*
|
|
337
|
+
* Set to `false` to let unknown keys through to the database, which is what
|
|
338
|
+
* happened before this existed: a typo reached the INSERT and came back as
|
|
339
|
+
* a Postgres error about a column, or — where a column really does exist
|
|
340
|
+
* that the config never declared, populated by a trigger or a default —
|
|
341
|
+
* quietly worked. The second case is the reason for the escape hatch.
|
|
342
|
+
*/
|
|
343
|
+
strictWrites?: boolean;
|
|
335
344
|
/**
|
|
336
345
|
* Should local changes be backed up in local storage, to prevent data loss on
|
|
337
346
|
* accidental navigations.
|
|
338
|
-
* - `manual_apply`: When the user navigates back to
|
|
347
|
+
* - `manual_apply`: When the user navigates back to a entity with local changes,
|
|
339
348
|
* they will be prompted to restore the changes.
|
|
340
|
-
* - `auto_apply`: When the user navigates back to
|
|
349
|
+
* - `auto_apply`: When the user navigates back to a entity with local changes,
|
|
341
350
|
* the changes will be automatically applied.
|
|
342
351
|
* - `false`: Local changes will not be backed up.
|
|
343
352
|
* Defaults to `manual_apply`.
|
|
@@ -397,7 +406,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
397
406
|
* Security rules for this collection (Row Level Security).
|
|
398
407
|
* When defined, the backend enforces access control policies.
|
|
399
408
|
*/
|
|
400
|
-
securityRules?: SecurityRule[];
|
|
409
|
+
securityRules?: readonly SecurityRule[];
|
|
401
410
|
/**
|
|
402
411
|
* Collection-scoped component overrides. These take precedence over
|
|
403
412
|
* global overrides set on `<Rebase>`, but only within this collection's
|
|
@@ -409,7 +418,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
409
418
|
*
|
|
410
419
|
* @example
|
|
411
420
|
* ```tsx
|
|
412
|
-
* const productsCollection:
|
|
421
|
+
* const productsCollection: PostgresCollectionConfig = {
|
|
413
422
|
* name: "Products",
|
|
414
423
|
* slug: "products",
|
|
415
424
|
* table: "products",
|
|
@@ -427,12 +436,12 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
427
436
|
* A collection backed by PostgreSQL (or any SQL database).
|
|
428
437
|
* Adds support for SQL-style relations (JOINs) and Row Level Security.
|
|
429
438
|
*
|
|
430
|
-
* Use this type instead of {@link
|
|
439
|
+
* Use this type instead of {@link CollectionConfig} when you want
|
|
431
440
|
* compile-time safety that only SQL-relevant fields appear.
|
|
432
441
|
*
|
|
433
442
|
* @group Models
|
|
434
443
|
*/
|
|
435
|
-
export interface
|
|
444
|
+
export interface PostgresCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseCollectionConfig<M, USER> {
|
|
436
445
|
properties: PostgresProperties;
|
|
437
446
|
/**
|
|
438
447
|
* The database engine for this collection. For Postgres collections this
|
|
@@ -455,7 +464,7 @@ export interface PostgresCollection<M extends Record<string, unknown> = Record<s
|
|
|
455
464
|
*/
|
|
456
465
|
relations?: Relation[];
|
|
457
466
|
/**
|
|
458
|
-
* Security rules for this collection (
|
|
467
|
+
* Security rules for this collection (PostgreSQL Row Level Security).
|
|
459
468
|
* When defined, the schema generator will enable RLS on the table and
|
|
460
469
|
* create the corresponding PostgreSQL policies.
|
|
461
470
|
*
|
|
@@ -469,24 +478,24 @@ export interface PostgresCollection<M extends Record<string, unknown> = Record<s
|
|
|
469
478
|
* - `auth.roles()` — comma-separated app role IDs
|
|
470
479
|
* - `auth.jwt()` — full JWT claims as JSONB
|
|
471
480
|
*/
|
|
472
|
-
securityRules?: SecurityRule[];
|
|
481
|
+
securityRules?: readonly SecurityRule[];
|
|
473
482
|
}
|
|
474
483
|
/**
|
|
475
484
|
* A collection backed by Firebase / Firestore.
|
|
476
485
|
* Adds support for subcollections (nested document collections).
|
|
477
486
|
*
|
|
478
|
-
* Use this type instead of {@link
|
|
487
|
+
* Use this type instead of {@link CollectionConfig} when you want
|
|
479
488
|
* compile-time safety that only Firestore-relevant fields appear.
|
|
480
489
|
*
|
|
481
490
|
* @group Models
|
|
482
491
|
*/
|
|
483
|
-
export interface
|
|
492
|
+
export interface FirebaseCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseCollectionConfig<M, USER> {
|
|
484
493
|
/**
|
|
485
494
|
* The database engine for this collection. Must be set to `"firestore"`.
|
|
486
495
|
*/
|
|
487
496
|
engine: "firestore";
|
|
488
497
|
/**
|
|
489
|
-
* Set of properties that compose
|
|
498
|
+
* Set of properties that compose a entity.
|
|
490
499
|
* Firestore collections support `reference` properties but not `relation`.
|
|
491
500
|
*/
|
|
492
501
|
properties: FirebaseProperties;
|
|
@@ -497,7 +506,7 @@ export interface FirebaseCollection<M extends Record<string, unknown> = Record<s
|
|
|
497
506
|
*
|
|
498
507
|
* @example
|
|
499
508
|
* ```typescript
|
|
500
|
-
* const fsCustomer:
|
|
509
|
+
* const fsCustomer: FirebaseCollectionConfig = {
|
|
501
510
|
* slug: "fs_customer", // URL: /c/fs_customer
|
|
502
511
|
* path: "customer", // Firestore path: customer
|
|
503
512
|
* name: "Customers (Firestore)",
|
|
@@ -510,25 +519,25 @@ export interface FirebaseCollection<M extends Record<string, unknown> = Record<s
|
|
|
510
519
|
/**
|
|
511
520
|
* You can add subcollections to your entity in the same way you define the root
|
|
512
521
|
* collections. The collections added here will be displayed when opening
|
|
513
|
-
* the side dialog of
|
|
522
|
+
* the side dialog of a entity.
|
|
514
523
|
*/
|
|
515
|
-
subcollections?: () =>
|
|
524
|
+
subcollections?: () => CollectionConfig<Record<string, unknown>>[];
|
|
516
525
|
}
|
|
517
526
|
/**
|
|
518
527
|
* A collection backed by MongoDB.
|
|
519
528
|
*
|
|
520
|
-
* Use this type instead of {@link
|
|
529
|
+
* Use this type instead of {@link CollectionConfig} when you want
|
|
521
530
|
* compile-time safety that only MongoDB-relevant fields appear.
|
|
522
531
|
*
|
|
523
532
|
* @group Models
|
|
524
533
|
*/
|
|
525
|
-
export interface
|
|
534
|
+
export interface MongoDBCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> extends BaseCollectionConfig<M, USER> {
|
|
526
535
|
/**
|
|
527
536
|
* The database engine for this collection. Must be set to `"mongodb"`.
|
|
528
537
|
*/
|
|
529
538
|
engine: "mongodb";
|
|
530
539
|
/**
|
|
531
|
-
* Set of properties that compose
|
|
540
|
+
* Set of properties that compose a entity.
|
|
532
541
|
* MongoDB collections support `reference` properties but not `relation`.
|
|
533
542
|
*/
|
|
534
543
|
properties: MongoProperties;
|
|
@@ -539,7 +548,7 @@ export interface MongoDBCollection<M extends Record<string, unknown> = Record<st
|
|
|
539
548
|
*
|
|
540
549
|
* @example
|
|
541
550
|
* ```typescript
|
|
542
|
-
* const mongoCustomer:
|
|
551
|
+
* const mongoCustomer: MongoDBCollectionConfig = {
|
|
543
552
|
* slug: "mongo_customer", // URL: /c/mongo_customer
|
|
544
553
|
* path: "customer", // MongoDB collection: customer
|
|
545
554
|
* name: "Customers (MongoDB)",
|
|
@@ -552,35 +561,35 @@ export interface MongoDBCollection<M extends Record<string, unknown> = Record<st
|
|
|
552
561
|
}
|
|
553
562
|
/**
|
|
554
563
|
* A collection backed by any data source.
|
|
555
|
-
* This is a discriminated union — use {@link
|
|
556
|
-
* {@link
|
|
564
|
+
* This is a discriminated union — use {@link PostgresCollectionConfig},
|
|
565
|
+
* {@link FirebaseCollectionConfig}, or {@link MongoDBCollectionConfig} for
|
|
557
566
|
* driver-specific type safety.
|
|
558
567
|
*
|
|
559
568
|
* @group Models
|
|
560
569
|
*/
|
|
561
|
-
export type
|
|
570
|
+
export type CollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = PostgresCollectionConfig<M, USER> | FirebaseCollectionConfig<M, USER> | MongoDBCollectionConfig<M, USER>;
|
|
562
571
|
/**
|
|
563
572
|
* Type guard for PostgreSQL collections.
|
|
564
573
|
* Returns true if the collection uses the Postgres engine (or the default engine).
|
|
565
574
|
* @group Models
|
|
566
575
|
*/
|
|
567
|
-
export declare function
|
|
576
|
+
export declare function isPostgresCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): collection is PostgresCollectionConfig<M, USER>;
|
|
568
577
|
/**
|
|
569
578
|
* Type guard for Firebase / Firestore collections.
|
|
570
579
|
* @group Models
|
|
571
580
|
*/
|
|
572
|
-
export declare function
|
|
581
|
+
export declare function isFirebaseCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): collection is FirebaseCollectionConfig<M, USER>;
|
|
573
582
|
/**
|
|
574
583
|
* Type guard for MongoDB collections.
|
|
575
584
|
* @group Models
|
|
576
585
|
*/
|
|
577
|
-
export declare function
|
|
586
|
+
export declare function isMongoDBCollectionConfig<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): collection is MongoDBCollectionConfig<M, USER>;
|
|
578
587
|
/**
|
|
579
588
|
* Returns the data path for a collection.
|
|
580
589
|
* For Firestore or MongoDB collections with a `path`, returns that value;
|
|
581
590
|
* otherwise falls back to `slug`.
|
|
582
591
|
*/
|
|
583
|
-
export declare function getCollectionDataPath<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection:
|
|
592
|
+
export declare function getCollectionDataPath<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): string;
|
|
584
593
|
/**
|
|
585
594
|
* Reads a collection's driver-declared subcollections thunk (the `subcollections`
|
|
586
595
|
* field) independent of engine identity, so engine-agnostic code doesn't have to
|
|
@@ -591,7 +600,7 @@ export declare function getCollectionDataPath<M extends Record<string, unknown>
|
|
|
591
600
|
* whether the engine honours subcollections at all before reading them.
|
|
592
601
|
* @group Models
|
|
593
602
|
*/
|
|
594
|
-
export declare function getDeclaredSubcollections<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection:
|
|
603
|
+
export declare function getDeclaredSubcollections<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>(collection: CollectionConfig<M, USER>): (() => CollectionConfig<Record<string, unknown>>[]) | undefined;
|
|
595
604
|
/**
|
|
596
605
|
* Configuration for Kanban board view mode.
|
|
597
606
|
* @group Collections
|
|
@@ -621,7 +630,7 @@ export type ViewMode = "list" | "table" | "cards" | "kanban";
|
|
|
621
630
|
*
|
|
622
631
|
* @group Models
|
|
623
632
|
*/
|
|
624
|
-
export interface CollectionActionsProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends
|
|
633
|
+
export interface CollectionActionsProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends CollectionConfig<M> = CollectionConfig<M>> {
|
|
625
634
|
/**
|
|
626
635
|
* Full collection path of this entity. This is the full path, like
|
|
627
636
|
* `users/1234/addresses`
|
|
@@ -677,7 +686,7 @@ export interface CollectionActionsProps<M extends Record<string, unknown> = Reco
|
|
|
677
686
|
}
|
|
678
687
|
/**
|
|
679
688
|
* Use this controller to retrieve the selected entities or modify them in
|
|
680
|
-
* an {@link
|
|
689
|
+
* an {@link CollectionConfig}
|
|
681
690
|
* @group Models
|
|
682
691
|
*/
|
|
683
692
|
export interface SelectionController<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -750,14 +759,14 @@ export interface AdditionalFieldDelegate<M extends Record<string, unknown> = Rec
|
|
|
750
759
|
context: RebaseContext;
|
|
751
760
|
}): string | number | Promise<string | number> | undefined;
|
|
752
761
|
}
|
|
753
|
-
export type
|
|
762
|
+
export type InferCollectionConfigType<S extends CollectionConfig> = S extends CollectionConfig<infer M> ? M : never;
|
|
754
763
|
/**
|
|
755
|
-
* Used in the {@link
|
|
764
|
+
* Used in the {@link CollectionConfig#defaultSelectedView} to define the default
|
|
756
765
|
* @group Models
|
|
757
766
|
*/
|
|
758
767
|
export type DefaultSelectedViewBuilder = (params: DefaultSelectedViewParams) => string | undefined;
|
|
759
768
|
/**
|
|
760
|
-
* Used in the {@link
|
|
769
|
+
* Used in the {@link CollectionConfig#defaultSelectedView} to define the default
|
|
761
770
|
* @group Models
|
|
762
771
|
*/
|
|
763
772
|
export type DefaultSelectedViewParams = {
|
|
@@ -810,7 +819,7 @@ export type SecurityOperation = "select" | "insert" | "update" | "delete" | "all
|
|
|
810
819
|
/**
|
|
811
820
|
* Flexible Row Level Security rule for a collection.
|
|
812
821
|
*
|
|
813
|
-
*
|
|
822
|
+
* Built on PostgreSQL Row Level Security. Rules can range from
|
|
814
823
|
* simple convenience shortcuts to fully custom SQL expressions, giving you the
|
|
815
824
|
* full power of PostgreSQL Row Level Security.
|
|
816
825
|
*
|
|
@@ -823,7 +832,7 @@ export type SecurityOperation = "select" | "insert" | "update" | "delete" | "all
|
|
|
823
832
|
*
|
|
824
833
|
* **How rules combine:** PostgreSQL evaluates all matching policies for an
|
|
825
834
|
* operation. Permissive rules are OR'd together (any one passing is enough).
|
|
826
|
-
* Restrictive rules are AND'd (all must pass). This
|
|
835
|
+
* Restrictive rules are AND'd (all must pass). This is standard PostgreSQL RLS behavior.
|
|
827
836
|
*
|
|
828
837
|
* **Mutual exclusivity:** `ownerField`, `access`, structured `condition`, and
|
|
829
838
|
* raw SQL (`using`/`withCheck`) cannot be combined. The type system enforces
|
|
@@ -882,7 +891,7 @@ export interface SecurityRuleBase {
|
|
|
882
891
|
* // Equivalent to operation: "all"
|
|
883
892
|
* { operations: ["all"], ownerField: "user_id" }
|
|
884
893
|
*/
|
|
885
|
-
operations?: SecurityOperation[];
|
|
894
|
+
operations?: readonly SecurityOperation[];
|
|
886
895
|
/**
|
|
887
896
|
* Whether this policy is `"permissive"` (default) or `"restrictive"`.
|
|
888
897
|
*
|
|
@@ -891,7 +900,7 @@ export interface SecurityRuleBase {
|
|
|
891
900
|
* - **restrictive**: Restrictive policies are AND'd with all permissive
|
|
892
901
|
* policies — they act as additional gates that *must* also pass.
|
|
893
902
|
*
|
|
894
|
-
* This is the
|
|
903
|
+
* This is the standard PostgreSQL RLS model.
|
|
895
904
|
*
|
|
896
905
|
* @default "permissive"
|
|
897
906
|
*/
|
|
@@ -923,7 +932,7 @@ export interface SecurityRuleBase {
|
|
|
923
932
|
* // Admins have unfiltered read access to all rows
|
|
924
933
|
* { operation: "select", roles: ["admin"], using: "true" }
|
|
925
934
|
*/
|
|
926
|
-
roles?: string[];
|
|
935
|
+
roles?: readonly string[];
|
|
927
936
|
/**
|
|
928
937
|
* **Advanced.** Native PostgreSQL database roles the policy applies to.
|
|
929
938
|
*
|
|
@@ -945,7 +954,7 @@ export interface SecurityRuleBase {
|
|
|
945
954
|
* // Only apply this policy when connected as `app_role`
|
|
946
955
|
* { operation: "select", access: "public", pgRoles: ["app_role"] }
|
|
947
956
|
*/
|
|
948
|
-
pgRoles?: string[];
|
|
957
|
+
pgRoles?: readonly string[];
|
|
949
958
|
}
|
|
950
959
|
/**
|
|
951
960
|
* Security rule that grants access based on row ownership.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
+
import type { Property } from "./properties";
|
|
3
|
+
import type { WhereFilterOp } from "./filter-operators";
|
|
2
4
|
/**
|
|
3
5
|
* Components that can only be overridden at the **app level** via the
|
|
4
6
|
* `components` prop on `<Rebase>`.
|
|
@@ -20,12 +22,68 @@ export type AppComponentName = "Shell.AppBar" | "Shell.Drawer" | "Shell.DrawerNa
|
|
|
20
22
|
*
|
|
21
23
|
* @group Component Overrides
|
|
22
24
|
*/
|
|
23
|
-
export type CollectionComponentName = "Collection.View" | "Collection.Table" | "Collection.Card" | "Collection.EmptyState" | "Collection.Actions" | "Entity.Form" | "
|
|
25
|
+
export type CollectionComponentName = "Collection.View" | "Collection.Table" | "Collection.Card" | "Collection.EmptyState" | "Collection.Actions" | "Collection.FilterField" | "Entity.Form" | "EditView.FormActions" | "DetailView" | "Entity.SidePanel" | "EntityPreview" | "Entity.MissingReference";
|
|
24
26
|
/**
|
|
25
27
|
* All overridable component names across all scopes.
|
|
26
28
|
* @group Component Overrides
|
|
27
29
|
*/
|
|
28
30
|
export type OverridableComponentName = AppComponentName | CollectionComponentName;
|
|
31
|
+
/**
|
|
32
|
+
* Props received by a filter field component — whether it is a built-in
|
|
33
|
+
* per-type field, a property-level replacement (`property.ui.Filter`), or a
|
|
34
|
+
* `"Collection.FilterField"` override.
|
|
35
|
+
*
|
|
36
|
+
* The `operators` list is **already resolved**: it is the intersection of the
|
|
37
|
+
* engine's {@link DataSourceCapabilities.filterOperators}, the property-type
|
|
38
|
+
* defaults, and any `property.ui.filterOperators` narrowing. A custom field
|
|
39
|
+
* should only offer operators from this list — anything else may throw at
|
|
40
|
+
* query time on engines that cannot execute it.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* function MyStatusFilter({ value, setValue, operators }: FilterFieldBindingProps) {
|
|
45
|
+
* return (
|
|
46
|
+
* <select
|
|
47
|
+
* value={value?.[1] as string ?? ""}
|
|
48
|
+
* onChange={e => setValue(e.target.value ? ["==", e.target.value] : undefined)}>
|
|
49
|
+
* <option value="">Any</option>
|
|
50
|
+
* <option value="active">Active</option>
|
|
51
|
+
* <option value="archived">Archived</option>
|
|
52
|
+
* </select>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @group Component Overrides
|
|
58
|
+
*/
|
|
59
|
+
export interface FilterFieldBindingProps {
|
|
60
|
+
/** Key of the property being filtered (the column id). */
|
|
61
|
+
propertyKey: string;
|
|
62
|
+
/**
|
|
63
|
+
* The resolved property. For array properties this is the **item**
|
|
64
|
+
* property (`property.of`), with `isArray` set to true.
|
|
65
|
+
*/
|
|
66
|
+
property: Property;
|
|
67
|
+
/** True when the underlying property is an array of `property`. */
|
|
68
|
+
isArray: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Operators this field may offer, already narrowed by engine
|
|
71
|
+
* capabilities, property-type defaults, and `property.ui.filterOperators`.
|
|
72
|
+
*/
|
|
73
|
+
operators: readonly WhereFilterOp[];
|
|
74
|
+
/** Current filter condition for this property, if any. */
|
|
75
|
+
value?: [WhereFilterOp, unknown];
|
|
76
|
+
/** Set (or clear, with `undefined`) the filter condition. */
|
|
77
|
+
setValue: (value?: [WhereFilterOp, unknown]) => void;
|
|
78
|
+
/** Display title for the field (usually the property name). */
|
|
79
|
+
title?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Coordination flags used by fields that open their own dialogs
|
|
82
|
+
* (e.g. the reference picker hides the parent filters dialog).
|
|
83
|
+
*/
|
|
84
|
+
hidden?: boolean;
|
|
85
|
+
setHidden?: (hidden: boolean) => void;
|
|
86
|
+
}
|
|
29
87
|
/**
|
|
30
88
|
* A single component override entry.
|
|
31
89
|
*
|
|
@@ -55,7 +113,7 @@ export type OverridableComponentName = AppComponentName | CollectionComponentNam
|
|
|
55
113
|
*
|
|
56
114
|
* @group Component Overrides
|
|
57
115
|
*/
|
|
58
|
-
export interface ComponentOverride<P =
|
|
116
|
+
export interface ComponentOverride<P = Record<string, unknown>> {
|
|
59
117
|
/**
|
|
60
118
|
* The replacement component. Receives the same props as the built-in
|
|
61
119
|
* component it replaces.
|
|
@@ -122,7 +180,7 @@ export type CollectionComponentOverrideMap = {
|
|
|
122
180
|
* "HomePage": { Component: MyDashboard },
|
|
123
181
|
*
|
|
124
182
|
* // Collection defaults: apply to ALL collections
|
|
125
|
-
* "
|
|
183
|
+
* "EditView.FormActions": {
|
|
126
184
|
* Component: MyFormActions,
|
|
127
185
|
* wrap: true
|
|
128
186
|
* },
|
package/dist/types/cron.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { RebaseClient } from "../controllers/client";
|
|
|
3
3
|
* Cron Job type definitions for Rebase.
|
|
4
4
|
*
|
|
5
5
|
* These types define the shape of cron job definitions, their runtime
|
|
6
|
-
* status, and execution log entries — used across server
|
|
6
|
+
* status, and execution log entries — used across server, client,
|
|
7
7
|
* and studio packages.
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
@@ -43,7 +43,16 @@ export interface CronJobContext {
|
|
|
43
43
|
scheduledAt: Date;
|
|
44
44
|
/** A simple logger scoped to this job run. */
|
|
45
45
|
log: (...args: unknown[]) => void;
|
|
46
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The server-side {@link RebaseClient}. This is the **same singleton**
|
|
48
|
+
* exposed as `rebase` (imported from `@rebasepro/server`) and as
|
|
49
|
+
* `context` in collection callbacks — it is only named `client` here.
|
|
50
|
+
*
|
|
51
|
+
* Its data plane (`client.data`) runs with **admin privileges and bypasses
|
|
52
|
+
* RLS** (`{ uid: "service", roles: ["admin"] }`). There is no per-request
|
|
53
|
+
* user in a cron, so treat every query as fully trusted and scope your own
|
|
54
|
+
* filters explicitly.
|
|
55
|
+
*/
|
|
47
56
|
client: RebaseClient;
|
|
48
57
|
}
|
|
49
58
|
export type CronJobRunState = "idle" | "running" | "success" | "error" | "disabled";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WhereFilterOp } from "./filter-operators";
|
|
1
2
|
/**
|
|
2
3
|
* Describes the capabilities and features supported by a data source (driver).
|
|
3
4
|
*
|
|
@@ -26,6 +27,16 @@ export interface DataSourceCapabilities {
|
|
|
26
27
|
supportsColumnTypes: boolean;
|
|
27
28
|
/** Does this source support real-time listeners? */
|
|
28
29
|
supportsRealtime: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Canonical filter operators this engine can execute.
|
|
32
|
+
*
|
|
33
|
+
* The admin UI intersects this set with the property-type defaults and
|
|
34
|
+
* any per-property narrowing (`property.ui.filterOperators`) to decide
|
|
35
|
+
* which operators to offer in filter fields — so an engine that cannot
|
|
36
|
+
* run `ilike` (e.g. Firestore) never shows a "Contains" filter that
|
|
37
|
+
* would throw at query time.
|
|
38
|
+
*/
|
|
39
|
+
filterOperators: readonly WhereFilterOp[];
|
|
29
40
|
/** Does this source support SQL admin operations (SQL editor, EXPLAIN, etc.)? */
|
|
30
41
|
supportsSQLAdmin: boolean;
|
|
31
42
|
/** Does this source support document admin operations (aggregation, stats)? */
|
|
@@ -84,9 +95,11 @@ export interface DataSourceDefinition {
|
|
|
84
95
|
*/
|
|
85
96
|
engine: string;
|
|
86
97
|
/**
|
|
87
|
-
* How the frontend reaches this source.
|
|
98
|
+
* How the frontend reaches this source. Optional — when omitted it is
|
|
99
|
+
* inferred: `"direct"` if the definition carries a client-side driver,
|
|
100
|
+
* `"server"` otherwise.
|
|
88
101
|
*/
|
|
89
|
-
transport
|
|
102
|
+
transport?: DataSourceTransport;
|
|
90
103
|
/**
|
|
91
104
|
* The physical database/schema/Firestore-database within the engine.
|
|
92
105
|
* Threaded to drivers/adapters as the existing `databaseId` runtime
|