@rebasepro/types 0.6.1 → 0.7.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 +16 -0
- package/dist/controllers/navigation.d.ts +14 -14
- package/dist/controllers/registry.d.ts +8 -2
- package/dist/index.es.js +8 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +8 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/types/api_keys.d.ts +57 -0
- package/dist/types/auth_adapter.d.ts +62 -0
- package/dist/types/backend.d.ts +1 -0
- package/dist/types/collections.d.ts +51 -17
- package/dist/types/data_source.d.ts +76 -0
- package/dist/types/entity_actions.d.ts +2 -2
- package/dist/types/entity_views.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/properties.d.ts +7 -0
- package/dist/types/translations.d.ts +8 -0
- package/package.json +1 -1
- package/src/controllers/client.ts +8 -0
- package/src/controllers/navigation.ts +17 -16
- package/src/controllers/registry.ts +10 -2
- package/src/types/api_keys.ts +52 -0
- package/src/types/auth_adapter.ts +76 -0
- package/src/types/backend.ts +1 -1
- package/src/types/collections.ts +54 -17
- package/src/types/data_source.ts +84 -0
- package/src/types/entity_actions.tsx +2 -2
- package/src/types/entity_views.tsx +1 -1
- package/src/types/index.ts +2 -0
- package/src/types/plugins.tsx +1 -1
- package/src/types/properties.ts +9 -1
- package/src/types/translations.ts +8 -0
package/src/types/collections.ts
CHANGED
|
@@ -58,34 +58,44 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* - `"mongodb"` - Route to MongoDB backend
|
|
66
|
-
* - Custom IDs for your own driver implementations
|
|
61
|
+
* The data source this collection belongs to — the routing key shared by
|
|
62
|
+
* the frontend router and the backend driver registry. It points at a
|
|
63
|
+
* {@link DataSourceDefinition} registered on `<Rebase dataSources>` (front)
|
|
64
|
+
* and `initRebase({ dataSources })` (back).
|
|
67
65
|
*
|
|
68
|
-
* If not specified, the default
|
|
66
|
+
* If not specified, the default data source `"(default)"` is used, which
|
|
67
|
+
* for a standard Rebase app is the server-mediated Postgres backend.
|
|
69
68
|
*
|
|
70
69
|
* @example
|
|
71
|
-
* //
|
|
70
|
+
* // Default data source (server-mediated Postgres)
|
|
72
71
|
* { slug: "products" }
|
|
73
72
|
*
|
|
74
|
-
* // Firestore
|
|
75
|
-
* { slug: "
|
|
73
|
+
* // A direct-transport Firestore data source registered as "analytics"
|
|
74
|
+
* { slug: "events", dataSource: "analytics" }
|
|
75
|
+
*/
|
|
76
|
+
dataSource?: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The engine backing this collection (`"postgres"`, `"firestore"`,
|
|
80
|
+
* `"mongodb"`, or a custom id). Drives editor capabilities (relations vs
|
|
81
|
+
* subcollections, RLS, column types).
|
|
82
|
+
*
|
|
83
|
+
* @deprecated Prefer {@link dataSource} for routing. `driver` is retained
|
|
84
|
+
* as an engine hint and for backward compatibility: when `dataSource` is
|
|
85
|
+
* omitted it also acts as the data-source key.
|
|
76
86
|
*
|
|
77
|
-
*
|
|
78
|
-
* { slug: "orders", driver: "postgres", databaseId: "orders_db" }
|
|
87
|
+
* If not specified, `"postgres"` is assumed.
|
|
79
88
|
*/
|
|
80
89
|
driver?: string;
|
|
81
90
|
|
|
82
91
|
/**
|
|
83
|
-
* Which database within the
|
|
92
|
+
* Which database within the engine.
|
|
84
93
|
* - For Firestore: The Firestore database ID (e.g., for multi-database projects)
|
|
85
94
|
* - For PostgreSQL: Schema or database name
|
|
86
95
|
* - For MongoDB: Database name
|
|
87
96
|
*
|
|
88
|
-
* If not specified, the default database of the
|
|
97
|
+
* If not specified, the default database of the engine is used. Resolved
|
|
98
|
+
* from the collection's {@link DataSourceDefinition} when omitted here.
|
|
89
99
|
*/
|
|
90
100
|
databaseId?: string;
|
|
91
101
|
|
|
@@ -165,6 +175,26 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
165
175
|
*/
|
|
166
176
|
auth?: boolean | AuthCollectionConfig;
|
|
167
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Opt out of the framework's default Row Level Security policies for
|
|
180
|
+
* authentication collections.
|
|
181
|
+
*
|
|
182
|
+
* When a collection has `auth` enabled, the schema generator automatically
|
|
183
|
+
* injects an admin-only write policy (INSERT/UPDATE/DELETE require the
|
|
184
|
+
* `admin` role, or the trusted server context) for any write operation that
|
|
185
|
+
* the collection does not already cover with an explicit `securityRules`
|
|
186
|
+
* entry. This makes privileged columns such as `roles` safe by default — a
|
|
187
|
+
* non-admin cannot modify the user row through the data API regardless of
|
|
188
|
+
* which code path issues the write.
|
|
189
|
+
*
|
|
190
|
+
* Defining your own write rule for an operation overrides the default for
|
|
191
|
+
* that operation. Set this flag to `true` to remove the default policies
|
|
192
|
+
* entirely and take full responsibility for the collection's RLS.
|
|
193
|
+
*
|
|
194
|
+
* @default false
|
|
195
|
+
*/
|
|
196
|
+
disableDefaultAuthPolicies?: boolean;
|
|
197
|
+
|
|
168
198
|
|
|
169
199
|
/**
|
|
170
200
|
* Order in which the properties are displayed.
|
|
@@ -321,6 +351,13 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
321
351
|
*/
|
|
322
352
|
ownerId?: string;
|
|
323
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Arbitrary key-value metadata for external consumers.
|
|
356
|
+
* Not interpreted by Rebase — passed through serialization unchanged.
|
|
357
|
+
* Used by domain apps to store custom per-collection config.
|
|
358
|
+
*/
|
|
359
|
+
metadata?: Record<string, unknown>;
|
|
360
|
+
|
|
324
361
|
/**
|
|
325
362
|
* Overrides for the entity view, like the data source or the storage source.
|
|
326
363
|
*/
|
|
@@ -375,7 +412,7 @@ export interface BaseEntityCollection<M extends Record<string, unknown> = Record
|
|
|
375
412
|
* Possible values: "table", "cards", "kanban".
|
|
376
413
|
* Defaults to all three: ["table", "cards", "kanban"].
|
|
377
414
|
* Note: "kanban" will only be available if the collection has at least
|
|
378
|
-
* one string property with
|
|
415
|
+
* one string property with `enum` defined, regardless of this setting.
|
|
379
416
|
*/
|
|
380
417
|
enabledViews?: ViewMode[];
|
|
381
418
|
|
|
@@ -619,9 +656,9 @@ export function isMongoDBCollection<M extends Record<string, unknown> = Record<s
|
|
|
619
656
|
export interface KanbanConfig<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
620
657
|
/**
|
|
621
658
|
* Property key to use for Kanban board columns.
|
|
622
|
-
* Must reference a string property with
|
|
659
|
+
* Must reference a string property with `enum` values defined.
|
|
623
660
|
* Entities will be grouped into columns based on this property's value.
|
|
624
|
-
* The column order is determined by the order of
|
|
661
|
+
* The column order is determined by the order of `enum` values in the property.
|
|
625
662
|
*/
|
|
626
663
|
columnProperty: Extract<keyof M, string> | (string & {});
|
|
627
664
|
}
|
package/src/types/data_source.ts
CHANGED
|
@@ -53,6 +53,90 @@ export interface DataSourceCapabilities {
|
|
|
53
53
|
*/
|
|
54
54
|
export type DataSourceFeatures = Omit<DataSourceCapabilities, "key" | "label">;
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* The default data-source key, used when a collection does not name a
|
|
58
|
+
* `dataSource`. Shared by the frontend router and the backend driver
|
|
59
|
+
* registry so both agree on "the default database".
|
|
60
|
+
* @group Models
|
|
61
|
+
*/
|
|
62
|
+
export const DEFAULT_DATA_SOURCE_KEY = "(default)";
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* How the *frontend* reaches a data source.
|
|
66
|
+
*
|
|
67
|
+
* - `"server"` — through the Rebase backend (the `RebaseClient`). The backend
|
|
68
|
+
* holds the actual database adapter and routes by data-source key. This is
|
|
69
|
+
* the default and covers Postgres, MongoDB, and any other server-mediated
|
|
70
|
+
* engine.
|
|
71
|
+
* - `"direct"` — straight from the client to the external backend via its own
|
|
72
|
+
* SDK driver (e.g. Firestore). The Rebase backend is not in the data path.
|
|
73
|
+
* - `"custom"` — a developer-supplied {@link DataDriver}, transport unspecified.
|
|
74
|
+
*
|
|
75
|
+
* @group Models
|
|
76
|
+
*/
|
|
77
|
+
export type DataSourceTransport = "server" | "direct" | "custom";
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Declarative definition of a data source — a named place data lives.
|
|
81
|
+
*
|
|
82
|
+
* Declared once and shared front and back: the frontend uses it to decide
|
|
83
|
+
* transport (client vs direct driver), the backend uses the same `key` to
|
|
84
|
+
* resolve a database adapter, and the editor derives capabilities from
|
|
85
|
+
* `engine`. Collections reference a definition by its `key` via
|
|
86
|
+
* `collection.dataSource`.
|
|
87
|
+
*
|
|
88
|
+
* @group Models
|
|
89
|
+
*/
|
|
90
|
+
export interface DataSourceDefinition {
|
|
91
|
+
/**
|
|
92
|
+
* Unique identifier for this data source. Collections point at it via
|
|
93
|
+
* `dataSource`. Defaults to {@link DEFAULT_DATA_SOURCE_KEY}.
|
|
94
|
+
*/
|
|
95
|
+
key: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The engine backing this data source (e.g. `"postgres"`, `"mongodb"`,
|
|
99
|
+
* `"firestore"`, or a custom id). Determines the
|
|
100
|
+
* {@link DataSourceCapabilities} surfaced in the editor.
|
|
101
|
+
*/
|
|
102
|
+
engine: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* How the frontend reaches this source. Defaults to `"server"`.
|
|
106
|
+
*/
|
|
107
|
+
transport: DataSourceTransport;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The physical database/schema/Firestore-database within the engine.
|
|
111
|
+
* Threaded to drivers/adapters as the existing `databaseId` runtime
|
|
112
|
+
* parameter. Defaults to the engine's own default.
|
|
113
|
+
*/
|
|
114
|
+
databaseId?: string;
|
|
115
|
+
|
|
116
|
+
/** Human-readable label for the UI. */
|
|
117
|
+
label?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The resolved data source for a collection: the single source of truth that
|
|
122
|
+
* the frontend router, backend registry, and editor all derive from.
|
|
123
|
+
* Produced by `resolveDataSource(collection, registry)`.
|
|
124
|
+
*
|
|
125
|
+
* @group Models
|
|
126
|
+
*/
|
|
127
|
+
export interface ResolvedDataSource {
|
|
128
|
+
/** Data-source key (routing key, shared front + back). */
|
|
129
|
+
key: string;
|
|
130
|
+
/** Engine backing the source (drives capabilities). */
|
|
131
|
+
engine: string;
|
|
132
|
+
/** Frontend transport. */
|
|
133
|
+
transport: DataSourceTransport;
|
|
134
|
+
/** Within-engine instance, if any (the `databaseId` runtime param). */
|
|
135
|
+
databaseId?: string;
|
|
136
|
+
/** Capabilities derived from {@link engine}. */
|
|
137
|
+
capabilities: DataSourceCapabilities;
|
|
138
|
+
}
|
|
139
|
+
|
|
56
140
|
// ── Built-in driver capabilities ─────────────────────────────────────
|
|
57
141
|
|
|
58
142
|
/** @group Models */
|
|
@@ -69,7 +69,7 @@ export interface EntityAction<M extends Record<string, unknown> = Record<string,
|
|
|
69
69
|
|
|
70
70
|
export type EntityActionClickProps<M extends Record<string, unknown>, USER extends User = User> = {
|
|
71
71
|
entity?: Entity<M>;
|
|
72
|
-
context
|
|
72
|
+
context?: RebaseContext<USER>;
|
|
73
73
|
|
|
74
74
|
path?: string;
|
|
75
75
|
collection?: EntityCollection<M>;
|
|
@@ -93,7 +93,7 @@ export type EntityActionClickProps<M extends Record<string, unknown>, USER exten
|
|
|
93
93
|
/**
|
|
94
94
|
* If the action is rendered in the form, is it open in a side panel or full screen?
|
|
95
95
|
*/
|
|
96
|
-
openEntityMode
|
|
96
|
+
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Optional selection controller, present if the action is being called from a collection view
|
|
@@ -55,7 +55,7 @@ export interface FormContext<M extends Record<string, unknown> = Record<string,
|
|
|
55
55
|
|
|
56
56
|
savingError?: Error;
|
|
57
57
|
|
|
58
|
-
openEntityMode
|
|
58
|
+
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* The underlying formex controller that powers the form.
|
package/src/types/index.ts
CHANGED
package/src/types/plugins.tsx
CHANGED
|
@@ -311,7 +311,7 @@ export interface PluginFormActionProps<USER extends User = User, EC extends Enti
|
|
|
311
311
|
disabled: boolean;
|
|
312
312
|
formContext?: FormContext;
|
|
313
313
|
context: RebaseContext<USER>;
|
|
314
|
-
openEntityMode
|
|
314
|
+
openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
/**
|
package/src/types/properties.ts
CHANGED
|
@@ -221,6 +221,14 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
221
221
|
*/
|
|
222
222
|
callbacks?: PropertyCallbacks;
|
|
223
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Arbitrary key-value metadata for external consumers.
|
|
226
|
+
* Not interpreted by Rebase — passed through serialization unchanged.
|
|
227
|
+
* Used by domain apps to store custom per-property config
|
|
228
|
+
* (e.g. CRM visibility flags, display hints).
|
|
229
|
+
*/
|
|
230
|
+
metadata?: Record<string, unknown>;
|
|
231
|
+
|
|
224
232
|
}
|
|
225
233
|
|
|
226
234
|
/**
|
|
@@ -1244,7 +1252,7 @@ export interface PropertyConditions {
|
|
|
1244
1252
|
defaultValue?: JsonLogicRule;
|
|
1245
1253
|
|
|
1246
1254
|
// ═══════════════════════════════════════════════════════════════════════
|
|
1247
|
-
// ENUM CONDITIONS (for string/number properties with
|
|
1255
|
+
// ENUM CONDITIONS (for string/number properties with enum values)
|
|
1248
1256
|
// ═══════════════════════════════════════════════════════════════════════
|
|
1249
1257
|
|
|
1250
1258
|
/**
|
|
@@ -47,6 +47,12 @@ export interface RebaseTranslations {
|
|
|
47
47
|
unsaved_changes_body: string;
|
|
48
48
|
discard_changes: string;
|
|
49
49
|
keep_editing: string;
|
|
50
|
+
/** Dialog title when clearing a new/copy form */
|
|
51
|
+
clear_form?: string;
|
|
52
|
+
/** Confirmation body when discarding changes on an existing entity */
|
|
53
|
+
discard_changes_confirmation?: string;
|
|
54
|
+
/** Confirmation body when clearing a new/copy form */
|
|
55
|
+
clear_form_confirmation?: string;
|
|
50
56
|
|
|
51
57
|
// ─── Collection table / toolbar ──────────────────────────────
|
|
52
58
|
search: string;
|
|
@@ -175,6 +181,8 @@ export interface RebaseTranslations {
|
|
|
175
181
|
form_modified: string;
|
|
176
182
|
/** Tooltip when the form is in sync with the database */
|
|
177
183
|
form_in_sync: string;
|
|
184
|
+
/** Tooltip/alert shown when form has validation errors */
|
|
185
|
+
fix_errors_before_saving?: string;
|
|
178
186
|
|
|
179
187
|
admin: string;
|
|
180
188
|
home: string;
|