@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
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,252 +1,189 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import { FieldProps, FormContext } from "./fields";
|
|
4
|
-
import { Property } from "./properties";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EntityCollection } from "./collections";
|
|
5
3
|
import { EntityStatus } from "./entities";
|
|
4
|
+
import { Property } from "./properties";
|
|
5
|
+
import { FormContext } from "./entity_views";
|
|
6
6
|
import { RebaseContext } from "../rebase_context";
|
|
7
|
-
import { NavigationGroupMapping,
|
|
8
|
-
import { User } from "../users";
|
|
7
|
+
import { NavigationGroupMapping, AppView } from "../controllers";
|
|
9
8
|
import { UserManagementDelegate } from "./user_management_delegate";
|
|
9
|
+
import { User } from "../users";
|
|
10
|
+
import { SlotContribution } from "./slots";
|
|
11
|
+
export type FieldProps<T = any, CustomProps = any, M extends Record<string, any> = any> = any;
|
|
10
12
|
/**
|
|
11
13
|
* Interface used to define plugins for Rebase.
|
|
12
|
-
*
|
|
14
|
+
* Plugins contribute UI via **slots**, wrap subtrees with **providers**,
|
|
15
|
+
* and inject behavioral logic via **hooks**.
|
|
13
16
|
* @group Core
|
|
14
17
|
*/
|
|
15
|
-
export
|
|
18
|
+
export interface RebasePlugin {
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* Unique key identifying this plugin.
|
|
18
21
|
*/
|
|
19
22
|
key: string;
|
|
20
23
|
/**
|
|
21
|
-
* If
|
|
22
|
-
* until the plugin is fully loaded.
|
|
24
|
+
* If true, no CMS content is shown until this plugin finishes loading.
|
|
23
25
|
*/
|
|
24
26
|
loading?: boolean;
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
27
|
-
* The components will be added to the root of the CMS, so any component
|
|
28
|
-
* rendered underneath by this plugin will have access to the context
|
|
29
|
-
* provided by this HOC.
|
|
30
|
-
* Anyhow, this is rendered below the {@link RebaseContext} provider, so
|
|
31
|
-
* you can use the hooks provided by the CMS.
|
|
32
|
-
* @param props
|
|
28
|
+
* UI slot contributions rendered at the matching extension points.
|
|
33
29
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
slots?: SlotContribution[];
|
|
31
|
+
/**
|
|
32
|
+
* HOC providers wrapping root or form content.
|
|
33
|
+
* Providers with `scope: "root"` wrap the entire CMS below RebaseContext.
|
|
34
|
+
* Providers with `scope: "form"` wrap each entity form/edit view.
|
|
35
|
+
*/
|
|
36
|
+
providers?: PluginProvider[];
|
|
37
|
+
/**
|
|
38
|
+
* Behavioral hooks (non-UI) — collection modification, search blocking,
|
|
39
|
+
* column reordering, navigation entries, etc.
|
|
40
|
+
*/
|
|
41
|
+
hooks?: PluginHooks;
|
|
42
|
+
/**
|
|
43
|
+
* Field wrapping for custom field rendering (e.g. data enhancement).
|
|
44
|
+
*/
|
|
45
|
+
fieldBuilder?: FieldBuilderConfig;
|
|
41
46
|
/**
|
|
42
47
|
* Views to be automatically added to the navigation.
|
|
43
|
-
* These views will be merged with the views provided to useBuildNavigationController.
|
|
44
48
|
*/
|
|
45
|
-
views?:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* Additional children to be rendered at the end of the home page.
|
|
57
|
-
*/
|
|
58
|
-
additionalChildrenEnd?: React.ReactNode;
|
|
59
|
-
/**
|
|
60
|
-
* Use this component to add custom actions to the navigation card
|
|
61
|
-
* in the home page.
|
|
62
|
-
*/
|
|
63
|
-
CollectionActions?: React.ComponentType<PluginHomePageActionsProps>;
|
|
64
|
-
/**
|
|
65
|
-
* Additional props passed to `CollectionActions`
|
|
66
|
-
*/
|
|
67
|
-
extraProps?: Record<string, unknown>;
|
|
68
|
-
/**
|
|
69
|
-
* Add additional cards to each collection group in the home page.
|
|
70
|
-
*/
|
|
71
|
-
AdditionalCards?: React.ComponentType<PluginHomePageAdditionalCardsProps> | React.ComponentType<PluginHomePageAdditionalCardsProps>[];
|
|
72
|
-
/**
|
|
73
|
-
* Include a section in the home page with a custom component and title.
|
|
74
|
-
* @param props
|
|
75
|
-
*/
|
|
76
|
-
includeSection?: (props: PluginGenericProps) => {
|
|
77
|
-
title: string;
|
|
78
|
-
children: React.ReactNode;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Allow reordering with drag and drop of the collections in the home page.
|
|
82
|
-
*/
|
|
83
|
-
allowDragAndDrop?: boolean;
|
|
84
|
-
navigationEntries?: NavigationGroupMapping[];
|
|
85
|
-
/**
|
|
86
|
-
* This method will be called when the entries are updated in the home page.
|
|
87
|
-
* group => navigationEntriesOrder (path)
|
|
88
|
-
* @param entries
|
|
89
|
-
*/
|
|
90
|
-
onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
|
|
91
|
-
};
|
|
92
|
-
collectionView?: {
|
|
93
|
-
/**
|
|
94
|
-
* Custom component to render when a collection loading error occurs.
|
|
95
|
-
* If provided, this replaces the default error view in all collection view modes
|
|
96
|
-
* (table, card, kanban).
|
|
97
|
-
* Return `null` from the component to fall back to the default error view.
|
|
98
|
-
*/
|
|
99
|
-
CollectionError?: React.ComponentType<{
|
|
100
|
-
path: string;
|
|
101
|
-
collection: EC;
|
|
102
|
-
parentCollectionIds?: string[];
|
|
103
|
-
error: Error;
|
|
104
|
-
}>;
|
|
105
|
-
/**
|
|
106
|
-
* Use this component to add custom actions to the entity collections
|
|
107
|
-
* toolbar.
|
|
108
|
-
*/
|
|
109
|
-
CollectionActions?: React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_PROPS>[];
|
|
110
|
-
collectionActionsProps?: COL_ACTIONS_PROPS;
|
|
111
|
-
CollectionActionsStart?: React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_START__PROPS>[];
|
|
112
|
-
collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
|
|
113
|
-
blockSearch?: (props: {
|
|
114
|
-
context: RebaseContext;
|
|
115
|
-
path: string;
|
|
116
|
-
collection: EC;
|
|
117
|
-
parentCollectionIds?: string[];
|
|
118
|
-
}) => boolean;
|
|
119
|
-
showTextSearchBar?: (props: {
|
|
120
|
-
context: RebaseContext;
|
|
121
|
-
path: string;
|
|
122
|
-
collection: EC;
|
|
123
|
-
parentCollectionIds?: string[];
|
|
124
|
-
}) => boolean;
|
|
125
|
-
onTextSearchClick?: (props: {
|
|
126
|
-
context: RebaseContext;
|
|
127
|
-
path: string;
|
|
128
|
-
collection: EC;
|
|
129
|
-
parentCollectionIds?: string[];
|
|
130
|
-
}) => Promise<boolean>;
|
|
131
|
-
/**
|
|
132
|
-
* Use this method to inject widgets to the entity collections header
|
|
133
|
-
* @param props
|
|
134
|
-
*/
|
|
135
|
-
HeaderAction?: React.ComponentType<{
|
|
136
|
-
property: Property;
|
|
137
|
-
propertyKey: string;
|
|
138
|
-
path: string;
|
|
139
|
-
parentCollectionIds: string[];
|
|
140
|
-
onHover: boolean;
|
|
141
|
-
collection: EC;
|
|
142
|
-
tableController: EntityTableController;
|
|
143
|
-
}>;
|
|
144
|
-
/**
|
|
145
|
-
* If you add this callback to your plugin, an add button will be added to the collection table.
|
|
146
|
-
* TODO: Only the first plugin that defines this callback will be used, at the moment.
|
|
147
|
-
*/
|
|
148
|
-
AddColumnComponent?: React.ComponentType<{
|
|
149
|
-
path: string;
|
|
150
|
-
parentCollectionIds: string[];
|
|
151
|
-
collection: EC;
|
|
152
|
-
tableController: EntityTableController;
|
|
153
|
-
}>;
|
|
154
|
-
/**
|
|
155
|
-
* Callback called when columns are reordered via drag and drop.
|
|
156
|
-
* Used by plugins to persist the new column order.
|
|
157
|
-
*/
|
|
158
|
-
onColumnsReorder?: (props: {
|
|
159
|
-
fullPath: string;
|
|
160
|
-
parentCollectionIds: string[];
|
|
161
|
-
collection: EC;
|
|
162
|
-
newPropertiesOrder: string[];
|
|
163
|
-
}) => void;
|
|
164
|
-
/**
|
|
165
|
-
* Callback called when Kanban board columns are reordered via drag and drop.
|
|
166
|
-
* Used by plugins to persist the new Kanban column order.
|
|
167
|
-
*/
|
|
168
|
-
onKanbanColumnsReorder?: (props: {
|
|
169
|
-
fullPath: string;
|
|
170
|
-
parentCollectionIds: string[];
|
|
171
|
-
collection: EC;
|
|
172
|
-
kanbanColumnProperty: string;
|
|
173
|
-
newColumnsOrder: string[];
|
|
174
|
-
}) => void;
|
|
175
|
-
/**
|
|
176
|
-
* Component to render when Kanban view is missing configuration.
|
|
177
|
-
* Used to provide a CTA to open the collection editor to configure Kanban.
|
|
178
|
-
*/
|
|
179
|
-
KanbanSetupComponent?: React.ComponentType<{
|
|
180
|
-
collection: EC;
|
|
181
|
-
fullPath: string;
|
|
182
|
-
parentCollectionIds: string[];
|
|
183
|
-
}>;
|
|
184
|
-
/**
|
|
185
|
-
* Component to render an "Add Column" button at the end of the Kanban board.
|
|
186
|
-
* Used to allow adding new enum values to the column property.
|
|
187
|
-
*/
|
|
188
|
-
AddKanbanColumnComponent?: React.ComponentType<{
|
|
189
|
-
collection: EC;
|
|
190
|
-
fullPath: string;
|
|
191
|
-
parentCollectionIds: string[];
|
|
192
|
-
columnProperty: string;
|
|
193
|
-
}>;
|
|
194
|
-
};
|
|
195
|
-
form?: {
|
|
196
|
-
provider?: {
|
|
197
|
-
Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<User, EC>>>;
|
|
198
|
-
props?: FORM_PROPS;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Add custom actions to the default ones ("Save", "Discard"...)
|
|
202
|
-
*/
|
|
203
|
-
Actions?: React.ComponentType<PluginFormActionProps<User, EC>>;
|
|
204
|
-
/**
|
|
205
|
-
* Add custom actions to the top of the form
|
|
206
|
-
*/
|
|
207
|
-
ActionsTop?: React.ComponentType<PluginFormActionProps<User, EC>>;
|
|
208
|
-
/**
|
|
209
|
-
* Add custom content above the entity title in the form view
|
|
210
|
-
*/
|
|
211
|
-
BeforeTitle?: React.ComponentType<PluginFormActionProps<User, EC>>;
|
|
212
|
-
fieldBuilder?: <T>(props: PluginFieldBuilderParams<Record<string, unknown>, EC>) => React.ComponentType<FieldProps<any>> | null;
|
|
213
|
-
fieldBuilderEnabled?: <T>(props: PluginFieldBuilderParams) => boolean;
|
|
214
|
-
};
|
|
215
|
-
collection?: {
|
|
216
|
-
/**
|
|
217
|
-
* Use this method to modify a single collection before it is rendered.
|
|
218
|
-
* @param collection
|
|
219
|
-
*/
|
|
220
|
-
modifyCollection?: (collection: EntityCollection) => EntityCollection;
|
|
221
|
-
/**
|
|
222
|
-
* Use this method to modify, add or remove collections.
|
|
223
|
-
* @param collections
|
|
224
|
-
*/
|
|
225
|
-
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
226
|
-
};
|
|
227
|
-
};
|
|
49
|
+
views?: AppView[];
|
|
50
|
+
/**
|
|
51
|
+
* User management delegate from this plugin.
|
|
52
|
+
*/
|
|
53
|
+
userManagement?: UserManagementDelegate;
|
|
54
|
+
/**
|
|
55
|
+
* Optional lifecycle hooks. Called by the Rebase runtime
|
|
56
|
+
* at appropriate points in the app lifecycle.
|
|
57
|
+
*/
|
|
58
|
+
lifecycle?: PluginLifecycle;
|
|
59
|
+
}
|
|
228
60
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* @group Models
|
|
61
|
+
* A HOC provider that wraps a subtree of the CMS.
|
|
62
|
+
* @group Plugins
|
|
233
63
|
*/
|
|
234
|
-
export interface
|
|
64
|
+
export interface PluginProvider {
|
|
235
65
|
/**
|
|
236
|
-
*
|
|
237
|
-
* `
|
|
66
|
+
* `"root"` — wraps the entire CMS below RebaseContext.
|
|
67
|
+
* `"form"` — wraps each entity form / edit view.
|
|
238
68
|
*/
|
|
239
|
-
|
|
69
|
+
scope: "root" | "form";
|
|
240
70
|
/**
|
|
241
|
-
* The
|
|
71
|
+
* The provider component. Must accept `children`.
|
|
72
|
+
* Typed loosely because extra props are passed via the `props` field;
|
|
73
|
+
* strict signatures cause contravariance issues.
|
|
242
74
|
*/
|
|
243
|
-
|
|
75
|
+
Component: React.ComponentType<any>;
|
|
76
|
+
/**
|
|
77
|
+
* Additional props passed to the Component.
|
|
78
|
+
*/
|
|
79
|
+
props?: Record<string, any>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Behavioral hooks that a plugin can provide.
|
|
83
|
+
* These are non-UI extension points for modifying CMS behavior.
|
|
84
|
+
* @group Plugins
|
|
85
|
+
*/
|
|
86
|
+
export interface PluginHooks {
|
|
87
|
+
/**
|
|
88
|
+
* Modify a single collection before it is rendered (synchronous).
|
|
89
|
+
*/
|
|
90
|
+
modifyCollection?: (collection: EntityCollection) => EntityCollection;
|
|
91
|
+
/**
|
|
92
|
+
* Async version of modifyCollection — supports fetching remote config.
|
|
93
|
+
* Runs during navigation resolution. If provided alongside `modifyCollection`,
|
|
94
|
+
* the sync version runs first, then the async version.
|
|
95
|
+
*/
|
|
96
|
+
modifyCollectionAsync?: (collection: EntityCollection) => Promise<EntityCollection>;
|
|
97
|
+
/**
|
|
98
|
+
* Modify, add or remove collections.
|
|
99
|
+
*/
|
|
100
|
+
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
101
|
+
/**
|
|
102
|
+
* Callback called when columns are reordered via drag and drop.
|
|
103
|
+
*/
|
|
104
|
+
onColumnsReorder?: (props: {
|
|
105
|
+
fullPath: string;
|
|
106
|
+
parentCollectionIds: string[];
|
|
107
|
+
collection: EntityCollection;
|
|
108
|
+
newPropertiesOrder: string[];
|
|
109
|
+
}) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Callback called when Kanban board columns are reordered.
|
|
112
|
+
*/
|
|
113
|
+
onKanbanColumnsReorder?: (props: {
|
|
114
|
+
fullPath: string;
|
|
115
|
+
parentCollectionIds: string[];
|
|
116
|
+
collection: EntityCollection;
|
|
117
|
+
kanbanColumnProperty: string;
|
|
118
|
+
newColumnsOrder: string[];
|
|
119
|
+
}) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Navigation entries contributed by this plugin.
|
|
122
|
+
*/
|
|
123
|
+
navigationEntries?: NavigationGroupMapping[];
|
|
244
124
|
/**
|
|
245
|
-
*
|
|
125
|
+
* Callback when navigation entry order changes (e.g. drag-and-drop).
|
|
246
126
|
*/
|
|
127
|
+
onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Allow reordering collections in the home page via drag and drop.
|
|
130
|
+
*/
|
|
131
|
+
allowDragAndDrop?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Lifecycle hooks for plugins. Called by the Rebase runtime
|
|
135
|
+
* at appropriate points in the app lifecycle.
|
|
136
|
+
* @group Plugins
|
|
137
|
+
*/
|
|
138
|
+
export interface PluginLifecycle {
|
|
139
|
+
/**
|
|
140
|
+
* Called once when the plugin is mounted in the Rebase tree.
|
|
141
|
+
* Can return a Promise for async initialization.
|
|
142
|
+
*/
|
|
143
|
+
onMount?: (context: RebaseContext) => void | Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Called when the plugin is unmounted from the Rebase tree.
|
|
146
|
+
* Use this for cleanup (subscriptions, timers, etc.).
|
|
147
|
+
*/
|
|
148
|
+
onUnmount?: () => void;
|
|
149
|
+
/**
|
|
150
|
+
* Called whenever the authentication state changes.
|
|
151
|
+
* Receives the new user (or null on sign-out).
|
|
152
|
+
*/
|
|
153
|
+
onAuthStateChange?: (user: User | null) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Called when a collection's visible entities change.
|
|
156
|
+
* Useful for analytics, caching, or cross-plugin coordination.
|
|
157
|
+
*/
|
|
158
|
+
onCollectionChange?: (slug: string, entities: any[]) => void;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Configuration for wrapping form field components.
|
|
162
|
+
* @group Plugins
|
|
163
|
+
*/
|
|
164
|
+
export interface FieldBuilderConfig {
|
|
165
|
+
/**
|
|
166
|
+
* Returns a wrapped field component, or null to skip wrapping.
|
|
167
|
+
*/
|
|
168
|
+
wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<any>> | null;
|
|
169
|
+
/**
|
|
170
|
+
* Optional guard — return false to skip wrapping for this field.
|
|
171
|
+
*/
|
|
172
|
+
enabled?: (params: PluginFieldBuilderParams) => boolean;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Props passed to home page collection card action components.
|
|
176
|
+
* @group Models
|
|
177
|
+
*/
|
|
178
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
179
|
+
slug: string;
|
|
180
|
+
collection: EC;
|
|
247
181
|
context: RebaseContext<USER>;
|
|
248
|
-
extraProps?: EP;
|
|
249
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Props passed to form action components in entity edit/form views.
|
|
185
|
+
* @group Models
|
|
186
|
+
*/
|
|
250
187
|
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
251
188
|
entityId?: string | number;
|
|
252
189
|
path: string;
|
|
@@ -258,6 +195,10 @@ export interface PluginFormActionProps<USER extends User = User, EC extends Enti
|
|
|
258
195
|
context: RebaseContext<USER>;
|
|
259
196
|
openEntityMode: "side_panel" | "full_screen";
|
|
260
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Parameters passed to the field builder wrap function.
|
|
200
|
+
* @group Models
|
|
201
|
+
*/
|
|
261
202
|
export type PluginFieldBuilderParams<M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
262
203
|
fieldConfigId: string;
|
|
263
204
|
propertyKey: string;
|
|
@@ -267,9 +208,17 @@ export type PluginFieldBuilderParams<M extends Record<string, any> = any, EC ext
|
|
|
267
208
|
path?: string;
|
|
268
209
|
collection?: EC;
|
|
269
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Generic props passed to plugin components that just need CMS context.
|
|
213
|
+
* @group Models
|
|
214
|
+
*/
|
|
270
215
|
export interface PluginGenericProps<USER extends User = User> {
|
|
271
216
|
context: RebaseContext<USER>;
|
|
272
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Props for additional card components in the home page.
|
|
220
|
+
* @group Models
|
|
221
|
+
*/
|
|
273
222
|
export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
|
|
274
223
|
group?: string;
|
|
275
224
|
context: RebaseContext<USER>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { FieldProps } from "./fields";
|
|
3
2
|
import { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
|
|
4
3
|
import { FilterValues } from "./collections";
|
|
5
|
-
import { PropertyPreviewProps } from "../components";
|
|
6
4
|
import { ColorKey, ColorScheme } from "./chips";
|
|
7
5
|
import { AuthController } from "../controllers";
|
|
8
6
|
import { Relation } from "./relations";
|
|
@@ -12,7 +10,7 @@ import { User } from "../users";
|
|
|
12
10
|
* Callbacks/Hooks for individual property fields
|
|
13
11
|
* @group Entity properties
|
|
14
12
|
*/
|
|
15
|
-
export type PropertyCallbacks<T =
|
|
13
|
+
export type PropertyCallbacks<T = unknown, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
|
|
16
14
|
/**
|
|
17
15
|
* Callback used after fetching data, to transform the value before rendering
|
|
18
16
|
*/
|
|
@@ -42,7 +40,7 @@ export type Properties = {
|
|
|
42
40
|
* A helper type to infer the underlying data type from a Property definition.
|
|
43
41
|
* This is the core of the type inference system.
|
|
44
42
|
*/
|
|
45
|
-
export type InferPropertyType<P extends Property> = P extends StringProperty ? string : P extends NumberProperty ? number : P extends BooleanProperty ? boolean : P extends DateProperty ? Date : P extends GeopointProperty ? GeoPoint : P extends ReferenceProperty ? EntityReference : P extends RelationProperty ? EntityRelation | EntityRelation[] : P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] :
|
|
43
|
+
export type InferPropertyType<P extends Property> = P extends StringProperty ? string : P extends NumberProperty ? number : P extends BooleanProperty ? boolean : P extends DateProperty ? Date : P extends GeopointProperty ? GeoPoint : P extends ReferenceProperty ? EntityReference : P extends RelationProperty ? EntityRelation | EntityRelation[] : P extends ArrayProperty ? (P["of"] extends Property ? InferPropertyType<P["of"]>[] : unknown[]) : P extends MapProperty ? (P["properties"] extends Properties ? InferEntityType<P["properties"]> : Record<string, unknown>) : never;
|
|
46
44
|
/**
|
|
47
45
|
* A generic type that converts a `Properties` schema definition into a corresponding
|
|
48
46
|
* TypeScript entity type. It correctly handles required and optional properties.
|
|
@@ -72,7 +70,7 @@ export type InferEntityType<P extends Properties> = {
|
|
|
72
70
|
* Interface including all common properties of a CMS property.
|
|
73
71
|
* @group Entity properties
|
|
74
72
|
*/
|
|
75
|
-
export interface BaseProperty<CustomProps =
|
|
73
|
+
export interface BaseProperty<CustomProps = unknown> {
|
|
76
74
|
/**
|
|
77
75
|
* Property name (e.g. Product)
|
|
78
76
|
*/
|
|
@@ -128,20 +126,6 @@ export interface BaseProperty<CustomProps = any> {
|
|
|
128
126
|
* or in `preview`.
|
|
129
127
|
*/
|
|
130
128
|
customProps?: CustomProps;
|
|
131
|
-
/**
|
|
132
|
-
* If you need to render a custom field, you can create a component that
|
|
133
|
-
* takes `FieldProps` as props. You receive the value, a function to
|
|
134
|
-
* update the value and additional utility props such as if there is an error.
|
|
135
|
-
* You can customize it by passing custom props that are received
|
|
136
|
-
* in the component.
|
|
137
|
-
*/
|
|
138
|
-
Field?: React.ComponentType<FieldProps<any, CustomProps>>;
|
|
139
|
-
/**
|
|
140
|
-
* Configure how a property is displayed as a preview, e.g. in the collection
|
|
141
|
-
* view. You can customize it by passing custom props that are received
|
|
142
|
-
* in the component.
|
|
143
|
-
*/
|
|
144
|
-
Preview?: React.ComponentType<PropertyPreviewProps<any, CustomProps>>;
|
|
145
129
|
/**
|
|
146
130
|
* Use this to define dynamic properties that change based on certain conditions
|
|
147
131
|
* or on the entity's values. For example, you can make a field read-only if
|
|
@@ -165,6 +149,16 @@ export interface BaseProperty<CustomProps = any> {
|
|
|
165
149
|
* Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
|
|
166
150
|
*/
|
|
167
151
|
callbacks?: PropertyCallbacks;
|
|
152
|
+
/**
|
|
153
|
+
* Custom field component to render this property in forms.
|
|
154
|
+
* Used by the CMS layer.
|
|
155
|
+
*/
|
|
156
|
+
Field?: React.ComponentType<any>;
|
|
157
|
+
/**
|
|
158
|
+
* Custom preview component to render this property in previews/tables.
|
|
159
|
+
* Used by the CMS layer.
|
|
160
|
+
*/
|
|
161
|
+
Preview?: React.ComponentType<any>;
|
|
168
162
|
}
|
|
169
163
|
/**
|
|
170
164
|
* @group Entity properties
|
|
@@ -452,7 +446,7 @@ export interface ArrayProperty extends BaseProperty {
|
|
|
452
446
|
* You can leave this field empty only if you are providing a custom field,
|
|
453
447
|
* or using the `oneOf` prop, otherwise an error will be thrown.
|
|
454
448
|
*/
|
|
455
|
-
of?: Property;
|
|
449
|
+
of?: Property | Property[];
|
|
456
450
|
/**
|
|
457
451
|
* Use this field if you would like to have an array of typed objects.
|
|
458
452
|
* It is useful if you need to have values of different types in the same
|
|
@@ -575,7 +569,7 @@ export interface MapProperty extends BaseProperty {
|
|
|
575
569
|
/**
|
|
576
570
|
* @group Entity properties
|
|
577
571
|
*/
|
|
578
|
-
export type PropertyBuilderProps<M extends Record<string,
|
|
572
|
+
export type PropertyBuilderProps<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
579
573
|
values: Partial<M>;
|
|
580
574
|
previousValues?: Partial<M>;
|
|
581
575
|
propertyValue?: unknown;
|
|
@@ -609,7 +603,7 @@ export interface PropertyDisabledConfig {
|
|
|
609
603
|
/**
|
|
610
604
|
* We use this type to define mapping between string or number values in
|
|
611
605
|
* the data source to a label (such in a select dropdown).
|
|
612
|
-
* The key in this Record is the value saved in the
|
|
606
|
+
* The key in this Record is the value saved in the driver, and the value in
|
|
613
607
|
* this record is the label displayed in the UI.
|
|
614
608
|
* You can add additional customization by assigning a {@link EnumValueConfig} for the
|
|
615
609
|
* label instead of a simple string (for enabling or disabling options and
|
|
@@ -726,12 +720,6 @@ export type StorageConfig = {
|
|
|
726
720
|
* accepts any image file, and so on.
|
|
727
721
|
*/
|
|
728
722
|
acceptedFiles?: FileType[];
|
|
729
|
-
/**
|
|
730
|
-
* Use client side image compression and resizing
|
|
731
|
-
* Will only be applied to these MIME types: image/jpeg, image/png and image/webp
|
|
732
|
-
* @deprecated Use `imageResize` instead
|
|
733
|
-
*/
|
|
734
|
-
imageCompression?: ImageResize;
|
|
735
723
|
/**
|
|
736
724
|
* Advanced image resizing and cropping configuration.
|
|
737
725
|
* Applied before upload to optimize storage and bandwidth.
|
|
@@ -784,7 +772,7 @@ export type StorageConfig = {
|
|
|
784
772
|
includeBucketUrl?: boolean;
|
|
785
773
|
/**
|
|
786
774
|
* When set to true, this flag indicates that the download URL of the file
|
|
787
|
-
* will be saved in the
|
|
775
|
+
* will be saved in the driver, instead of the storage path.
|
|
788
776
|
*
|
|
789
777
|
* Note that the generated URL may use a token that, if disabled, may
|
|
790
778
|
* make the URL unusable and lose the original reference to Cloud Storage,
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ArrayProperty, MapProperty } from "./properties";
|
|
3
|
-
import {
|
|
2
|
+
import { ArrayProperty, MapProperty, StringProperty, NumberProperty, BooleanProperty, DateProperty, GeopointProperty, ReferenceProperty, RelationProperty } from "./properties";
|
|
3
|
+
import { BaseProperty } from "./properties";
|
|
4
|
+
type CMSBasePropertyNoName = Omit<BaseProperty, "name">;
|
|
4
5
|
export type ConfigProperty = (Omit<StringProperty, "name"> & {
|
|
5
6
|
name?: string;
|
|
6
|
-
}) | (Omit<NumberProperty, "name"> & {
|
|
7
|
+
} & CMSBasePropertyNoName) | (Omit<NumberProperty, "name"> & {
|
|
7
8
|
name?: string;
|
|
8
|
-
}) | (Omit<BooleanProperty, "name"> & {
|
|
9
|
+
} & CMSBasePropertyNoName) | (Omit<BooleanProperty, "name"> & {
|
|
9
10
|
name?: string;
|
|
10
|
-
}) | (Omit<DateProperty, "name"> & {
|
|
11
|
+
} & CMSBasePropertyNoName) | (Omit<DateProperty, "name"> & {
|
|
11
12
|
name?: string;
|
|
12
|
-
}) | (Omit<GeopointProperty, "name"> & {
|
|
13
|
+
} & CMSBasePropertyNoName) | (Omit<GeopointProperty, "name"> & {
|
|
13
14
|
name?: string;
|
|
14
|
-
}) | (Omit<ReferenceProperty, "name"> & {
|
|
15
|
+
} & CMSBasePropertyNoName) | (Omit<ReferenceProperty, "name"> & {
|
|
15
16
|
name?: string;
|
|
16
|
-
}) | (Omit<RelationProperty, "name"> & {
|
|
17
|
+
} & CMSBasePropertyNoName) | (Omit<RelationProperty, "name"> & {
|
|
17
18
|
name?: string;
|
|
18
|
-
}) | (Omit<ArrayProperty, "name" | "of" | "oneOf"> & {
|
|
19
|
+
} & CMSBasePropertyNoName) | (Omit<ArrayProperty, "name" | "of" | "oneOf"> & {
|
|
19
20
|
name?: string;
|
|
20
21
|
of?: ConfigProperty | ConfigProperty[];
|
|
21
22
|
oneOf?: {
|
|
@@ -24,10 +25,10 @@ export type ConfigProperty = (Omit<StringProperty, "name"> & {
|
|
|
24
25
|
valueField?: string;
|
|
25
26
|
propertiesOrder?: string[];
|
|
26
27
|
};
|
|
27
|
-
}) | (Omit<MapProperty, "name" | "properties"> & {
|
|
28
|
+
} & CMSBasePropertyNoName) | (Omit<MapProperty, "name" | "properties"> & {
|
|
28
29
|
name?: string;
|
|
29
30
|
properties?: Record<string, ConfigProperty>;
|
|
30
|
-
});
|
|
31
|
+
} & CMSBasePropertyNoName);
|
|
31
32
|
/**
|
|
32
33
|
* This is the configuration object for a property.
|
|
33
34
|
* These configs are generated by default for the properties defined in your
|
|
@@ -66,3 +67,4 @@ export type PropertyConfig = {
|
|
|
66
67
|
description?: string;
|
|
67
68
|
};
|
|
68
69
|
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" | "reference_as_string" | "multi_references" | "relation" | "switch" | "date_time" | "repeat" | "custom_array" | "block";
|
|
70
|
+
export {};
|