@rebasepro/admin-types 0.10.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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/dist/admin_collection.d.ts +464 -0
  3. package/dist/augment.d.ts +66 -0
  4. package/dist/collections.d.ts +226 -0
  5. package/dist/controllers/analytics_controller.d.ts +7 -0
  6. package/dist/controllers/auth.d.ts +110 -0
  7. package/dist/controllers/customization_controller.d.ts +61 -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 +225 -0
  12. package/dist/controllers/registry.d.ts +80 -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 +24 -0
  16. package/dist/index.d.ts +18 -0
  17. package/dist/index.es.js +92 -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 +26 -0
  22. package/dist/types/builders.d.ts +15 -0
  23. package/dist/types/component_overrides.d.ts +196 -0
  24. package/dist/types/entity_actions.d.ts +105 -0
  25. package/dist/types/entity_link_builder.d.ts +7 -0
  26. package/dist/types/entity_views.d.ts +95 -0
  27. package/dist/types/export_import.d.ts +21 -0
  28. package/dist/types/formex.d.ts +40 -0
  29. package/dist/types/index.d.ts +15 -0
  30. package/dist/types/locales.d.ts +4 -0
  31. package/dist/types/modify_collections.d.ts +5 -0
  32. package/dist/types/plugins.d.ts +277 -0
  33. package/dist/types/property_config.d.ts +74 -0
  34. package/dist/types/property_options.d.ts +154 -0
  35. package/dist/types/slots.d.ts +263 -0
  36. package/dist/types/translations.d.ts +915 -0
  37. package/dist/types/user_management_delegate.d.ts +22 -0
  38. package/package.json +103 -0
  39. package/src/admin_collection.ts +582 -0
  40. package/src/augment.ts +60 -0
  41. package/src/collections.ts +256 -0
  42. package/src/controllers/analytics_controller.tsx +57 -0
  43. package/src/controllers/auth.ts +121 -0
  44. package/src/controllers/customization_controller.tsx +72 -0
  45. package/src/controllers/dialogs_controller.tsx +37 -0
  46. package/src/controllers/index.ts +10 -0
  47. package/src/controllers/local_config_persistence.tsx +22 -0
  48. package/src/controllers/navigation.ts +264 -0
  49. package/src/controllers/registry.ts +96 -0
  50. package/src/controllers/side_dialogs_controller.tsx +82 -0
  51. package/src/controllers/side_panel_controller.tsx +112 -0
  52. package/src/controllers/snackbar.ts +29 -0
  53. package/src/index.ts +20 -0
  54. package/src/react_component_ref.ts +52 -0
  55. package/src/rebase_context.ts +81 -0
  56. package/src/types/breadcrumbs.ts +27 -0
  57. package/src/types/builders.ts +18 -0
  58. package/src/types/component_overrides.ts +244 -0
  59. package/src/types/entity_actions.tsx +127 -0
  60. package/src/types/entity_link_builder.ts +8 -0
  61. package/src/types/entity_views.tsx +114 -0
  62. package/src/types/export_import.ts +26 -0
  63. package/src/types/formex.ts +45 -0
  64. package/src/types/index.ts +15 -0
  65. package/src/types/locales.ts +81 -0
  66. package/src/types/modify_collections.tsx +6 -0
  67. package/src/types/plugins.tsx +346 -0
  68. package/src/types/property_config.tsx +95 -0
  69. package/src/types/property_options.ts +169 -0
  70. package/src/types/slots.tsx +309 -0
  71. package/src/types/translations.ts +1026 -0
  72. package/src/types/user_management_delegate.ts +23 -0
