@rebasepro/cms-types 0.17.0-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 (78) hide show
  1. package/LICENSE +21 -0
  2. package/dist/admin_collection.d.ts +650 -0
  3. package/dist/augment.d.ts +81 -0
  4. package/dist/collections.d.ts +282 -0
  5. package/dist/controllers/analytics_controller.d.ts +7 -0
  6. package/dist/controllers/auth.d.ts +111 -0
  7. package/dist/controllers/customization_controller.d.ts +69 -0
  8. package/dist/controllers/dialogs_controller.d.ts +36 -0
  9. package/dist/controllers/index.d.ts +10 -0
  10. package/dist/controllers/local_config_persistence.d.ts +20 -0
  11. package/dist/controllers/navigation.d.ts +248 -0
  12. package/dist/controllers/registry.d.ts +96 -0
  13. package/dist/controllers/side_dialogs_controller.d.ts +67 -0
  14. package/dist/controllers/side_panel_controller.d.ts +97 -0
  15. package/dist/controllers/snackbar.d.ts +45 -0
  16. package/dist/index.d.ts +18 -0
  17. package/dist/index.es.js +154 -0
  18. package/dist/index.es.js.map +1 -0
  19. package/dist/react_component_ref.d.ts +43 -0
  20. package/dist/rebase_context.d.ts +68 -0
  21. package/dist/types/breadcrumbs.d.ts +15 -0
  22. package/dist/types/builders.d.ts +15 -0
  23. package/dist/types/collection_views.d.ts +105 -0
  24. package/dist/types/component_overrides.d.ts +196 -0
  25. package/dist/types/entity_actions.d.ts +112 -0
  26. package/dist/types/entity_display.d.ts +148 -0
  27. package/dist/types/entity_link_builder.d.ts +7 -0
  28. package/dist/types/entity_views.d.ts +115 -0
  29. package/dist/types/export_import.d.ts +21 -0
  30. package/dist/types/form_layout.d.ts +126 -0
  31. package/dist/types/formex.d.ts +40 -0
  32. package/dist/types/index.d.ts +18 -0
  33. package/dist/types/locales.d.ts +4 -0
  34. package/dist/types/modify_collections.d.ts +5 -0
  35. package/dist/types/plugins.d.ts +277 -0
  36. package/dist/types/property_config.d.ts +74 -0
  37. package/dist/types/property_options.d.ts +255 -0
  38. package/dist/types/slots.d.ts +279 -0
  39. package/dist/types/translations.d.ts +989 -0
  40. package/dist/types/user_management_delegate.d.ts +22 -0
  41. package/package.json +103 -0
  42. package/src/admin_collection.ts +775 -0
  43. package/src/augment.ts +79 -0
  44. package/src/collections.ts +312 -0
  45. package/src/controllers/analytics_controller.tsx +57 -0
  46. package/src/controllers/auth.ts +122 -0
  47. package/src/controllers/customization_controller.tsx +81 -0
  48. package/src/controllers/dialogs_controller.tsx +37 -0
  49. package/src/controllers/index.ts +10 -0
  50. package/src/controllers/local_config_persistence.tsx +22 -0
  51. package/src/controllers/navigation.ts +288 -0
  52. package/src/controllers/registry.ts +114 -0
  53. package/src/controllers/side_dialogs_controller.tsx +82 -0
  54. package/src/controllers/side_panel_controller.tsx +112 -0
  55. package/src/controllers/snackbar.ts +51 -0
  56. package/src/index.ts +20 -0
  57. package/src/react_component_ref.ts +52 -0
  58. package/src/rebase_context.ts +81 -0
  59. package/src/types/breadcrumbs.ts +16 -0
  60. package/src/types/builders.ts +18 -0
  61. package/src/types/collection_views.tsx +125 -0
  62. package/src/types/component_overrides.ts +244 -0
  63. package/src/types/entity_actions.tsx +134 -0
  64. package/src/types/entity_display.ts +182 -0
  65. package/src/types/entity_link_builder.ts +8 -0
  66. package/src/types/entity_views.tsx +135 -0
  67. package/src/types/export_import.ts +26 -0
  68. package/src/types/form_layout.ts +137 -0
  69. package/src/types/formex.ts +45 -0
  70. package/src/types/index.ts +18 -0
  71. package/src/types/locales.ts +81 -0
  72. package/src/types/modify_collections.tsx +6 -0
  73. package/src/types/plugins.tsx +346 -0
  74. package/src/types/property_config.tsx +97 -0
  75. package/src/types/property_options.ts +300 -0
  76. package/src/types/slots.tsx +334 -0
  77. package/src/types/translations.ts +1104 -0
  78. package/src/types/user_management_delegate.ts +23 -0
