@rebasepro/sdk-generator 0.0.1-canary.09e5ec5
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 +56 -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 +58 -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 +22 -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 +232 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.es.js +229 -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 +119 -0
- package/dist/types/src/controllers/client.d.ts +170 -0
- package/dist/types/src/controllers/collection_registry.d.ts +45 -0
- package/dist/types/src/controllers/customization_controller.d.ts +60 -0
- package/dist/types/src/controllers/data.d.ts +168 -0
- package/dist/types/src/controllers/data_driver.d.ts +160 -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/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +18 -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 +54 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +171 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +105 -0
- package/dist/types/src/types/backend.d.ts +536 -0
- package/dist/types/src/types/builders.d.ts +15 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +856 -0
- package/dist/types/src/types/cron.d.ts +102 -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 +10 -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 +23 -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 +279 -0
- package/dist/types/src/types/properties.d.ts +1176 -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 +252 -0
- package/dist/types/src/types/translations.d.ts +870 -0
- package/dist/types/src/types/user_management_delegate.d.ts +121 -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 +199 -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 +88 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +49 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "./entities";
|
|
2
|
+
export * from "./chips";
|
|
3
|
+
export * from "./properties";
|
|
4
|
+
export * from "./collections";
|
|
5
|
+
export * from "./relations";
|
|
6
|
+
export * from "./locales";
|
|
7
|
+
export * from "./entity_link_builder";
|
|
8
|
+
export * from "./user_management_delegate";
|
|
9
|
+
export * from "./entity_callbacks";
|
|
10
|
+
export * from "./entity_overrides";
|
|
11
|
+
export * from "./export_import";
|
|
12
|
+
export * from "./modify_collections";
|
|
13
|
+
export * from "./websockets";
|
|
14
|
+
export * from "./backend";
|
|
15
|
+
export * from "./translations";
|
|
16
|
+
export * from "./plugins";
|
|
17
|
+
export * from "./builders";
|
|
18
|
+
export * from "./slots";
|
|
19
|
+
export * from "./entity_actions";
|
|
20
|
+
export * from "./property_config";
|
|
21
|
+
export * from "./entity_views";
|
|
22
|
+
export * from "./data_source";
|
|
23
|
+
export * from "./cron";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @group Models
|
|
3
|
+
*/
|
|
4
|
+
export type Locale = "af" | "ar" | "arDZ" | "arMA" | "arSA" | "az" | "be" | "bg" | "bn" | "ca" | "cs" | "cy" | "da" | "de" | "el" | "enAU" | "enCA" | "enGB" | "enIN" | "enNZ" | "enUS" | "eo" | "es" | "et" | "eu" | "faIR" | "fi" | "fil" | "fr" | "frCA" | "frCH" | "gd" | "gl" | "gu" | "he" | "hi" | "hr" | "hu" | "hy" | "id" | "is" | "it" | "ja" | "ka" | "kk" | "kn" | "ko" | "lb" | "lt" | "lv" | "mk" | "ms" | "mt" | "nb" | "nl" | "nlBE" | "nn" | "pl" | "pt" | "ptBR" | "ro" | "ru" | "sk" | "sl" | "sr" | "srLatn" | "sv" | "ta" | "te" | "th" | "tr" | "ug" | "uk" | "uz" | "vi" | "zhCN" | "zhTW";
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import type { EntityCollection } from "./collections";
|
|
3
|
+
import type { EntityStatus } from "./entities";
|
|
4
|
+
import type { InferPropertyType, Property } from "./properties";
|
|
5
|
+
import type { FormContext } from "./entity_views";
|
|
6
|
+
import type { RebaseContext } from "../rebase_context";
|
|
7
|
+
import type { NavigationGroupMapping, AppView } from "../controllers/navigation";
|
|
8
|
+
import type { UserManagementDelegate } from "./user_management_delegate";
|
|
9
|
+
import type { User } from "../users";
|
|
10
|
+
import type { SlotContribution } from "./slots";
|
|
11
|
+
/**
|
|
12
|
+
* Props interface for custom field components.
|
|
13
|
+
*
|
|
14
|
+
* The `@rebasepro/admin` package re-exports a narrower version of this
|
|
15
|
+
* interface that adds `formex` and layout-specific fields. This base
|
|
16
|
+
* definition captures the core contract that every field renderer must
|
|
17
|
+
* satisfy, regardless of where it is rendered.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam P - The property type this field is bound to
|
|
20
|
+
* @typeParam CustomProps - Extra props injected via the property's `customProps`
|
|
21
|
+
* @typeParam M - The entity model type
|
|
22
|
+
* @group Form custom fields
|
|
23
|
+
*/
|
|
24
|
+
export interface FieldProps<P extends Property = Property, CustomProps = unknown, M extends Record<string, unknown> = Record<string, unknown>> {
|
|
25
|
+
/** Key of the property (e.g. "user.name" for a nested path) */
|
|
26
|
+
propertyKey: string;
|
|
27
|
+
/** Current value of this field */
|
|
28
|
+
value: InferPropertyType<P> | null;
|
|
29
|
+
/** Set value of field directly */
|
|
30
|
+
setValue: (value: InferPropertyType<P> | null, shouldValidate?: boolean) => void;
|
|
31
|
+
/** Set value of a different field directly */
|
|
32
|
+
setFieldValue: (propertyKey: string, value: unknown, shouldValidate?: boolean) => void;
|
|
33
|
+
/** Is the form currently submitting */
|
|
34
|
+
isSubmitting?: boolean;
|
|
35
|
+
/** Should this field show the error indicator */
|
|
36
|
+
showError?: boolean;
|
|
37
|
+
/** Error message for this field, or undefined if valid */
|
|
38
|
+
error?: string;
|
|
39
|
+
/** Has this field been touched */
|
|
40
|
+
touched?: boolean;
|
|
41
|
+
/** Property related to this field */
|
|
42
|
+
property: P;
|
|
43
|
+
/** Should this field include a description */
|
|
44
|
+
includeDescription?: boolean;
|
|
45
|
+
/** Flag to indicate that the underlying value has been updated in the driver */
|
|
46
|
+
underlyingValueHasChanged?: boolean;
|
|
47
|
+
/** Is this field part of an array */
|
|
48
|
+
partOfArray?: boolean;
|
|
49
|
+
/** Is this field part of a block */
|
|
50
|
+
partOfBlock?: boolean;
|
|
51
|
+
/** Display the child properties directly, without being wrapped in an extendable panel */
|
|
52
|
+
minimalistView?: boolean;
|
|
53
|
+
/** Should this field autofocus on mount */
|
|
54
|
+
autoFocus?: boolean;
|
|
55
|
+
/** Additional properties set by the developer */
|
|
56
|
+
customProps?: CustomProps;
|
|
57
|
+
/** Additional values related to the state of the form or the entity */
|
|
58
|
+
context: FormContext<M>;
|
|
59
|
+
/** Flag to indicate if this field should be disabled */
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
/** Size of the field */
|
|
62
|
+
size?: "small" | "medium" | "large";
|
|
63
|
+
/** Callback when internal property state changes (e.g. panel expansion) */
|
|
64
|
+
onPropertyChange?: (property: Partial<Property>) => void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Interface used to define plugins for Rebase.
|
|
68
|
+
* Plugins contribute UI via **slots**, wrap subtrees with **providers**,
|
|
69
|
+
* and inject behavioral logic via **hooks**.
|
|
70
|
+
* @group Core
|
|
71
|
+
*/
|
|
72
|
+
export interface RebasePlugin {
|
|
73
|
+
/**
|
|
74
|
+
* Unique key identifying this plugin.
|
|
75
|
+
*/
|
|
76
|
+
key: string;
|
|
77
|
+
/**
|
|
78
|
+
* If true, no CMS content is shown until this plugin finishes loading.
|
|
79
|
+
*/
|
|
80
|
+
loading?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* UI slot contributions rendered at the matching extension points.
|
|
83
|
+
*/
|
|
84
|
+
slots?: SlotContribution[];
|
|
85
|
+
/**
|
|
86
|
+
* HOC providers wrapping root or form content.
|
|
87
|
+
* Providers with `scope: "root"` wrap the entire CMS below RebaseContext.
|
|
88
|
+
* Providers with `scope: "form"` wrap each entity form/edit view.
|
|
89
|
+
*/
|
|
90
|
+
providers?: PluginProvider[];
|
|
91
|
+
/**
|
|
92
|
+
* Behavioral hooks (non-UI) — collection modification, search blocking,
|
|
93
|
+
* column reordering, navigation entries, etc.
|
|
94
|
+
*/
|
|
95
|
+
hooks?: PluginHooks;
|
|
96
|
+
/**
|
|
97
|
+
* Field wrapping for custom field rendering (e.g. data enhancement).
|
|
98
|
+
*/
|
|
99
|
+
fieldBuilder?: FieldBuilderConfig;
|
|
100
|
+
/**
|
|
101
|
+
* Views to be automatically added to the navigation.
|
|
102
|
+
*/
|
|
103
|
+
views?: AppView[];
|
|
104
|
+
/**
|
|
105
|
+
* User management delegate from this plugin.
|
|
106
|
+
*/
|
|
107
|
+
userManagement?: UserManagementDelegate;
|
|
108
|
+
/**
|
|
109
|
+
* Optional lifecycle hooks. Called by the Rebase runtime
|
|
110
|
+
* at appropriate points in the app lifecycle.
|
|
111
|
+
*/
|
|
112
|
+
lifecycle?: PluginLifecycle;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A HOC provider that wraps a subtree of the CMS.
|
|
116
|
+
* @group Plugins
|
|
117
|
+
*/
|
|
118
|
+
export interface PluginProvider {
|
|
119
|
+
/**
|
|
120
|
+
* `"root"` — wraps the entire CMS below RebaseContext.
|
|
121
|
+
* `"form"` — wraps each entity form / edit view.
|
|
122
|
+
*/
|
|
123
|
+
scope: "root" | "form";
|
|
124
|
+
/**
|
|
125
|
+
* The provider component. Must accept `children`.
|
|
126
|
+
* Typed loosely because extra props are passed via the `props` field;
|
|
127
|
+
* strict signatures cause contravariance issues.
|
|
128
|
+
*/
|
|
129
|
+
Component: React.ComponentType<PropsWithChildren<Record<string, unknown>>>;
|
|
130
|
+
/**
|
|
131
|
+
* Additional props passed to the Component.
|
|
132
|
+
*/
|
|
133
|
+
props?: Record<string, unknown>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Behavioral hooks that a plugin can provide.
|
|
137
|
+
* These are non-UI extension points for modifying CMS behavior.
|
|
138
|
+
* @group Plugins
|
|
139
|
+
*/
|
|
140
|
+
export interface PluginHooks {
|
|
141
|
+
/**
|
|
142
|
+
* Modify a single collection before it is rendered (synchronous).
|
|
143
|
+
*/
|
|
144
|
+
modifyCollection?: (collection: EntityCollection) => EntityCollection;
|
|
145
|
+
/**
|
|
146
|
+
* Async version of modifyCollection — supports fetching remote config.
|
|
147
|
+
* Runs during navigation resolution. If provided alongside `modifyCollection`,
|
|
148
|
+
* the sync version runs first, then the async version.
|
|
149
|
+
*/
|
|
150
|
+
modifyCollectionAsync?: (collection: EntityCollection) => Promise<EntityCollection>;
|
|
151
|
+
/**
|
|
152
|
+
* Modify, add or remove collections.
|
|
153
|
+
*/
|
|
154
|
+
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
155
|
+
/**
|
|
156
|
+
* Callback called when columns are reordered via drag and drop.
|
|
157
|
+
*/
|
|
158
|
+
onColumnsReorder?: (props: {
|
|
159
|
+
fullPath: string;
|
|
160
|
+
parentCollectionIds: string[];
|
|
161
|
+
collection: EntityCollection;
|
|
162
|
+
newPropertiesOrder: string[];
|
|
163
|
+
}) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Callback called when Kanban board columns are reordered.
|
|
166
|
+
*/
|
|
167
|
+
onKanbanColumnsReorder?: (props: {
|
|
168
|
+
fullPath: string;
|
|
169
|
+
parentCollectionIds: string[];
|
|
170
|
+
collection: EntityCollection;
|
|
171
|
+
kanbanColumnProperty: string;
|
|
172
|
+
newColumnsOrder: string[];
|
|
173
|
+
}) => void;
|
|
174
|
+
/**
|
|
175
|
+
* Navigation entries contributed by this plugin.
|
|
176
|
+
*/
|
|
177
|
+
navigationEntries?: NavigationGroupMapping[];
|
|
178
|
+
/**
|
|
179
|
+
* Callback when navigation entry order changes (e.g. drag-and-drop).
|
|
180
|
+
*/
|
|
181
|
+
onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
|
|
182
|
+
/**
|
|
183
|
+
* Allow reordering collections in the home page via drag and drop.
|
|
184
|
+
*/
|
|
185
|
+
allowDragAndDrop?: boolean;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Lifecycle hooks for plugins. Called by the Rebase runtime
|
|
189
|
+
* at appropriate points in the app lifecycle.
|
|
190
|
+
* @group Plugins
|
|
191
|
+
*/
|
|
192
|
+
export interface PluginLifecycle {
|
|
193
|
+
/**
|
|
194
|
+
* Called once when the plugin is mounted in the Rebase tree.
|
|
195
|
+
* Can return a Promise for async initialization.
|
|
196
|
+
*/
|
|
197
|
+
onMount?: (context: RebaseContext) => void | Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Called when the plugin is unmounted from the Rebase tree.
|
|
200
|
+
* Use this for cleanup (subscriptions, timers, etc.).
|
|
201
|
+
*/
|
|
202
|
+
onUnmount?: () => void;
|
|
203
|
+
/**
|
|
204
|
+
* Called whenever the authentication state changes.
|
|
205
|
+
* Receives the new user (or null on sign-out).
|
|
206
|
+
*/
|
|
207
|
+
onAuthStateChange?: (user: User | null) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Called when a collection's visible entities change.
|
|
210
|
+
* Useful for analytics, caching, or cross-plugin coordination.
|
|
211
|
+
*/
|
|
212
|
+
onCollectionChange?: (slug: string, entities: unknown[]) => void;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Configuration for wrapping form field components.
|
|
216
|
+
* @group Plugins
|
|
217
|
+
*/
|
|
218
|
+
export interface FieldBuilderConfig {
|
|
219
|
+
/**
|
|
220
|
+
* Returns a wrapped field component, or null to skip wrapping.
|
|
221
|
+
*/
|
|
222
|
+
wrap: <T>(params: PluginFieldBuilderParams) => React.ComponentType<FieldProps<Property>> | null;
|
|
223
|
+
/**
|
|
224
|
+
* Optional guard — return false to skip wrapping for this field.
|
|
225
|
+
*/
|
|
226
|
+
enabled?: (params: PluginFieldBuilderParams) => boolean;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Props passed to home page collection card action components.
|
|
230
|
+
* @group Models
|
|
231
|
+
*/
|
|
232
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
233
|
+
slug: string;
|
|
234
|
+
collection: EC;
|
|
235
|
+
context: RebaseContext<USER>;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Props passed to form action components in entity edit/form views.
|
|
239
|
+
* @group Models
|
|
240
|
+
*/
|
|
241
|
+
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
242
|
+
entityId?: string | number;
|
|
243
|
+
path: string;
|
|
244
|
+
parentCollectionIds: string[];
|
|
245
|
+
status: EntityStatus;
|
|
246
|
+
collection: EC;
|
|
247
|
+
disabled: boolean;
|
|
248
|
+
formContext?: FormContext;
|
|
249
|
+
context: RebaseContext<USER>;
|
|
250
|
+
openEntityMode: "side_panel" | "full_screen" | "split";
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Parameters passed to the field builder wrap function.
|
|
254
|
+
* @group Models
|
|
255
|
+
*/
|
|
256
|
+
export type PluginFieldBuilderParams<M extends Record<string, unknown> = Record<string, unknown>, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
257
|
+
fieldConfigId: string;
|
|
258
|
+
propertyKey: string;
|
|
259
|
+
property: Property;
|
|
260
|
+
Field: React.ComponentType<FieldProps<Property, unknown, M>>;
|
|
261
|
+
plugin: RebasePlugin;
|
|
262
|
+
path?: string;
|
|
263
|
+
collection?: EC;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Generic props passed to plugin components that just need CMS context.
|
|
267
|
+
* @group Models
|
|
268
|
+
*/
|
|
269
|
+
export interface PluginGenericProps<USER extends User = User> {
|
|
270
|
+
context: RebaseContext<USER>;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Props for additional card components in the home page.
|
|
274
|
+
* @group Models
|
|
275
|
+
*/
|
|
276
|
+
export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
|
|
277
|
+
group?: string;
|
|
278
|
+
context: RebaseContext<USER>;
|
|
279
|
+
}
|