@rebasepro/types 0.0.1-canary.2 → 0.0.1-canary.4d4fb3e
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 +1 -1
- package/dist/controllers/analytics_controller.d.ts +2 -2
- package/dist/controllers/auth.d.ts +50 -6
- package/dist/controllers/client.d.ts +58 -0
- package/dist/controllers/collection_registry.d.ts +44 -0
- package/dist/controllers/customization_controller.d.ts +5 -1
- package/dist/controllers/data.d.ts +141 -0
- package/dist/controllers/{datasource.d.ts → data_driver.d.ts} +25 -36
- package/dist/controllers/database_admin.d.ts +11 -0
- package/dist/controllers/effective_role.d.ts +4 -0
- package/dist/controllers/index.d.ts +11 -5
- package/dist/controllers/navigation.d.ts +9 -58
- package/dist/controllers/registry.d.ts +51 -0
- package/dist/controllers/side_entity_controller.d.ts +1 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +113 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +112 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +35 -25
- package/dist/types/backend.d.ts +296 -17
- package/dist/types/builders.d.ts +14 -0
- package/dist/types/collections.d.ts +166 -241
- package/dist/types/data_source.d.ts +64 -0
- package/dist/types/entities.d.ts +29 -24
- package/dist/types/entity_actions.d.ts +7 -7
- package/dist/types/entity_callbacks.d.ts +4 -4
- package/dist/types/entity_overrides.d.ts +6 -2
- package/dist/types/entity_views.d.ts +61 -0
- package/dist/types/index.d.ts +8 -5
- package/dist/types/plugins.d.ts +170 -221
- package/dist/types/properties.d.ts +17 -29
- package/dist/types/property_config.d.ts +13 -11
- package/dist/types/slots.d.ts +228 -0
- package/dist/types/translations.d.ts +826 -0
- package/dist/types/user_management_delegate.d.ts +42 -0
- package/dist/types/websockets.d.ts +45 -0
- package/dist/users/user.d.ts +4 -0
- package/package.json +7 -39
- package/src/controllers/analytics_controller.tsx +2 -2
- package/src/controllers/auth.tsx +53 -6
- package/src/controllers/client.ts +74 -0
- package/src/controllers/collection_registry.ts +53 -0
- package/src/controllers/customization_controller.tsx +6 -1
- package/src/controllers/data.ts +153 -0
- package/src/controllers/{datasource.ts → data_driver.ts} +41 -37
- package/src/controllers/database_admin.ts +22 -0
- package/src/controllers/effective_role.ts +4 -0
- package/src/controllers/index.ts +14 -5
- package/src/controllers/navigation.ts +9 -73
- package/src/controllers/registry.ts +62 -0
- package/src/controllers/side_entity_controller.tsx +1 -2
- package/src/index.ts +0 -1
- package/src/rebase_context.tsx +37 -33
- package/src/types/backend.ts +351 -19
- package/src/types/builders.ts +16 -0
- package/src/types/collections.ts +196 -259
- package/src/types/data_source.ts +156 -0
- package/src/types/entities.ts +35 -28
- package/src/types/entity_actions.tsx +6 -6
- package/src/types/entity_callbacks.ts +4 -4
- package/src/types/entity_overrides.tsx +6 -2
- package/src/types/entity_views.tsx +77 -0
- package/src/types/index.ts +9 -5
- package/src/types/plugins.tsx +198 -256
- package/src/types/properties.ts +22 -31
- package/src/types/property_config.tsx +11 -11
- package/src/types/slots.tsx +271 -0
- package/src/types/translations.ts +923 -0
- package/src/types/user_management_delegate.ts +43 -0
- package/src/types/websockets.ts +48 -0
- package/src/users/user.ts +5 -0
- package/dist/components/EntityFormActionsProps.d.ts +0 -17
- package/dist/components/EntityFormProps.d.ts +0 -46
- package/dist/components/PropertyPreviewProps.d.ts +0 -50
- package/dist/components/formex.d.ts +0 -40
- package/dist/components/index.d.ts +0 -3
- package/dist/types/fields.d.ts +0 -221
- package/dist/types/rebase.d.ts +0 -180
- package/src/components/EntityFormActionsProps.tsx +0 -18
- package/src/components/EntityFormProps.tsx +0 -52
- package/src/components/PropertyPreviewProps.tsx +0 -61
- package/src/components/formex.tsx +0 -46
- package/src/components/index.ts +0 -3
- package/src/types/fields.tsx +0 -298
- package/src/types/rebase.tsx +0 -211
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes the capabilities and features supported by a data source (driver).
|
|
3
|
+
*
|
|
4
|
+
* Each driver (Postgres, Firebase, MongoDB, etc.) declares which features it
|
|
5
|
+
* supports. The CMS uses this descriptor to:
|
|
6
|
+
* - Show/hide editor tabs (e.g. Relations for SQL, Subcollections for Firebase)
|
|
7
|
+
* - Filter the property type picker (e.g. `relation` for SQL, `reference` for Firebase)
|
|
8
|
+
* - Toggle driver-specific form controls (e.g. `columnType` for SQL)
|
|
9
|
+
*
|
|
10
|
+
* @group Models
|
|
11
|
+
*/
|
|
12
|
+
export interface DataSourceCapabilities {
|
|
13
|
+
/** Unique driver key (e.g. "postgres", "firestore", "mongodb") */
|
|
14
|
+
key: string;
|
|
15
|
+
|
|
16
|
+
/** Human-readable label for the UI (e.g. "PostgreSQL", "Firebase / Firestore") */
|
|
17
|
+
label: string;
|
|
18
|
+
|
|
19
|
+
// ── Feature flags ─────────────────────────────────────────────────
|
|
20
|
+
/** Does this source support SQL-style relations (JOINs)? */
|
|
21
|
+
supportsRelations: boolean;
|
|
22
|
+
|
|
23
|
+
/** Does this source support nested subcollections? */
|
|
24
|
+
supportsSubcollections: boolean;
|
|
25
|
+
|
|
26
|
+
/** Does this source support Row Level Security policies? */
|
|
27
|
+
supportsRLS: boolean;
|
|
28
|
+
|
|
29
|
+
/** Does this source support document references (Firebase-style)? */
|
|
30
|
+
supportsReferences: boolean;
|
|
31
|
+
|
|
32
|
+
/** Does this source support SQL column type annotations? */
|
|
33
|
+
supportsColumnTypes: boolean;
|
|
34
|
+
|
|
35
|
+
/** Does this source support real-time listeners? */
|
|
36
|
+
supportsRealtime: boolean;
|
|
37
|
+
|
|
38
|
+
// ── Admin capability flags ───────────────────────────────────────
|
|
39
|
+
/** Does this source support SQL admin operations (SQL editor, EXPLAIN, etc.)? */
|
|
40
|
+
supportsSQLAdmin: boolean;
|
|
41
|
+
|
|
42
|
+
/** Does this source support document admin operations (aggregation, stats)? */
|
|
43
|
+
supportsDocumentAdmin: boolean;
|
|
44
|
+
|
|
45
|
+
/** Does this source support schema admin (unmapped tables, table metadata)? */
|
|
46
|
+
supportsSchemaAdmin: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Subset of DataSourceCapabilities containing only feature flags.
|
|
51
|
+
* Useful when you only need to check capabilities without UI metadata.
|
|
52
|
+
* @group Models
|
|
53
|
+
*/
|
|
54
|
+
export type DataSourceFeatures = Pick<
|
|
55
|
+
DataSourceCapabilities,
|
|
56
|
+
| "supportsRelations"
|
|
57
|
+
| "supportsSubcollections"
|
|
58
|
+
| "supportsRLS"
|
|
59
|
+
| "supportsReferences"
|
|
60
|
+
| "supportsColumnTypes"
|
|
61
|
+
| "supportsRealtime"
|
|
62
|
+
| "supportsSQLAdmin"
|
|
63
|
+
| "supportsDocumentAdmin"
|
|
64
|
+
| "supportsSchemaAdmin"
|
|
65
|
+
>;
|
|
66
|
+
|
|
67
|
+
// ── Built-in driver capabilities ─────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
/** @group Models */
|
|
70
|
+
export const POSTGRES_CAPABILITIES: DataSourceCapabilities = {
|
|
71
|
+
key: "postgres",
|
|
72
|
+
label: "PostgreSQL",
|
|
73
|
+
supportsRelations: true,
|
|
74
|
+
supportsSubcollections: false,
|
|
75
|
+
supportsRLS: true,
|
|
76
|
+
supportsReferences: false,
|
|
77
|
+
supportsColumnTypes: true,
|
|
78
|
+
supportsRealtime: true,
|
|
79
|
+
supportsSQLAdmin: true,
|
|
80
|
+
supportsDocumentAdmin: false,
|
|
81
|
+
supportsSchemaAdmin: true,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** @group Models */
|
|
85
|
+
export const FIREBASE_CAPABILITIES: DataSourceCapabilities = {
|
|
86
|
+
key: "firestore",
|
|
87
|
+
label: "Firebase / Firestore",
|
|
88
|
+
supportsRelations: false,
|
|
89
|
+
supportsSubcollections: true,
|
|
90
|
+
supportsRLS: false,
|
|
91
|
+
supportsReferences: true,
|
|
92
|
+
supportsColumnTypes: false,
|
|
93
|
+
supportsRealtime: true,
|
|
94
|
+
supportsSQLAdmin: false,
|
|
95
|
+
supportsDocumentAdmin: false,
|
|
96
|
+
supportsSchemaAdmin: false,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** @group Models */
|
|
100
|
+
export const MONGODB_CAPABILITIES: DataSourceCapabilities = {
|
|
101
|
+
key: "mongodb",
|
|
102
|
+
label: "MongoDB",
|
|
103
|
+
supportsRelations: false,
|
|
104
|
+
supportsSubcollections: true,
|
|
105
|
+
supportsRLS: false,
|
|
106
|
+
supportsReferences: true,
|
|
107
|
+
supportsColumnTypes: false,
|
|
108
|
+
supportsRealtime: false,
|
|
109
|
+
supportsSQLAdmin: false,
|
|
110
|
+
supportsDocumentAdmin: true,
|
|
111
|
+
supportsSchemaAdmin: true,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Fallback capabilities when the driver is unknown.
|
|
116
|
+
* Enables everything so nothing is hidden unexpectedly.
|
|
117
|
+
* @group Models
|
|
118
|
+
*/
|
|
119
|
+
export const DEFAULT_CAPABILITIES: DataSourceCapabilities = {
|
|
120
|
+
key: "(default)",
|
|
121
|
+
label: "Default",
|
|
122
|
+
supportsRelations: true,
|
|
123
|
+
supportsSubcollections: true,
|
|
124
|
+
supportsRLS: true,
|
|
125
|
+
supportsReferences: true,
|
|
126
|
+
supportsColumnTypes: true,
|
|
127
|
+
supportsRealtime: true,
|
|
128
|
+
supportsSQLAdmin: true,
|
|
129
|
+
supportsDocumentAdmin: true,
|
|
130
|
+
supportsSchemaAdmin: true,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const CAPABILITIES_REGISTRY: Record<string, DataSourceCapabilities> = {
|
|
134
|
+
postgres: POSTGRES_CAPABILITIES,
|
|
135
|
+
firestore: FIREBASE_CAPABILITIES,
|
|
136
|
+
mongodb: MONGODB_CAPABILITIES,
|
|
137
|
+
"(default)": DEFAULT_CAPABILITIES,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Look up capabilities for a given driver key.
|
|
142
|
+
* If `driver` is undefined or not found, returns `DEFAULT_CAPABILITIES`.
|
|
143
|
+
* @group Models
|
|
144
|
+
*/
|
|
145
|
+
export function getDataSourceCapabilities(driver?: string): DataSourceCapabilities {
|
|
146
|
+
if (!driver) return POSTGRES_CAPABILITIES; // postgres is the default driver
|
|
147
|
+
return CAPABILITIES_REGISTRY[driver] ?? DEFAULT_CAPABILITIES;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Register custom capabilities for a third-party driver.
|
|
152
|
+
* @group Models
|
|
153
|
+
*/
|
|
154
|
+
export function registerDataSourceCapabilities(capabilities: DataSourceCapabilities): void {
|
|
155
|
+
CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
|
|
156
|
+
}
|
package/src/types/entities.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
export type EntityStatus = "new" | "existing" | "copy";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Representation of an entity fetched from the
|
|
8
|
+
* Representation of an entity fetched from the driver
|
|
9
9
|
* @group Models
|
|
10
10
|
*/
|
|
11
|
-
export interface Entity<M extends
|
|
11
|
+
export interface Entity<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* ID of the entity
|
|
@@ -27,14 +27,14 @@ export interface Entity<M extends object = object> {
|
|
|
27
27
|
values: EntityValues<M>;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Which
|
|
31
|
-
* If not specified, the default
|
|
30
|
+
* Which driver this entity belongs to (e.g., 'postgres', 'firestore').
|
|
31
|
+
* If not specified, the default driver is assumed.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
driver?: string;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Which database within the
|
|
37
|
-
* If not specified, the default database of the
|
|
36
|
+
* Which database within the driver (e.g., for Firestore multi-database).
|
|
37
|
+
* If not specified, the default database of the driver is used.
|
|
38
38
|
*/
|
|
39
39
|
databaseId?: string;
|
|
40
40
|
}
|
|
@@ -44,7 +44,7 @@ export interface Entity<M extends object = object> {
|
|
|
44
44
|
* entity collection.
|
|
45
45
|
* @group Models
|
|
46
46
|
*/
|
|
47
|
-
export type EntityValues<M extends
|
|
47
|
+
export type EntityValues<M extends Record<string, unknown>> = M;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Props for creating an EntityReference
|
|
@@ -54,9 +54,9 @@ export interface EntityReferenceProps {
|
|
|
54
54
|
id: string;
|
|
55
55
|
/** Path of the collection (relative to the root of the database) */
|
|
56
56
|
path: string;
|
|
57
|
-
/** Which
|
|
58
|
-
|
|
59
|
-
/** Which database within the
|
|
57
|
+
/** Which driver (e.g., 'postgres', 'firestore'). Defaults to "(default)" */
|
|
58
|
+
driver?: string;
|
|
59
|
+
/** Which database within the driver. Defaults to "(default)" */
|
|
60
60
|
databaseId?: string;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -64,14 +64,14 @@ export interface EntityReferenceProps {
|
|
|
64
64
|
* Class used to create a reference to an entity in a different path.
|
|
65
65
|
*
|
|
66
66
|
* @example
|
|
67
|
-
* // Simple reference (most common case - single
|
|
67
|
+
* // Simple reference (most common case - single driver, single db)
|
|
68
68
|
* new EntityReference({ id: "123", path: "users" })
|
|
69
69
|
*
|
|
70
|
-
* // Reference to a different
|
|
71
|
-
* new EntityReference({ id: "123", path: "analytics",
|
|
70
|
+
* // Reference to a different driver (e.g., Firestore)
|
|
71
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
72
72
|
*
|
|
73
|
-
* // Reference to a specific database within a
|
|
74
|
-
* new EntityReference({ id: "123", path: "orders",
|
|
73
|
+
* // Reference to a specific database within a driver
|
|
74
|
+
* new EntityReference({ id: "123", path: "orders", driver: "postgres", databaseId: "orders_db" })
|
|
75
75
|
*/
|
|
76
76
|
export class EntityReference {
|
|
77
77
|
|
|
@@ -87,13 +87,13 @@ export class EntityReference {
|
|
|
87
87
|
readonly path: string;
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* Which
|
|
90
|
+
* Which driver (e.g., 'postgres', 'firestore').
|
|
91
91
|
* Defaults to "(default)" if not specified.
|
|
92
92
|
*/
|
|
93
|
-
readonly
|
|
93
|
+
readonly driver?: string;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* Which database within the
|
|
96
|
+
* Which database within the driver.
|
|
97
97
|
* Defaults to "(default)" if not specified.
|
|
98
98
|
*/
|
|
99
99
|
readonly databaseId?: string;
|
|
@@ -105,13 +105,13 @@ export class EntityReference {
|
|
|
105
105
|
* // Simple reference (most common case)
|
|
106
106
|
* new EntityReference({ id: "123", path: "users" })
|
|
107
107
|
*
|
|
108
|
-
* // With
|
|
109
|
-
* new EntityReference({ id: "123", path: "analytics",
|
|
108
|
+
* // With driver
|
|
109
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
110
110
|
*/
|
|
111
111
|
constructor(props: EntityReferenceProps) {
|
|
112
112
|
this.id = props.id;
|
|
113
113
|
this.path = props.path;
|
|
114
|
-
this.
|
|
114
|
+
this.driver = props.driver;
|
|
115
115
|
this.databaseId = props.databaseId;
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -120,15 +120,15 @@ export class EntityReference {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* Get the full path including
|
|
124
|
-
* For the common case (single
|
|
123
|
+
* Get the full path including driver and database prefixes if specified.
|
|
124
|
+
* For the common case (single driver, single db), this just returns pathWithId.
|
|
125
125
|
*/
|
|
126
126
|
get fullPath() {
|
|
127
127
|
const parts: string[] = [];
|
|
128
128
|
|
|
129
|
-
// Add
|
|
130
|
-
if (this.
|
|
131
|
-
parts.push(this.
|
|
129
|
+
// Add driver prefix if not default
|
|
130
|
+
if (this.driver && this.driver !== "(default)") {
|
|
131
|
+
parts.push(this.driver);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// Add database prefix if specified
|
|
@@ -163,9 +163,16 @@ export class EntityRelation {
|
|
|
163
163
|
*/
|
|
164
164
|
readonly path: string;
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Pre-fetched data payload to eliminate N+1 queries.
|
|
168
|
+
* When present, clients can use this directly instead of fetching.
|
|
169
|
+
*/
|
|
170
|
+
readonly data?: Entity;
|
|
171
|
+
|
|
172
|
+
constructor(id: string | number, path: string, data?: Entity) {
|
|
167
173
|
this.id = id;
|
|
168
174
|
this.path = path;
|
|
175
|
+
this.data = data;
|
|
169
176
|
}
|
|
170
177
|
|
|
171
178
|
get pathWithId() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Entity } from "./entities";
|
|
3
3
|
import { EntityCollection, SelectionController } from "./collections";
|
|
4
|
-
import { FormContext } from "./
|
|
4
|
+
import { FormContext } from "./entity_views";
|
|
5
5
|
import { User } from "../users";
|
|
6
6
|
import { RebaseContext } from "../rebase_context";
|
|
7
7
|
import { SideEntityController } from "../controllers";
|
|
@@ -10,7 +10,7 @@ import { SideEntityController } from "../controllers";
|
|
|
10
10
|
* An entity action is a custom action that can be performed on an entity.
|
|
11
11
|
* They are displayed in the entity view and in the collection view.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export interface EntityAction<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> {
|
|
14
14
|
/**
|
|
15
15
|
* Title of the action
|
|
16
16
|
*/
|
|
@@ -38,13 +38,13 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
|
38
38
|
* Callback when the action is clicked
|
|
39
39
|
* @param props
|
|
40
40
|
*/
|
|
41
|
-
onClick
|
|
41
|
+
onClick(props: EntityActionClickProps<M, USER>): Promise<void> | void;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Optional callback in case you want to disable the action
|
|
45
45
|
* @param props
|
|
46
46
|
*/
|
|
47
|
-
isEnabled
|
|
47
|
+
isEnabled?(props: EntityActionClickProps<M, USER>): boolean;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Show this action collapsed in the menu of the collection view.
|
|
@@ -60,12 +60,12 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
|
60
60
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export type EntityActionClickProps<M extends
|
|
63
|
+
export type EntityActionClickProps<M extends Record<string, unknown>, USER extends User = User> = {
|
|
64
64
|
entity?: Entity<M>;
|
|
65
65
|
context: RebaseContext<USER>;
|
|
66
66
|
|
|
67
67
|
path?: string;
|
|
68
|
-
collection?: EntityCollection<
|
|
68
|
+
collection?: EntityCollection<Record<string, unknown>, any>;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Optional form context, present if the action is being called from a form.
|
|
@@ -70,7 +70,7 @@ export interface EntityAfterReadProps<M extends Record<string, any> = any, USER
|
|
|
70
70
|
/**
|
|
71
71
|
* Collection of the entity
|
|
72
72
|
*/
|
|
73
|
-
collection: EntityCollection<
|
|
73
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Full path of the CMS where this collection is being fetched.
|
|
@@ -117,7 +117,7 @@ export interface EntityAfterSaveProps<M extends Record<string, any> = any, USER
|
|
|
117
117
|
/**
|
|
118
118
|
* Resolved collection of the entity
|
|
119
119
|
*/
|
|
120
|
-
collection: EntityCollection<
|
|
120
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Full path of the CMS where this entity is being saved.
|
|
@@ -160,7 +160,7 @@ export interface EntityBeforeDeleteProps<M extends Record<string, any> = any, US
|
|
|
160
160
|
/**
|
|
161
161
|
* collection of the entity being deleted
|
|
162
162
|
*/
|
|
163
|
-
collection: EntityCollection<
|
|
163
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
166
|
* Path of the parent collection
|
|
@@ -192,7 +192,7 @@ export interface EntityAfterDeleteProps<M extends Record<string, any> = any, USE
|
|
|
192
192
|
/**
|
|
193
193
|
* collection of the entity being deleted
|
|
194
194
|
*/
|
|
195
|
-
collection: EntityCollection<
|
|
195
|
+
collection: EntityCollection<Record<string, unknown>, any>;
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Path of the parent collection
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataDriver, StorageSource } from "../controllers";
|
|
2
2
|
|
|
3
3
|
export type EntityOverrides = {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Internal driver override for this collection.
|
|
6
|
+
* Used by the CMS engine to route data operations.
|
|
7
|
+
*/
|
|
8
|
+
driver?: DataDriver;
|
|
5
9
|
storageSource?: StorageSource;
|
|
6
10
|
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Entity, EntityValues } from "./entities";
|
|
3
|
+
import { EntityCollection } from "./collections";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Context passed to custom fields and entity views.
|
|
7
|
+
* This is the base definition — `@rebasepro/cms` re-exports a
|
|
8
|
+
* fully-typed version that narrows the `formex` field.
|
|
9
|
+
* @group Form custom fields
|
|
10
|
+
*/
|
|
11
|
+
export interface FormContext<M extends Record<string, any> = any> {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Current values of the entity
|
|
15
|
+
*/
|
|
16
|
+
values: M;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Update the value of a field
|
|
20
|
+
*/
|
|
21
|
+
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Save the entity.
|
|
25
|
+
*/
|
|
26
|
+
save: (values: M) => void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Collection of the entity being modified
|
|
30
|
+
*/
|
|
31
|
+
collection?: EntityCollection<M>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Entity id, it can be undefined if it's a new entity
|
|
35
|
+
*/
|
|
36
|
+
entityId?: string | number;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Path this entity is located at
|
|
40
|
+
*/
|
|
41
|
+
path?: string;
|
|
42
|
+
|
|
43
|
+
status: "new" | "existing" | "copy";
|
|
44
|
+
|
|
45
|
+
entity?: Entity<M>;
|
|
46
|
+
|
|
47
|
+
savingError?: Error;
|
|
48
|
+
|
|
49
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The underlying formex controller that powers the form.
|
|
53
|
+
* Prefer importing `FormContext` from `@rebasepro/cms` for the
|
|
54
|
+
* fully-typed `FormexController<M>` version.
|
|
55
|
+
*/
|
|
56
|
+
formex: Record<string, unknown>;
|
|
57
|
+
|
|
58
|
+
disabled: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export type EntityCustomView<M extends Record<string, any> = any> = {
|
|
63
|
+
key: string;
|
|
64
|
+
name: string;
|
|
65
|
+
tabComponent?: React.ReactNode;
|
|
66
|
+
includeActions?: boolean | "bottom";
|
|
67
|
+
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
|
|
68
|
+
position?: "start" | "end";
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export interface EntityCustomViewParams<M extends Record<string, any> = any> {
|
|
72
|
+
collection: EntityCollection<M>;
|
|
73
|
+
entity?: Entity<M>;
|
|
74
|
+
modifiedValues?: EntityValues<M>;
|
|
75
|
+
formContext: FormContext<M>;
|
|
76
|
+
parentCollectionIds?: string[];
|
|
77
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
export * from "./entities";
|
|
2
2
|
export * from "./chips";
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
export * from "./properties";
|
|
5
5
|
export * from "./collections";
|
|
6
6
|
export * from "./relations";
|
|
7
7
|
|
|
8
8
|
export * from "./locales";
|
|
9
|
-
export * from "./fields";
|
|
10
|
-
export * from "./property_config";
|
|
11
9
|
export * from "./entity_link_builder";
|
|
12
10
|
export * from "./user_management_delegate";
|
|
13
11
|
export * from "./entity_callbacks";
|
|
14
12
|
export * from "./entity_overrides";
|
|
15
|
-
export * from "./plugins";
|
|
16
|
-
export * from "./rebase";
|
|
17
13
|
export * from "./export_import";
|
|
18
14
|
export * from "./modify_collections";
|
|
19
15
|
export * from "./websockets";
|
|
20
16
|
export * from "./backend";
|
|
17
|
+
export * from "./translations";
|
|
18
|
+
export * from "./plugins";
|
|
19
|
+
export * from "./builders";
|
|
20
|
+
export * from "./slots";
|
|
21
|
+
export * from "./entity_actions";
|
|
22
|
+
export * from "./property_config";
|
|
23
|
+
export * from "./entity_views";
|
|
24
|
+
export * from "./data_source";
|