@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
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { Role, User } from "../users";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Result of creating a new user via admin flow.
|
|
5
|
+
* Contains the created user plus information about how credentials were delivered.
|
|
6
|
+
*/
|
|
7
|
+
export interface UserCreationResult<USER extends User = User> {
|
|
8
|
+
/** The created user */
|
|
9
|
+
user: USER;
|
|
10
|
+
/** Whether an invitation email was sent to the user */
|
|
11
|
+
invitationSent: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Temporary password (only present when email service is not configured).
|
|
14
|
+
* This is returned one-time and should be shown to the admin to share manually.
|
|
15
|
+
*/
|
|
16
|
+
temporaryPassword?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
3
19
|
|
|
4
20
|
/**
|
|
5
21
|
* Delegate to manage users, roles, and their permissions.
|
|
6
22
|
* This interface allows the CMS to be completely agnostic of the underlying
|
|
7
23
|
* authentication provider or backend.
|
|
8
|
-
*
|
|
24
|
+
*
|
|
9
25
|
* @group Models
|
|
10
26
|
*/
|
|
11
27
|
export interface UserManagementDelegate<USER extends User = User> {
|
|
@@ -28,19 +44,47 @@ export interface UserManagementDelegate<USER extends User = User> {
|
|
|
28
44
|
/**
|
|
29
45
|
* Function to get a user by its uid. This is used to show
|
|
30
46
|
* user information when assigning ownership of an entity.
|
|
31
|
-
* @param uid
|
|
47
|
+
* @param uid
|
|
32
48
|
*/
|
|
33
49
|
getUser: (uid: string) => USER | null;
|
|
34
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Search users with server-side pagination.
|
|
53
|
+
* When provided, the CMS will use this for the users table
|
|
54
|
+
* instead of loading all users into memory.
|
|
55
|
+
*/
|
|
56
|
+
searchUsers?: (options: {
|
|
57
|
+
search?: string;
|
|
58
|
+
limit?: number;
|
|
59
|
+
offset?: number;
|
|
60
|
+
orderBy?: string;
|
|
61
|
+
orderDir?: "asc" | "desc";
|
|
62
|
+
roleId?: string;
|
|
63
|
+
}) => Promise<{ users: USER[]; total: number }>;
|
|
64
|
+
|
|
35
65
|
/**
|
|
36
66
|
* Save a user (create or update)
|
|
37
|
-
* @param user
|
|
67
|
+
* @param user
|
|
38
68
|
*/
|
|
39
69
|
saveUser?: (user: USER) => Promise<USER>;
|
|
40
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Create a new user with invitation/password generation support.
|
|
73
|
+
* Returns additional info about how the credentials were delivered.
|
|
74
|
+
* Falls back to saveUser if not provided.
|
|
75
|
+
*/
|
|
76
|
+
createUser?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Reset the password for an existing user.
|
|
80
|
+
* Returns a temporary password if no email service is configured,
|
|
81
|
+
* or a flag indicating an email invitation was sent.
|
|
82
|
+
*/
|
|
83
|
+
resetPassword?: (user: USER) => Promise<UserCreationResult<USER>>;
|
|
84
|
+
|
|
41
85
|
/**
|
|
42
86
|
* Delete a user
|
|
43
|
-
* @param user
|
|
87
|
+
* @param user
|
|
44
88
|
*/
|
|
45
89
|
deleteUser?: (user: USER) => Promise<void>;
|
|
46
90
|
|
|
@@ -56,13 +100,13 @@ export interface UserManagementDelegate<USER extends User = User> {
|
|
|
56
100
|
|
|
57
101
|
/**
|
|
58
102
|
* Save a role (create or update)
|
|
59
|
-
* @param role
|
|
103
|
+
* @param role
|
|
60
104
|
*/
|
|
61
105
|
saveRole?: (role: Role) => Promise<void>;
|
|
62
106
|
|
|
63
107
|
/**
|
|
64
108
|
* Delete a role
|
|
65
|
-
* @param role
|
|
109
|
+
* @param role
|
|
66
110
|
*/
|
|
67
111
|
deleteRole?: (role: Role) => Promise<void>;
|
|
68
112
|
|
|
@@ -82,7 +126,6 @@ export interface UserManagementDelegate<USER extends User = User> {
|
|
|
82
126
|
includeCollectionConfigPermissions?: boolean;
|
|
83
127
|
|
|
84
128
|
|
|
85
|
-
|
|
86
129
|
/**
|
|
87
130
|
* Optionally define roles for a given user. This is useful when the roles
|
|
88
131
|
* are coming from a separate provider than the one issuing the tokens.
|
package/src/types/websockets.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Entity } from "./entities";
|
|
2
2
|
|
|
3
|
+
export interface WebSocketErrorPayload {
|
|
4
|
+
error?: string | { message: string; code?: string };
|
|
5
|
+
message?: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
export interface WebSocketMessage {
|
|
4
10
|
type: string;
|
|
5
11
|
payload?: unknown;
|
|
@@ -22,6 +28,20 @@ export interface EntityUpdateMessage extends WebSocketMessage {
|
|
|
22
28
|
entity: Entity<Record<string, unknown>> | null;
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Lightweight patch message sent to collection subscribers when a single
|
|
33
|
+
* entity is created, updated, or deleted. The client can merge this into
|
|
34
|
+
* its cached collection data for near-instant cross-tab updates without
|
|
35
|
+
* waiting for a full collection refetch.
|
|
36
|
+
*/
|
|
37
|
+
export interface CollectionEntityPatchMessage extends WebSocketMessage {
|
|
38
|
+
type: "collection_entity_patch";
|
|
39
|
+
subscriptionId: string;
|
|
40
|
+
entityId: string;
|
|
41
|
+
/** The updated entity, or null if deleted */
|
|
42
|
+
entity: Entity<Record<string, unknown>> | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
25
45
|
/**
|
|
26
46
|
* Column metadata returned by table introspection.
|
|
27
47
|
*/
|
|
@@ -35,3 +55,31 @@ export interface TableColumnInfo {
|
|
|
35
55
|
/** Enum values, populated for USER-DEFINED (enum) columns */
|
|
36
56
|
enum_values?: string[];
|
|
37
57
|
}
|
|
58
|
+
|
|
59
|
+
export interface TableForeignKeyInfo {
|
|
60
|
+
column_name: string;
|
|
61
|
+
foreign_table_name: string;
|
|
62
|
+
foreign_column_name: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface TableJunctionInfo {
|
|
66
|
+
junction_table_name: string;
|
|
67
|
+
source_column_name: string;
|
|
68
|
+
target_table_name: string;
|
|
69
|
+
target_column_name: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface TablePolicyInfo {
|
|
73
|
+
policy_name: string;
|
|
74
|
+
roles: string[];
|
|
75
|
+
cmd: string;
|
|
76
|
+
qual?: string;
|
|
77
|
+
with_check?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface TableMetadata {
|
|
81
|
+
columns: TableColumnInfo[];
|
|
82
|
+
foreignKeys: TableForeignKeyInfo[];
|
|
83
|
+
junctions: TableJunctionInfo[];
|
|
84
|
+
policies: TablePolicyInfo[];
|
|
85
|
+
}
|
package/src/users/roles.ts
CHANGED
package/src/users/user.ts
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Entity, EntityCollection, FormContext } from "../types";
|
|
2
|
-
import { FormexController } from "./formex";
|
|
3
|
-
export interface EntityFormActionsProps {
|
|
4
|
-
path: string;
|
|
5
|
-
collection: EntityCollection;
|
|
6
|
-
entity?: Entity;
|
|
7
|
-
layout: "bottom" | "side";
|
|
8
|
-
savingError?: Error;
|
|
9
|
-
formex: FormexController<any>;
|
|
10
|
-
disabled: boolean;
|
|
11
|
-
status: "new" | "existing" | "copy";
|
|
12
|
-
pluginActions: React.ReactNode[];
|
|
13
|
-
openEntityMode: "side_panel" | "full_screen";
|
|
14
|
-
showDefaultActions?: boolean;
|
|
15
|
-
navigateBack: () => void;
|
|
16
|
-
formContext: FormContext;
|
|
17
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Entity, EntityCollection, EntityCustomViewParams, EntityStatus, FormContext } from "../types";
|
|
2
|
-
import { FormexController } from "./formex";
|
|
3
|
-
import { EntityFormActionsProps } from "./EntityFormActionsProps";
|
|
4
|
-
export type EntityFormProps<M extends Record<string, any>> = {
|
|
5
|
-
path: string;
|
|
6
|
-
fullIdPath?: string;
|
|
7
|
-
collection: EntityCollection<M>;
|
|
8
|
-
entityId?: string | number;
|
|
9
|
-
entity?: Entity<M>;
|
|
10
|
-
databaseId?: string;
|
|
11
|
-
onIdChange?: (id: string | number) => void;
|
|
12
|
-
onValuesModified?: (modified: boolean, values: M) => void;
|
|
13
|
-
onSaved?: (params: OnUpdateParams) => void;
|
|
14
|
-
initialDirtyValues?: Partial<M>;
|
|
15
|
-
onFormContextReady?: (formContext: FormContext) => void;
|
|
16
|
-
forceActionsAtTheBottom?: boolean;
|
|
17
|
-
className?: string;
|
|
18
|
-
initialStatus: EntityStatus;
|
|
19
|
-
onStatusChange?: (status: EntityStatus) => void;
|
|
20
|
-
onEntityChange?: (entity: Entity<M>) => void;
|
|
21
|
-
formex?: FormexController<M>;
|
|
22
|
-
openEntityMode?: "side_panel" | "full_screen";
|
|
23
|
-
/**
|
|
24
|
-
* If true, the form will be disabled and no actions will be available
|
|
25
|
-
*/
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Include the copy and delete actions in the form
|
|
29
|
-
*/
|
|
30
|
-
showDefaultActions?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Display the entity path in the form
|
|
33
|
-
*/
|
|
34
|
-
showEntityPath?: boolean;
|
|
35
|
-
EntityFormActionsComponent?: React.FC<EntityFormActionsProps>;
|
|
36
|
-
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
|
|
37
|
-
children?: React.ReactNode;
|
|
38
|
-
};
|
|
39
|
-
export type OnUpdateParams = {
|
|
40
|
-
entity: Entity<any>;
|
|
41
|
-
status: EntityStatus;
|
|
42
|
-
path: string;
|
|
43
|
-
entityId?: string | number;
|
|
44
|
-
selectedTab?: string;
|
|
45
|
-
collection: EntityCollection<any>;
|
|
46
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { InferPropertyType, Property } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* @group Preview components
|
|
4
|
-
*/
|
|
5
|
-
export type PreviewSize = "small" | "medium" | "large";
|
|
6
|
-
/**
|
|
7
|
-
* @group Preview components
|
|
8
|
-
*/
|
|
9
|
-
export interface PropertyPreviewProps<P extends Property, CustomProps = unknown> {
|
|
10
|
-
/**
|
|
11
|
-
* Name of the property
|
|
12
|
-
*/
|
|
13
|
-
propertyKey?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Current value of the property, inferred from the property schema P
|
|
16
|
-
*/
|
|
17
|
-
value: InferPropertyType<P>;
|
|
18
|
-
/**
|
|
19
|
-
* Property this display is related to, now strongly typed to P
|
|
20
|
-
*/
|
|
21
|
-
property: P;
|
|
22
|
-
/**
|
|
23
|
-
* Desired size of the preview, depending on the context.
|
|
24
|
-
*/
|
|
25
|
-
size: PreviewSize;
|
|
26
|
-
/**
|
|
27
|
-
* Max height assigned to the preview, depending on the context.
|
|
28
|
-
* It may be undefined if unlimited.
|
|
29
|
-
*/
|
|
30
|
-
height?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Max height width to the preview, depending on the context.
|
|
33
|
-
* It may be undefined if unlimited.
|
|
34
|
-
*/
|
|
35
|
-
width?: number;
|
|
36
|
-
/**
|
|
37
|
-
* Additional properties set by the developer
|
|
38
|
-
*/
|
|
39
|
-
customProps?: CustomProps;
|
|
40
|
-
/**
|
|
41
|
-
* If the preview should be interactive or not.
|
|
42
|
-
* This applies only to videos.
|
|
43
|
-
*/
|
|
44
|
-
interactive?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* If true, image previews will fill their container completely.
|
|
47
|
-
* Only applies to image type properties.
|
|
48
|
-
*/
|
|
49
|
-
fill?: boolean;
|
|
50
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React, { FormEvent } from "react";
|
|
2
|
-
export type FormexController<T extends object> = {
|
|
3
|
-
values: T;
|
|
4
|
-
initialValues: T;
|
|
5
|
-
setValues: (values: T) => void;
|
|
6
|
-
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
7
|
-
touched: Record<string, boolean>;
|
|
8
|
-
setFieldTouched: (key: string, touched: boolean, shouldValidate?: boolean) => void;
|
|
9
|
-
setTouched: (touched: Record<string, boolean>) => void;
|
|
10
|
-
dirty: boolean;
|
|
11
|
-
setDirty: (dirty: boolean) => void;
|
|
12
|
-
setSubmitCount: (submitCount: number) => void;
|
|
13
|
-
errors: Record<string, string>;
|
|
14
|
-
setFieldError: (key: string, error?: string) => void;
|
|
15
|
-
handleChange: (event: React.SyntheticEvent) => void;
|
|
16
|
-
handleBlur: (event: React.FocusEvent) => void;
|
|
17
|
-
handleSubmit: (event?: FormEvent<HTMLFormElement>) => void;
|
|
18
|
-
validate: () => void;
|
|
19
|
-
resetForm: (props?: FormexResetProps<T>) => void;
|
|
20
|
-
submitCount: number;
|
|
21
|
-
isSubmitting: boolean;
|
|
22
|
-
setSubmitting: (isSubmitting: boolean) => void;
|
|
23
|
-
isValidating: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* The version of the form. This is incremented every time the form is reset
|
|
26
|
-
* or the form is submitted.
|
|
27
|
-
*/
|
|
28
|
-
version: number;
|
|
29
|
-
debugId?: string;
|
|
30
|
-
undo: () => void;
|
|
31
|
-
redo: () => void;
|
|
32
|
-
canUndo: boolean;
|
|
33
|
-
canRedo: boolean;
|
|
34
|
-
};
|
|
35
|
-
export type FormexResetProps<T extends object> = {
|
|
36
|
-
values?: T;
|
|
37
|
-
submitCount?: number;
|
|
38
|
-
errors?: Record<string, string>;
|
|
39
|
-
touched?: Record<string, boolean>;
|
|
40
|
-
};
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { Entity, EntityCollection, EntityStatus, EntityValues, FilterValues, TableColumnInfo } from "../types";
|
|
2
|
-
import { RebaseContext } from "../rebase_context";
|
|
3
|
-
/**
|
|
4
|
-
* @group Datasource
|
|
5
|
-
*/
|
|
6
|
-
export interface FetchEntityProps<M extends Record<string, any> = any> {
|
|
7
|
-
path: string;
|
|
8
|
-
entityId: string | number;
|
|
9
|
-
databaseId?: string;
|
|
10
|
-
collection?: EntityCollection<M, any>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @group Datasource
|
|
14
|
-
*/
|
|
15
|
-
export type ListenEntityProps<M extends Record<string, any> = any> = FetchEntityProps<M> & {
|
|
16
|
-
onUpdate: (entity: Entity<M> | null) => void;
|
|
17
|
-
onError?: (error: Error) => void;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* @group Datasource
|
|
21
|
-
*/
|
|
22
|
-
export interface FetchCollectionProps<M extends Record<string, any> = any> {
|
|
23
|
-
path: string;
|
|
24
|
-
collection?: EntityCollection<M>;
|
|
25
|
-
filter?: FilterValues<Extract<keyof M, string>>;
|
|
26
|
-
limit?: number;
|
|
27
|
-
startAfter?: unknown;
|
|
28
|
-
orderBy?: string;
|
|
29
|
-
searchString?: string;
|
|
30
|
-
order?: "desc" | "asc";
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @group Datasource
|
|
34
|
-
*/
|
|
35
|
-
export type ListenCollectionProps<M extends Record<string, any> = any> = FetchCollectionProps<M> & {
|
|
36
|
-
onUpdate: (entities: Entity<M>[]) => void;
|
|
37
|
-
onError?: (error: Error) => void;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* @group Datasource
|
|
41
|
-
*/
|
|
42
|
-
export interface SaveEntityProps<M extends Record<string, any> = any> {
|
|
43
|
-
path: string;
|
|
44
|
-
values: Partial<EntityValues<M>>;
|
|
45
|
-
entityId?: string | number;
|
|
46
|
-
previousValues?: Partial<EntityValues<M>>;
|
|
47
|
-
collection?: EntityCollection<M>;
|
|
48
|
-
status: EntityStatus;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @group Datasource
|
|
52
|
-
*/
|
|
53
|
-
export interface DeleteEntityProps<M extends Record<string, any> = any> {
|
|
54
|
-
entity: Entity<M>;
|
|
55
|
-
collection?: EntityCollection<M>;
|
|
56
|
-
}
|
|
57
|
-
export type FilterCombinationValidProps = {
|
|
58
|
-
path: string;
|
|
59
|
-
databaseId?: string;
|
|
60
|
-
collection: EntityCollection<any>;
|
|
61
|
-
filterValues: FilterValues<any>;
|
|
62
|
-
sortBy?: [string, "asc" | "desc"];
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Component in charge of communicating with the data source.
|
|
66
|
-
* @group Datasource
|
|
67
|
-
*/
|
|
68
|
-
export interface DataSource {
|
|
69
|
-
/**
|
|
70
|
-
* Key that identifies this data source
|
|
71
|
-
*/
|
|
72
|
-
key?: string;
|
|
73
|
-
/**
|
|
74
|
-
* If the data source has been initialised
|
|
75
|
-
*/
|
|
76
|
-
initialised?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Fetch data from a collection
|
|
79
|
-
* @param props
|
|
80
|
-
* @return Promise of entities
|
|
81
|
-
* @see useCollectionFetch if you need this functionality implemented as a hook
|
|
82
|
-
*/
|
|
83
|
-
fetchCollection<M extends Record<string, any> = any>(props: FetchCollectionProps<M>): Promise<Entity<M>[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Listen to a collection in a given path. If you don't implement this method
|
|
86
|
-
* `fetchCollection` will be used instead, with no real time updates.
|
|
87
|
-
* @param props
|
|
88
|
-
* @return Function to cancel subscription
|
|
89
|
-
* @see useCollectionFetch if you need this functionality implemented as a hook
|
|
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 datasource
|
|
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
|
-
* Execute raw SQL (if supported by the datasource)
|
|
150
|
-
*/
|
|
151
|
-
executeSql?(sql: string, options?: {
|
|
152
|
-
database?: string;
|
|
153
|
-
role?: string;
|
|
154
|
-
}): Promise<Record<string, unknown>[]>;
|
|
155
|
-
/**
|
|
156
|
-
* Fetch the available databases (if supported by the datasource)
|
|
157
|
-
*/
|
|
158
|
-
fetchAvailableDatabases?(): Promise<string[]>;
|
|
159
|
-
/**
|
|
160
|
-
* Fetch the available roles (if supported by the datasource)
|
|
161
|
-
*/
|
|
162
|
-
fetchAvailableRoles?(): Promise<string[]>;
|
|
163
|
-
/**
|
|
164
|
-
* Fetch the current database name (if supported by the datasource)
|
|
165
|
-
*/
|
|
166
|
-
fetchCurrentDatabase?(): Promise<string | undefined>;
|
|
167
|
-
/**
|
|
168
|
-
* Fetch database tables not yet mapped to a collection (if supported)
|
|
169
|
-
*/
|
|
170
|
-
fetchUnmappedTables?(mappedPaths?: string[]): Promise<string[]>;
|
|
171
|
-
/**
|
|
172
|
-
* Fetch column metadata for a given table (if supported)
|
|
173
|
-
*/
|
|
174
|
-
fetchTableColumns?(tableName: string): Promise<TableColumnInfo[]>;
|
|
175
|
-
/**
|
|
176
|
-
* Flag to indicate if the datasource delegate has requested the initialization of the text search index
|
|
177
|
-
*/
|
|
178
|
-
needsInitTextSearch?: boolean;
|
|
179
|
-
}
|