@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,58 @@
|
|
|
1
|
+
import { User } from "../users";
|
|
2
|
+
import { RebaseData } from "./data";
|
|
3
|
+
/**
|
|
4
|
+
* Event type for authentication state changes
|
|
5
|
+
*/
|
|
6
|
+
export type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED';
|
|
7
|
+
/**
|
|
8
|
+
* Standard session interface representing an authenticated state
|
|
9
|
+
*/
|
|
10
|
+
export interface RebaseSession {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
expiresAt: number;
|
|
14
|
+
user: User;
|
|
15
|
+
}
|
|
16
|
+
import { StorageSource } from "./storage";
|
|
17
|
+
/**
|
|
18
|
+
* Unified Authentication Client Interface
|
|
19
|
+
* Pure functional SDK interface, decoupled from UI and React hooks
|
|
20
|
+
*/
|
|
21
|
+
export interface AuthClient {
|
|
22
|
+
/**
|
|
23
|
+
* Get the current user from the server or cache
|
|
24
|
+
*/
|
|
25
|
+
getUser(): Promise<User | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the currently active session
|
|
28
|
+
*/
|
|
29
|
+
getSession(): RebaseSession | null;
|
|
30
|
+
/**
|
|
31
|
+
* Sign out the current user and clear local session
|
|
32
|
+
*/
|
|
33
|
+
signOut(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Subscribe to authentication state changes
|
|
36
|
+
*/
|
|
37
|
+
onAuthStateChange(callback: (event: AuthChangeEvent, session: RebaseSession | null) => void): () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Manually refresh the session token
|
|
40
|
+
*/
|
|
41
|
+
refreshSession(): Promise<RebaseSession>;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Overarching abstraction that unites Data, Auth, and Storage.
|
|
46
|
+
* Adapters for Supabase or Firebase simply need to implement this interface.
|
|
47
|
+
*/
|
|
48
|
+
export interface RebaseClient<DB = any> {
|
|
49
|
+
/** Unified Data access layer */
|
|
50
|
+
data: RebaseData;
|
|
51
|
+
/** Unified Authentication layer */
|
|
52
|
+
auth: AuthClient;
|
|
53
|
+
/** Unified Storage layer */
|
|
54
|
+
storage?: StorageSource;
|
|
55
|
+
/** Optional admin panel specific tasks */
|
|
56
|
+
admin?: any;
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EntityCollection, EntityReference } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Controller that provides access to the registered entity collections.
|
|
4
|
+
* @group Models
|
|
5
|
+
*/
|
|
6
|
+
export type CollectionRegistryController<EC extends EntityCollection = EntityCollection<any>> = {
|
|
7
|
+
/**
|
|
8
|
+
* List of the mapped collections in the CMS.
|
|
9
|
+
* Each entry relates to a collection in the root database.
|
|
10
|
+
* Each of the navigation entries in this field
|
|
11
|
+
* generates an entry in the main menu.
|
|
12
|
+
*/
|
|
13
|
+
collections?: EntityCollection[];
|
|
14
|
+
/**
|
|
15
|
+
* Is the registry ready to be used
|
|
16
|
+
*/
|
|
17
|
+
initialised: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get the collection configuration for a given path.
|
|
20
|
+
* The collection is resolved from the given path or alias.
|
|
21
|
+
*/
|
|
22
|
+
getCollection: (slugOrPath: string, includeUserOverride?: boolean) => EC | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get the raw, un-normalized collection configuration.
|
|
25
|
+
* This bypasses the `CollectionRegistry` normalization (such as injecting `relation` instances).
|
|
26
|
+
* This is strictly for the Visual Editor to manipulate AST code without persisting runtime state.
|
|
27
|
+
*/
|
|
28
|
+
getRawCollection: (slugOrPath: string) => EC | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve all the related parent references for a given path
|
|
31
|
+
* @param path
|
|
32
|
+
*/
|
|
33
|
+
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
34
|
+
/**
|
|
35
|
+
* Retrieve all the related parent collection ids for a given path
|
|
36
|
+
* @param path
|
|
37
|
+
*/
|
|
38
|
+
getParentCollectionIds: (path: string) => string[];
|
|
39
|
+
/**
|
|
40
|
+
* Resolve paths from a list of ids
|
|
41
|
+
* @param ids
|
|
42
|
+
*/
|
|
43
|
+
convertIdsToPaths: (ids: string[]) => string[];
|
|
44
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EntityLinkBuilder, Locale, EntityAction, EntityCustomView, RebasePlugin, PropertyConfig, SlotContribution } from "../types";
|
|
3
|
+
export type CustomizationController = {
|
|
4
|
+
/**
|
|
5
|
+
* Builder for generating utility links for entities
|
|
6
|
+
*/
|
|
7
|
+
entityLinkBuilder?: EntityLinkBuilder;
|
|
8
|
+
/**
|
|
9
|
+
* Use plugins to modify the behaviour of the CMS.
|
|
10
|
+
*/
|
|
11
|
+
plugins?: RebasePlugin[];
|
|
12
|
+
/**
|
|
13
|
+
* Pre-merged slots from plugins + direct slot contributions.
|
|
14
|
+
*/
|
|
15
|
+
resolvedSlots: SlotContribution[];
|
|
16
|
+
/**
|
|
17
|
+
* List of additional custom views for entities.
|
|
18
|
+
* You can use the key to reference the custom view in
|
|
19
|
+
* the `entityViews` prop of a collection.
|
|
20
|
+
*
|
|
21
|
+
* You can also define an entity view from the UI.
|
|
22
|
+
*/
|
|
23
|
+
entityViews?: EntityCustomView[];
|
|
24
|
+
/**
|
|
25
|
+
* List of actions that can be performed on entities.
|
|
26
|
+
* These actions are displayed in the entity view and in the collection view.
|
|
27
|
+
* You can later reuse these actions in the `entityActions` prop of a collection,
|
|
28
|
+
* by specifying the `key` of the action.
|
|
29
|
+
*/
|
|
30
|
+
entityActions?: EntityAction[];
|
|
31
|
+
/**
|
|
32
|
+
* Format of the dates in the CMS.
|
|
33
|
+
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
34
|
+
*/
|
|
35
|
+
dateTimeFormat?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Locale of the CMS, currently only affecting dates
|
|
38
|
+
*/
|
|
39
|
+
locale?: Locale;
|
|
40
|
+
/**
|
|
41
|
+
* Record of custom form fields to be used in the CMS.
|
|
42
|
+
* You can use the key to reference the custom field in
|
|
43
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
44
|
+
*/
|
|
45
|
+
propertyConfigs: Record<string, PropertyConfig>;
|
|
46
|
+
components?: {
|
|
47
|
+
/**
|
|
48
|
+
* Component to render when a reference is missing
|
|
49
|
+
*/
|
|
50
|
+
missingReference?: React.ComponentType<{
|
|
51
|
+
path: string;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Entity, EntityValues } from "../types/entities";
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for querying a collection.
|
|
4
|
+
* Uses PostgREST-style filter syntax for consistency between
|
|
5
|
+
* the SDK (HTTP) and framework (in-process) contexts.
|
|
6
|
+
*
|
|
7
|
+
* @group Data
|
|
8
|
+
*/
|
|
9
|
+
export interface FindParams {
|
|
10
|
+
/** Maximum number of items to return (default: 20) */
|
|
11
|
+
limit?: number;
|
|
12
|
+
/** Number of items to skip */
|
|
13
|
+
offset?: number;
|
|
14
|
+
/** Page number (1-indexed), alternative to offset */
|
|
15
|
+
page?: number;
|
|
16
|
+
/**
|
|
17
|
+
* PostgREST-style filter object.
|
|
18
|
+
* Keys are field names, values use "operator.value" format.
|
|
19
|
+
* Operators: eq, neq, gt, gte, lt, lte, in, nin, cs (array-contains), csa (array-contains-any)
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* { status: "eq.published" }
|
|
23
|
+
* { age: "gte.18" }
|
|
24
|
+
* { role: "in.(admin,editor)" }
|
|
25
|
+
*/
|
|
26
|
+
where?: Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* Sort order. Format: "field:direction".
|
|
29
|
+
* @example "created_at:desc", "name:asc"
|
|
30
|
+
*/
|
|
31
|
+
orderBy?: string;
|
|
32
|
+
/** Relations to include in the response */
|
|
33
|
+
include?: string[];
|
|
34
|
+
/** Full-text search string */
|
|
35
|
+
searchString?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Paginated response from a collection query.
|
|
39
|
+
* @group Data
|
|
40
|
+
*/
|
|
41
|
+
export interface FindResponse<M extends Record<string, any> = any> {
|
|
42
|
+
/** Array of entities matching the query */
|
|
43
|
+
data: Entity<M>[];
|
|
44
|
+
/** Pagination metadata */
|
|
45
|
+
meta: {
|
|
46
|
+
total: number;
|
|
47
|
+
limit: number;
|
|
48
|
+
offset: number;
|
|
49
|
+
hasMore: boolean;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A single collection's CRUD accessor.
|
|
54
|
+
*
|
|
55
|
+
* This is the unified API surface used in both:
|
|
56
|
+
* - The generated SDK (`client.data.products.create(...)`)
|
|
57
|
+
* - Framework callbacks (`context.data.products.create(...)`)
|
|
58
|
+
*
|
|
59
|
+
* @group Data
|
|
60
|
+
*/
|
|
61
|
+
export interface CollectionAccessor<M extends Record<string, any> = any> {
|
|
62
|
+
/**
|
|
63
|
+
* Find multiple records with optional filtering, pagination, and sorting.
|
|
64
|
+
*/
|
|
65
|
+
find(params?: FindParams): Promise<FindResponse<M>>;
|
|
66
|
+
/**
|
|
67
|
+
* Find a single record by its ID.
|
|
68
|
+
*/
|
|
69
|
+
findById(id: string | number): Promise<Entity<M> | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a new record.
|
|
72
|
+
* @param data The entity data to create.
|
|
73
|
+
* @param id Optional specific ID to use for the new record.
|
|
74
|
+
* @returns The created entity
|
|
75
|
+
*/
|
|
76
|
+
create(data: Partial<EntityValues<M>>, id?: string | number): Promise<Entity<M>>;
|
|
77
|
+
/**
|
|
78
|
+
* Update an existing record by ID.
|
|
79
|
+
* @returns The updated entity
|
|
80
|
+
*/
|
|
81
|
+
update(id: string | number, data: Partial<EntityValues<M>>): Promise<Entity<M>>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete a record by ID.
|
|
84
|
+
*/
|
|
85
|
+
delete(id: string | number): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Subscribe to a collection for real-time updates.
|
|
88
|
+
* Optional method, may not be supported by all implementations (like stateless HTTP clients).
|
|
89
|
+
*/
|
|
90
|
+
listen?(params: FindParams | undefined, onUpdate: (response: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
|
|
91
|
+
/**
|
|
92
|
+
* Subscribe to a single record for real-time updates.
|
|
93
|
+
* Optional method.
|
|
94
|
+
*/
|
|
95
|
+
listenById?(id: string | number, onUpdate: (entity: Entity<M> | undefined) => void, onError?: (error: Error) => void): () => void;
|
|
96
|
+
/**
|
|
97
|
+
* Count the number of records matching the given filter.
|
|
98
|
+
*/
|
|
99
|
+
count?(params?: FindParams): Promise<number>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The unified data access object.
|
|
103
|
+
*
|
|
104
|
+
* Access collections as dynamic properties: `data.products.find(...)`.
|
|
105
|
+
* In the SDK this is backed by HTTP transport (typed, generated per-project).
|
|
106
|
+
* In the framework this is backed by a Proxy + in-process database driver (dynamic).
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* // SDK
|
|
110
|
+
* const client = createRebaseClient({ baseUrl: "..." });
|
|
111
|
+
* await client.data.products.create({ name: "Camera", price: 299 });
|
|
112
|
+
*
|
|
113
|
+
* // Framework callback
|
|
114
|
+
* callbacks: {
|
|
115
|
+
* afterSave({ context }) {
|
|
116
|
+
* await context.data.logs.create({ action: "saved", timestamp: new Date() });
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* @group Data
|
|
121
|
+
*/
|
|
122
|
+
export interface RebaseData {
|
|
123
|
+
/**
|
|
124
|
+
* Get a collection accessor by slug.
|
|
125
|
+
* Alternative to dynamic property access for cases where
|
|
126
|
+
* the collection name is a variable.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* const accessor = data.collection("products");
|
|
130
|
+
* await accessor.find({ limit: 10 });
|
|
131
|
+
*/
|
|
132
|
+
collection(slug: string): CollectionAccessor;
|
|
133
|
+
/**
|
|
134
|
+
* Dynamic collection accessor.
|
|
135
|
+
* Access any collection by its slug as a property.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* data.products.find({ where: { status: "eq.published" } })
|
|
139
|
+
*/
|
|
140
|
+
[collectionSlug: string]: CollectionAccessor | ((slug: string) => CollectionAccessor);
|
|
141
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Entity, EntityCollection, EntityStatus, EntityValues, FilterValues } from "../types";
|
|
2
|
+
import { RebaseContext } from "../rebase_context";
|
|
3
|
+
import { TableMetadata } from "../types/websockets";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export interface FetchEntityProps<M extends Record<string, any> = any> {
|
|
8
|
+
path: string;
|
|
9
|
+
entityId: string | number;
|
|
10
|
+
databaseId?: string;
|
|
11
|
+
collection?: EntityCollection<M, any>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export type ListenEntityProps<M extends Record<string, any> = any> = 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, any> = any> {
|
|
24
|
+
path: string;
|
|
25
|
+
collection?: EntityCollection<M>;
|
|
26
|
+
filter?: FilterValues<Extract<keyof M, string>>;
|
|
27
|
+
limit?: number;
|
|
28
|
+
startAfter?: unknown;
|
|
29
|
+
orderBy?: string;
|
|
30
|
+
searchString?: string;
|
|
31
|
+
order?: "desc" | "asc";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export type ListenCollectionProps<M extends Record<string, any> = any> = FetchCollectionProps<M> & {
|
|
37
|
+
onUpdate: (entities: Entity<M>[]) => void;
|
|
38
|
+
onError?: (error: Error) => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export interface SaveEntityProps<M extends Record<string, any> = any> {
|
|
44
|
+
path: string;
|
|
45
|
+
values: Partial<EntityValues<M>>;
|
|
46
|
+
entityId?: string | number;
|
|
47
|
+
previousValues?: Partial<EntityValues<M>>;
|
|
48
|
+
collection?: EntityCollection<M>;
|
|
49
|
+
status: EntityStatus;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export interface DeleteEntityProps<M extends Record<string, any> = any> {
|
|
55
|
+
entity: Entity<M>;
|
|
56
|
+
collection?: EntityCollection<M>;
|
|
57
|
+
}
|
|
58
|
+
export type FilterCombinationValidProps = {
|
|
59
|
+
path: string;
|
|
60
|
+
databaseId?: string;
|
|
61
|
+
collection: EntityCollection<any>;
|
|
62
|
+
filterValues: FilterValues<any>;
|
|
63
|
+
sortBy?: [string, "asc" | "desc"];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Internal driver interface for communicating with the data layer.
|
|
67
|
+
* This is NOT the public API — use `RebaseData` / `context.data` instead.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export interface DataDriver {
|
|
71
|
+
/**
|
|
72
|
+
* Key that identifies this driver
|
|
73
|
+
*/
|
|
74
|
+
key?: string;
|
|
75
|
+
/**
|
|
76
|
+
* If the driver has been initialised
|
|
77
|
+
*/
|
|
78
|
+
initialised?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Fetch data from a collection
|
|
81
|
+
* @param props
|
|
82
|
+
* @return Promise of entities
|
|
83
|
+
*/
|
|
84
|
+
fetchCollection<M extends Record<string, any> = any>(props: FetchCollectionProps<M>): Promise<Entity<M>[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Listen to a collection in a given path. If you don't implement this method
|
|
87
|
+
* `fetchCollection` will be used instead, with no real time updates.
|
|
88
|
+
* @param props
|
|
89
|
+
* @return Function to cancel subscription
|
|
90
|
+
*/
|
|
91
|
+
listenCollection?<M extends Record<string, any> = any>(props: ListenCollectionProps<M>): () => void;
|
|
92
|
+
/**
|
|
93
|
+
* Retrieve an entity given a path and a collection
|
|
94
|
+
* @param props
|
|
95
|
+
*/
|
|
96
|
+
fetchEntity<M extends Record<string, any> = any>(props: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
|
|
97
|
+
/**
|
|
98
|
+
* Get realtime updates on one entity.
|
|
99
|
+
* @param props
|
|
100
|
+
* @return Function to cancel subscription
|
|
101
|
+
*/
|
|
102
|
+
listenEntity?<M extends Record<string, any> = any>(props: ListenEntityProps<M>): () => void;
|
|
103
|
+
/**
|
|
104
|
+
* Save entity to the specified path
|
|
105
|
+
* @param props
|
|
106
|
+
*/
|
|
107
|
+
saveEntity<M extends Record<string, any> = any>(props: SaveEntityProps<M>): Promise<Entity<M>>;
|
|
108
|
+
/**
|
|
109
|
+
* Delete an entity
|
|
110
|
+
* @param props
|
|
111
|
+
* @return was the whole deletion flow successful
|
|
112
|
+
*/
|
|
113
|
+
deleteEntity<M extends Record<string, any> = any>(props: DeleteEntityProps<M>): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Check if the given property is unique in the given collection
|
|
116
|
+
* @param path Collection path
|
|
117
|
+
* @param name of the property
|
|
118
|
+
* @param value
|
|
119
|
+
* @param entityId
|
|
120
|
+
* @param collection
|
|
121
|
+
* @return `true` if there are no other fields besides the given entity
|
|
122
|
+
*/
|
|
123
|
+
checkUniqueField(path: string, name: string, value: unknown, entityId?: string | number, collection?: EntityCollection): Promise<boolean>;
|
|
124
|
+
/**
|
|
125
|
+
* Count the number of entities in a collection
|
|
126
|
+
*/
|
|
127
|
+
countEntities?<M extends Record<string, any> = any>(props: FetchCollectionProps<M>): Promise<number>;
|
|
128
|
+
/**
|
|
129
|
+
* Check if the given filter combination is valid
|
|
130
|
+
* @param props
|
|
131
|
+
*/
|
|
132
|
+
isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection"> & {
|
|
133
|
+
databaseId?: string;
|
|
134
|
+
}): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Get the object to generate the current time in the driver
|
|
137
|
+
*/
|
|
138
|
+
currentTime?: () => unknown;
|
|
139
|
+
delegateToCMSModel?: (data: unknown) => unknown;
|
|
140
|
+
cmsToDelegateModel?: (data: unknown) => unknown;
|
|
141
|
+
initTextSearch?: (props: {
|
|
142
|
+
context: RebaseContext;
|
|
143
|
+
path: string;
|
|
144
|
+
databaseId?: string;
|
|
145
|
+
collection: EntityCollection;
|
|
146
|
+
parentCollectionIds?: string[];
|
|
147
|
+
}) => Promise<boolean>;
|
|
148
|
+
/**
|
|
149
|
+
* Flag to indicate if the driver has requested the initialization of the text search index
|
|
150
|
+
*/
|
|
151
|
+
needsInitTextSearch?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Return the admin capabilities of this driver.
|
|
154
|
+
* @see SQLAdmin
|
|
155
|
+
* @see DocumentAdmin
|
|
156
|
+
* @see SchemaAdmin
|
|
157
|
+
*/
|
|
158
|
+
admin?: import("../types/backend").DatabaseAdmin;
|
|
159
|
+
executeSql?(sql: string, options?: {
|
|
160
|
+
database?: string;
|
|
161
|
+
role?: string;
|
|
162
|
+
}): Promise<Record<string, unknown>[]>;
|
|
163
|
+
fetchAvailableDatabases?(): Promise<string[]>;
|
|
164
|
+
fetchAvailableRoles?(): Promise<string[]>;
|
|
165
|
+
fetchCurrentDatabase?(): Promise<string | undefined>;
|
|
166
|
+
fetchUnmappedTables?(mappedPaths?: string[]): Promise<string[]>;
|
|
167
|
+
fetchTableMetadata?(tableName: string): Promise<TableMetadata>;
|
|
168
|
+
}
|
|
@@ -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,17 @@
|
|
|
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 "./client";
|
|
12
|
+
export * from "./customization_controller";
|
|
13
|
+
export * from "./side_entity_controller";
|
|
14
|
+
export * from "./side_dialogs_controller";
|
|
15
|
+
export * from "./dialogs_controller";
|
|
16
|
+
export * from "./snackbar";
|
|
17
|
+
export * from "./registry";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EntityCollection } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* @group Models
|
|
4
|
+
*/
|
|
5
|
+
export type PartialEntityCollection<M extends Record<string, any> = any> = 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, any> = any>(path: string, partialCollection: PartialEntityCollection<M>) => void;
|
|
13
|
+
getCollectionConfig: <M extends Record<string, any> = any>(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
|
+
}
|