@rebasepro/sdk-generator 0.0.1-canary.4d4fb3e
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/LICENSE +6 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +48 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +36 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +12 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/index.cjs +211 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.es.js +208 -0
- package/dist/index.es.js.map +1 -0
- package/dist/sdk-generator/src/generate-types.d.ts +2 -0
- package/dist/sdk-generator/src/index.d.ts +19 -0
- package/dist/sdk-generator/src/utils.d.ts +22 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +117 -0
- package/dist/types/src/controllers/client.d.ts +58 -0
- package/dist/types/src/controllers/collection_registry.d.ts +44 -0
- package/dist/types/src/controllers/customization_controller.d.ts +54 -0
- package/dist/types/src/controllers/data.d.ts +141 -0
- package/dist/types/src/controllers/data_driver.d.ts +168 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/index.d.ts +17 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +51 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +89 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +173 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +101 -0
- package/dist/types/src/types/backend.d.ts +533 -0
- package/dist/types/src/types/builders.d.ts +14 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +812 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +9 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +22 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +225 -0
- package/dist/types/src/types/properties.d.ts +1091 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +228 -0
- package/dist/types/src/types/translations.d.ts +826 -0
- package/dist/types/src/types/user_management_delegate.d.ts +120 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/jest.config.cjs +13 -0
- package/package.json +51 -0
- package/src/generate-types.ts +176 -0
- package/src/index.ts +71 -0
- package/src/json-logic-js.d.ts +8 -0
- package/src/utils.ts +42 -0
- package/test/sdk-generator.test.ts +78 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +49 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EntityCollection } from "./collections";
|
|
3
|
+
import { EntityStatus } from "./entities";
|
|
4
|
+
import { Property } from "./properties";
|
|
5
|
+
import { FormContext } from "./entity_views";
|
|
6
|
+
import { RebaseContext } from "../rebase_context";
|
|
7
|
+
import { NavigationGroupMapping, AppView } from "../controllers";
|
|
8
|
+
import { UserManagementDelegate } from "./user_management_delegate";
|
|
9
|
+
import { User } from "../users";
|
|
10
|
+
import { SlotContribution } from "./slots";
|
|
11
|
+
export type FieldProps<T = any, CustomProps = any, M extends Record<string, any> = any> = any;
|
|
12
|
+
/**
|
|
13
|
+
* Interface used to define plugins for Rebase.
|
|
14
|
+
* Plugins contribute UI via **slots**, wrap subtrees with **providers**,
|
|
15
|
+
* and inject behavioral logic via **hooks**.
|
|
16
|
+
* @group Core
|
|
17
|
+
*/
|
|
18
|
+
export interface RebasePlugin {
|
|
19
|
+
/**
|
|
20
|
+
* Unique key identifying this plugin.
|
|
21
|
+
*/
|
|
22
|
+
key: string;
|
|
23
|
+
/**
|
|
24
|
+
* If true, no CMS content is shown until this plugin finishes loading.
|
|
25
|
+
*/
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* UI slot contributions rendered at the matching extension points.
|
|
29
|
+
*/
|
|
30
|
+
slots?: SlotContribution[];
|
|
31
|
+
/**
|
|
32
|
+
* HOC providers wrapping root or form content.
|
|
33
|
+
* Providers with `scope: "root"` wrap the entire CMS below RebaseContext.
|
|
34
|
+
* Providers with `scope: "form"` wrap each entity form/edit view.
|
|
35
|
+
*/
|
|
36
|
+
providers?: PluginProvider[];
|
|
37
|
+
/**
|
|
38
|
+
* Behavioral hooks (non-UI) — collection modification, search blocking,
|
|
39
|
+
* column reordering, navigation entries, etc.
|
|
40
|
+
*/
|
|
41
|
+
hooks?: PluginHooks;
|
|
42
|
+
/**
|
|
43
|
+
* Field wrapping for custom field rendering (e.g. data enhancement).
|
|
44
|
+
*/
|
|
45
|
+
fieldBuilder?: FieldBuilderConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Views to be automatically added to the navigation.
|
|
48
|
+
*/
|
|
49
|
+
views?: AppView[];
|
|
50
|
+
/**
|
|
51
|
+
* User management delegate from this plugin.
|
|
52
|
+
*/
|
|
53
|
+
userManagement?: UserManagementDelegate;
|
|
54
|
+
/**
|
|
55
|
+
* Optional lifecycle hooks. Called by the Rebase runtime
|
|
56
|
+
* at appropriate points in the app lifecycle.
|
|
57
|
+
*/
|
|
58
|
+
lifecycle?: PluginLifecycle;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A HOC provider that wraps a subtree of the CMS.
|
|
62
|
+
* @group Plugins
|
|
63
|
+
*/
|
|
64
|
+
export interface PluginProvider {
|
|
65
|
+
/**
|
|
66
|
+
* `"root"` — wraps the entire CMS below RebaseContext.
|
|
67
|
+
* `"form"` — wraps each entity form / edit view.
|
|
68
|
+
*/
|
|
69
|
+
scope: "root" | "form";
|
|
70
|
+
/**
|
|
71
|
+
* The provider component. Must accept `children`.
|
|
72
|
+
* Typed loosely because extra props are passed via the `props` field;
|
|
73
|
+
* strict signatures cause contravariance issues.
|
|
74
|
+
*/
|
|
75
|
+
Component: React.ComponentType<any>;
|
|
76
|
+
/**
|
|
77
|
+
* Additional props passed to the Component.
|
|
78
|
+
*/
|
|
79
|
+
props?: Record<string, any>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Behavioral hooks that a plugin can provide.
|
|
83
|
+
* These are non-UI extension points for modifying CMS behavior.
|
|
84
|
+
* @group Plugins
|
|
85
|
+
*/
|
|
86
|
+
export interface PluginHooks {
|
|
87
|
+
/**
|
|
88
|
+
* Modify a single collection before it is rendered (synchronous).
|
|
89
|
+
*/
|
|
90
|
+
modifyCollection?: (collection: EntityCollection) => EntityCollection;
|
|
91
|
+
/**
|
|
92
|
+
* Async version of modifyCollection — supports fetching remote config.
|
|
93
|
+
* Runs during navigation resolution. If provided alongside `modifyCollection`,
|
|
94
|
+
* the sync version runs first, then the async version.
|
|
95
|
+
*/
|
|
96
|
+
modifyCollectionAsync?: (collection: EntityCollection) => Promise<EntityCollection>;
|
|
97
|
+
/**
|
|
98
|
+
* Modify, add or remove collections.
|
|
99
|
+
*/
|
|
100
|
+
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
101
|
+
/**
|
|
102
|
+
* Callback called when columns are reordered via drag and drop.
|
|
103
|
+
*/
|
|
104
|
+
onColumnsReorder?: (props: {
|
|
105
|
+
fullPath: string;
|
|
106
|
+
parentCollectionIds: string[];
|
|
107
|
+
collection: EntityCollection;
|
|
108
|
+
newPropertiesOrder: string[];
|
|
109
|
+
}) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Callback called when Kanban board columns are reordered.
|
|
112
|
+
*/
|
|
113
|
+
onKanbanColumnsReorder?: (props: {
|
|
114
|
+
fullPath: string;
|
|
115
|
+
parentCollectionIds: string[];
|
|
116
|
+
collection: EntityCollection;
|
|
117
|
+
kanbanColumnProperty: string;
|
|
118
|
+
newColumnsOrder: string[];
|
|
119
|
+
}) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Navigation entries contributed by this plugin.
|
|
122
|
+
*/
|
|
123
|
+
navigationEntries?: NavigationGroupMapping[];
|
|
124
|
+
/**
|
|
125
|
+
* Callback when navigation entry order changes (e.g. drag-and-drop).
|
|
126
|
+
*/
|
|
127
|
+
onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Allow reordering collections in the home page via drag and drop.
|
|
130
|
+
*/
|
|
131
|
+
allowDragAndDrop?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Lifecycle hooks for plugins. Called by the Rebase runtime
|
|
135
|
+
* at appropriate points in the app lifecycle.
|
|
136
|
+
* @group Plugins
|
|
137
|
+
*/
|
|
138
|
+
export interface PluginLifecycle {
|
|
139
|
+
/**
|
|
140
|
+
* Called once when the plugin is mounted in the Rebase tree.
|
|
141
|
+
* Can return a Promise for async initialization.
|
|
142
|
+
*/
|
|
143
|
+
onMount?: (context: RebaseContext) => void | Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Called when the plugin is unmounted from the Rebase tree.
|
|
146
|
+
* Use this for cleanup (subscriptions, timers, etc.).
|
|
147
|
+
*/
|
|
148
|
+
onUnmount?: () => void;
|
|
149
|
+
/**
|
|
150
|
+
* Called whenever the authentication state changes.
|
|
151
|
+
* Receives the new user (or null on sign-out).
|
|
152
|
+
*/
|
|
153
|
+
onAuthStateChange?: (user: User | null) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Called when a collection's visible entities change.
|
|
156
|
+
* Useful for analytics, caching, or cross-plugin coordination.
|
|
157
|
+
*/
|
|
158
|
+
onCollectionChange?: (slug: string, entities: any[]) => void;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Configuration for wrapping form field components.
|
|
162
|
+
* @group Plugins
|
|
163
|
+
*/
|
|
164
|
+
export interface FieldBuilderConfig {
|
|
165
|
+
/**
|
|
166
|
+
* Returns a wrapped field component, or null to skip wrapping.
|
|
167
|
+
*/
|
|
168
|
+
wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<any>> | null;
|
|
169
|
+
/**
|
|
170
|
+
* Optional guard — return false to skip wrapping for this field.
|
|
171
|
+
*/
|
|
172
|
+
enabled?: (params: PluginFieldBuilderParams) => boolean;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Props passed to home page collection card action components.
|
|
176
|
+
* @group Models
|
|
177
|
+
*/
|
|
178
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
179
|
+
slug: string;
|
|
180
|
+
collection: EC;
|
|
181
|
+
context: RebaseContext<USER>;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Props passed to form action components in entity edit/form views.
|
|
185
|
+
* @group Models
|
|
186
|
+
*/
|
|
187
|
+
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
188
|
+
entityId?: string | number;
|
|
189
|
+
path: string;
|
|
190
|
+
parentCollectionIds: string[];
|
|
191
|
+
status: EntityStatus;
|
|
192
|
+
collection: EC;
|
|
193
|
+
disabled: boolean;
|
|
194
|
+
formContext?: FormContext;
|
|
195
|
+
context: RebaseContext<USER>;
|
|
196
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Parameters passed to the field builder wrap function.
|
|
200
|
+
* @group Models
|
|
201
|
+
*/
|
|
202
|
+
export type PluginFieldBuilderParams<M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
203
|
+
fieldConfigId: string;
|
|
204
|
+
propertyKey: string;
|
|
205
|
+
property: Property;
|
|
206
|
+
Field: React.ComponentType<FieldProps<Property, unknown, M>>;
|
|
207
|
+
plugin: RebasePlugin;
|
|
208
|
+
path?: string;
|
|
209
|
+
collection?: EC;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Generic props passed to plugin components that just need CMS context.
|
|
213
|
+
* @group Models
|
|
214
|
+
*/
|
|
215
|
+
export interface PluginGenericProps<USER extends User = User> {
|
|
216
|
+
context: RebaseContext<USER>;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Props for additional card components in the home page.
|
|
220
|
+
* @group Models
|
|
221
|
+
*/
|
|
222
|
+
export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
|
|
223
|
+
group?: string;
|
|
224
|
+
context: RebaseContext<USER>;
|
|
225
|
+
}
|