package/src/augment.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The admin block, added back onto the core types by declaration merging.
3
+ *
4
+ * `@rebasepro/types` declares no `admin` field — not on `BaseCollectionConfig`, not on
5
+ * any property. A BaaS install therefore cannot write one: `admin: { … }` on a property
6
+ * there is a type error, which is the whole point. Installing this package is what makes
7
+ * the surface exist.
8
+ *
9
+ * This works because every target is an `interface`. Interfaces merge; `type` aliases do
10
+ * not, so `BaseProperty` and the ten concrete property types must stay interfaces in core
11
+ * for this file to be possible at all.
12
+ *
13
+ * Two consequences worth knowing:
14
+ *
15
+ * - The augmentation applies to the whole **program**, not to the files that import it.
16
+ * `config/` and `frontend/` are separate tsconfig programs, so a collection file needs
17
+ * this package in *its* program. The templates do that with one line in one file —
18
+ * `config/cms.d.ts`, holding `/// <reference types="@rebasepro/cms-types" />` —
19
+ * which is why no collection file has to import anything from here to write `admin`.
20
+ * That reference resolves through `typeRoots`, so the project must also depend on this
21
+ * package; `tooling/scripts/check-templates.mjs` asserts both halves.
22
+ * - Each concrete property narrows the block to its own options type
23
+ * (`AdminStringOptions` on `StringProperty`, and so on). That is legal because each
24
+ * extends `AdminPropertyOptions`, exactly as it was declared when these lived in core.
25
+ */
26
+ import type {
27
+ AdminArrayOptions,
28
+ AdminDateOptions,
29
+ AdminMapOptions,
30
+ AdminNumberOptions,
31
+ AdminPropertyOptions,
32
+ AdminReferenceOptions,
33
+ AdminRelationOptions,
34
+ AdminStringOptions,
35
+ AdminVectorOptions
36
+ } from "./types/property_options";
37
+ import type { AdminCollectionOptions } from "./admin_collection";
38
+ // Named in the merged declaration's parameter list, which must match core's.
39
+ import type { User } from "@rebasepro/types";
40
+
41
+ declare module "@rebasepro/types" {
42
+
43
+ /**
44
+ * Presentation and behaviour for a collection in the admin panel.
45
+ *
46
+ * The type parameters are repeated here verbatim because declaration
47
+ * merging requires an identical parameter list — and they have to be
48
+ * *forwarded* to `AdminCollectionOptions`, which is the part that was
49
+ * missing. Written as a bare `admin?: AdminCollectionOptions`, `M` fell
50
+ * back to its default `Record<string, unknown>`, so `Extract<keyof M,
51
+ * string>` widened to `string` and every key-shaped field in the block —
52
+ * `display`, `sort`, `propertiesOrder`, `listProperties` — silently
53
+ * accepted any string. The completion `defineCollection` advertises is
54
+ * derived from `M`, so it never appeared: the inference was computed,
55
+ * carried to this seam, and dropped one line short of the field that
56
+ * needed it.
57
+ */
58
+ interface BaseCollectionConfig<
59
+ M extends Record<string, unknown> = Record<string, unknown>,
60
+ USER extends User = User
61
+ > {
62
+ admin?: AdminCollectionOptions<M, USER>;
63
+ }
64
+
65
+ interface BaseProperty<CustomProps = unknown> {
66
+ admin?: AdminPropertyOptions<CustomProps>;
67
+ }
68
+
69
+ interface StringProperty { admin?: AdminStringOptions; }
70
+ interface NumberProperty { admin?: AdminNumberOptions; }
71
+ interface BooleanProperty { admin?: AdminPropertyOptions; }
72
+ interface VectorProperty { admin?: AdminVectorOptions; }
73
+ interface DateProperty { admin?: AdminDateOptions; }
74
+ interface GeopointProperty { admin?: AdminPropertyOptions; }
75
+ interface ReferenceProperty { admin?: AdminReferenceOptions; }
76
+ interface RelationProperty { admin?: AdminRelationOptions; }
77
+ interface ArrayProperty { admin?: AdminArrayOptions; }
78
+ interface MapProperty { admin?: AdminMapOptions; }
79
+ }
@@ -0,0 +1,312 @@
1
+ /**
2
+ * Admin-panel view models for a collection.
3
+ *
4
+ * These twelve types came out of `collections.ts`, where they sat interleaved
5
+ * with the collection shape itself. None of them describes data: they are the
6
+ * table's controllers, the selection state, the kanban layout, the shape of a
7
+ * toolbar action's props. Every one names `React` or `RebaseContext`, and none is
8
+ * imported by a single backend package — checked across `server`,
9
+ * `server-postgres`, `server-mongo`, `client`, `common`, `utils`, `cli` and
10
+ * `codegen`.
11
+ *
12
+ * That is what made them safe to lift: they were never part of the BaaS surface,
13
+ * only stored next to it.
14
+ */
15
+ import React, { Dispatch, SetStateAction } from "react";
16
+ import type { Entity, EntityStatus, FilterValues, OrderByTuple, Property, User } from "@rebasepro/types";
17
+
18
+ import type { RebaseContext } from "./rebase_context";
19
+ import type { AdminCollection, PropertyPath } from "@rebasepro/cms-types";
20
+
21
+ /**
22
+ * Configuration for Kanban board view mode.
23
+ * @group Collections
24
+ */
25
+ export interface KanbanConfig<M extends Record<string, unknown> = Record<string, unknown>> {
26
+ /**
27
+ * Property key to use for Kanban board columns.
28
+ * Must reference a string property with `enum` values defined.
29
+ * Entities will be grouped into columns based on this property's value.
30
+ * The column order is determined by the order of `enum` values in the property.
31
+ *
32
+ * Left permissive on purpose, unlike the *optional* key fields on the admin
33
+ * block (`display`, `sort`, `propertiesOrder`, …), which are checked
34
+ * against `M`.
35
+ *
36
+ * This one is **required**, and that is the whole difference: a required
37
+ * generic-dependent property puts `Extract<keyof M, string>` in an invariant
38
+ * position, so `AdminCollection<M>` stops being assignable to
39
+ * `AdminCollection`. The admin package passes collections between those two
40
+ * forms in roughly fifteen places — `CollectionBoardViewBinding`, the
41
+ * collection editor, the view bindings — and every one of them breaks.
42
+ * Tightening this is a worthwhile change, but it is a refactor of those call
43
+ * sites rather than a type edit. Verified by trying it: `columnProperty:
44
+ * Extract<keyof M, string>` alone produced ~15 errors, and doing it alongside
45
+ * `entityViews`/`formView`/`Actions` produced 95.
46
+ */
47
+ columnProperty: Extract<keyof M, string> | (string & {});
48
+ }
49
+
50
+ /**
51
+ * View mode for displaying a collection.
52
+ * - "list": Simple, clean list view — the classic admin default
53
+ * - "table": Table with inline editing
54
+ * - "cards": Grid of visual cards with thumbnails
55
+ * - "kanban": Board view grouped by a property
56
+ *
57
+ * Any other string is the `key` of a custom view declared in
58
+ * `admin.customViews` or registered on `<RebaseCMS collectionViews={…}>`.
59
+ * The `(string & {})` arm is what keeps the four built-ins in autocomplete
60
+ * while still admitting those keys.
61
+ *
62
+ * @group Collections
63
+ */
64
+ export type ViewMode = "list" | "table" | "cards" | "kanban" | (string & {});
65
+
66
+ /**
67
+ * Parameter passed to the `Actions` prop in the collection configuration.
68
+ * The component will receive this prop when it is rendered in the collection
69
+ * toolbar.
70
+ *
71
+ * @group Models
72
+ */
73
+ export interface CollectionActionsProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends AdminCollection<M> = AdminCollection<M>> {
74
+ /**
75
+ * Full collection path of this entity. This is the full path, like
76
+ * `users/1234/addresses`
77
+ */
78
+ path: string;
79
+
80
+ /**
81
+ * Path of the last collection, like `addresses`
82
+ */
83
+ relativePath: string;
84
+
85
+ /**
86
+ * Array of the parent path segments like `['users']`
87
+ */
88
+ parentCollectionSlugs: string[];
89
+ parentEntityIds: string[];
90
+
91
+ /**
92
+ * The collection configuration
93
+ */
94
+ collection: EC;
95
+
96
+ /**
97
+ * Use this controller to get the selected entities and to update the
98
+ * selected entities state.
99
+ */
100
+ selectionController: SelectionController<M>;
101
+
102
+ /**
103
+ * Use this controller to get the table controller and to update the
104
+ * table controller state.
105
+ */
106
+ tableController: EntityTableController<M>;
107
+
108
+ /**
109
+ * Context of the app status
110
+ */
111
+ context: RebaseContext<USER>;
112
+
113
+ /**
114
+ * Count of the entities in this collection.
115
+ * undefined means the count is still loading.
116
+ */
117
+ collectionEntitiesCount?: number;
118
+
119
+ /**
120
+ * Programmatically open the new-document form for this collection,
121
+ * optionally pre-populating it with initial field values.
122
+ * The form opens in the same mode configured for the collection
123
+ * (side panel, full screen, or split).
124
+ *
125
+ * This is the primary hook for workflows that need to create a document
126
+ * from external data — e.g. fetching content from a URL, importing from
127
+ * a third-party API, or duplicating from another system.
128
+ *
129
+ * @example
130
+ * // Inside a custom CollectionAction component:
131
+ * openNewDocument({ title: "Fetched title", body: "..." });
132
+ */
133
+ openNewDocument: (defaultValues?: Record<string, unknown>) => void;
134
+
135
+ }
136
+
137
+ /**
138
+ * Use this controller to retrieve the selected entities or modify them in
139
+ * an {@link AdminCollection}
140
+ * @group Models
141
+ */
142
+ export interface SelectionController<M extends Record<string, unknown> = Record<string, unknown>> {
143
+ selectedEntities: Entity<M>[];
144
+ setSelectedEntities(entities: Entity<M>[]): void;
145
+ setSelectedEntities(action: (prev: Entity<M>[]) => Entity<M>[]): void;
146
+ isEntitySelected(entity: Entity<M>): boolean;
147
+ toggleEntitySelection(entity: Entity<M>, newSelectedState?: boolean): void;
148
+ }
149
+
150
+ // Canonical filter types — re-exported from the single source-of-truth.
151
+
152
+ /**
153
+ * Used to indicate valid filter combinations (e.g. created in Firestore)
154
+ * If the user selects a specific filter/sort combination, the admin checks if it's
155
+ * valid, otherwise it reverts to the simpler valid case
156
+ * @group Models
157
+ */
158
+ export type FilterCombination<Key extends string> = Partial<Record<Key, "asc" | "desc">>;
159
+
160
+ /**
161
+ * Sizes in which a collection can be rendered
162
+ * @group Models
163
+ */
164
+ export type CollectionSize = "xs" | "s" | "m" | "l" | "xl";
165
+
166
+ export type AdditionalFieldDelegateProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User> = {
167
+ entity: Entity<M>,
168
+ context: RebaseContext<USER>
169
+ };
170
+
171
+ /**
172
+ * Use this interface for adding additional fields to entity collection views and forms.
173
+ *
174
+ * **Computed for display only. The server never sees it.**
175
+ *
176
+ * `value` is async and receives the whole {@link RebaseContext}, so it *can*
177
+ * read another collection, and its result is cached per record. That makes it
178
+ * read like a computed column, and it is not one: it runs in the browser, once
179
+ * per row, **after** the page has already been fetched and ordered. There is no
180
+ * point at which its result could take part in choosing which rows came back or
181
+ * in what order. So a derived value can be shown, and can never be filtered,
182
+ * sorted or paged on — no matter what it is derived from.
183
+ *
184
+ * To filter or sort on a derived value it has to exist in the database. Two
185
+ * ways, in order of preference:
186
+ *
187
+ * - if the value is an aggregate over a relation, ask for it in the query
188
+ * instead — `where: { "applications.status": ["in", [...]] }` and
189
+ * `orderBy: [[{ relation: "applications", field: "created_at", agg: "min" }, "asc"]]`
190
+ * are both compiled by the driver, which means they run before paging;
191
+ * - otherwise denormalise it onto the row — a generated column, or a
192
+ * trigger-maintained one — and it becomes an ordinary property.
193
+ *
194
+ * @group Models
195
+ */
196
+ export interface AdditionalFieldDelegate<M extends Record<string, unknown> = Record<string, unknown>,
197
+ USER extends User = User> {
198
+
199
+ /**
200
+ * ID of this column. You can use this id in the `properties` field of the
201
+ * collection in any order you want
202
+ */
203
+ key: string;
204
+
205
+ /**
206
+ * Header of this column
207
+ */
208
+ name: string;
209
+
210
+ /**
211
+ * Width of the generated column in pixels
212
+ */
213
+ width?: number;
214
+
215
+ /**
216
+ * Builder for the custom field
217
+ */
218
+ Builder?(props: { entity: Entity<M>, context: RebaseContext<USER> }): React.ReactNode;
219
+
220
+ /**
221
+ * If this column needs to update dynamically based on other properties,
222
+ * you can define an array of keys as strings with the
223
+ * `dependencies` prop.
224
+ * e.g. ["name", "surname"]
225
+ * This is a performance optimization, if you don't define dependencies
226
+ * it will be updated in every render.
227
+ *
228
+ * A key that is not a property of this collection can never change, so
229
+ * listing one is always a mistake — it silently pins the column to the
230
+ * "never re-render" path, which reads as a stale cell rather than a typo.
231
+ * The `NoInfer` wrappers keep these keys from participating in inference of
232
+ * `M`; the `(string & {})` arms they used to sit beside made the whole union
233
+ * `string`, so the wrappers had nothing to protect.
234
+ */
235
+ dependencies?: NoInfer<PropertyPath<M>> | NoInfer<PropertyPath<M>>[];
236
+
237
+ /**
238
+ * Use this prop to define the value of the column as a string or number.
239
+ * This is the value that will be used for exporting the collection.
240
+ * If `Builder` is defined, this prop will be ignored in the collection
241
+ * view.
242
+ * @param entity
243
+ */
244
+ value?(props: {
245
+ entity: Entity<M>,
246
+ context: RebaseContext
247
+ }): string | number | Promise<string | number> | undefined;
248
+ }
249
+
250
+ /**
251
+ * Used in the {@link AdminCollection#defaultSelectedView} to define the default
252
+ * @group Models
253
+ */
254
+ export type DefaultSelectedViewBuilder = (params: DefaultSelectedViewParams) => string | undefined;
255
+
256
+ /**
257
+ * Used in the {@link AdminCollection#defaultSelectedView} to define the default
258
+ * @group Models
259
+ */
260
+ export type DefaultSelectedViewParams = {
261
+ status?: EntityStatus;
262
+ entityId?: string | number;
263
+ };
264
+
265
+ /**
266
+ * You can use this controller to control the table view of a collection.
267
+ */
268
+ export type EntityTableController<M extends Record<string, unknown> = Record<string, unknown>> = {
269
+ data: Entity<M>[];
270
+ dataLoading: boolean;
271
+ noMoreToLoad: boolean;
272
+ dataLoadingError?: Error;
273
+ filterValues?: FilterValues<Extract<keyof M, string> | (string & {})>;
274
+ setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string> | (string & {})>) => void;
275
+ /**
276
+ * The sort keys in order of significance, the second breaking ties on the
277
+ * first. A single key is a one-element list — this was a bare tuple, which
278
+ * could only ever express one, so `collection.sort` could not describe an
279
+ * order like "by role, newest first within each role" and the table had no
280
+ * state to hold one in.
281
+ */
282
+ sortBy?: OrderByTuple<Extract<keyof M, string> | (string & {})>[];
283
+ setSortBy?: (sortBy?: OrderByTuple<Extract<keyof M, string> | (string & {})>[]) => void;
284
+ searchString?: string;
285
+ setSearchString?: (searchString?: string) => void;
286
+ clearFilter?: () => void;
287
+ itemCount?: number;
288
+ setItemCount?: (itemCount: number) => void;
289
+ initialScroll?: number;
290
+ onScroll?: (props: {
291
+ scrollDirection: "forward" | "backward",
292
+ scrollOffset: number,
293
+ scrollUpdateWasRequested: boolean
294
+ }) => void;
295
+ paginationEnabled?: boolean;
296
+ pageSize?: number;
297
+ checkFilterCombination?: (filterValues: FilterValues<string>,
298
+ sortBy?: OrderByTuple[]) => boolean;
299
+ popupCell?: SelectedCellProps<M>;
300
+ setPopupCell?: (popupCell?: SelectedCellProps<M>) => void;
301
+
302
+ onAddColumn?: (column: string) => void;
303
+ }
304
+
305
+ export type SelectedCellProps<M extends Record<string, unknown> = Record<string, unknown>> = {
306
+ propertyKey: Extract<keyof M, string> | (string & {});
307
+ cellRect: DOMRect;
308
+ width: number;
309
+ height: number;
310
+ entityPath: string;
311
+ entityId: string | number;
312
+ };
@@ -0,0 +1,57 @@
1
+ export type AnalyticsController = {
2
+
3
+ /**
4
+ * Callback used to get analytics events from the admin
5
+ */
6
+ onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
7
+
8
+ }
9
+
10
+ export type AnalyticsEvent =
11
+ | "entity_click"
12
+ | "entity_click_from_reference"
13
+
14
+ | "reference_selection_clear"
15
+ | "reference_selection_toggle"
16
+ | "reference_selected_single"
17
+ | "reference_selection_new_entity"
18
+
19
+ | "edit_entity_clicked"
20
+ | "entity_edited"
21
+ | "new_entity_click"
22
+ | "new_entity_saved"
23
+ | "copy_entity_click"
24
+ | "entity_copied"
25
+
26
+ | "single_delete_dialog_open"
27
+ | "multiple_delete_dialog_open"
28
+ | "single_entity_deleted"
29
+ | "multiple_entities_deleted"
30
+
31
+ | "drawer_navigate_to_home"
32
+ | "drawer_navigate_to_collection"
33
+ | "drawer_navigate_to_view"
34
+
35
+ | "home_navigate_to_collection"
36
+ | "home_favorite_navigate_to_collection"
37
+ | "home_navigate_to_view"
38
+ | "home_navigate_to_admin_view"
39
+ | "home_favorite_navigate_to_view"
40
+ | "home_move_card"
41
+ | "home_move_group"
42
+ | "home_drop_new_group"
43
+
44
+ | "collection_inline_editing"
45
+
46
+ | "view_mode_changed"
47
+
48
+ | "kanban_card_moved"
49
+ | "kanban_column_reorder"
50
+ | "kanban_property_changed"
51
+ | "kanban_new_entity_in_column"
52
+ | "kanban_backfill_order"
53
+
54
+ | "card_view_entity_click"
55
+
56
+ | "unmapped_event"
57
+ ;
@@ -0,0 +1,122 @@
1
+ import type { User } from "@rebasepro/types";
2
+
3
+ /**
4
+ * Capabilities advertised by an auth provider.
5
+ * UI components use this to show/hide features dynamically
6
+ * (e.g. password reset, registration, session management).
7
+ * @group Hooks and utilities
8
+ */
9
+ export interface AuthCapabilities {
10
+ emailPasswordLogin?: boolean;
11
+ googleLogin?: boolean;
12
+ /** Self-registration is open right now — the wire's `registrationEnabled`. */
13
+ registrationEnabled?: boolean;
14
+ /** Self-service password reset (emailing a reset link) is available. */
15
+ passwordReset?: boolean;
16
+ /**
17
+ * An admin can reset another user's password. Gates the "Reset Password"
18
+ * entity action in the admin UI. See `AuthAdapterCapabilities`.
19
+ */
20
+ adminPasswordReset?: boolean;
21
+ sessionManagement?: boolean;
22
+ profileUpdate?: boolean;
23
+ emailVerification?: boolean;
24
+ /** List of enabled OAuth provider IDs (e.g. ["google", "github", "discord"]) */
25
+ enabledProviders?: string[];
26
+ }
27
+
28
+ /**
29
+ * Controller for retrieving the logged user or performing auth related operations.
30
+ * Note that if you are implementing your AuthController, you probably will want
31
+ * to do it as the result of a hook.
32
+ * @group Hooks and utilities
33
+ */
34
+ export type AuthController<USER extends User = User, ExtraData = unknown> = {
35
+
36
+ /**
37
+ * The user currently logged in
38
+ * The values can be: the user object, null if they skipped login
39
+ */
40
+ user: USER | null;
41
+
42
+ /**
43
+ * Initial loading flag. It is used not to display the login screen
44
+ * when the app first loads, and it has not been checked whether the user
45
+ * is logged in or not.
46
+ */
47
+ initialLoading?: boolean;
48
+
49
+ /**
50
+ * Loading flag. It is used to display a loading screen when the user is
51
+ * logging in or out.
52
+ */
53
+ authLoading: boolean;
54
+
55
+ /**
56
+ * Sign out
57
+ */
58
+ signOut: () => Promise<void>;
59
+
60
+ /**
61
+ * Error initializing the authentication
62
+ */
63
+ authError?: unknown;
64
+
65
+ /**
66
+ * Error dispatched by the auth provider
67
+ */
68
+ authProviderError?: unknown;
69
+
70
+ /**
71
+ * You can use this method to retrieve the auth token for the current user.
72
+ */
73
+ getAuthToken: () => Promise<string>;
74
+
75
+ /**
76
+ * Has the user skipped the login process
77
+ */
78
+ loginSkipped: boolean;
79
+
80
+ extra: ExtraData;
81
+
82
+ setExtra: (extra: ExtraData) => void;
83
+
84
+
85
+ setUser?(user: USER | null): void;
86
+
87
+ setUserRoles?(roles: string[]): void;
88
+
89
+ /**
90
+ * Capabilities advertised by the auth provider.
91
+ * UI components use this to feature-detect what the backend supports.
92
+ */
93
+ capabilities?: AuthCapabilities;
94
+
95
+ };
96
+
97
+ /**
98
+ * Extended auth controller with common optional auth methods.
99
+ * Backend implementations (Rebase backend, Firebase, etc.)
100
+ * extend this with their own backend-specific extras.
101
+ * @group Hooks and utilities
102
+ */
103
+ export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
104
+ /** Login with email and password */
105
+ emailPasswordLogin?(email: string, password: string): Promise<void>;
106
+ /** Login with Google — accepts an ID token, access token, or authorization code payload */
107
+ googleLogin?: (payload: { idToken: string } | { accessToken: string } | { code: string; redirectUri: string }) => Promise<void>;
108
+ /** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
109
+ oauthLogin?: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
110
+ /** Register a new user */
111
+ register?(email: string, password: string, displayName?: string): Promise<void>;
112
+ /** Skip login (for anonymous access if enabled) */
113
+ skipLogin?(): void;
114
+ /** Request password reset email */
115
+ forgotPassword?(email: string): Promise<void>;
116
+ /** Reset password using a token */
117
+ resetPassword?(token: string, password: string): Promise<void>;
118
+ /** Change password for the authenticated user */
119
+ changePassword?(oldPassword: string, newPassword: string): Promise<void>;
120
+ /** Update user profile */
121
+ updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
122
+ }
@@ -0,0 +1,81 @@
1
+
2
+ import type { EntityLinkBuilder } from "../types/entity_link_builder";
3
+ import type { Locale } from "../types/locales";
4
+ import type { EntityAction } from "../types/entity_actions";
5
+ import type { EntityCustomView } from "../types/entity_views";
6
+ import type { CollectionCustomView } from "../types/collection_views";
7
+ import type { RebasePlugin } from "../types/plugins";
8
+ import type { PropertyConfig } from "../types/property_config";
9
+ import type { SlotContribution } from "../types/slots";
10
+ import type { ComponentOverrideMap } from "../types/component_overrides";
11
+
12
+ export type CustomizationController = {
13
+
14
+ /**
15
+ * Builder for generating utility links for entities
16
+ */
17
+ entityLinkBuilder?: EntityLinkBuilder;
18
+
19
+ /**
20
+ * Use plugins to modify the behaviour of the admin.
21
+ */
22
+ plugins?: RebasePlugin[];
23
+
24
+ /**
25
+ * Pre-merged slots from plugins + direct slot contributions.
26
+ */
27
+ resolvedSlots: SlotContribution[];
28
+
29
+ /**
30
+ * List of additional custom views for entities.
31
+ * You can use the key to reference the custom view in
32
+ * the `entityViews` prop of a collection.
33
+ *
34
+ * You can also define a entity view from the UI.
35
+ */
36
+ entityViews?: EntityCustomView[];
37
+
38
+ /**
39
+ * List of additional ways to render a collection's rows. You can use the
40
+ * key to reference the view in the `admin.customViews` prop of a
41
+ * collection, which is also what makes it selectable from the collection
42
+ * editor.
43
+ */
44
+ collectionViews?: CollectionCustomView[];
45
+
46
+ /**
47
+ * List of actions that can be performed on entities.
48
+ * These actions are displayed in the entity view and in the collection view.
49
+ * You can later reuse these actions in the `entityActions` prop of a collection,
50
+ * by specifying the `key` of the action.
51
+ */
52
+ entityActions?: EntityAction[];
53
+
54
+ /**
55
+ * Format of the dates in the admin.
56
+ * Defaults to 'MMMM dd, yyyy, HH:mm:ss'
57
+ */
58
+ dateTimeFormat?: string;
59
+
60
+ /**
61
+ * Locale of the admin, currently only affecting dates
62
+ */
63
+ locale?: Locale;
64
+
65
+ /**
66
+ * Record of custom form fields to be used in the admin.
67
+ * You can use the key to reference the custom field in
68
+ * the `propertyConfig` prop of a property in a collection.
69
+ */
70
+ propertyConfigs: Record<string, PropertyConfig>;
71
+
72
+ /**
73
+ * Global component overrides. Keys are component names from
74
+ * {@link OverridableComponentName}. Values replace the default
75
+ * implementation everywhere in the app.
76
+ *
77
+ * Collection-scoped overrides (set on individual collections)
78
+ * take precedence over global overrides.
79
+ */
80
+ components?: ComponentOverrideMap;
81
+ }
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+
3
+ /**
4
+ * Controller to open the side dialog
5
+ * @group Hooks and utilities
6
+ */
7
+ export interface DialogsController {
8
+
9
+ /**
10
+ * Close the last dialog
11
+ */
12
+ close: () => void;
13
+
14
+ /**
15
+ * Open a dialog
16
+ * @param props
17
+ */
18
+ open: <T extends object = object>(props: DialogControllerEntryProps<T>) => { closeDialog: () => void };
19
+ }
20
+
21
+ /**
22
+ * Props used to open a side dialog
23
+ * @group Hooks and utilities
24
+ */
25
+ export interface DialogControllerEntryProps<T extends object = object> {
26
+
27
+ key: string;
28
+ /**
29
+ * The component type that will be rendered
30
+ */
31
+ Component: React.ComponentType<{ open: boolean, closeDialog: () => void } & T>;
32
+ /**
33
+ * Props to pass to the dialog component
34
+ */
35
+ props?: T;
36
+
37
+ }