@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,160 @@
|
|
|
1
|
+
import type { Entity, EntityStatus, EntityValues } from "../types/entities";
|
|
2
|
+
import type { EntityCollection, FilterValues } from "../types/collections";
|
|
3
|
+
import type { RebaseContext } from "../rebase_context";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export interface FetchEntityProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
8
|
+
path: string;
|
|
9
|
+
entityId: string | number;
|
|
10
|
+
databaseId?: string;
|
|
11
|
+
collection?: EntityCollection<M>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export type ListenEntityProps<M extends Record<string, unknown> = Record<string, unknown>> = FetchEntityProps<M> & {
|
|
17
|
+
onUpdate: (entity: Entity<M> | null) => void;
|
|
18
|
+
onError?: (error: Error) => void;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export interface FetchCollectionProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
24
|
+
path: string;
|
|
25
|
+
collection?: EntityCollection<M>;
|
|
26
|
+
filter?: FilterValues<Extract<keyof M, string>>;
|
|
27
|
+
limit?: number;
|
|
28
|
+
offset?: number;
|
|
29
|
+
startAfter?: unknown;
|
|
30
|
+
orderBy?: string;
|
|
31
|
+
searchString?: string;
|
|
32
|
+
order?: "desc" | "asc";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export type ListenCollectionProps<M extends Record<string, unknown> = Record<string, unknown>> = FetchCollectionProps<M> & {
|
|
38
|
+
onUpdate: (entities: Entity<M>[]) => void;
|
|
39
|
+
onError?: (error: Error) => void;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export interface SaveEntityProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
45
|
+
path: string;
|
|
46
|
+
values: Partial<EntityValues<M>>;
|
|
47
|
+
entityId?: string | number;
|
|
48
|
+
previousValues?: Partial<EntityValues<M>>;
|
|
49
|
+
collection?: EntityCollection<M>;
|
|
50
|
+
status: EntityStatus;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export interface DeleteEntityProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
56
|
+
entity: Entity<M>;
|
|
57
|
+
collection?: EntityCollection<M>;
|
|
58
|
+
}
|
|
59
|
+
export type FilterCombinationValidProps = {
|
|
60
|
+
path: string;
|
|
61
|
+
databaseId?: string;
|
|
62
|
+
collection: EntityCollection;
|
|
63
|
+
filterValues: FilterValues<string>;
|
|
64
|
+
sortBy?: [string, "asc" | "desc"];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Internal driver interface for communicating with the data layer.
|
|
68
|
+
* This is NOT the public API — use `RebaseData` / `context.data` instead.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export interface DataDriver {
|
|
72
|
+
/**
|
|
73
|
+
* Key that identifies this driver
|
|
74
|
+
*/
|
|
75
|
+
key?: string;
|
|
76
|
+
/**
|
|
77
|
+
* If the driver has been initialised
|
|
78
|
+
*/
|
|
79
|
+
initialised?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Fetch data from a collection
|
|
82
|
+
* @param props
|
|
83
|
+
* @return Promise of entities
|
|
84
|
+
*/
|
|
85
|
+
fetchCollection<M extends Record<string, unknown> = Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<Entity<M>[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Listen to a collection in a given path. If you don't implement this method
|
|
88
|
+
* `fetchCollection` will be used instead, with no real time updates.
|
|
89
|
+
* @param props
|
|
90
|
+
* @return Function to cancel subscription
|
|
91
|
+
*/
|
|
92
|
+
listenCollection?<M extends Record<string, unknown> = Record<string, unknown>>(props: ListenCollectionProps<M>): () => void;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve an entity given a path and a collection
|
|
95
|
+
* @param props
|
|
96
|
+
*/
|
|
97
|
+
fetchEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
|
|
98
|
+
/**
|
|
99
|
+
* Get realtime updates on one entity.
|
|
100
|
+
* @param props
|
|
101
|
+
* @return Function to cancel subscription
|
|
102
|
+
*/
|
|
103
|
+
listenEntity?<M extends Record<string, unknown> = Record<string, unknown>>(props: ListenEntityProps<M>): () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Save entity to the specified path
|
|
106
|
+
* @param props
|
|
107
|
+
*/
|
|
108
|
+
saveEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: SaveEntityProps<M>): Promise<Entity<M>>;
|
|
109
|
+
/**
|
|
110
|
+
* Delete an entity
|
|
111
|
+
* @param props
|
|
112
|
+
* @return was the whole deletion flow successful
|
|
113
|
+
*/
|
|
114
|
+
deleteEntity<M extends Record<string, unknown> = Record<string, unknown>>(props: DeleteEntityProps<M>): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Check if the given property is unique in the given collection
|
|
117
|
+
* @param path Collection path
|
|
118
|
+
* @param name of the property
|
|
119
|
+
* @param value
|
|
120
|
+
* @param entityId
|
|
121
|
+
* @param collection
|
|
122
|
+
* @return `true` if there are no other fields besides the given entity
|
|
123
|
+
*/
|
|
124
|
+
checkUniqueField(path: string, name: string, value: unknown, entityId?: string | number, collection?: EntityCollection): Promise<boolean>;
|
|
125
|
+
/**
|
|
126
|
+
* Count the number of entities in a collection
|
|
127
|
+
*/
|
|
128
|
+
countEntities?<M extends Record<string, unknown> = Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<number>;
|
|
129
|
+
/**
|
|
130
|
+
* Check if the given filter combination is valid
|
|
131
|
+
* @param props
|
|
132
|
+
*/
|
|
133
|
+
isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection"> & {
|
|
134
|
+
databaseId?: string;
|
|
135
|
+
}): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Get the object to generate the current time in the driver
|
|
138
|
+
*/
|
|
139
|
+
currentTime?: () => unknown;
|
|
140
|
+
delegateToCMSModel?: (data: unknown) => unknown;
|
|
141
|
+
cmsToDelegateModel?: (data: unknown) => unknown;
|
|
142
|
+
initTextSearch?: (props: {
|
|
143
|
+
context: RebaseContext;
|
|
144
|
+
path: string;
|
|
145
|
+
databaseId?: string;
|
|
146
|
+
collection: EntityCollection;
|
|
147
|
+
parentCollectionIds?: string[];
|
|
148
|
+
}) => Promise<boolean>;
|
|
149
|
+
/**
|
|
150
|
+
* Flag to indicate if the driver has requested the initialization of the text search index
|
|
151
|
+
*/
|
|
152
|
+
needsInitTextSearch?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Return the admin capabilities of this driver.
|
|
155
|
+
* @see SQLAdmin
|
|
156
|
+
* @see DocumentAdmin
|
|
157
|
+
* @see SchemaAdmin
|
|
158
|
+
*/
|
|
159
|
+
admin?: import("../types/backend").DatabaseAdmin;
|
|
160
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module database_admin
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the capability-specific admin interfaces from `@rebasepro/types/backend`.
|
|
5
|
+
* This file is kept for backwards compatibility — new code should import from
|
|
6
|
+
* `@rebasepro/types` directly.
|
|
7
|
+
*
|
|
8
|
+
* @group Admin
|
|
9
|
+
*/
|
|
10
|
+
export type { SQLAdmin, DocumentAdmin, SchemaAdmin, DatabaseAdmin, HealthCheckResult } from "../types/backend";
|
|
11
|
+
export { isSQLAdmin, isDocumentAdmin, isSchemaAdmin } from "../types/backend";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Controller to open the side dialog
|
|
4
|
+
* @group Hooks and utilities
|
|
5
|
+
*/
|
|
6
|
+
export interface DialogsController {
|
|
7
|
+
/**
|
|
8
|
+
* Close the last dialog
|
|
9
|
+
*/
|
|
10
|
+
close: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Open a dialog
|
|
13
|
+
* @param props
|
|
14
|
+
*/
|
|
15
|
+
open: <T extends object = object>(props: DialogControllerEntryProps<T>) => {
|
|
16
|
+
closeDialog: () => void;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Props used to open a side dialog
|
|
21
|
+
* @group Hooks and utilities
|
|
22
|
+
*/
|
|
23
|
+
export interface DialogControllerEntryProps<T extends object = object> {
|
|
24
|
+
key: string;
|
|
25
|
+
/**
|
|
26
|
+
* The component type that will be rendered
|
|
27
|
+
*/
|
|
28
|
+
Component: React.ComponentType<{
|
|
29
|
+
open: boolean;
|
|
30
|
+
closeDialog: () => void;
|
|
31
|
+
} & T>;
|
|
32
|
+
/**
|
|
33
|
+
* Props to pass to the dialog component
|
|
34
|
+
*/
|
|
35
|
+
props?: T;
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email service types — portable interface shared by RebaseClient and server-core.
|
|
3
|
+
*
|
|
4
|
+
* The concrete SMTP implementation lives in `@rebasepro/server-core/email`.
|
|
5
|
+
* This file provides only the consumer-facing contract so that it can be
|
|
6
|
+
* referenced from `RebaseClient` without dragging in nodemailer.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Options for sending an email via the Rebase email service.
|
|
10
|
+
*/
|
|
11
|
+
export interface EmailSendOptions {
|
|
12
|
+
/** Recipient email address(es). */
|
|
13
|
+
to: string | string[];
|
|
14
|
+
/** Email subject line. */
|
|
15
|
+
subject: string;
|
|
16
|
+
/** HTML body content. */
|
|
17
|
+
html: string;
|
|
18
|
+
/** Optional plain-text fallback. */
|
|
19
|
+
text?: string;
|
|
20
|
+
/** Optional reply-to address. */
|
|
21
|
+
replyTo?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Abstraction over an email delivery backend.
|
|
25
|
+
*
|
|
26
|
+
* Implementations may use SMTP, AWS SES, Resend, Postmark, or any other
|
|
27
|
+
* provider — consumers only interact through this interface.
|
|
28
|
+
*/
|
|
29
|
+
export interface EmailService {
|
|
30
|
+
/** Send a single email. */
|
|
31
|
+
send(options: EmailSendOptions): Promise<void>;
|
|
32
|
+
/** Returns `true` when the service has valid credentials / is ready to send. */
|
|
33
|
+
isConfigured(): boolean;
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./collection_registry";
|
|
2
|
+
export * from "./analytics_controller";
|
|
3
|
+
export * from "./auth";
|
|
4
|
+
export * from "./data";
|
|
5
|
+
export * from "./database_admin";
|
|
6
|
+
export * from "./data_driver";
|
|
7
|
+
export * from "./local_config_persistence";
|
|
8
|
+
export * from "./navigation";
|
|
9
|
+
export * from "./effective_role";
|
|
10
|
+
export * from "./storage";
|
|
11
|
+
export * from "./email";
|
|
12
|
+
export * from "./client";
|
|
13
|
+
export * from "./customization_controller";
|
|
14
|
+
export * from "./side_entity_controller";
|
|
15
|
+
export * from "./side_dialogs_controller";
|
|
16
|
+
export * from "./dialogs_controller";
|
|
17
|
+
export * from "./snackbar";
|
|
18
|
+
export * from "./registry";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EntityCollection } from "../types/collections";
|
|
2
|
+
/**
|
|
3
|
+
* @group Models
|
|
4
|
+
*/
|
|
5
|
+
export type PartialEntityCollection<M extends Record<string, unknown> = Record<string, unknown>> = Partial<EntityCollection<M>>;
|
|
6
|
+
/**
|
|
7
|
+
* This interface is in charge of defining the controller that persists
|
|
8
|
+
* modifications to a collection or collection, and retrieves them back from
|
|
9
|
+
* a data source, such as local storage or Firestore.
|
|
10
|
+
*/
|
|
11
|
+
export interface UserConfigurationPersistence {
|
|
12
|
+
onCollectionModified: <M extends Record<string, unknown> = Record<string, unknown>>(path: string, partialCollection: PartialEntityCollection<M>) => void;
|
|
13
|
+
getCollectionConfig: <M extends Record<string, unknown> = Record<string, unknown>>(path: string) => PartialEntityCollection<M>;
|
|
14
|
+
recentlyVisitedPaths: string[];
|
|
15
|
+
setRecentlyVisitedPaths: (paths: string[]) => void;
|
|
16
|
+
favouritePaths: string[];
|
|
17
|
+
setFavouritePaths: (paths: string[]) => void;
|
|
18
|
+
collapsedGroups: string[];
|
|
19
|
+
setCollapsedGroups: (paths: string[]) => void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { EntityCollection } from "../types/collections";
|
|
3
|
+
import type { RebasePlugin } from "../types/plugins";
|
|
4
|
+
/**
|
|
5
|
+
* Controller that handles URL path building and resolution.
|
|
6
|
+
* @group Models
|
|
7
|
+
*/
|
|
8
|
+
export type UrlController = {
|
|
9
|
+
/**
|
|
10
|
+
* Default path under the navigation routes of the CMS will be created.
|
|
11
|
+
* Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
|
|
12
|
+
*/
|
|
13
|
+
basePath: string;
|
|
14
|
+
/**
|
|
15
|
+
* Default path under the collection routes of the CMS will be created.
|
|
16
|
+
* It defaults to '/c'
|
|
17
|
+
*/
|
|
18
|
+
baseCollectionPath: string;
|
|
19
|
+
/**
|
|
20
|
+
* Convert a URL path to a collection or entity path
|
|
21
|
+
* `/c/products` => `products`
|
|
22
|
+
* `/my_cms/c/products/B34SAP8Z` => `products/B34SAP8Z`
|
|
23
|
+
* `/my_cms/my_view` => `my_view`
|
|
24
|
+
* @param cmsPath
|
|
25
|
+
*/
|
|
26
|
+
urlPathToDataPath: (cmsPath: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Base url path for the home screen
|
|
29
|
+
*/
|
|
30
|
+
homeUrl: string;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a url path belongs to a collection
|
|
33
|
+
* @param path
|
|
34
|
+
*/
|
|
35
|
+
isUrlCollectionPath: (urlPath: string) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Build a URL collection path from a data path
|
|
38
|
+
* `products` => `/c/products`
|
|
39
|
+
* `products/B34SAP8Z` => `/c/products/B34SAP8Z`
|
|
40
|
+
* @param path
|
|
41
|
+
*/
|
|
42
|
+
buildUrlCollectionPath: (path: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Build a URL path for the CMS (e.g. for custom views)
|
|
45
|
+
* @param path
|
|
46
|
+
*/
|
|
47
|
+
buildAppUrlPath: (path: string) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Turn a path with collection ids into a resolved path.
|
|
50
|
+
* The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
|
|
51
|
+
* @param path
|
|
52
|
+
*/
|
|
53
|
+
resolveDatabasePathsFrom: (path: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* A function to navigate to a specified route or URL.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} to - The target route or URL to navigate to.
|
|
58
|
+
* @param {NavigateOptions} [options] - Optional configuration settings for navigation, such as replace behavior or state data.
|
|
59
|
+
*/
|
|
60
|
+
navigate: (to: string, options?: NavigateOptions) => void;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Controller that manages the state of the navigation menu,
|
|
64
|
+
* including resolved views and top-level grouping.
|
|
65
|
+
* @group Models
|
|
66
|
+
*/
|
|
67
|
+
export type NavigationStateController = {
|
|
68
|
+
/**
|
|
69
|
+
* Custom additional views created by the developer, added to the main
|
|
70
|
+
* navigation
|
|
71
|
+
*/
|
|
72
|
+
views?: AppView[];
|
|
73
|
+
/**
|
|
74
|
+
* Custom additional views created by the developer, added to the admin
|
|
75
|
+
* navigation
|
|
76
|
+
*/
|
|
77
|
+
adminViews?: AppView[];
|
|
78
|
+
/**
|
|
79
|
+
* Configuration for the views that should be displayed at the top
|
|
80
|
+
* level of the navigation (e.g. in the home page or the navigation
|
|
81
|
+
* drawer)
|
|
82
|
+
*/
|
|
83
|
+
topLevelNavigation?: NavigationResult;
|
|
84
|
+
/**
|
|
85
|
+
* Is the navigation loading (the configuration persistence has not
|
|
86
|
+
* loaded yet, or a specified navigation builder has not completed)
|
|
87
|
+
*/
|
|
88
|
+
loading: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Was there an error while loading the navigation data
|
|
91
|
+
*/
|
|
92
|
+
navigationLoadingError?: unknown;
|
|
93
|
+
/**
|
|
94
|
+
* Call this method to recalculate the navigation
|
|
95
|
+
*/
|
|
96
|
+
refreshNavigation: () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Plugin system allowing to extend the CMS functionality.
|
|
99
|
+
*/
|
|
100
|
+
plugins?: RebasePlugin[];
|
|
101
|
+
};
|
|
102
|
+
export interface NavigateOptions {
|
|
103
|
+
replace?: boolean;
|
|
104
|
+
state?: unknown;
|
|
105
|
+
preventScrollReset?: boolean;
|
|
106
|
+
relative?: "route" | "path";
|
|
107
|
+
flushSync?: boolean;
|
|
108
|
+
viewTransition?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export type NavigationBlocker = {
|
|
111
|
+
updateBlockListener: (path: string, block: boolean, basePath?: string) => () => void;
|
|
112
|
+
isBlocked: (path: string) => boolean;
|
|
113
|
+
proceed?: () => void;
|
|
114
|
+
reset?: () => void;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Custom additional views created by the developer, added to the main
|
|
118
|
+
* navigation.
|
|
119
|
+
* @group Models
|
|
120
|
+
*/
|
|
121
|
+
export interface AppView {
|
|
122
|
+
/**
|
|
123
|
+
* CMS Path you can reach this view from.
|
|
124
|
+
*/
|
|
125
|
+
slug: string;
|
|
126
|
+
/**
|
|
127
|
+
* Name of this view
|
|
128
|
+
*/
|
|
129
|
+
name: string;
|
|
130
|
+
/**
|
|
131
|
+
* Optional description of this view. You can use Markdown
|
|
132
|
+
*/
|
|
133
|
+
description?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Icon key to use in this view.
|
|
136
|
+
* You can use any of the icons in the Lucide specs:
|
|
137
|
+
* https://lucide.dev/icons/
|
|
138
|
+
* e.g. 'ShoppingCart' or 'User'
|
|
139
|
+
* Find all the icons in https://rebase.pro/docs/icons
|
|
140
|
+
*/
|
|
141
|
+
icon?: string | React.ReactNode;
|
|
142
|
+
/**
|
|
143
|
+
* Should this view be hidden from the main navigation panel.
|
|
144
|
+
* It will still be accessible if you reach the specified path
|
|
145
|
+
*/
|
|
146
|
+
hideFromNavigation?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Component to be rendered. This can be any React component, and can use
|
|
149
|
+
* any of the provided hooks
|
|
150
|
+
*/
|
|
151
|
+
view: React.ReactNode;
|
|
152
|
+
/**
|
|
153
|
+
* Optional field used to group top level navigation entries under a
|
|
154
|
+
* navigation view.
|
|
155
|
+
* This prop is ignored for admin views.
|
|
156
|
+
*/
|
|
157
|
+
group?: string;
|
|
158
|
+
/**
|
|
159
|
+
* If true, a wildcard route (slug/*) is automatically registered
|
|
160
|
+
* alongside the base route, enabling nested navigation within this view.
|
|
161
|
+
*/
|
|
162
|
+
nestedRoutes?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* A composable section that can be rendered on the home page.
|
|
166
|
+
* Use this to add custom content alongside the auto-generated
|
|
167
|
+
* navigation groups.
|
|
168
|
+
* @group Models
|
|
169
|
+
*/
|
|
170
|
+
export interface HomePageSection {
|
|
171
|
+
/**
|
|
172
|
+
* Unique key for this section.
|
|
173
|
+
*/
|
|
174
|
+
key: string;
|
|
175
|
+
/**
|
|
176
|
+
* Title displayed as the section header.
|
|
177
|
+
*/
|
|
178
|
+
title: string;
|
|
179
|
+
/**
|
|
180
|
+
* Arbitrary React content rendered inside the section.
|
|
181
|
+
*/
|
|
182
|
+
children: React.ReactNode;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Used to group navigation entries in the main navigation.
|
|
186
|
+
*/
|
|
187
|
+
export interface NavigationGroupMapping {
|
|
188
|
+
/**
|
|
189
|
+
* Name of the group, used to display the group header in the UI
|
|
190
|
+
*/
|
|
191
|
+
name: string;
|
|
192
|
+
/**
|
|
193
|
+
* List of collection ids or view paths that belong to this group.
|
|
194
|
+
*/
|
|
195
|
+
entries: string[];
|
|
196
|
+
}
|
|
197
|
+
export interface NavigationEntry {
|
|
198
|
+
id: string;
|
|
199
|
+
url: string;
|
|
200
|
+
name: string;
|
|
201
|
+
slug: string;
|
|
202
|
+
type: "collection" | "view" | "admin";
|
|
203
|
+
collection?: EntityCollection;
|
|
204
|
+
view?: AppView;
|
|
205
|
+
description?: string;
|
|
206
|
+
group: string;
|
|
207
|
+
}
|
|
208
|
+
export type NavigationResult = {
|
|
209
|
+
allowDragAndDrop: boolean;
|
|
210
|
+
navigationEntries: NavigationEntry[];
|
|
211
|
+
groups: string[];
|
|
212
|
+
onNavigationEntriesUpdate: (entries: NavigationGroupMapping[]) => void;
|
|
213
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import type { EntityCollection } from "../types/collections";
|
|
3
|
+
import type { EntityCollectionsBuilder } from "../types/builders";
|
|
4
|
+
import type { EntityCustomView } from "../types/entity_views";
|
|
5
|
+
import type { EntityAction } from "../types/entity_actions";
|
|
6
|
+
import type { AppView } from "./navigation";
|
|
7
|
+
/**
|
|
8
|
+
* Options to enable the built-in collection editor.
|
|
9
|
+
* When provided to `<RebaseCMS>`, the editor is auto-wired as a native feature.
|
|
10
|
+
*/
|
|
11
|
+
export interface CollectionEditorOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Function that returns an auth token for schema-editor API calls.
|
|
14
|
+
* Falls back to `authController.getAuthToken` when omitted.
|
|
15
|
+
*/
|
|
16
|
+
getAuthToken?: () => Promise<string | null>;
|
|
17
|
+
/** Mark the editor as read-only (disable mutations). */
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
/** Suggested base paths shown when creating new collections. */
|
|
20
|
+
pathSuggestions?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface RebaseCMSConfig<EC extends EntityCollection = any> {
|
|
23
|
+
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
24
|
+
homePage?: ReactNode;
|
|
25
|
+
entityViews?: EntityCustomView<any>[];
|
|
26
|
+
entityActions?: EntityAction[];
|
|
27
|
+
plugins?: any[];
|
|
28
|
+
/**
|
|
29
|
+
* Enable the built-in visual collection/schema editor.
|
|
30
|
+
* Pass `true` for zero-config, or an options object for fine-grained control.
|
|
31
|
+
* When enabled, the editor slots, provider, and Studio schema view
|
|
32
|
+
* are all auto-wired — no plugin or manual view injection needed.
|
|
33
|
+
*/
|
|
34
|
+
collectionEditor?: boolean | CollectionEditorOptions;
|
|
35
|
+
}
|
|
36
|
+
export interface RebaseStudioConfig {
|
|
37
|
+
tools?: ("sql" | "js" | "rls" | "schema" | "storage" | "cron" | "schema-visualizer" | "branches" | "api")[];
|
|
38
|
+
homePage?: ReactNode;
|
|
39
|
+
devViews?: AppView[];
|
|
40
|
+
}
|
|
41
|
+
export interface RebaseAuthConfig {
|
|
42
|
+
loginView?: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
export interface RebaseRegistryController {
|
|
45
|
+
cmsConfig: RebaseCMSConfig | null;
|
|
46
|
+
studioConfig: RebaseStudioConfig | null;
|
|
47
|
+
authConfig: RebaseAuthConfig | null;
|
|
48
|
+
registerCMS: (config: RebaseCMSConfig) => void;
|
|
49
|
+
unregisterCMS: () => void;
|
|
50
|
+
registerStudio: (config: RebaseStudioConfig) => void;
|
|
51
|
+
unregisterStudio: () => void;
|
|
52
|
+
registerAuth: (config: RebaseAuthConfig) => void;
|
|
53
|
+
unregisterAuth: () => void;
|
|
54
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Controller to open the side dialog
|
|
4
|
+
* @group Hooks and utilities
|
|
5
|
+
*/
|
|
6
|
+
export interface SideDialogsController {
|
|
7
|
+
/**
|
|
8
|
+
* Close the last panel
|
|
9
|
+
*/
|
|
10
|
+
close: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* List of side panels currently open
|
|
13
|
+
*/
|
|
14
|
+
sidePanels: SideDialogPanelProps[];
|
|
15
|
+
/**
|
|
16
|
+
* Override the current side panels
|
|
17
|
+
* @param panels
|
|
18
|
+
*/
|
|
19
|
+
setSidePanels: (panels: SideDialogPanelProps[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Open one or multiple side panels
|
|
22
|
+
* @param props
|
|
23
|
+
*/
|
|
24
|
+
open: (panelProps: SideDialogPanelProps | SideDialogPanelProps[]) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Replace the last open panel with the given one
|
|
27
|
+
* @param props
|
|
28
|
+
*/
|
|
29
|
+
replace: (panelProps: SideDialogPanelProps | SideDialogPanelProps[]) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Props used to open a side dialog
|
|
33
|
+
* @group Hooks and utilities
|
|
34
|
+
*/
|
|
35
|
+
export interface SideDialogPanelProps {
|
|
36
|
+
/**
|
|
37
|
+
* A key that identifies this panel
|
|
38
|
+
*/
|
|
39
|
+
key: string;
|
|
40
|
+
/**
|
|
41
|
+
* The component type that will be rendered
|
|
42
|
+
*/
|
|
43
|
+
component: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Optional width of the panel
|
|
46
|
+
*/
|
|
47
|
+
width?: string;
|
|
48
|
+
/**
|
|
49
|
+
* When open, change the URL to this path.
|
|
50
|
+
* Note that if you want to restore state from a URL you need to add the
|
|
51
|
+
* logic yourself by listening to URL updates, and probably call `open`.
|
|
52
|
+
*/
|
|
53
|
+
urlPath?: string;
|
|
54
|
+
/**
|
|
55
|
+
* If the navigation stack is empty (you landed in the `urlPath` url), what
|
|
56
|
+
* url path to change to when the panel gets closed.
|
|
57
|
+
*/
|
|
58
|
+
parentUrlPath?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Callback when the panel is closed
|
|
61
|
+
*/
|
|
62
|
+
onClose?: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Use this prop to store additional data in the panel
|
|
65
|
+
*/
|
|
66
|
+
additional?: unknown;
|
|
67
|
+
}
|