@rebasepro/types 0.0.1-canary.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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/components/EntityFormActionsProps.d.ts +17 -0
  4. package/dist/components/EntityFormProps.d.ts +46 -0
  5. package/dist/components/PropertyPreviewProps.d.ts +50 -0
  6. package/dist/components/formex.d.ts +40 -0
  7. package/dist/components/index.d.ts +3 -0
  8. package/dist/controllers/analytics_controller.d.ts +7 -0
  9. package/dist/controllers/auth.d.ts +73 -0
  10. package/dist/controllers/customization_controller.d.ts +50 -0
  11. package/dist/controllers/datasource.d.ts +179 -0
  12. package/dist/controllers/dialogs_controller.d.ts +36 -0
  13. package/dist/controllers/index.d.ts +11 -0
  14. package/dist/controllers/local_config_persistence.d.ts +20 -0
  15. package/dist/controllers/navigation.d.ts +262 -0
  16. package/dist/controllers/side_dialogs_controller.d.ts +67 -0
  17. package/dist/controllers/side_entity_controller.d.ts +90 -0
  18. package/dist/controllers/snackbar.d.ts +24 -0
  19. package/dist/controllers/storage.d.ts +173 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.es.js +113 -0
  22. package/dist/index.es.js.map +1 -0
  23. package/dist/index.umd.js +117 -0
  24. package/dist/index.umd.js.map +1 -0
  25. package/dist/rebase_context.d.ts +91 -0
  26. package/dist/types/backend.d.ts +254 -0
  27. package/dist/types/chips.d.ts +5 -0
  28. package/dist/types/collections.d.ts +887 -0
  29. package/dist/types/entities.d.ts +140 -0
  30. package/dist/types/entity_actions.d.ts +98 -0
  31. package/dist/types/entity_callbacks.d.ts +173 -0
  32. package/dist/types/entity_link_builder.d.ts +7 -0
  33. package/dist/types/entity_overrides.d.ts +5 -0
  34. package/dist/types/export_import.d.ts +21 -0
  35. package/dist/types/fields.d.ts +221 -0
  36. package/dist/types/index.d.ts +19 -0
  37. package/dist/types/locales.d.ts +4 -0
  38. package/dist/types/modify_collections.d.ts +5 -0
  39. package/dist/types/plugins.d.ts +276 -0
  40. package/dist/types/properties.d.ts +1103 -0
  41. package/dist/types/property_config.d.ts +68 -0
  42. package/dist/types/rebase.d.ts +180 -0
  43. package/dist/types/relations.d.ts +336 -0
  44. package/dist/types/user_management_delegate.d.ts +78 -0
  45. package/dist/types/websockets.d.ts +33 -0
  46. package/dist/users/index.d.ts +2 -0
  47. package/dist/users/roles.d.ts +22 -0
  48. package/dist/users/user.d.ts +42 -0
  49. package/package.json +137 -0
  50. package/src/components/EntityFormActionsProps.tsx +18 -0
  51. package/src/components/EntityFormProps.tsx +52 -0
  52. package/src/components/PropertyPreviewProps.tsx +61 -0
  53. package/src/components/formex.tsx +46 -0
  54. package/src/components/index.ts +3 -0
  55. package/src/controllers/analytics_controller.tsx +57 -0
  56. package/src/controllers/auth.tsx +94 -0
  57. package/src/controllers/customization_controller.tsx +61 -0
  58. package/src/controllers/datasource.ts +218 -0
  59. package/src/controllers/dialogs_controller.tsx +37 -0
  60. package/src/controllers/index.ts +11 -0
  61. package/src/controllers/local_config_persistence.tsx +22 -0
  62. package/src/controllers/navigation.ts +317 -0
  63. package/src/controllers/side_dialogs_controller.tsx +82 -0
  64. package/src/controllers/side_entity_controller.tsx +104 -0
  65. package/src/controllers/snackbar.ts +29 -0
  66. package/src/controllers/storage.ts +196 -0
  67. package/src/index.ts +5 -0
  68. package/src/rebase_context.tsx +122 -0
  69. package/src/types/backend.ts +385 -0
  70. package/src/types/chips.ts +46 -0
  71. package/src/types/collections.ts +1013 -0
  72. package/src/types/entities.ts +207 -0
  73. package/src/types/entity_actions.tsx +118 -0
  74. package/src/types/entity_callbacks.ts +217 -0
  75. package/src/types/entity_link_builder.ts +8 -0
  76. package/src/types/entity_overrides.tsx +6 -0
  77. package/src/types/export_import.ts +26 -0
  78. package/src/types/fields.tsx +298 -0
  79. package/src/types/index.ts +20 -0
  80. package/src/types/locales.ts +81 -0
  81. package/src/types/modify_collections.tsx +6 -0
  82. package/src/types/plugins.tsx +328 -0
  83. package/src/types/properties.ts +1270 -0
  84. package/src/types/property_config.tsx +93 -0
  85. package/src/types/rebase.tsx +211 -0
  86. package/src/types/relations.ts +351 -0
  87. package/src/types/user_management_delegate.ts +98 -0
  88. package/src/types/websockets.ts +37 -0
  89. package/src/users/index.ts +2 -0
  90. package/src/users/roles.ts +33 -0
  91. package/src/users/user.ts +46 -0
