@rebasepro/types 0.0.1-canary.0 → 0.0.1-canary.0e2f892
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/README.md +1 -1
- package/dist/controllers/analytics_controller.d.ts +2 -2
- package/dist/controllers/auth.d.ts +52 -6
- package/dist/controllers/client.d.ts +170 -0
- package/dist/controllers/collection_registry.d.ts +45 -0
- package/dist/controllers/customization_controller.d.ts +11 -1
- package/dist/controllers/data.d.ts +168 -0
- package/dist/controllers/data_driver.d.ts +160 -0
- package/dist/controllers/database_admin.d.ts +11 -0
- package/dist/controllers/effective_role.d.ts +4 -0
- package/dist/controllers/email.d.ts +34 -0
- package/dist/controllers/index.d.ts +12 -5
- package/dist/controllers/local_config_persistence.d.ts +4 -4
- package/dist/controllers/navigation.d.ts +12 -61
- package/dist/controllers/registry.d.ts +54 -0
- package/dist/controllers/side_entity_controller.d.ts +7 -7
- package/dist/controllers/storage.d.ts +24 -26
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +119 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +118 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/rebase_context.d.ts +40 -26
- package/dist/types/backend.d.ts +300 -18
- package/dist/types/builders.d.ts +15 -0
- package/dist/types/chips.d.ts +1 -1
- package/dist/types/collections.d.ts +324 -355
- package/dist/types/cron.d.ts +102 -0
- package/dist/types/data_source.d.ts +64 -0
- package/dist/types/entities.d.ts +29 -24
- package/dist/types/entity_actions.d.ts +12 -12
- package/dist/types/entity_callbacks.d.ts +12 -12
- package/dist/types/entity_link_builder.d.ts +1 -1
- package/dist/types/entity_overrides.d.ts +7 -2
- package/dist/types/entity_views.d.ts +61 -0
- package/dist/types/export_import.d.ts +3 -3
- package/dist/types/index.d.ts +9 -5
- package/dist/types/plugins.d.ts +228 -225
- package/dist/types/properties.d.ts +135 -62
- package/dist/types/property_config.d.ts +13 -11
- package/dist/types/relations.d.ts +1 -1
- package/dist/types/slots.d.ts +252 -0
- package/dist/types/translations.d.ts +870 -0
- package/dist/types/user_management_delegate.d.ts +43 -0
- package/dist/types/websockets.d.ts +45 -0
- package/dist/users/user.d.ts +4 -0
- package/package.json +99 -131
- package/src/controllers/analytics_controller.tsx +2 -2
- package/src/controllers/auth.tsx +55 -6
- package/src/controllers/client.ts +133 -0
- package/src/controllers/collection_registry.ts +57 -0
- package/src/controllers/customization_controller.tsx +12 -1
- package/src/controllers/data.ts +191 -0
- package/src/controllers/{datasource.ts → data_driver.ts} +50 -61
- package/src/controllers/database_admin.ts +22 -0
- package/src/controllers/effective_role.ts +4 -0
- package/src/controllers/email.ts +36 -0
- package/src/controllers/index.ts +15 -5
- package/src/controllers/local_config_persistence.tsx +4 -4
- package/src/controllers/navigation.ts +13 -76
- package/src/controllers/registry.ts +65 -0
- package/src/controllers/side_entity_controller.tsx +7 -7
- package/src/controllers/storage.ts +25 -28
- package/src/index.ts +0 -1
- package/src/rebase_context.tsx +41 -39
- package/src/types/backend.ts +359 -24
- package/src/types/builders.ts +17 -0
- package/src/types/chips.ts +15 -40
- package/src/types/collections.ts +375 -383
- package/src/types/cron.ts +149 -0
- package/src/types/data_source.ts +145 -0
- package/src/types/entities.ts +40 -33
- package/src/types/entity_actions.tsx +11 -11
- package/src/types/entity_callbacks.ts +12 -12
- package/src/types/entity_link_builder.ts +1 -1
- package/src/types/entity_overrides.tsx +7 -2
- package/src/types/entity_views.tsx +77 -0
- package/src/types/export_import.ts +3 -3
- package/src/types/index.ts +10 -5
- package/src/types/plugins.tsx +280 -261
- package/src/types/properties.ts +163 -61
- package/src/types/property_config.tsx +11 -11
- package/src/types/relations.ts +1 -1
- package/src/types/slots.tsx +297 -0
- package/src/types/translations.ts +977 -0
- package/src/types/user_management_delegate.ts +50 -7
- package/src/types/websockets.ts +48 -0
- package/src/users/roles.ts +0 -1
- package/src/users/user.ts +5 -0
- package/dist/components/EntityFormActionsProps.d.ts +0 -17
- package/dist/components/EntityFormProps.d.ts +0 -46
- package/dist/components/PropertyPreviewProps.d.ts +0 -50
- package/dist/components/formex.d.ts +0 -40
- package/dist/components/index.d.ts +0 -3
- package/dist/controllers/datasource.d.ts +0 -179
- package/dist/types/fields.d.ts +0 -221
- package/dist/types/rebase.d.ts +0 -180
- package/src/components/EntityFormActionsProps.tsx +0 -18
- package/src/components/EntityFormProps.tsx +0 -52
- package/src/components/PropertyPreviewProps.tsx +0 -61
- package/src/components/formex.tsx +0 -46
- package/src/components/index.ts +0 -3
- package/src/types/fields.tsx +0 -298
- package/src/types/rebase.tsx +0 -211
|
@@ -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
|
+
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
export * from "./collection_registry";
|
|
1
2
|
export * from "./analytics_controller";
|
|
2
3
|
export * from "./auth";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
4
|
+
export * from "./data";
|
|
5
|
+
export * from "./database_admin";
|
|
6
|
+
export * from "./data_driver";
|
|
6
7
|
export * from "./local_config_persistence";
|
|
7
8
|
export * from "./navigation";
|
|
8
|
-
export * from "./
|
|
9
|
+
export * from "./effective_role";
|
|
10
|
+
export * from "./storage";
|
|
11
|
+
export * from "./email";
|
|
12
|
+
export * from "./client";
|
|
13
|
+
export * from "./customization_controller";
|
|
9
14
|
export * from "./side_entity_controller";
|
|
15
|
+
export * from "./side_dialogs_controller";
|
|
16
|
+
export * from "./dialogs_controller";
|
|
10
17
|
export * from "./snackbar";
|
|
11
|
-
export * from "./
|
|
18
|
+
export * from "./registry";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { EntityCollection } from "../types";
|
|
1
|
+
import type { EntityCollection } from "../types/collections";
|
|
2
2
|
/**
|
|
3
3
|
* @group Models
|
|
4
4
|
*/
|
|
5
|
-
export type PartialEntityCollection<M extends Record<string,
|
|
5
|
+
export type PartialEntityCollection<M extends Record<string, unknown> = Record<string, unknown>> = Partial<EntityCollection<M>>;
|
|
6
6
|
/**
|
|
7
7
|
* This interface is in charge of defining the controller that persists
|
|
8
8
|
* modifications to a collection or collection, and retrieves them back from
|
|
9
9
|
* a data source, such as local storage or Firestore.
|
|
10
10
|
*/
|
|
11
11
|
export interface UserConfigurationPersistence {
|
|
12
|
-
onCollectionModified: <M extends Record<string,
|
|
13
|
-
getCollectionConfig: <M extends Record<string,
|
|
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
14
|
recentlyVisitedPaths: string[];
|
|
15
15
|
setRecentlyVisitedPaths: (paths: string[]) => void;
|
|
16
16
|
favouritePaths: string[];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { EntityCollection
|
|
2
|
+
import type { EntityCollection } from "../types/collections";
|
|
3
|
+
import type { RebasePlugin } from "../types/plugins";
|
|
3
4
|
/**
|
|
4
5
|
* Controller that handles URL path building and resolution.
|
|
5
6
|
* @group Models
|
|
6
7
|
*/
|
|
7
|
-
export type
|
|
8
|
+
export type UrlController = {
|
|
8
9
|
/**
|
|
9
10
|
* Default path under the navigation routes of the CMS will be created.
|
|
10
11
|
* Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
|
|
@@ -43,7 +44,7 @@ export type CMSUrlController = {
|
|
|
43
44
|
* Build a URL path for the CMS (e.g. for custom views)
|
|
44
45
|
* @param path
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
buildAppUrlPath: (path: string) => string;
|
|
47
48
|
/**
|
|
48
49
|
* Turn a path with collection ids into a resolved path.
|
|
49
50
|
* The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
|
|
@@ -68,12 +69,12 @@ export type NavigationStateController = {
|
|
|
68
69
|
* Custom additional views created by the developer, added to the main
|
|
69
70
|
* navigation
|
|
70
71
|
*/
|
|
71
|
-
views?:
|
|
72
|
+
views?: AppView[];
|
|
72
73
|
/**
|
|
73
74
|
* Custom additional views created by the developer, added to the admin
|
|
74
75
|
* navigation
|
|
75
76
|
*/
|
|
76
|
-
adminViews?:
|
|
77
|
+
adminViews?: AppView[];
|
|
77
78
|
/**
|
|
78
79
|
* Configuration for the views that should be displayed at the top
|
|
79
80
|
* level of the navigation (e.g. in the home page or the navigation
|
|
@@ -96,58 +97,8 @@ export type NavigationStateController = {
|
|
|
96
97
|
/**
|
|
97
98
|
* Plugin system allowing to extend the CMS functionality.
|
|
98
99
|
*/
|
|
99
|
-
plugins?: RebasePlugin
|
|
100
|
+
plugins?: RebasePlugin[];
|
|
100
101
|
};
|
|
101
|
-
/**
|
|
102
|
-
* Controller that provides access to the registered entity collections.
|
|
103
|
-
* @group Models
|
|
104
|
-
*/
|
|
105
|
-
export type CollectionRegistryController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
106
|
-
/**
|
|
107
|
-
* List of the mapped collections in the CMS.
|
|
108
|
-
* Each entry relates to a collection in the root database.
|
|
109
|
-
* Each of the navigation entries in this field
|
|
110
|
-
* generates an entry in the main menu.
|
|
111
|
-
*/
|
|
112
|
-
collections?: EntityCollection[];
|
|
113
|
-
/**
|
|
114
|
-
* Is the registry ready to be used
|
|
115
|
-
*/
|
|
116
|
-
initialised: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Get the collection configuration for a given path.
|
|
119
|
-
* The collection is resolved from the given path or alias.
|
|
120
|
-
*/
|
|
121
|
-
getCollection: (slugOrPath: string, includeUserOverride?: boolean) => EC | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* Get the raw, un-normalized collection configuration.
|
|
124
|
-
* This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
|
|
125
|
-
* This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
|
|
126
|
-
*/
|
|
127
|
-
getRawCollection: (slugOrPath: string) => EC | undefined;
|
|
128
|
-
/**
|
|
129
|
-
* Retrieve all the related parent references for a given path
|
|
130
|
-
* @param path
|
|
131
|
-
*/
|
|
132
|
-
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
133
|
-
/**
|
|
134
|
-
* Retrieve all the related parent collection ids for a given path
|
|
135
|
-
* @param path
|
|
136
|
-
*/
|
|
137
|
-
getParentCollectionIds: (path: string) => string[];
|
|
138
|
-
/**
|
|
139
|
-
* Resolve paths from a list of ids
|
|
140
|
-
* @param ids
|
|
141
|
-
*/
|
|
142
|
-
convertIdsToPaths: (ids: string[]) => string[];
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Legacy monolithic controller that includes the resolved navigation and utility methods and attributes.
|
|
146
|
-
* It is a combination of CMSUrlController, NavigationStateController, and CollectionRegistryController.
|
|
147
|
-
* @group Models
|
|
148
|
-
* @deprecated Use the specific controllers instead.
|
|
149
|
-
*/
|
|
150
|
-
export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = CMSUrlController & NavigationStateController & CollectionRegistryController<EC>;
|
|
151
102
|
export interface NavigateOptions {
|
|
152
103
|
replace?: boolean;
|
|
153
104
|
state?: unknown;
|
|
@@ -167,7 +118,7 @@ export type NavigationBlocker = {
|
|
|
167
118
|
* navigation.
|
|
168
119
|
* @group Models
|
|
169
120
|
*/
|
|
170
|
-
export interface
|
|
121
|
+
export interface AppView {
|
|
171
122
|
/**
|
|
172
123
|
* CMS Path you can reach this view from.
|
|
173
124
|
*/
|
|
@@ -182,9 +133,9 @@ export interface CMSView {
|
|
|
182
133
|
description?: string;
|
|
183
134
|
/**
|
|
184
135
|
* Icon key to use in this view.
|
|
185
|
-
* You can use any of the icons in the
|
|
186
|
-
* https://
|
|
187
|
-
* e.g. '
|
|
136
|
+
* You can use any of the icons in the Lucide specs:
|
|
137
|
+
* https://lucide.dev/icons/
|
|
138
|
+
* e.g. 'ShoppingCart' or 'User'
|
|
188
139
|
* Find all the icons in https://rebase.pro/docs/icons
|
|
189
140
|
*/
|
|
190
141
|
icon?: string | React.ReactNode;
|
|
@@ -250,7 +201,7 @@ export interface NavigationEntry {
|
|
|
250
201
|
slug: string;
|
|
251
202
|
type: "collection" | "view" | "admin";
|
|
252
203
|
collection?: EntityCollection;
|
|
253
|
-
view?:
|
|
204
|
+
view?: AppView;
|
|
254
205
|
description?: string;
|
|
255
206
|
group: string;
|
|
256
207
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Entity
|
|
2
|
-
import {
|
|
1
|
+
import type { Entity } from "../types/entities";
|
|
2
|
+
import type { EntityCollection } from "../types/collections";
|
|
3
3
|
/**
|
|
4
4
|
* Props used to open a side dialog
|
|
5
5
|
* @group Hooks and utilities
|
|
6
6
|
*/
|
|
7
|
-
export interface EntitySidePanelProps<M extends Record<string,
|
|
7
|
+
export interface EntitySidePanelProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
8
8
|
/**
|
|
9
9
|
* Absolute path of the entity
|
|
10
10
|
*/
|
|
@@ -44,7 +44,7 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
|
|
|
44
44
|
* @param params
|
|
45
45
|
*/
|
|
46
46
|
onUpdate?: (params: {
|
|
47
|
-
entity: Entity<
|
|
47
|
+
entity: Entity<M>;
|
|
48
48
|
}) => void;
|
|
49
49
|
/**
|
|
50
50
|
* Callback when the dialog is closed
|
|
@@ -57,7 +57,7 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
|
|
|
57
57
|
/**
|
|
58
58
|
* Override some form properties
|
|
59
59
|
*/
|
|
60
|
-
formProps?:
|
|
60
|
+
formProps?: Record<string, unknown>;
|
|
61
61
|
/**
|
|
62
62
|
* Allow the user to open the entity fullscreen
|
|
63
63
|
*/
|
|
@@ -81,10 +81,10 @@ export interface SideEntityController {
|
|
|
81
81
|
* (or a new one with that id).
|
|
82
82
|
* @param props
|
|
83
83
|
*/
|
|
84
|
-
open: <M extends Record<string,
|
|
84
|
+
open: <M extends Record<string, unknown> = Record<string, unknown>>(props: EntitySidePanelProps<M>) => void;
|
|
85
85
|
/**
|
|
86
86
|
* Replace the last open entity panel with the given one.
|
|
87
87
|
* @param props
|
|
88
88
|
*/
|
|
89
|
-
replace: <M extends Record<string,
|
|
89
|
+
replace: <M extends Record<string, unknown> = Record<string, unknown>>(props: EntitySidePanelProps<M>) => void;
|
|
90
90
|
}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface UploadFileProps {
|
|
5
5
|
file: File;
|
|
6
|
-
|
|
7
|
-
path?: string;
|
|
6
|
+
key: string;
|
|
8
7
|
metadata?: Record<string, unknown>;
|
|
9
8
|
bucket?: string;
|
|
10
9
|
}
|
|
@@ -13,9 +12,9 @@ export interface UploadFileProps {
|
|
|
13
12
|
*/
|
|
14
13
|
export interface UploadFileResult {
|
|
15
14
|
/**
|
|
16
|
-
* Storage
|
|
15
|
+
* Storage key including the file name where the file was uploaded.
|
|
17
16
|
*/
|
|
18
|
-
|
|
17
|
+
key: string;
|
|
19
18
|
/**
|
|
20
19
|
* Bucket where the file was uploaded
|
|
21
20
|
*/
|
|
@@ -23,7 +22,7 @@ export interface UploadFileResult {
|
|
|
23
22
|
/**
|
|
24
23
|
* Fully qualified storage URL for the uploaded file.
|
|
25
24
|
*
|
|
26
|
-
* For example: `
|
|
25
|
+
* For example: `s3://my-bucket/path/to/file.png`.
|
|
27
26
|
*
|
|
28
27
|
* This is optional for backwards compatibility.
|
|
29
28
|
*/
|
|
@@ -74,39 +73,38 @@ export declare interface DownloadMetadata {
|
|
|
74
73
|
*/
|
|
75
74
|
export interface StorageSource {
|
|
76
75
|
/**
|
|
77
|
-
* Upload
|
|
76
|
+
* Upload an object, specifying a key
|
|
78
77
|
* @param file
|
|
79
|
-
* @param
|
|
80
|
-
* @param path
|
|
78
|
+
* @param key
|
|
81
79
|
* @param metadata
|
|
82
80
|
* @param bucket
|
|
83
81
|
*/
|
|
84
|
-
|
|
82
|
+
putObject: ({ file, key, metadata, bucket }: UploadFileProps) => Promise<UploadFileResult>;
|
|
85
83
|
/**
|
|
86
|
-
* Convert a storage
|
|
87
|
-
* @param
|
|
84
|
+
* Convert a storage key or URL into a download configuration (signed URL equivalent)
|
|
85
|
+
* @param keyOrUrl
|
|
88
86
|
* @param bucket
|
|
89
87
|
*/
|
|
90
|
-
|
|
88
|
+
getSignedUrl: (keyOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
|
|
91
89
|
/**
|
|
92
|
-
* Get
|
|
93
|
-
* It returns null if the
|
|
94
|
-
* @param
|
|
90
|
+
* Get an object from a storage key.
|
|
91
|
+
* It returns null if the object does not exist.
|
|
92
|
+
* @param key
|
|
95
93
|
* @param bucket
|
|
96
94
|
*/
|
|
97
|
-
|
|
95
|
+
getObject: (key: string, bucket?: string) => Promise<File | null>;
|
|
98
96
|
/**
|
|
99
|
-
* Delete
|
|
100
|
-
* @param
|
|
97
|
+
* Delete an object.
|
|
98
|
+
* @param key
|
|
101
99
|
* @param bucket
|
|
102
100
|
*/
|
|
103
|
-
|
|
101
|
+
deleteObject: (key: string, bucket?: string) => Promise<void>;
|
|
104
102
|
/**
|
|
105
|
-
* List the contents of a
|
|
106
|
-
* @param
|
|
103
|
+
* List the contents of a prefix.
|
|
104
|
+
* @param prefix
|
|
107
105
|
* @param options
|
|
108
106
|
*/
|
|
109
|
-
|
|
107
|
+
listObjects: (prefix: string, options?: {
|
|
110
108
|
bucket?: string;
|
|
111
109
|
maxResults?: number;
|
|
112
110
|
pageToken?: string;
|
|
@@ -137,15 +135,15 @@ export declare interface StorageListResult {
|
|
|
137
135
|
nextPageToken?: string;
|
|
138
136
|
}
|
|
139
137
|
/**
|
|
140
|
-
* Represents a reference to
|
|
138
|
+
* Represents a reference to an S3-compatible storage object. Developers can
|
|
141
139
|
* upload, download, and delete objects, as well as get/set object metadata.
|
|
142
140
|
* @public
|
|
143
141
|
*/
|
|
144
142
|
export declare interface StorageReference {
|
|
145
143
|
/**
|
|
146
|
-
* Returns a
|
|
147
|
-
* `
|
|
148
|
-
* @returns The
|
|
144
|
+
* Returns a s3:// URL for this object in the form
|
|
145
|
+
* `s3://<bucket>/<path>/<to>/<object>`
|
|
146
|
+
* @returns The s3:// URL.
|
|
149
147
|
*/
|
|
150
148
|
toString(): string;
|
|
151
149
|
/**
|
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -10,42 +10,42 @@ class EntityReference {
|
|
|
10
10
|
*/
|
|
11
11
|
path;
|
|
12
12
|
/**
|
|
13
|
-
* Which
|
|
13
|
+
* Which driver (e.g., 'postgres', 'firestore').
|
|
14
14
|
* Defaults to "(default)" if not specified.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
driver;
|
|
17
17
|
/**
|
|
18
|
-
* Which database within the
|
|
18
|
+
* Which database within the driver.
|
|
19
19
|
* Defaults to "(default)" if not specified.
|
|
20
20
|
*/
|
|
21
21
|
databaseId;
|
|
22
22
|
/**
|
|
23
23
|
* Create a reference to an entity.
|
|
24
|
-
*
|
|
24
|
+
*
|
|
25
25
|
* @example
|
|
26
26
|
* // Simple reference (most common case)
|
|
27
27
|
* new EntityReference({ id: "123", path: "users" })
|
|
28
|
-
*
|
|
29
|
-
* // With
|
|
30
|
-
* new EntityReference({ id: "123", path: "analytics",
|
|
28
|
+
*
|
|
29
|
+
* // With driver
|
|
30
|
+
* new EntityReference({ id: "123", path: "analytics", driver: "firestore" })
|
|
31
31
|
*/
|
|
32
32
|
constructor(props) {
|
|
33
33
|
this.id = props.id;
|
|
34
34
|
this.path = props.path;
|
|
35
|
-
this.
|
|
35
|
+
this.driver = props.driver;
|
|
36
36
|
this.databaseId = props.databaseId;
|
|
37
37
|
}
|
|
38
38
|
get pathWithId() {
|
|
39
39
|
return `${this.path}/${this.id}`;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Get the full path including
|
|
43
|
-
* For the common case (single
|
|
42
|
+
* Get the full path including driver and database prefixes if specified.
|
|
43
|
+
* For the common case (single driver, single db), this just returns pathWithId.
|
|
44
44
|
*/
|
|
45
45
|
get fullPath() {
|
|
46
46
|
const parts = [];
|
|
47
|
-
if (this.
|
|
48
|
-
parts.push(this.
|
|
47
|
+
if (this.driver && this.driver !== "(default)") {
|
|
48
|
+
parts.push(this.driver);
|
|
49
49
|
}
|
|
50
50
|
if (this.databaseId && this.databaseId !== "(default)") {
|
|
51
51
|
parts.push(this.databaseId);
|
|
@@ -70,9 +70,15 @@ class EntityRelation {
|
|
|
70
70
|
* to the root of the database).
|
|
71
71
|
*/
|
|
72
72
|
path;
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Pre-fetched data payload to eliminate N+1 queries.
|
|
75
|
+
* When present, clients can use this directly instead of fetching.
|
|
76
|
+
*/
|
|
77
|
+
data;
|
|
78
|
+
constructor(id, path, data) {
|
|
74
79
|
this.id = id;
|
|
75
80
|
this.path = path;
|
|
81
|
+
this.data = data;
|
|
76
82
|
}
|
|
77
83
|
get pathWithId() {
|
|
78
84
|
return `${this.path}/${this.id}`;
|
|
@@ -104,10 +110,109 @@ class Vector {
|
|
|
104
110
|
this.value = value;
|
|
105
111
|
}
|
|
106
112
|
}
|
|
113
|
+
function isPostgresCollection(collection) {
|
|
114
|
+
return !collection.driver || collection.driver === "postgres";
|
|
115
|
+
}
|
|
116
|
+
function isFirebaseCollection(collection) {
|
|
117
|
+
return collection.driver === "firestore";
|
|
118
|
+
}
|
|
119
|
+
function isMongoDBCollection(collection) {
|
|
120
|
+
return collection.driver === "mongodb";
|
|
121
|
+
}
|
|
122
|
+
function isSQLAdmin(admin) {
|
|
123
|
+
return !!admin && typeof admin.executeSql === "function";
|
|
124
|
+
}
|
|
125
|
+
function isDocumentAdmin(admin) {
|
|
126
|
+
return !!admin && (typeof admin.executeAggregate === "function" || typeof admin.fetchCollectionStats === "function");
|
|
127
|
+
}
|
|
128
|
+
function isSchemaAdmin(admin) {
|
|
129
|
+
return !!admin && (typeof admin.fetchUnmappedTables === "function" || typeof admin.fetchTableMetadata === "function");
|
|
130
|
+
}
|
|
131
|
+
function isBranchAdmin(admin) {
|
|
132
|
+
return !!admin && typeof admin.createBranch === "function";
|
|
133
|
+
}
|
|
134
|
+
const POSTGRES_CAPABILITIES = {
|
|
135
|
+
key: "postgres",
|
|
136
|
+
label: "PostgreSQL",
|
|
137
|
+
supportsRelations: true,
|
|
138
|
+
supportsSubcollections: false,
|
|
139
|
+
supportsRLS: true,
|
|
140
|
+
supportsReferences: false,
|
|
141
|
+
supportsColumnTypes: true,
|
|
142
|
+
supportsRealtime: true,
|
|
143
|
+
supportsSQLAdmin: true,
|
|
144
|
+
supportsDocumentAdmin: false,
|
|
145
|
+
supportsSchemaAdmin: true
|
|
146
|
+
};
|
|
147
|
+
const FIREBASE_CAPABILITIES = {
|
|
148
|
+
key: "firestore",
|
|
149
|
+
label: "Firebase / Firestore",
|
|
150
|
+
supportsRelations: false,
|
|
151
|
+
supportsSubcollections: true,
|
|
152
|
+
supportsRLS: false,
|
|
153
|
+
supportsReferences: true,
|
|
154
|
+
supportsColumnTypes: false,
|
|
155
|
+
supportsRealtime: true,
|
|
156
|
+
supportsSQLAdmin: false,
|
|
157
|
+
supportsDocumentAdmin: false,
|
|
158
|
+
supportsSchemaAdmin: false
|
|
159
|
+
};
|
|
160
|
+
const MONGODB_CAPABILITIES = {
|
|
161
|
+
key: "mongodb",
|
|
162
|
+
label: "MongoDB",
|
|
163
|
+
supportsRelations: false,
|
|
164
|
+
supportsSubcollections: true,
|
|
165
|
+
supportsRLS: false,
|
|
166
|
+
supportsReferences: true,
|
|
167
|
+
supportsColumnTypes: false,
|
|
168
|
+
supportsRealtime: false,
|
|
169
|
+
supportsSQLAdmin: false,
|
|
170
|
+
supportsDocumentAdmin: true,
|
|
171
|
+
supportsSchemaAdmin: true
|
|
172
|
+
};
|
|
173
|
+
const DEFAULT_CAPABILITIES = {
|
|
174
|
+
key: "(default)",
|
|
175
|
+
label: "Default",
|
|
176
|
+
supportsRelations: true,
|
|
177
|
+
supportsSubcollections: true,
|
|
178
|
+
supportsRLS: true,
|
|
179
|
+
supportsReferences: true,
|
|
180
|
+
supportsColumnTypes: true,
|
|
181
|
+
supportsRealtime: true,
|
|
182
|
+
supportsSQLAdmin: true,
|
|
183
|
+
supportsDocumentAdmin: true,
|
|
184
|
+
supportsSchemaAdmin: true
|
|
185
|
+
};
|
|
186
|
+
const CAPABILITIES_REGISTRY = {
|
|
187
|
+
postgres: POSTGRES_CAPABILITIES,
|
|
188
|
+
firestore: FIREBASE_CAPABILITIES,
|
|
189
|
+
mongodb: MONGODB_CAPABILITIES,
|
|
190
|
+
"(default)": DEFAULT_CAPABILITIES
|
|
191
|
+
};
|
|
192
|
+
function getDataSourceCapabilities(driver) {
|
|
193
|
+
if (!driver) return POSTGRES_CAPABILITIES;
|
|
194
|
+
return CAPABILITIES_REGISTRY[driver] ?? DEFAULT_CAPABILITIES;
|
|
195
|
+
}
|
|
196
|
+
function registerDataSourceCapabilities(capabilities) {
|
|
197
|
+
CAPABILITIES_REGISTRY[capabilities.key] = capabilities;
|
|
198
|
+
}
|
|
107
199
|
export {
|
|
200
|
+
DEFAULT_CAPABILITIES,
|
|
108
201
|
EntityReference,
|
|
109
202
|
EntityRelation,
|
|
203
|
+
FIREBASE_CAPABILITIES,
|
|
110
204
|
GeoPoint,
|
|
111
|
-
|
|
205
|
+
MONGODB_CAPABILITIES,
|
|
206
|
+
POSTGRES_CAPABILITIES,
|
|
207
|
+
Vector,
|
|
208
|
+
getDataSourceCapabilities,
|
|
209
|
+
isBranchAdmin,
|
|
210
|
+
isDocumentAdmin,
|
|
211
|
+
isFirebaseCollection,
|
|
212
|
+
isMongoDBCollection,
|
|
213
|
+
isPostgresCollection,
|
|
214
|
+
isSQLAdmin,
|
|
215
|
+
isSchemaAdmin,
|
|
216
|
+
registerDataSourceCapabilities
|
|
112
217
|
};
|
|
113
218
|
//# sourceMappingURL=index.es.js.map
|