@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.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/dist/controllers/analytics_controller.d.ts +2 -2
  3. package/dist/controllers/auth.d.ts +52 -6
  4. package/dist/controllers/client.d.ts +170 -0
  5. package/dist/controllers/collection_registry.d.ts +45 -0
  6. package/dist/controllers/customization_controller.d.ts +11 -1
  7. package/dist/controllers/data.d.ts +168 -0
  8. package/dist/controllers/data_driver.d.ts +160 -0
  9. package/dist/controllers/database_admin.d.ts +11 -0
  10. package/dist/controllers/effective_role.d.ts +4 -0
  11. package/dist/controllers/email.d.ts +34 -0
  12. package/dist/controllers/index.d.ts +12 -5
  13. package/dist/controllers/local_config_persistence.d.ts +4 -4
  14. package/dist/controllers/navigation.d.ts +12 -61
  15. package/dist/controllers/registry.d.ts +54 -0
  16. package/dist/controllers/side_entity_controller.d.ts +7 -7
  17. package/dist/controllers/storage.d.ts +24 -26
  18. package/dist/index.d.ts +0 -1
  19. package/dist/index.es.js +119 -14
  20. package/dist/index.es.js.map +1 -1
  21. package/dist/index.umd.js +118 -13
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/rebase_context.d.ts +40 -26
  24. package/dist/types/backend.d.ts +300 -18
  25. package/dist/types/builders.d.ts +15 -0
  26. package/dist/types/chips.d.ts +1 -1
  27. package/dist/types/collections.d.ts +324 -355
  28. package/dist/types/cron.d.ts +102 -0
  29. package/dist/types/data_source.d.ts +64 -0
  30. package/dist/types/entities.d.ts +29 -24
  31. package/dist/types/entity_actions.d.ts +12 -12
  32. package/dist/types/entity_callbacks.d.ts +12 -12
  33. package/dist/types/entity_link_builder.d.ts +1 -1
  34. package/dist/types/entity_overrides.d.ts +7 -2
  35. package/dist/types/entity_views.d.ts +61 -0
  36. package/dist/types/export_import.d.ts +3 -3
  37. package/dist/types/index.d.ts +9 -5
  38. package/dist/types/plugins.d.ts +228 -225
  39. package/dist/types/properties.d.ts +135 -62
  40. package/dist/types/property_config.d.ts +13 -11
  41. package/dist/types/relations.d.ts +1 -1
  42. package/dist/types/slots.d.ts +252 -0
  43. package/dist/types/translations.d.ts +870 -0
  44. package/dist/types/user_management_delegate.d.ts +43 -0
  45. package/dist/types/websockets.d.ts +45 -0
  46. package/dist/users/user.d.ts +4 -0
  47. package/package.json +99 -131
  48. package/src/controllers/analytics_controller.tsx +2 -2
  49. package/src/controllers/auth.tsx +55 -6
  50. package/src/controllers/client.ts +133 -0
  51. package/src/controllers/collection_registry.ts +57 -0
  52. package/src/controllers/customization_controller.tsx +12 -1
  53. package/src/controllers/data.ts +191 -0
  54. package/src/controllers/{datasource.ts → data_driver.ts} +50 -61
  55. package/src/controllers/database_admin.ts +22 -0
  56. package/src/controllers/effective_role.ts +4 -0
  57. package/src/controllers/email.ts +36 -0
  58. package/src/controllers/index.ts +15 -5
  59. package/src/controllers/local_config_persistence.tsx +4 -4
  60. package/src/controllers/navigation.ts +13 -76
  61. package/src/controllers/registry.ts +65 -0
  62. package/src/controllers/side_entity_controller.tsx +7 -7
  63. package/src/controllers/storage.ts +25 -28
  64. package/src/index.ts +0 -1
  65. package/src/rebase_context.tsx +41 -39
  66. package/src/types/backend.ts +359 -24
  67. package/src/types/builders.ts +17 -0
  68. package/src/types/chips.ts +15 -40
  69. package/src/types/collections.ts +375 -383
  70. package/src/types/cron.ts +149 -0
  71. package/src/types/data_source.ts +145 -0
  72. package/src/types/entities.ts +40 -33
  73. package/src/types/entity_actions.tsx +11 -11
  74. package/src/types/entity_callbacks.ts +12 -12
  75. package/src/types/entity_link_builder.ts +1 -1
  76. package/src/types/entity_overrides.tsx +7 -2
  77. package/src/types/entity_views.tsx +77 -0
  78. package/src/types/export_import.ts +3 -3
  79. package/src/types/index.ts +10 -5
  80. package/src/types/plugins.tsx +280 -261
  81. package/src/types/properties.ts +163 -61
  82. package/src/types/property_config.tsx +11 -11
  83. package/src/types/relations.ts +1 -1
  84. package/src/types/slots.tsx +297 -0
  85. package/src/types/translations.ts +977 -0
  86. package/src/types/user_management_delegate.ts +50 -7
  87. package/src/types/websockets.ts +48 -0
  88. package/src/users/roles.ts +0 -1
  89. package/src/users/user.ts +5 -0
  90. package/dist/components/EntityFormActionsProps.d.ts +0 -17
  91. package/dist/components/EntityFormProps.d.ts +0 -46
  92. package/dist/components/PropertyPreviewProps.d.ts +0 -50
  93. package/dist/components/formex.d.ts +0 -40
  94. package/dist/components/index.d.ts +0 -3
  95. package/dist/controllers/datasource.d.ts +0 -179
  96. package/dist/types/fields.d.ts +0 -221
  97. package/dist/types/rebase.d.ts +0 -180
  98. package/src/components/EntityFormActionsProps.tsx +0 -18
  99. package/src/components/EntityFormProps.tsx +0 -52
  100. package/src/components/PropertyPreviewProps.tsx +0 -61
  101. package/src/components/formex.tsx +0 -46
  102. package/src/components/index.ts +0 -3
  103. package/src/types/fields.tsx +0 -298
  104. package/src/types/rebase.tsx +0 -211