@@ -0,0 +1,15 @@
1
+ export * from "./breadcrumbs";
2
+ export * from "./builders";
3
+ export * from "./component_overrides";
4
+ export * from "./entity_actions";
5
+ export * from "./entity_link_builder";
6
+ export * from "./entity_views";
7
+ export * from "./export_import";
8
+ export * from "./formex";
9
+ export * from "./locales";
10
+ export * from "./modify_collections";
11
+ export * from "./plugins";
12
+ export * from "./property_config";
13
+ export * from "./slots";
14
+ export * from "./translations";
15
+ export * from "./user_management_delegate";
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @group Models
3
+ */
4
+ export type Locale =
5
+ "af" |
6
+ "ar" |
7
+ "arDZ" |
8
+ "arMA" |
9
+ "arSA" |
10
+ "az" |
11
+ "be" |
12
+ "bg" |
13
+ "bn" |
14
+ "ca" |
15
+ "cs" |
16
+ "cy" |
17
+ "da" |
18
+ "de" |
19
+ "el" |
20
+ "enAU" |
21
+ "enCA" |
22
+ "enGB" |
23
+ "enIN" |
24
+ "enNZ" |
25
+ "enUS" |
26
+ "eo" |
27
+ "es" |
28
+ "et" |
29
+ "eu" |
30
+ "faIR" |
31
+ "fi" |
32
+ "fil" |
33
+ "fr" |
34
+ "frCA" |
35
+ "frCH" |
36
+ "gd" |
37
+ "gl" |
38
+ "gu" |
39
+ "he" |
40
+ "hi" |
41
+ "hr" |
42
+ "hu" |
43
+ "hy" |
44
+ "id" |
45
+ "is" |
46
+ "it" |
47
+ "ja" |
48
+ "ka" |
49
+ "kk" |
50
+ "kn" |
51
+ "ko" |
52
+ "lb" |
53
+ "lt" |
54
+ "lv" |
55
+ "mk" |
56
+ "ms" |
57
+ "mt" |
58
+ "nb" |
59
+ "nl" |
60
+ "nlBE" |
61
+ "nn" |
62
+ "pl" |
63
+ "pt" |
64
+ "ptBR" |
65
+ "ro" |
66
+ "ru" |
67
+ "sk" |
68
+ "sl" |
69
+ "sr" |
70
+ "srLatn" |
71
+ "sv" |
72
+ "ta" |
73
+ "te" |
74
+ "th" |
75
+ "tr" |
76
+ "ug" |
77
+ "uk" |
78
+ "uz" |
79
+ "vi" |
80
+ "zhCN" |
81
+ "zhTW";
@@ -0,0 +1,6 @@
1
+ import type { AdminCollection } from "@rebasepro/admin-types";
2
+
3
+ export type ModifyCollectionProps = {
4
+ collection: AdminCollection,
5
+ parentPaths: string[],
6
+ };
@@ -0,0 +1,346 @@
1
+ import React, { PropsWithChildren } from "react";
2
+
3
+ import type { CollectionActionsProps, EntityTableController, SelectionController } from "../collections";
4
+ import type { EntityStatus } from "@rebasepro/types";
5
+ import type { InferPropertyType, Property } from "@rebasepro/types";
6
+ import type { FormContext } from "./entity_views";
7
+ import type { RebaseContext } from "../rebase_context";
8
+ import type { NavigationGroupMapping, AppView } from "../controllers/navigation";
9
+
10
+ import type { User } from "@rebasepro/types";
11
+ import type { SlotContribution } from "./slots";
12
+ import type { AdminCollection } from "@rebasepro/admin-types";
13
+
14
+ /**
15
+ * Props interface for custom field components.
16
+ *
17
+ * The `@rebasepro/admin` package re-exports a narrower version of this
18
+ * interface that adds `formex` and layout-specific fields. This base
19
+ * definition captures the core contract that every field renderer must
20
+ * satisfy, regardless of where it is rendered.
21
+ *
22
+ * @typeParam P - The property type this field is bound to
23
+ * @typeParam CustomProps - Extra props injected via the property's `customProps`
24
+ * @typeParam M - The entity model type
25
+ * @group Form custom fields
26
+ */
27
+ export interface FieldProps<
28
+ P extends Property = Property,
29
+ CustomProps = unknown,
30
+ M extends Record<string, unknown> = Record<string, unknown>
31
+ > {
32
+ /** Key of the property (e.g. "user.name" for a nested path) */
33
+ propertyKey: string;
34
+
35
+ /** Current value of this field */
36
+ value: InferPropertyType<P> | null;
37
+
38
+ /** Set value of field directly */
39
+ setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
40
+
41
+ /** Set value of a different field directly */
42
+ setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
43
+
44
+ /** Is the form currently submitting */
45
+ isSubmitting?: boolean;
46
+
47
+ /** Should this field show the error indicator */
48
+ showError?: boolean;
49
+
50
+ /** Error message for this field, or undefined if valid */
51
+ error?: string;
52
+
53
+ /** Has this field been touched */
54
+ touched?: boolean;
55
+
56
+ /** Property related to this field */
57
+ property: P;
58
+
59
+ /** Should this field include a description */
60
+ includeDescription?: boolean;
61
+
62
+ /** Flag to indicate that the underlying value has been updated in the driver */
63
+ underlyingValueHasChanged?: boolean;
64
+
65
+ /** Is this field part of an array */
66
+ partOfArray?: boolean;
67
+
68
+ /** Is this field part of a block */
69
+ partOfBlock?: boolean;
70
+
71
+ /** Display the child properties directly, without being wrapped in an extendable panel */
72
+ minimalistView?: boolean;
73
+
74
+ /** Should this field autofocus on mount */
75
+ autoFocus?: boolean;
76
+
77
+ /** Additional properties set by the developer */
78
+ customProps?: CustomProps;
79
+
80
+ /** Additional values related to the state of the form or the entity */
81
+ context: FormContext<M>;
82
+
83
+ /** Flag to indicate if this field should be disabled */
84
+ disabled?: boolean;
85
+
86
+ /** Size of the field */
87
+ size?: "small" | "medium" | "large";
88
+
89
+ /** Callback when internal property state changes (e.g. panel expansion) */
90
+ onPropertyChange?: (property: Partial<Property>) => void;
91
+ }
92
+
93
+ // ── Plugin ────────────────────────────────────────────────────────────
94
+
95
+ /**
96
+ * Interface used to define plugins for Rebase.
97
+ * Plugins contribute UI via **slots**, wrap subtrees with **providers**,
98
+ * and inject behavioral logic via **hooks**.
99
+ * @group Core
100
+ */
101
+ export interface RebasePlugin {
102
+ /**
103
+ * Unique key identifying this plugin.
104
+ */
105
+ key: string;
106
+
107
+ /**
108
+ * If true, no CMS content is shown until this plugin finishes loading.
109
+ */
110
+ loading?: boolean;
111
+
112
+ /**
113
+ * UI slot contributions rendered at the matching extension points.
114
+ */
115
+ slots?: SlotContribution[];
116
+
117
+ /**
118
+ * HOC providers wrapping root or form content.
119
+ * Providers with `scope: "root"` wrap the entire CMS below RebaseContext.
120
+ * Providers with `scope: "form"` wrap each entity form/edit view.
121
+ */
122
+ providers?: PluginProvider[];
123
+
124
+ /**
125
+ * Behavioral hooks (non-UI) — collection modification, search blocking,
126
+ * column reordering, navigation entries, etc.
127
+ */
128
+ hooks?: PluginHooks;
129
+
130
+ /**
131
+ * Field wrapping for custom field rendering (e.g. data enhancement).
132
+ */
133
+ fieldBuilder?: FieldBuilderConfig;
134
+
135
+ /**
136
+ * Views to be automatically added to the navigation.
137
+ */
138
+ views?: AppView[];
139
+
140
+ /**
141
+ * Optional lifecycle hooks. Called by the Rebase runtime
142
+ * at appropriate points in the app lifecycle.
143
+ */
144
+ lifecycle?: PluginLifecycle;
145
+ }
146
+
147
+ // ── Provider ──────────────────────────────────────────────────────────
148
+
149
+ /**
150
+ * A HOC provider that wraps a subtree of the CMS.
151
+ * @group Plugins
152
+ */
153
+ export interface PluginProvider {
154
+ /**
155
+ * `"root"` — wraps the entire CMS below RebaseContext.
156
+ * `"form"` — wraps each entity form / edit view.
157
+ */
158
+ scope: "root" | "form";
159
+
160
+ /**
161
+ * The provider component. Must accept `children`.
162
+ * Typed loosely because extra props are passed via the `props` field;
163
+ * strict signatures cause contravariance issues.
164
+ */
165
+ Component: React.ComponentType<PropsWithChildren<Record<string, unknown>>>;
166
+
167
+ /**
168
+ * Additional props passed to the Component.
169
+ */
170
+ props?: Record<string, unknown>;
171
+ }
172
+
173
+ // ── Hooks ─────────────────────────────────────────────────────────────
174
+
175
+ /**
176
+ * Behavioral hooks that a plugin can provide.
177
+ * These are non-UI extension points for modifying CMS behavior.
178
+ * @group Plugins
179
+ */
180
+ export interface PluginHooks {
181
+ /**
182
+ * Modify a single collection before it is rendered (synchronous).
183
+ */
184
+ modifyCollection?: (collection: AdminCollection) => AdminCollection;
185
+
186
+ /**
187
+ * Async version of modifyCollection — supports fetching remote config.
188
+ * Runs during navigation resolution. If provided alongside `modifyCollection`,
189
+ * the sync version runs first, then the async version.
190
+ */
191
+ modifyCollectionAsync?: (collection: AdminCollection) => Promise<AdminCollection>;
192
+
193
+ /**
194
+ * Modify, add or remove collections.
195
+ */
196
+ injectCollections?: (collections: AdminCollection[]) => AdminCollection[];
197
+
198
+ /**
199
+ * Callback called when columns are reordered via drag and drop.
200
+ */
201
+ onColumnsReorder?: (props: {
202
+ fullPath: string;
203
+ parentCollectionSlugs: string[];
204
+ parentEntityIds: string[];
205
+ collection: AdminCollection;
206
+ newPropertiesOrder: string[];
207
+ }) => void;
208
+
209
+ /**
210
+ * Callback called when Kanban board columns are reordered.
211
+ */
212
+ onKanbanColumnsReorder?: (props: {
213
+ fullPath: string;
214
+ parentCollectionSlugs: string[];
215
+ parentEntityIds: string[];
216
+ collection: AdminCollection;
217
+ kanbanColumnProperty: string;
218
+ newColumnsOrder: string[];
219
+ }) => void;
220
+
221
+ /**
222
+ * Navigation entries contributed by this plugin.
223
+ */
224
+ navigationEntries?: NavigationGroupMapping[];
225
+
226
+ /**
227
+ * Callback when navigation entry order changes (e.g. drag-and-drop).
228
+ */
229
+ onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
230
+
231
+ /**
232
+ * Allow reordering collections in the home page via drag and drop.
233
+ */
234
+ allowDragAndDrop?: boolean;
235
+ }
236
+
237
+ // ── Plugin Lifecycle ──────────────────────────────────────────────────
238
+
239
+ /**
240
+ * Lifecycle hooks for plugins. Called by the Rebase runtime
241
+ * at appropriate points in the app lifecycle.
242
+ * @group Plugins
243
+ */
244
+ export interface PluginLifecycle {
245
+ /**
246
+ * Called once when the plugin is mounted in the Rebase tree.
247
+ * Can return a Promise for async initialization.
248
+ */
249
+ onMount?: (context: RebaseContext) => void | Promise<void>;
250
+
251
+ /**
252
+ * Called when the plugin is unmounted from the Rebase tree.
253
+ * Use this for cleanup (subscriptions, timers, etc.).
254
+ */
255
+ onUnmount?: () => void;
256
+
257
+ /**
258
+ * Called whenever the authentication state changes.
259
+ * Receives the new user (or null on sign-out).
260
+ */
261
+ onAuthStateChange?: (user: User | null) => void;
262
+
263
+ /**
264
+ * Called when a collection's visible entities change.
265
+ * Useful for analytics, caching, or cross-plugin coordination.
266
+ */
267
+ onCollectionChange?: (slug: string, entities: unknown[]) => void;
268
+ }
269
+
270
+ // ── Field Builder ─────────────────────────────────────────────────────
271
+
272
+ /**
273
+ * Configuration for wrapping form field components.
274
+ * @group Plugins
275
+ */
276
+ export interface FieldBuilderConfig {
277
+ /**
278
+ * Returns a wrapped field component, or null to skip wrapping.
279
+ */
280
+ wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<Property>> | null;
281
+
282
+ /**
283
+ * Optional guard — return false to skip wrapping for this field.
284
+ */
285
+ enabled?: (params: PluginFieldBuilderParams) => boolean;
286
+ }
287
+
288
+ // ── Prop interfaces ───────────────────────────────────────────────────
289
+
290
+ /**
291
+ * Props passed to home page collection card action components.
292
+ * @group Models
293
+ */
294
+ export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends AdminCollection<M> = AdminCollection<M>> {
295
+ slug: string;
296
+ collection: EC;
297
+ context: RebaseContext<USER>;
298
+ }
299
+
300
+ /**
301
+ * Props passed to form action components in entity edit/form views.
302
+ * @group Models
303
+ */
304
+ export interface PluginFormActionProps<USER extends User = User, EC extends AdminCollection = AdminCollection> {
305
+ entityId?: string | number;
306
+ path: string;
307
+ parentCollectionSlugs: string[];
308
+ parentEntityIds: string[];
309
+ status: EntityStatus;
310
+ collection: EC;
311
+ disabled: boolean;
312
+ formContext?: FormContext;
313
+ context: RebaseContext<USER>;
314
+ openEntityMode?: "side_panel" | "full_screen" | "split" | "dialog";
315
+ }
316
+
317
+ /**
318
+ * Parameters passed to the field builder wrap function.
319
+ * @group Models
320
+ */
321
+ export type PluginFieldBuilderParams<M extends Record<string, unknown> = Record<string, unknown>, EC extends AdminCollection<M> = AdminCollection<M>> = {
322
+ fieldConfigId: string;
323
+ propertyKey: string;
324
+ property: Property;
325
+ Field: React.ComponentType<FieldProps<Property, unknown, M>>;
326
+ plugin: RebasePlugin;
327
+ path?: string;
328
+ collection?: EC;
329
+ };
330
+
331
+ /**
332
+ * Generic props passed to plugin components that just need CMS context.
333
+ * @group Models
334
+ */
335
+ export interface PluginGenericProps<USER extends User = User> {
336
+ context: RebaseContext<USER>;
337
+ }
338
+
339
+ /**
340
+ * Props for additional card components in the home page.
341
+ * @group Models
342
+ */
343
+ export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
344
+ group?: string;
345
+ context: RebaseContext<USER>;
346
+ }
@@ -0,0 +1,95 @@
1
+ import React from "react";
2
+ import { ArrayProperty, MapProperty, Property, StringProperty, NumberProperty, BooleanProperty, DateProperty, GeopointProperty, ReferenceProperty, RelationProperty, VectorProperty, BinaryProperty } from "@rebasepro/types";import { BaseProperty } from "@rebasepro/types";
3
+
4
+ type CMSBasePropertyNoName = Omit<BaseProperty, "name">;
5
+
6
+ export type ConfigProperty =
7
+ | (Omit<StringProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
8
+ | (Omit<NumberProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
9
+ | (Omit<BooleanProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
10
+ | (Omit<DateProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
11
+ | (Omit<GeopointProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
12
+ | (Omit<ReferenceProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
13
+ | (Omit<RelationProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
14
+ | (Omit<ArrayProperty, "name" | "of" | "oneOf"> & {
15
+ name?: string;
16
+ of?: ConfigProperty | ConfigProperty[];
17
+ oneOf?: { properties: Record<string, ConfigProperty>; typeField?: string; valueField?: string; propertiesOrder?: string[] }
18
+ } & CMSBasePropertyNoName)
19
+ | (Omit<MapProperty, "name" | "properties"> & {
20
+ name?: string;
21
+ properties?: Record<string, ConfigProperty>
22
+ } & CMSBasePropertyNoName)
23
+ | (Omit<VectorProperty, "name"> & { name?: string } & CMSBasePropertyNoName)
24
+ | (Omit<BinaryProperty, "name"> & { name?: string } & CMSBasePropertyNoName);
25
+
26
+ /**
27
+ * This is the configuration object for a property.
28
+ * These configs are generated by default for the properties defined in your
29
+ * collections' configuration, but you can define your own to be used.
30
+ */
31
+ export type PropertyConfig = {
32
+
33
+ /**
34
+ * Key used to identify this property config.
35
+ */
36
+ key: PropertyConfigId | string;
37
+
38
+ /**
39
+ * Name of this field type.
40
+ * This is not the name of the property.
41
+ */
42
+ name: string;
43
+
44
+ /**
45
+ * Default config for the property.
46
+ * This property or builder will be used as the base values for the resulting property.
47
+ * You can also use a builder function to generate the base property.
48
+ */
49
+ property: ConfigProperty;
50
+
51
+ /**
52
+ * Optional icon to be used in the field selector.
53
+ * Use a 24x24 component, in order not to break the layout.
54
+ * Any Rebase icon can be used.
55
+ */
56
+ Icon?: React.ComponentType;
57
+
58
+ /**
59
+ * CSS color, used only in some plugins like the field selector.
60
+ * e.g. "#2d7ff9"
61
+ */
62
+ color?: string;
63
+
64
+ /**
65
+ * Description of this field type.
66
+ */
67
+ description?: string;
68
+
69
+ }
70
+
71
+ export type PropertyConfigId =
72
+ "text_field" |
73
+ "multiline" |
74
+ "markdown" |
75
+ "url" |
76
+ "email" |
77
+ "user_select" |
78
+ "select" |
79
+ "multi_select" |
80
+ "number_input" |
81
+ "number_select" |
82
+ "multi_number_select" |
83
+ "file_upload" |
84
+ "multi_file_upload" |
85
+ "group" |
86
+ "key_value" |
87
+ "reference" |
88
+ "multi_references" |
89
+ "relation" |
90
+ "switch" |
91
+ "date_time" |
92
+ "repeat" |
93
+ "custom_array" |
94
+ "block" |
95
+ "vector_input";