@rebasepro/types 0.0.1-canary.0 → 0.0.1-canary.0e2f892
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 +52 -6
- package/dist/controllers/client.d.ts +170 -0
- package/dist/controllers/collection_registry.d.ts +45 -0
- package/dist/controllers/customization_controller.d.ts +11 -1
- package/dist/controllers/data.d.ts +168 -0
- package/dist/controllers/data_driver.d.ts +160 -0
- package/dist/controllers/database_admin.d.ts +11 -0
- package/dist/controllers/effective_role.d.ts +4 -0
- package/dist/controllers/email.d.ts +34 -0
- package/dist/controllers/index.d.ts +12 -5
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +12 -61
- package/dist/controllers/registry.d.ts +54 -0
- package/dist/controllers/side_entity_controller.d.ts +7 -7
- package/dist/controllers/storage.d.ts +24 -26
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +119 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +118 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +40 -26
- package/dist/types/backend.d.ts +300 -18
- package/dist/types/builders.d.ts +15 -0
- package/dist/types/chips.d.ts +1 -1
- package/dist/types/collections.d.ts +324 -355
- package/dist/types/cron.d.ts +102 -0
- package/dist/types/data_source.d.ts +64 -0
- package/dist/types/entities.d.ts +29 -24
- package/dist/types/entity_actions.d.ts +12 -12
- package/dist/types/entity_callbacks.d.ts +12 -12
- package/dist/types/entity_link_builder.d.ts +1 -1
- package/dist/types/entity_overrides.d.ts +7 -2
- package/dist/types/entity_views.d.ts +61 -0
- package/dist/types/export_import.d.ts +3 -3
- package/dist/types/index.d.ts +9 -5
- package/dist/types/plugins.d.ts +228 -225
- package/dist/types/properties.d.ts +135 -62
- package/dist/types/property_config.d.ts +13 -11
- package/dist/types/relations.d.ts +1 -1
- package/dist/types/slots.d.ts +252 -0
- package/dist/types/translations.d.ts +870 -0
- package/dist/types/user_management_delegate.d.ts +43 -0
- package/dist/types/websockets.d.ts +45 -0
- package/dist/users/user.d.ts +4 -0
- package/package.json +99 -131
- package/src/controllers/analytics_controller.tsx +2 -2
- package/src/controllers/auth.tsx +55 -6
- package/src/controllers/client.ts +133 -0
- package/src/controllers/collection_registry.ts +57 -0
- package/src/controllers/customization_controller.tsx +12 -1
- package/src/controllers/data.ts +191 -0
- package/src/controllers/{datasource.ts → data_driver.ts} +50 -61
- package/src/controllers/database_admin.ts +22 -0
- package/src/controllers/effective_role.ts +4 -0
- package/src/controllers/email.ts +36 -0
- package/src/controllers/index.ts +15 -5
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +13 -76
- package/src/controllers/registry.ts +65 -0
- package/src/controllers/side_entity_controller.tsx +7 -7
- package/src/controllers/storage.ts +25 -28
- package/src/index.ts +0 -1
- package/src/rebase_context.tsx +41 -39
- package/src/types/backend.ts +359 -24
- package/src/types/builders.ts +17 -0
- package/src/types/chips.ts +15 -40
- package/src/types/collections.ts +375 -383
- package/src/types/cron.ts +149 -0
- package/src/types/data_source.ts +145 -0
- package/src/types/entities.ts +40 -33
- package/src/types/entity_actions.tsx +11 -11
- package/src/types/entity_callbacks.ts +12 -12
- package/src/types/entity_link_builder.ts +1 -1
- package/src/types/entity_overrides.tsx +7 -2
- package/src/types/entity_views.tsx +77 -0
- package/src/types/export_import.ts +3 -3
- package/src/types/index.ts +10 -5
- package/src/types/plugins.tsx +280 -261
- package/src/types/properties.ts +163 -61
- package/src/types/property_config.tsx +11 -11
- package/src/types/relations.ts +1 -1
- package/src/types/slots.tsx +297 -0
- package/src/types/translations.ts +977 -0
- package/src/types/user_management_delegate.ts +50 -7
- package/src/types/websockets.ts +48 -0
- package/src/users/roles.ts +0 -1
- 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/controllers/datasource.d.ts +0 -179
- 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,243 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Property } from "./properties";
|
|
5
|
-
import {
|
|
6
|
-
import { RebaseContext } from "../rebase_context";
|
|
7
|
-
import { NavigationGroupMapping,
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import type { EntityCollection } from "./collections";
|
|
3
|
+
import type { EntityStatus } from "./entities";
|
|
4
|
+
import type { InferPropertyType, Property } from "./properties";
|
|
5
|
+
import type { FormContext } from "./entity_views";
|
|
6
|
+
import type { RebaseContext } from "../rebase_context";
|
|
7
|
+
import type { NavigationGroupMapping, AppView } from "../controllers/navigation";
|
|
8
|
+
import type { UserManagementDelegate } from "./user_management_delegate";
|
|
9
|
+
import type { User } from "../users";
|
|
10
|
+
import type { SlotContribution } from "./slots";
|
|
11
|
+
/**
|
|
12
|
+
* Props interface for custom field components.
|
|
13
|
+
*
|
|
14
|
+
* The `@rebasepro/admin` package re-exports a narrower version of this
|
|
15
|
+
* interface that adds `formex` and layout-specific fields. This base
|
|
16
|
+
* definition captures the core contract that every field renderer must
|
|
17
|
+
* satisfy, regardless of where it is rendered.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam P - The property type this field is bound to
|
|
20
|
+
* @typeParam CustomProps - Extra props injected via the property's `customProps`
|
|
21
|
+
* @typeParam M - The entity model type
|
|
22
|
+
* @group Form custom fields
|
|
23
|
+
*/
|
|
24
|
+
export interface FieldProps<P extends Property = Property, CustomProps = unknown, M extends Record<string, unknown> = Record<string, unknown>> {
|
|
25
|
+
/** Key of the property (e.g. "user.name" for a nested path) */
|
|
26
|
+
propertyKey: string;
|
|
27
|
+
/** Current value of this field */
|
|
28
|
+
value: InferPropertyType<P> | null;
|
|
29
|
+
/** Set value of field directly */
|
|
30
|
+
setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
|
|
31
|
+
/** Set value of a different field directly */
|
|
32
|
+
setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
|
|
33
|
+
/** Is the form currently submitting */
|
|
34
|
+
isSubmitting?: boolean;
|
|
35
|
+
/** Should this field show the error indicator */
|
|
36
|
+
showError?: boolean;
|
|
37
|
+
/** Error message for this field, or undefined if valid */
|
|
38
|
+
error?: string;
|
|
39
|
+
/** Has this field been touched */
|
|
40
|
+
touched?: boolean;
|
|
41
|
+
/** Property related to this field */
|
|
42
|
+
property: P;
|
|
43
|
+
/** Should this field include a description */
|
|
44
|
+
includeDescription?: boolean;
|
|
45
|
+
/** Flag to indicate that the underlying value has been updated in the driver */
|
|
46
|
+
underlyingValueHasChanged?: boolean;
|
|
47
|
+
/** Is this field part of an array */
|
|
48
|
+
partOfArray?: boolean;
|
|
49
|
+
/** Is this field part of a block */
|
|
50
|
+
partOfBlock?: boolean;
|
|
51
|
+
/** Display the child properties directly, without being wrapped in an extendable panel */
|
|
52
|
+
minimalistView?: boolean;
|
|
53
|
+
/** Should this field autofocus on mount */
|
|
54
|
+
autoFocus?: boolean;
|
|
55
|
+
/** Additional properties set by the developer */
|
|
56
|
+
customProps?: CustomProps;
|
|
57
|
+
/** Additional values related to the state of the form or the entity */
|
|
58
|
+
context: FormContext<M>;
|
|
59
|
+
/** Flag to indicate if this field should be disabled */
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
/** Size of the field */
|
|
62
|
+
size?: "small" | "medium" | "large";
|
|
63
|
+
/** Callback when internal property state changes (e.g. panel expansion) */
|
|
64
|
+
onPropertyChange?: (property: Partial<Property>) => void;
|
|
65
|
+
}
|
|
10
66
|
/**
|
|
11
67
|
* Interface used to define plugins for Rebase.
|
|
12
|
-
*
|
|
68
|
+
* Plugins contribute UI via **slots**, wrap subtrees with **providers**,
|
|
69
|
+
* and inject behavioral logic via **hooks**.
|
|
13
70
|
* @group Core
|
|
14
71
|
*/
|
|
15
|
-
export
|
|
72
|
+
export interface RebasePlugin {
|
|
16
73
|
/**
|
|
17
|
-
*
|
|
74
|
+
* Unique key identifying this plugin.
|
|
18
75
|
*/
|
|
19
76
|
key: string;
|
|
20
77
|
/**
|
|
21
|
-
* If
|
|
22
|
-
* until the plugin is fully loaded.
|
|
78
|
+
* If true, no CMS content is shown until this plugin finishes loading.
|
|
23
79
|
*/
|
|
24
80
|
loading?: boolean;
|
|
25
81
|
/**
|
|
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
|
|
82
|
+
* UI slot contributions rendered at the matching extension points.
|
|
33
83
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
84
|
+
slots?: SlotContribution[];
|
|
85
|
+
/**
|
|
86
|
+
* HOC providers wrapping root or form content.
|
|
87
|
+
* Providers with `scope: "root"` wrap the entire CMS below RebaseContext.
|
|
88
|
+
* Providers with `scope: "form"` wrap each entity form/edit view.
|
|
89
|
+
*/
|
|
90
|
+
providers?: PluginProvider[];
|
|
91
|
+
/**
|
|
92
|
+
* Behavioral hooks (non-UI) — collection modification, search blocking,
|
|
93
|
+
* column reordering, navigation entries, etc.
|
|
94
|
+
*/
|
|
95
|
+
hooks?: PluginHooks;
|
|
96
|
+
/**
|
|
97
|
+
* Field wrapping for custom field rendering (e.g. data enhancement).
|
|
98
|
+
*/
|
|
99
|
+
fieldBuilder?: FieldBuilderConfig;
|
|
41
100
|
/**
|
|
42
101
|
* Views to be automatically added to the navigation.
|
|
43
|
-
* These views will be merged with the views provided to useBuildNavigationController.
|
|
44
102
|
*/
|
|
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
|
-
};
|
|
103
|
+
views?: AppView[];
|
|
104
|
+
/**
|
|
105
|
+
* User management delegate from this plugin.
|
|
106
|
+
*/
|
|
107
|
+
userManagement?: UserManagementDelegate;
|
|
108
|
+
/**
|
|
109
|
+
* Optional lifecycle hooks. Called by the Rebase runtime
|
|
110
|
+
* at appropriate points in the app lifecycle.
|
|
111
|
+
*/
|
|
112
|
+
lifecycle?: PluginLifecycle;
|
|
113
|
+
}
|
|
228
114
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* @group Models
|
|
115
|
+
* A HOC provider that wraps a subtree of the CMS.
|
|
116
|
+
* @group Plugins
|
|
233
117
|
*/
|
|
234
|
-
export interface
|
|
118
|
+
export interface PluginProvider {
|
|
235
119
|
/**
|
|
236
|
-
*
|
|
237
|
-
* `
|
|
120
|
+
* `"root"` — wraps the entire CMS below RebaseContext.
|
|
121
|
+
* `"form"` — wraps each entity form / edit view.
|
|
238
122
|
*/
|
|
239
|
-
|
|
123
|
+
scope: "root" | "form";
|
|
240
124
|
/**
|
|
241
|
-
* The
|
|
125
|
+
* The provider component. Must accept `children`.
|
|
126
|
+
* Typed loosely because extra props are passed via the `props` field;
|
|
127
|
+
* strict signatures cause contravariance issues.
|
|
242
128
|
*/
|
|
243
|
-
|
|
129
|
+
Component: React.ComponentType<PropsWithChildren<Record<string, unknown>>>;
|
|
130
|
+
/**
|
|
131
|
+
* Additional props passed to the Component.
|
|
132
|
+
*/
|
|
133
|
+
props?: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Behavioral hooks that a plugin can provide.
|
|
137
|
+
* These are non-UI extension points for modifying CMS behavior.
|
|
138
|
+
* @group Plugins
|
|
139
|
+
*/
|
|
140
|
+
export interface PluginHooks {
|
|
141
|
+
/**
|
|
142
|
+
* Modify a single collection before it is rendered (synchronous).
|
|
143
|
+
*/
|
|
144
|
+
modifyCollection?: (collection: EntityCollection) => EntityCollection;
|
|
145
|
+
/**
|
|
146
|
+
* Async version of modifyCollection — supports fetching remote config.
|
|
147
|
+
* Runs during navigation resolution. If provided alongside `modifyCollection`,
|
|
148
|
+
* the sync version runs first, then the async version.
|
|
149
|
+
*/
|
|
150
|
+
modifyCollectionAsync?: (collection: EntityCollection) => Promise<EntityCollection>;
|
|
151
|
+
/**
|
|
152
|
+
* Modify, add or remove collections.
|
|
153
|
+
*/
|
|
154
|
+
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
244
155
|
/**
|
|
245
|
-
*
|
|
156
|
+
* Callback called when columns are reordered via drag and drop.
|
|
246
157
|
*/
|
|
158
|
+
onColumnsReorder?: (props: {
|
|
159
|
+
fullPath: string;
|
|
160
|
+
parentCollectionIds: string[];
|
|
161
|
+
collection: EntityCollection;
|
|
162
|
+
newPropertiesOrder: string[];
|
|
163
|
+
}) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Callback called when Kanban board columns are reordered.
|
|
166
|
+
*/
|
|
167
|
+
onKanbanColumnsReorder?: (props: {
|
|
168
|
+
fullPath: string;
|
|
169
|
+
parentCollectionIds: string[];
|
|
170
|
+
collection: EntityCollection;
|
|
171
|
+
kanbanColumnProperty: string;
|
|
172
|
+
newColumnsOrder: string[];
|
|
173
|
+
}) => void;
|
|
174
|
+
/**
|
|
175
|
+
* Navigation entries contributed by this plugin.
|
|
176
|
+
*/
|
|
177
|
+
navigationEntries?: NavigationGroupMapping[];
|
|
178
|
+
/**
|
|
179
|
+
* Callback when navigation entry order changes (e.g. drag-and-drop).
|
|
180
|
+
*/
|
|
181
|
+
onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
|
|
182
|
+
/**
|
|
183
|
+
* Allow reordering collections in the home page via drag and drop.
|
|
184
|
+
*/
|
|
185
|
+
allowDragAndDrop?: boolean;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Lifecycle hooks for plugins. Called by the Rebase runtime
|
|
189
|
+
* at appropriate points in the app lifecycle.
|
|
190
|
+
* @group Plugins
|
|
191
|
+
*/
|
|
192
|
+
export interface PluginLifecycle {
|
|
193
|
+
/**
|
|
194
|
+
* Called once when the plugin is mounted in the Rebase tree.
|
|
195
|
+
* Can return a Promise for async initialization.
|
|
196
|
+
*/
|
|
197
|
+
onMount?: (context: RebaseContext) => void | Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Called when the plugin is unmounted from the Rebase tree.
|
|
200
|
+
* Use this for cleanup (subscriptions, timers, etc.).
|
|
201
|
+
*/
|
|
202
|
+
onUnmount?: () => void;
|
|
203
|
+
/**
|
|
204
|
+
* Called whenever the authentication state changes.
|
|
205
|
+
* Receives the new user (or null on sign-out).
|
|
206
|
+
*/
|
|
207
|
+
onAuthStateChange?: (user: User | null) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Called when a collection's visible entities change.
|
|
210
|
+
* Useful for analytics, caching, or cross-plugin coordination.
|
|
211
|
+
*/
|
|
212
|
+
onCollectionChange?: (slug: string, entities: unknown[]) => void;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Configuration for wrapping form field components.
|
|
216
|
+
* @group Plugins
|
|
217
|
+
*/
|
|
218
|
+
export interface FieldBuilderConfig {
|
|
219
|
+
/**
|
|
220
|
+
* Returns a wrapped field component, or null to skip wrapping.
|
|
221
|
+
*/
|
|
222
|
+
wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<Property>> | null;
|
|
223
|
+
/**
|
|
224
|
+
* Optional guard — return false to skip wrapping for this field.
|
|
225
|
+
*/
|
|
226
|
+
enabled?: (params: PluginFieldBuilderParams) => boolean;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Props passed to home page collection card action components.
|
|
230
|
+
* @group Models
|
|
231
|
+
*/
|
|
232
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
233
|
+
slug: string;
|
|
234
|
+
collection: EC;
|
|
247
235
|
context: RebaseContext<USER>;
|
|
248
|
-
extraProps?: EP;
|
|
249
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Props passed to form action components in entity edit/form views.
|
|
239
|
+
* @group Models
|
|
240
|
+
*/
|
|
250
241
|
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
251
242
|
entityId?: string | number;
|
|
252
243
|
path: string;
|
|
@@ -256,9 +247,13 @@ export interface PluginFormActionProps<USER extends User = User, EC extends Enti
|
|
|
256
247
|
disabled: boolean;
|
|
257
248
|
formContext?: FormContext;
|
|
258
249
|
context: RebaseContext<USER>;
|
|
259
|
-
openEntityMode: "side_panel" | "full_screen";
|
|
250
|
+
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
260
251
|
}
|
|
261
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Parameters passed to the field builder wrap function.
|
|
254
|
+
* @group Models
|
|
255
|
+
*/
|
|
256
|
+
export type PluginFieldBuilderParams<M extends Record<string, unknown> = Record<string, unknown>, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
262
257
|
fieldConfigId: string;
|
|
263
258
|
propertyKey: string;
|
|
264
259
|
property: Property;
|
|
@@ -267,9 +262,17 @@ export type PluginFieldBuilderParams<M extends Record<string, any> = any, EC ext
|
|
|
267
262
|
path?: string;
|
|
268
263
|
collection?: EC;
|
|
269
264
|
};
|
|
265
|
+
/**
|
|
266
|
+
* Generic props passed to plugin components that just need CMS context.
|
|
267
|
+
* @group Models
|
|
268
|
+
*/
|
|
270
269
|
export interface PluginGenericProps<USER extends User = User> {
|
|
271
270
|
context: RebaseContext<USER>;
|
|
272
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Props for additional card components in the home page.
|
|
274
|
+
* @group Models
|
|
275
|
+
*/
|
|
273
276
|
export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
|
|
274
277
|
group?: string;
|
|
275
278
|
context: RebaseContext<USER>;
|