@@ -1,298 +0,0 @@
1
- import { InferPropertyType, Property } from "./properties";
2
- import { Entity } from "./entities";
3
- import { FormexController } from "../components/formex";
4
- import { EntityCollection } from "./collections";
5
-
6
- export type DefaultFieldConfig =
7
- | "text_field"
8
- | "multiline"
9
- | "markdown"
10
- | "url"
11
- | "email"
12
- | "switch"
13
- | "select"
14
- | "multi_select"
15
- | "user_select"
16
- | "number_input"
17
- | "number_select"
18
- | "multi_number_select"
19
- | "file_upload"
20
- | "multi_file_upload"
21
- | "reference_as_string"
22
- | "reference"
23
- | "multi_references"
24
- | "relation"
25
- | "date_time"
26
- | "group"
27
- | "key_value"
28
- | "repeat"
29
- | "custom_array"
30
- | "block";
31
-
32
- /**
33
- * When building a custom field you need to create a React component that takes
34
- * this interface as props.
35
- *
36
- * @group Form custom fields
37
- */
38
- export interface FieldProps<
39
- P extends Property = Property,
40
- CustomProps = any,
41
- M extends Record<string, any> = any> {
42
-
43
- /**
44
- * Key of the property
45
- * E.g. "user.name" for a property with path "user.name"
46
- */
47
- propertyKey: string;
48
-
49
- /**
50
- * Current value of this field, inferred from the property type P
51
- */
52
- value: InferPropertyType<P>;
53
-
54
- /**
55
- * Set value of field directly
56
- */
57
- setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
58
-
59
- /**
60
- * Set value of a different field directly
61
- * @param propertyKey
62
- * @param value
63
- * @param shouldValidate
64
- */
65
- setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
66
-
67
- /**
68
- * Is the form currently submitting
69
- */
70
- isSubmitting?: boolean;
71
-
72
- /**
73
- * Should this field show the error indicator.
74
- * Note that there might be an error (like an empty field that should be
75
- * filled) but we don't want to show the error until the user has tried
76
- * saving.
77
- */
78
- showError?: boolean;
79
-
80
- /**
81
- * Is there an error in this field. The error field has the same shape as
82
- * the field, replacing values with a string containing the error.
83
- * It takes the value `null` if there is no error
84
- */
85
- error?: string;
86
-
87
- /**
88
- * Has this field been touched
89
- */
90
- touched?: boolean;
91
-
92
- /**
93
- * Property related to this field, now strongly typed to P
94
- */
95
- property: P;
96
-
97
- /**
98
- * Should this field include a description
99
- */
100
- includeDescription?: boolean;
101
-
102
- /**
103
- * Flag to indicate that the underlying value has been updated in the
104
- * datasource
105
- */
106
- underlyingValueHasChanged?: boolean;
107
-
108
- /**
109
- * Is this field part of an array
110
- */
111
- partOfArray?: boolean;
112
-
113
- /**
114
- * Is this field part of a block
115
- */
116
- partOfBlock?: boolean;
117
-
118
- /**
119
- * Display the child properties directly, without being wrapped in an
120
- * extendable panel. Note that this will also hide the title of this property.
121
- */
122
- minimalistView?: boolean;
123
-
124
- /**
125
- * Should this field autofocus on mount
126
- */
127
- autoFocus?: boolean;
128
-
129
- /**
130
- * Additional properties set by the developer
131
- */
132
- customProps: CustomProps
133
-
134
- /**
135
- * Additional values related to the state of the form or the entity
136
- */
137
- context: FormContext<M>;
138
-
139
- /**
140
- * Flag to indicate if this field should be disabled
141
- */
142
- disabled?: boolean;
143
-
144
- /**
145
- * Size of the field
146
- */
147
- size?: "small" | "medium" | "large";
148
-
149
- /**
150
- * Some properties might change internal state (like expanding a panel).
151
- * This function should be called when the internal state changes.
152
- * This is used to preserve state in array containers.
153
- *
154
- * @param property
155
- */
156
- onPropertyChange?: (property: Partial<Property>) => void;
157
-
158
- }
159
-
160
- /**
161
- * Context passed to custom fields
162
- * @group Form custom fields
163
- */
164
- export interface FormContext<M extends Record<string, any> = any> {
165
-
166
- /**
167
- * Current values of the entity
168
- */
169
- values: M;
170
-
171
- /**
172
- * Update the value of a field
173
- * @param key
174
- * @param value
175
- * @param shouldValidate
176
- */
177
- setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
178
-
179
- /**
180
- * Save the entity.
181
- */
182
- save: (values: M) => void;
183
-
184
- /**
185
- * Collection of the entity being modified
186
- */
187
- collection?: EntityCollection<M>;
188
-
189
- /**
190
- * Entity id, it can be undefined if it's a new entity
191
- */
192
- entityId?: string | number;
193
-
194
- /**
195
- * Path this entity is located at
196
- */
197
- path?: string;
198
-
199
- status: "new" | "existing" | "copy";
200
-
201
- entity?: Entity<M>;
202
-
203
- savingError?: Error;
204
-
205
- openEntityMode: "side_panel" | "full_screen";
206
-
207
- /**
208
- * This is the underlying formex controller that powers the form.
209
- * If you are in a red only mode, the formex controller is there, but you can't
210
- * operate with it
211
- */
212
- formex: FormexController<M>;
213
-
214
- disabled: boolean;
215
- }
216
-
217
- /**
218
- * In case you need to render a field bound to a Property inside your
219
- * custom field you can use {@link PropertyFieldBinding} with these props.
220
- * @group Form custom fields
221
- */
222
- export interface PropertyFieldBindingProps<M extends Record<string, any> = any> {
223
-
224
- /**
225
- * The key/path of the property, such as `age`. You can use nested and array
226
- * indexed such as `address.street` or `people[3]`
227
- */
228
- propertyKey: string;
229
-
230
- /**
231
- * The CMS property you are binding this field to
232
- */
233
- property: Property;
234
-
235
- /**
236
- * The context where this field is being rendered. You get a context as a
237
- * prop when creating a custom field.
238
- */
239
- context: FormContext<M>;
240
-
241
- /**
242
- * Should the description be included in this field
243
- */
244
- includeDescription?: boolean;
245
-
246
- /**
247
- * Has the value of this property been updated in the database while this
248
- * field is being edited
249
- */
250
- underlyingValueHasChanged?: boolean;
251
-
252
- /**
253
- * Is this field part of an array
254
- */
255
- partOfArray?: boolean;
256
-
257
- /**
258
- * Is this field part of a block
259
- */
260
- partOfBlock?: boolean;
261
-
262
- /**
263
- * Display the child properties directly, without being wrapped in an
264
- * extendable panel. Note that this will also hide the title of this property.
265
- */
266
- minimalistView?: boolean;
267
-
268
- /**
269
- * Should the field take focus when rendered. When opening the popup view
270
- * in table mode, it makes sense to put the focus on the only field rendered.
271
- */
272
- autoFocus?: boolean;
273
-
274
- /**
275
- * Should this field be disabled
276
- */
277
- disabled?: boolean;
278
-
279
- /**
280
- * Index of the field in the array.
281
- * Only used when the field is part of an array.
282
- */
283
- index?: number;
284
-
285
- /**
286
- * The size of the field
287
- */
288
- size?: "small" | "medium" | "large",
289
-
290
- /**
291
- * Some properties might change internal state (like expanding a panel).
292
- * This function should be called when the internal state changes.
293
- * This is used to preserve state in array containers.
294
- *
295
- * @param property
296
- */
297
- onPropertyChange?: (property: Partial<Property>) => void;
298
- }
@@ -1,211 +0,0 @@
1
- import React from "react";
2
- import { EntityCollection, EntityCustomView } from "./collections";
3
- import { PropertyConfig } from "./property_config";
4
- import { Locale } from "./locales";
5
- import { EntityLinkBuilder } from "./entity_link_builder";
6
- import { RebasePlugin } from "./plugins";
7
- import { EntityAction } from "./entity_actions";
8
- import { User } from "../users";
9
- import {
10
- AuthController, CMSAnalyticsEvent, CMSView, DataSource, StorageSource,
11
- UserConfigurationPersistence, CollectionRegistryController, CMSUrlController, NavigationStateController
12
- } from "../controllers";
13
- import { RebaseContext } from "../rebase_context";
14
- import { UserManagementDelegate } from "./user_management_delegate";
15
-
16
- /**
17
- * Controller to simulate different roles when dev mode is active.
18
- * @group Models
19
- */
20
- export interface EffectiveRoleController {
21
- effectiveRole: string | null;
22
- setEffectiveRole: (role: string | null) => void;
23
- }
24
-
25
- /**
26
- * Use this callback to build entity collections dynamically.
27
- * You can use the user to decide which collections to show.
28
- * You can also use the data source to fetch additional data to build the
29
- * collections.
30
- * Note: you can use any type of synchronous or asynchronous code here,
31
- * including fetching data from external sources, like using the Firestore
32
- * APIs directly, or a REST API.
33
- * @group Models
34
- */
35
- export type EntityCollectionsBuilder<EC extends EntityCollection = EntityCollection> = (params: {
36
- user: User | null,
37
- authController: AuthController,
38
- dataSource: DataSource
39
- }) => EC[] | Promise<EC[]>;
40
-
41
- /**
42
- * Use this callback to build custom views dynamically.
43
- * You can use the user to decide which views to show.
44
- * You can also use the data source to fetch additional data to build the
45
- * views. Note: you can use any type of synchronous or asynchronous code here,
46
- * including fetching data from external sources, like using the Firestore
47
- * APIs directly, or a REST API.
48
- * @group Models
49
- */
50
- export type CMSViewsBuilder = (params: {
51
- user: User | null,
52
- authController: AuthController,
53
- dataSource: DataSource
54
- }) => CMSView[] | Promise<CMSView[]>;
55
-
56
- /**
57
- * @group Models
58
- */
59
- export type RebaseProps<USER extends User> = {
60
-
61
- /**
62
- * Use this function to return the components you want to render under
63
- * Rebase
64
- * @param props
65
- */
66
- children: (props: {
67
- /**
68
- * Context of the app
69
- */
70
- context: RebaseContext;
71
- /**
72
- * Is one of the main processes, auth and navigation resolving, currently
73
- * loading. If you are building your custom implementation, you probably
74
- * want to show a loading indicator if this flag is `true`
75
- */
76
- loading: boolean;
77
- }) => React.ReactNode;
78
-
79
- /**
80
- * If you have a custom API key, you can use it here.
81
- */
82
- apiKey?: string;
83
-
84
- /**
85
- * Base URL for the backend API (e.g. "http://localhost:3001").
86
- * When provided, this is available via `useApiConfig()` to any hook
87
- * in the tree, reducing repetitive `apiUrl` threading.
88
- */
89
- apiUrl?: string;
90
-
91
- /**
92
- * Record of custom form fields to be used in the CMS.
93
- * You can use the key to reference the custom field in
94
- * the `propertyConfig` prop of a property in a collection.
95
- */
96
- propertyConfigs?: Record<string, PropertyConfig>;
97
-
98
- /**
99
- * This controller is in charge of resolving the collection and entity paths.
100
- */
101
- collectionRegistryController: CollectionRegistryController;
102
-
103
- /**
104
- * This controller is in charge of resolving the URL configurations map and building paths
105
- */
106
- cmsUrlController: CMSUrlController;
107
-
108
- /**
109
- * This controller is in charge of resolving the navigation views and state
110
- */
111
- navigationStateController: NavigationStateController;
112
-
113
- /**
114
- * List of additional custom views for entities.
115
- * You can use the key to reference the custom view in
116
- * the `entityViews` prop of a collection.
117
- *
118
- * You can also define an entity view from the UI.
119
- */
120
- entityViews?: EntityCustomView[];
121
-
122
- /**
123
- * List of actions that can be performed on entities.
124
- * These actions are displayed in the entity view and in the collection view.
125
- * You can later reuse these actions in the `entityActions` prop of a collection,
126
- * by specifying the `key` of the action.
127
- */
128
- entityActions?: EntityAction[];
129
-
130
- /**
131
- * Format of the dates in the CMS.
132
- * Defaults to 'MMMM dd, yyyy, HH:mm:ss'
133
- */
134
- dateTimeFormat?: string;
135
-
136
- /**
137
- * Locale of the CMS, currently only affecting dates
138
- */
139
- locale?: Locale;
140
-
141
- /**
142
- * Connector to your database
143
- */
144
- dataSource: DataSource;
145
-
146
- /**
147
- * Connector to your file upload/fetch implementation
148
- */
149
- storageSource: StorageSource;
150
-
151
- /**
152
- * Delegate for implementing your auth operations.
153
- */
154
- authController: AuthController<USER>;
155
-
156
- /**
157
- * Use this controller to access the configuration that is stored locally,
158
- * and not defined in code
159
- */
160
- userConfigPersistence?: UserConfigurationPersistence;
161
-
162
- /**
163
- * Use plugins to modify the behaviour of the CMS.
164
- * DEPRECATED: use the `plugins` prop in the `useBuildNavigationController` instead.
165
- * This prop will work as a fallback for the `plugins` prop in the `useBuildNavigationController`.
166
- * @deprecated
167
- */
168
- plugins?: RebasePlugin<any, any, any>[];
169
-
170
- /**
171
- * Callback used to get analytics events from the CMS
172
- */
173
- onAnalyticsEvent?: (event: CMSAnalyticsEvent, data?: object) => void;
174
-
175
- /**
176
- * Optional link builder you can add to generate a button in your entity forms.
177
- * The function must return a URL that gets opened when the button is clicked
178
- */
179
- entityLinkBuilder?: EntityLinkBuilder;
180
-
181
- /**
182
- * You can use this props to provide your own user management implementation.
183
- * Note that this will not affect the UI, but it will be used to show user information
184
- * in various places of the CMS, for example, to show who created or modified an entity,
185
- * or to assign ownership of an entity.
186
- *
187
- * You can also use this data to be retrieved in your custom properties,
188
- * for example, to show a list of users in a dropdown.
189
- *
190
- * If you are using the Rebase user management plugin, this
191
- * prop will be implemented automatically.
192
- */
193
- userManagement?: UserManagementDelegate;
194
-
195
- components?: {
196
-
197
- /**
198
- * Component to render when a reference is missing
199
- */
200
- missingReference?: React.ComponentType<{
201
- path: string,
202
- }>;
203
-
204
- };
205
-
206
- /**
207
- * Controller to simulate different roles when dev mode is active.
208
- */
209
- effectiveRoleController?: EffectiveRoleController;
210
-
211
- };