@@ -0,0 +1,328 @@
1
+ import React, { PropsWithChildren } from "react";
2
+
3
+ import { CollectionActionsProps, EntityCollection, EntityTableController } from "./collections";
4
+ import { FieldProps, FormContext } from "./fields";
5
+ import { Property } from "./properties";
6
+ import { EntityStatus } from "./entities";
7
+ import { RebaseContext } from "../rebase_context";
8
+ import { NavigationGroupMapping, CMSView } from "../controllers";
9
+ import { User } from "../users";
10
+ import { UserManagementDelegate } from "./user_management_delegate";
11
+
12
+ /**
13
+ * Interface used to define plugins for Rebase.
14
+ * NOTE: This is a work in progress and the API is not stable yet.
15
+ * @group Core
16
+ */
17
+ export type RebasePlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
18
+
19
+ /**
20
+ * Key of the plugin. This is used to identify the plugin in the CMS.
21
+ */
22
+ key: string;
23
+
24
+ /**
25
+ * If this flag is set to true, no content will be shown in the CMS
26
+ * until the plugin is fully loaded.
27
+ */
28
+ loading?: boolean;
29
+
30
+ /**
31
+ * You can use this prop to add higher order components to the CMS.
32
+ * The components will be added to the root of the CMS, so any component
33
+ * rendered underneath by this plugin will have access to the context
34
+ * provided by this HOC.
35
+ * Anyhow, this is rendered below the {@link RebaseContext} provider, so
36
+ * you can use the hooks provided by the CMS.
37
+ * @param props
38
+ */
39
+ provider?: {
40
+ Component: React.ComponentType<PropsWithChildren<PROPS & {
41
+ context: RebaseContext
42
+ }>>;
43
+ props?: PROPS;
44
+ };
45
+
46
+ userManagement?: UserManagementDelegate;
47
+
48
+ /**
49
+ * Views to be automatically added to the navigation.
50
+ * These views will be merged with the views provided to useBuildNavigationController.
51
+ */
52
+ views?: CMSView[];
53
+
54
+ homePage?: {
55
+
56
+ /**
57
+ * Additional actions to be rendered in the home page, close to the search bar.
58
+ */
59
+ additionalActions?: React.ReactNode;
60
+
61
+ /**
62
+ * Additional children to be rendered in the beginning of the home page.
63
+ */
64
+ additionalChildrenStart?: React.ReactNode;
65
+
66
+ /**
67
+ * Additional children to be rendered at the end of the home page.
68
+ */
69
+ additionalChildrenEnd?: React.ReactNode;
70
+
71
+ /**
72
+ * Use this component to add custom actions to the navigation card
73
+ * in the home page.
74
+ */
75
+ CollectionActions?: React.ComponentType<PluginHomePageActionsProps>;
76
+
77
+ /**
78
+ * Additional props passed to `CollectionActions`
79
+ */
80
+ extraProps?: Record<string, unknown>;
81
+
82
+ /**
83
+ * Add additional cards to each collection group in the home page.
84
+ */
85
+ AdditionalCards?: React.ComponentType<PluginHomePageAdditionalCardsProps> | React.ComponentType<PluginHomePageAdditionalCardsProps>[];
86
+
87
+ /**
88
+ * Include a section in the home page with a custom component and title.
89
+ * @param props
90
+ */
91
+ includeSection?: (props: PluginGenericProps) => {
92
+ title: string;
93
+ children: React.ReactNode;
94
+ }
95
+
96
+ /**
97
+ * Allow reordering with drag and drop of the collections in the home page.
98
+ */
99
+ allowDragAndDrop?: boolean;
100
+
101
+ navigationEntries?: NavigationGroupMapping[];
102
+
103
+ /**
104
+ * This method will be called when the entries are updated in the home page.
105
+ * group => navigationEntriesOrder (path)
106
+ * @param entries
107
+ */
108
+ onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
109
+
110
+ }
111
+
112
+ collectionView?: {
113
+
114
+ /**
115
+ * Custom component to render when a collection loading error occurs.
116
+ * If provided, this replaces the default error view in all collection view modes
117
+ * (table, card, kanban).
118
+ * Return `null` from the component to fall back to the default error view.
119
+ */
120
+ CollectionError?: React.ComponentType<{
121
+ path: string;
122
+ collection: EC;
123
+ parentCollectionIds?: string[];
124
+ error: Error;
125
+ }>;
126
+
127
+ /**
128
+ * Use this component to add custom actions to the entity collections
129
+ * toolbar.
130
+ */
131
+ CollectionActions?: React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<Record<string, unknown>, User, EC> & COL_ACTIONS_PROPS>[];
132
+ collectionActionsProps?: COL_ACTIONS_PROPS;
133
+
134
+ 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>[];
135
+ collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
136
+
137
+ blockSearch?: (props: {
138
+ context: RebaseContext,
139
+ path: string,
140
+ collection: EC,
141
+ parentCollectionIds?: string[]
142
+ }) => boolean;
143
+
144
+ showTextSearchBar?: (props: {
145
+ context: RebaseContext,
146
+ path: string,
147
+ collection: EC,
148
+ parentCollectionIds?: string[]
149
+ }) => boolean;
150
+
151
+ onTextSearchClick?: (props: {
152
+ context: RebaseContext,
153
+ path: string,
154
+ collection: EC,
155
+ parentCollectionIds?: string[]
156
+ }) => Promise<boolean>;
157
+
158
+ /**
159
+ * Use this method to inject widgets to the entity collections header
160
+ * @param props
161
+ */
162
+ HeaderAction?: React.ComponentType<{
163
+ property: Property,
164
+ propertyKey: string,
165
+ path: string,
166
+ parentCollectionIds: string[],
167
+ onHover: boolean,
168
+ collection: EC;
169
+ tableController: EntityTableController;
170
+ }>;
171
+
172
+ /**
173
+ * If you add this callback to your plugin, an add button will be added to the collection table.
174
+ * TODO: Only the first plugin that defines this callback will be used, at the moment.
175
+ */
176
+ AddColumnComponent?: React.ComponentType<{
177
+ path: string,
178
+ parentCollectionIds: string[],
179
+ collection: EC;
180
+ tableController: EntityTableController;
181
+ }>;
182
+
183
+ /**
184
+ * Callback called when columns are reordered via drag and drop.
185
+ * Used by plugins to persist the new column order.
186
+ */
187
+ onColumnsReorder?: (props: {
188
+ fullPath: string;
189
+ parentCollectionIds: string[];
190
+ collection: EC;
191
+ newPropertiesOrder: string[];
192
+ }) => void;
193
+
194
+ /**
195
+ * Callback called when Kanban board columns are reordered via drag and drop.
196
+ * Used by plugins to persist the new Kanban column order.
197
+ */
198
+ onKanbanColumnsReorder?: (props: {
199
+ fullPath: string;
200
+ parentCollectionIds: string[];
201
+ collection: EC;
202
+ kanbanColumnProperty: string;
203
+ newColumnsOrder: string[];
204
+ }) => void;
205
+
206
+ /**
207
+ * Component to render when Kanban view is missing configuration.
208
+ * Used to provide a CTA to open the collection editor to configure Kanban.
209
+ */
210
+ KanbanSetupComponent?: React.ComponentType<{
211
+ collection: EC;
212
+ fullPath: string;
213
+ parentCollectionIds: string[];
214
+ }>;
215
+
216
+ /**
217
+ * Component to render an "Add Column" button at the end of the Kanban board.
218
+ * Used to allow adding new enum values to the column property.
219
+ */
220
+ AddKanbanColumnComponent?: React.ComponentType<{
221
+ collection: EC;
222
+ fullPath: string;
223
+ parentCollectionIds: string[];
224
+ columnProperty: string;
225
+ }>;
226
+ }
227
+
228
+ form?: {
229
+ provider?: {
230
+ Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<User, EC>>>;
231
+ props?: FORM_PROPS;
232
+ }
233
+
234
+ /**
235
+ * Add custom actions to the default ones ("Save", "Discard"...)
236
+ */
237
+ Actions?: React.ComponentType<PluginFormActionProps<User, EC>>;
238
+
239
+ /**
240
+ * Add custom actions to the top of the form
241
+ */
242
+ ActionsTop?: React.ComponentType<PluginFormActionProps<User, EC>>;
243
+
244
+ /**
245
+ * Add custom content above the entity title in the form view
246
+ */
247
+ BeforeTitle?: React.ComponentType<PluginFormActionProps<User, EC>>;
248
+
249
+ fieldBuilder?: <T>(props: PluginFieldBuilderParams<Record<string, unknown>, EC>) => React.ComponentType<FieldProps<any>> | null;
250
+
251
+ fieldBuilderEnabled?: <T>(props: PluginFieldBuilderParams) => boolean;
252
+ }
253
+
254
+ collection?: {
255
+
256
+ /**
257
+ * Use this method to modify a single collection before it is rendered.
258
+ * @param collection
259
+ */
260
+ modifyCollection?: (collection: EntityCollection) => EntityCollection;
261
+
262
+ /**
263
+ * Use this method to modify, add or remove collections.
264
+ * @param collections
265
+ */
266
+ injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
267
+
268
+ }
269
+
270
+ }
271
+
272
+ /**
273
+ * Props passed to the {@link RebasePlugin.homePage.CollectionActions} method.
274
+ * You can use it to add custom actions to the navigation card of each collection.
275
+ *
276
+ * @group Models
277
+ */
278
+ export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
279
+ /**
280
+ * Collection path of this entity. This is the full path, like
281
+ * `users/1234/addresses`
282
+ */
283
+ slug: string;
284
+
285
+ /**
286
+ * The collection configuration
287
+ */
288
+ collection: EC;
289
+
290
+ /**
291
+ * Context of the app status
292
+ */
293
+ context: RebaseContext<USER>;
294
+
295
+ extraProps?: EP;
296
+
297
+ }
298
+
299
+ export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
300
+ entityId?: string | number;
301
+ path: string;
302
+ parentCollectionIds: string[];
303
+ status: EntityStatus;
304
+ collection: EC;
305
+ disabled: boolean;
306
+ formContext?: FormContext;
307
+ context: RebaseContext<USER>;
308
+ openEntityMode: "side_panel" | "full_screen";
309
+ }
310
+
311
+ export type PluginFieldBuilderParams<M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
312
+ fieldConfigId: string;
313
+ propertyKey: string;
314
+ property: Property;
315
+ Field: React.ComponentType<FieldProps<Property, unknown, M>>;
316
+ plugin: RebasePlugin;
317
+ path?: string;
318
+ collection?: EC;
319
+ };
320
+
321
+ export interface PluginGenericProps<USER extends User = User> {
322
+ context: RebaseContext<USER>;
323
+ }
324
+
325
+ export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
326
+ group?: string;
327
+ context: RebaseContext<USER>;
328
+ }