@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,213 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EntityCollection } from "../types/collections";
|
|
3
|
+
import { 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 Material specs:
|
|
137
|
+
* https://fonts.google.com/icons
|
|
138
|
+
* e.g. 'account_tree' or 'person'
|
|
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,51 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { EntityCollection, EntityCollectionsBuilder, EntityCustomView, EntityAction } from "../types";
|
|
3
|
+
import { AppView } from "./navigation";
|
|
4
|
+
/**
|
|
5
|
+
* Options to enable the built-in collection editor.
|
|
6
|
+
* When provided to `<RebaseCMS>`, the editor is auto-wired as a native feature.
|
|
7
|
+
*/
|
|
8
|
+
export interface CollectionEditorOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Function that returns an auth token for schema-editor API calls.
|
|
11
|
+
* Falls back to `authController.getAuthToken` when omitted.
|
|
12
|
+
*/
|
|
13
|
+
getAuthToken?: () => Promise<string | null>;
|
|
14
|
+
/** Mark the editor as read-only (disable mutations). */
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
/** Suggested base paths shown when creating new collections. */
|
|
17
|
+
pathSuggestions?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface RebaseCMSConfig<EC extends EntityCollection = any> {
|
|
20
|
+
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
21
|
+
homePage?: ReactNode;
|
|
22
|
+
entityViews?: EntityCustomView<any>[];
|
|
23
|
+
entityActions?: EntityAction[];
|
|
24
|
+
plugins?: any[];
|
|
25
|
+
/**
|
|
26
|
+
* Enable the built-in visual collection/schema editor.
|
|
27
|
+
* Pass `true` for zero-config, or an options object for fine-grained control.
|
|
28
|
+
* When enabled, the editor slots, provider, and Studio schema view
|
|
29
|
+
* are all auto-wired — no plugin or manual view injection needed.
|
|
30
|
+
*/
|
|
31
|
+
collectionEditor?: boolean | CollectionEditorOptions;
|
|
32
|
+
}
|
|
33
|
+
export interface RebaseStudioConfig {
|
|
34
|
+
tools?: ("sql" | "js" | "rls" | "schema" | "storage")[];
|
|
35
|
+
homePage?: ReactNode;
|
|
36
|
+
devViews?: AppView[];
|
|
37
|
+
}
|
|
38
|
+
export interface RebaseAuthConfig {
|
|
39
|
+
loginView?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export interface RebaseRegistryController {
|
|
42
|
+
cmsConfig: RebaseCMSConfig | null;
|
|
43
|
+
studioConfig: RebaseStudioConfig | null;
|
|
44
|
+
authConfig: RebaseAuthConfig | null;
|
|
45
|
+
registerCMS: (config: RebaseCMSConfig) => void;
|
|
46
|
+
unregisterCMS: () => void;
|
|
47
|
+
registerStudio: (config: RebaseStudioConfig) => void;
|
|
48
|
+
unregisterStudio: () => void;
|
|
49
|
+
registerAuth: (config: RebaseAuthConfig) => void;
|
|
50
|
+
unregisterAuth: () => void;
|
|
51
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Entity, EntityCollection } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Props used to open a side dialog
|
|
4
|
+
* @group Hooks and utilities
|
|
5
|
+
*/
|
|
6
|
+
export interface EntitySidePanelProps<M extends Record<string, any> = any> {
|
|
7
|
+
/**
|
|
8
|
+
* Absolute path of the entity
|
|
9
|
+
*/
|
|
10
|
+
path: string;
|
|
11
|
+
/**
|
|
12
|
+
* ID of the entity, if not set, it means we are creating a new entity
|
|
13
|
+
*/
|
|
14
|
+
entityId?: string | number;
|
|
15
|
+
/**
|
|
16
|
+
* Set this flag to true if you want to make a copy of an existing entity
|
|
17
|
+
*/
|
|
18
|
+
copy?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Open the entity with a selected sub-collection view. If the panel for this
|
|
21
|
+
* entity was already open, it is replaced.
|
|
22
|
+
*/
|
|
23
|
+
selectedTab?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Use this prop to override the width of the form view.
|
|
26
|
+
* e.g. "600px"
|
|
27
|
+
*/
|
|
28
|
+
width?: number | string;
|
|
29
|
+
/**
|
|
30
|
+
* Collection representing the entities of this view.
|
|
31
|
+
* If you leave it blank it will be induced by your navigation
|
|
32
|
+
*/
|
|
33
|
+
collection?: EntityCollection<M>;
|
|
34
|
+
/**
|
|
35
|
+
* Should update the URL when opening the dialog.
|
|
36
|
+
* Consider that if the collection that you provide is not defined in the base
|
|
37
|
+
* config of your `Rebase` component, you will not be able to recreate
|
|
38
|
+
* the state if copying the URL to a different window.
|
|
39
|
+
*/
|
|
40
|
+
updateUrl?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Callback when the entity is updated
|
|
43
|
+
* @param params
|
|
44
|
+
*/
|
|
45
|
+
onUpdate?: (params: {
|
|
46
|
+
entity: Entity<any>;
|
|
47
|
+
}) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Callback when the dialog is closed
|
|
50
|
+
*/
|
|
51
|
+
onClose?: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Should this panel close when saving
|
|
54
|
+
*/
|
|
55
|
+
closeOnSave?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Override some form properties
|
|
58
|
+
*/
|
|
59
|
+
formProps?: any;
|
|
60
|
+
/**
|
|
61
|
+
* Allow the user to open the entity fullscreen
|
|
62
|
+
*/
|
|
63
|
+
allowFullScreen?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Controller to open the side dialog displaying entity forms
|
|
67
|
+
* @group Hooks and utilities
|
|
68
|
+
*/
|
|
69
|
+
export interface SideEntityController {
|
|
70
|
+
/**
|
|
71
|
+
* Close the last panel
|
|
72
|
+
*/
|
|
73
|
+
close: () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Open a new entity sideDialog. By default, the collection and configuration
|
|
76
|
+
* of the view is fetched from the collections you have specified in the
|
|
77
|
+
* navigation.
|
|
78
|
+
* At least you need to pass the path of the entity you would like
|
|
79
|
+
* to edit. You can set an entityId if you would like to edit and existing one
|
|
80
|
+
* (or a new one with that id).
|
|
81
|
+
* @param props
|
|
82
|
+
*/
|
|
83
|
+
open: <M extends Record<string, any> = any>(props: EntitySidePanelProps<M>) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Replace the last open entity panel with the given one.
|
|
86
|
+
* @param props
|
|
87
|
+
*/
|
|
88
|
+
replace: <M extends Record<string, any> = any>(props: EntitySidePanelProps<M>) => void;
|
|
89
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Possible snackbar types
|
|
3
|
+
* @group Hooks and utilities
|
|
4
|
+
*/
|
|
5
|
+
export type SnackbarMessageType = "success" | "info" | "warning" | "error";
|
|
6
|
+
/**
|
|
7
|
+
* Controller to display snackbars
|
|
8
|
+
* @group Hooks and utilities
|
|
9
|
+
*/
|
|
10
|
+
export interface SnackbarController {
|
|
11
|
+
/**
|
|
12
|
+
* Close the currently open snackbar
|
|
13
|
+
*/
|
|
14
|
+
close: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Display a new snackbar. You need to specify the type and message.
|
|
17
|
+
* You can optionally specify a title
|
|
18
|
+
*/
|
|
19
|
+
open: (props: {
|
|
20
|
+
type: SnackbarMessageType;
|
|
21
|
+
message: React.ReactNode;
|
|
22
|
+
autoHideDuration?: number;
|
|
23
|
+
}) => void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @group Models
|
|
3
|
+
*/
|
|
4
|
+
export interface UploadFileProps {
|
|
5
|
+
file: File;
|
|
6
|
+
fileName?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
bucket?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @group Models
|
|
13
|
+
*/
|
|
14
|
+
export interface UploadFileResult {
|
|
15
|
+
/**
|
|
16
|
+
* Storage path including the file name where the file was uploaded.
|
|
17
|
+
*/
|
|
18
|
+
path: string;
|
|
19
|
+
/**
|
|
20
|
+
* Bucket where the file was uploaded
|
|
21
|
+
*/
|
|
22
|
+
bucket: string;
|
|
23
|
+
/**
|
|
24
|
+
* Fully qualified storage URL for the uploaded file.
|
|
25
|
+
*
|
|
26
|
+
* For example: `gs://my-bucket/path/to/file.png`.
|
|
27
|
+
*
|
|
28
|
+
* This is optional for backwards compatibility.
|
|
29
|
+
*/
|
|
30
|
+
storageUrl?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @group Models
|
|
34
|
+
*/
|
|
35
|
+
export interface DownloadConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Temporal url that can be used to download the file
|
|
38
|
+
*/
|
|
39
|
+
url: string | null;
|
|
40
|
+
metadata?: DownloadMetadata;
|
|
41
|
+
fileNotFound?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The full set of object metadata, including read-only properties.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare interface DownloadMetadata {
|
|
48
|
+
/**
|
|
49
|
+
* The bucket this object is contained in.
|
|
50
|
+
*/
|
|
51
|
+
bucket: string;
|
|
52
|
+
/**
|
|
53
|
+
* The full path of this object.
|
|
54
|
+
*/
|
|
55
|
+
fullPath: string;
|
|
56
|
+
/**
|
|
57
|
+
* The short name of this object, which is the last component of the full path.
|
|
58
|
+
* For example, if path is 'full/path/image.png', name is 'image.png'.
|
|
59
|
+
*/
|
|
60
|
+
name: string;
|
|
61
|
+
/**
|
|
62
|
+
* The size of this object, in bytes.
|
|
63
|
+
*/
|
|
64
|
+
size: number;
|
|
65
|
+
/**
|
|
66
|
+
* Type of the uploaded file
|
|
67
|
+
* e.g. "image/jpeg"
|
|
68
|
+
*/
|
|
69
|
+
contentType: string;
|
|
70
|
+
customMetadata: Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @group Models
|
|
74
|
+
*/
|
|
75
|
+
export interface StorageSource {
|
|
76
|
+
/**
|
|
77
|
+
* Upload a file, specifying a name and a path
|
|
78
|
+
* @param file
|
|
79
|
+
* @param fileName
|
|
80
|
+
* @param path
|
|
81
|
+
* @param metadata
|
|
82
|
+
* @param bucket
|
|
83
|
+
*/
|
|
84
|
+
uploadFile: ({ file, fileName, path, metadata, bucket }: UploadFileProps) => Promise<UploadFileResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Convert a storage path or URL into a download configuration
|
|
87
|
+
* @param path
|
|
88
|
+
* @param bucket
|
|
89
|
+
*/
|
|
90
|
+
getDownloadURL: (pathOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
|
|
91
|
+
/**
|
|
92
|
+
* Get a file from a storage path.
|
|
93
|
+
* It returns null if the file does not exist.
|
|
94
|
+
* @param props
|
|
95
|
+
* @param bucket
|
|
96
|
+
*/
|
|
97
|
+
getFile: (path: string, bucket?: string) => Promise<File | null>;
|
|
98
|
+
/**
|
|
99
|
+
* Delete a file.
|
|
100
|
+
* @param path
|
|
101
|
+
* @param bucket
|
|
102
|
+
*/
|
|
103
|
+
deleteFile: (path: string, bucket?: string) => Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* List the contents of a path.
|
|
106
|
+
* @param path
|
|
107
|
+
* @param options
|
|
108
|
+
*/
|
|
109
|
+
list: (path: string, options?: {
|
|
110
|
+
bucket?: string;
|
|
111
|
+
maxResults?: number;
|
|
112
|
+
pageToken?: string;
|
|
113
|
+
}) => Promise<StorageListResult>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Result returned by list().
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export declare interface StorageListResult {
|
|
120
|
+
/**
|
|
121
|
+
* References to prefixes (sub-folders). You can call list() on them to
|
|
122
|
+
* get its contents.
|
|
123
|
+
*
|
|
124
|
+
* Folders are implicit based on '/' in the object paths.
|
|
125
|
+
* For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
|
|
126
|
+
* will return '/a/b' as a prefix.
|
|
127
|
+
*/
|
|
128
|
+
prefixes: StorageReference[];
|
|
129
|
+
/**
|
|
130
|
+
* Objects in this directory.
|
|
131
|
+
* You can call getMetadata() and getDownloadUrl() on them.
|
|
132
|
+
*/
|
|
133
|
+
items: StorageReference[];
|
|
134
|
+
/**
|
|
135
|
+
* If set, there might be more results for this list. Use this token to resume the list.
|
|
136
|
+
*/
|
|
137
|
+
nextPageToken?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Represents a reference to a Google Cloud Storage object. Developers can
|
|
141
|
+
* upload, download, and delete objects, as well as get/set object metadata.
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare interface StorageReference {
|
|
145
|
+
/**
|
|
146
|
+
* Returns a gs:// URL for this object in the form
|
|
147
|
+
* `gs://<bucket>/<path>/<to>/<object>`
|
|
148
|
+
* @returns The gs:// URL.
|
|
149
|
+
*/
|
|
150
|
+
toString(): string;
|
|
151
|
+
/**
|
|
152
|
+
* A reference to the root of this object's bucket.
|
|
153
|
+
*/
|
|
154
|
+
root: StorageReference;
|
|
155
|
+
/**
|
|
156
|
+
* The name of the bucket containing this reference's object.
|
|
157
|
+
*/
|
|
158
|
+
bucket: string;
|
|
159
|
+
/**
|
|
160
|
+
* The full path of this object.
|
|
161
|
+
*/
|
|
162
|
+
fullPath: string;
|
|
163
|
+
/**
|
|
164
|
+
* The short name of this object, which is the last component of the full path.
|
|
165
|
+
* For example, if path is 'full/path/image.png', name is 'image.png'.
|
|
166
|
+
*/
|
|
167
|
+
name: string;
|
|
168
|
+
/**
|
|
169
|
+
* A reference pointing to the parent location of this reference, or null if
|
|
170
|
+
* this reference is the root.
|
|
171
|
+
*/
|
|
172
|
+
parent: StorageReference | null;
|
|
173
|
+
}
|