@rebasepro/types 0.0.1-canary.0
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 +21 -0
- package/README.md +174 -0
- package/dist/components/EntityFormActionsProps.d.ts +17 -0
- package/dist/components/EntityFormProps.d.ts +46 -0
- package/dist/components/PropertyPreviewProps.d.ts +50 -0
- package/dist/components/formex.d.ts +40 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/controllers/analytics_controller.d.ts +7 -0
- package/dist/controllers/auth.d.ts +73 -0
- package/dist/controllers/customization_controller.d.ts +50 -0
- package/dist/controllers/datasource.d.ts +179 -0
- package/dist/controllers/dialogs_controller.d.ts +36 -0
- package/dist/controllers/index.d.ts +11 -0
- package/dist/controllers/local_config_persistence.d.ts +20 -0
- package/dist/controllers/navigation.d.ts +262 -0
- package/dist/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/controllers/side_entity_controller.d.ts +90 -0
- package/dist/controllers/snackbar.d.ts +24 -0
- package/dist/controllers/storage.d.ts +173 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +113 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +117 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/rebase_context.d.ts +91 -0
- package/dist/types/backend.d.ts +254 -0
- package/dist/types/chips.d.ts +5 -0
- package/dist/types/collections.d.ts +887 -0
- package/dist/types/entities.d.ts +140 -0
- package/dist/types/entity_actions.d.ts +98 -0
- package/dist/types/entity_callbacks.d.ts +173 -0
- package/dist/types/entity_link_builder.d.ts +7 -0
- package/dist/types/entity_overrides.d.ts +5 -0
- package/dist/types/export_import.d.ts +21 -0
- package/dist/types/fields.d.ts +221 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/locales.d.ts +4 -0
- package/dist/types/modify_collections.d.ts +5 -0
- package/dist/types/plugins.d.ts +276 -0
- package/dist/types/properties.d.ts +1103 -0
- package/dist/types/property_config.d.ts +68 -0
- package/dist/types/rebase.d.ts +180 -0
- package/dist/types/relations.d.ts +336 -0
- package/dist/types/user_management_delegate.d.ts +78 -0
- package/dist/types/websockets.d.ts +33 -0
- package/dist/users/index.d.ts +2 -0
- package/dist/users/roles.d.ts +22 -0
- package/dist/users/user.d.ts +42 -0
- package/package.json +137 -0
- package/src/components/EntityFormActionsProps.tsx +18 -0
- package/src/components/EntityFormProps.tsx +52 -0
- package/src/components/PropertyPreviewProps.tsx +61 -0
- package/src/components/formex.tsx +46 -0
- package/src/components/index.ts +3 -0
- package/src/controllers/analytics_controller.tsx +57 -0
- package/src/controllers/auth.tsx +94 -0
- package/src/controllers/customization_controller.tsx +61 -0
- package/src/controllers/datasource.ts +218 -0
- package/src/controllers/dialogs_controller.tsx +37 -0
- package/src/controllers/index.ts +11 -0
- package/src/controllers/local_config_persistence.tsx +22 -0
- package/src/controllers/navigation.ts +317 -0
- package/src/controllers/side_dialogs_controller.tsx +82 -0
- package/src/controllers/side_entity_controller.tsx +104 -0
- package/src/controllers/snackbar.ts +29 -0
- package/src/controllers/storage.ts +196 -0
- package/src/index.ts +5 -0
- package/src/rebase_context.tsx +122 -0
- package/src/types/backend.ts +385 -0
- package/src/types/chips.ts +46 -0
- package/src/types/collections.ts +1013 -0
- package/src/types/entities.ts +207 -0
- package/src/types/entity_actions.tsx +118 -0
- package/src/types/entity_callbacks.ts +217 -0
- package/src/types/entity_link_builder.ts +8 -0
- package/src/types/entity_overrides.tsx +6 -0
- package/src/types/export_import.ts +26 -0
- package/src/types/fields.tsx +298 -0
- package/src/types/index.ts +20 -0
- package/src/types/locales.ts +81 -0
- package/src/types/modify_collections.tsx +6 -0
- package/src/types/plugins.tsx +328 -0
- package/src/types/properties.ts +1270 -0
- package/src/types/property_config.tsx +93 -0
- package/src/types/rebase.tsx +211 -0
- package/src/types/relations.ts +351 -0
- package/src/types/user_management_delegate.ts +98 -0
- package/src/types/websockets.ts +37 -0
- package/src/users/index.ts +2 -0
- package/src/users/roles.ts +33 -0
- package/src/users/user.ts +46 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Role, User } from "../users";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Delegate to manage users, roles, and their permissions.
|
|
6
|
+
* This interface allows the CMS to be completely agnostic of the underlying
|
|
7
|
+
* authentication provider or backend.
|
|
8
|
+
*
|
|
9
|
+
* @group Models
|
|
10
|
+
*/
|
|
11
|
+
export interface UserManagementDelegate<USER extends User = User> {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Are the users and roles currently being fetched?
|
|
15
|
+
*/
|
|
16
|
+
loading: boolean;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* List of users managed by the CMS.
|
|
20
|
+
*/
|
|
21
|
+
users: USER[];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Optional error if users failed to load.
|
|
25
|
+
*/
|
|
26
|
+
usersError?: Error;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Function to get a user by its uid. This is used to show
|
|
30
|
+
* user information when assigning ownership of an entity.
|
|
31
|
+
* @param uid
|
|
32
|
+
*/
|
|
33
|
+
getUser: (uid: string) => USER | null;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Save a user (create or update)
|
|
37
|
+
* @param user
|
|
38
|
+
*/
|
|
39
|
+
saveUser?: (user: USER) => Promise<USER>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Delete a user
|
|
43
|
+
* @param user
|
|
44
|
+
*/
|
|
45
|
+
deleteUser?: (user: USER) => Promise<void>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* List of roles defined in the CMS.
|
|
49
|
+
*/
|
|
50
|
+
roles?: Role[];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Optional error if roles failed to load.
|
|
54
|
+
*/
|
|
55
|
+
rolesError?: Error;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Save a role (create or update)
|
|
59
|
+
* @param role
|
|
60
|
+
*/
|
|
61
|
+
saveRole?: (role: Role) => Promise<void>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Delete a role
|
|
65
|
+
* @param role
|
|
66
|
+
*/
|
|
67
|
+
deleteRole?: (role: Role) => Promise<void>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Is the currently logged in user an admin?
|
|
71
|
+
*/
|
|
72
|
+
isAdmin?: boolean;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* If true, the UI will allow the user to create the default roles (admin, editor, viewer).
|
|
76
|
+
*/
|
|
77
|
+
allowDefaultRolesCreation?: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Should collection config permissions be included?
|
|
81
|
+
*/
|
|
82
|
+
includeCollectionConfigPermissions?: boolean;
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Optionally define roles for a given user. This is useful when the roles
|
|
88
|
+
* are coming from a separate provider than the one issuing the tokens.
|
|
89
|
+
*/
|
|
90
|
+
defineRolesFor?: (user: USER) => Promise<Role[] | undefined> | Role[] | undefined;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Optional function to bootstrap an admin user.
|
|
94
|
+
* Often used when the database is empty.
|
|
95
|
+
*/
|
|
96
|
+
bootstrapAdmin?: () => Promise<void>;
|
|
97
|
+
|
|
98
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Entity } from "./entities";
|
|
2
|
+
|
|
3
|
+
export interface WebSocketMessage {
|
|
4
|
+
type: string;
|
|
5
|
+
payload?: unknown;
|
|
6
|
+
subscriptionId?: string;
|
|
7
|
+
requestId?: string;
|
|
8
|
+
entities?: Entity<Record<string, unknown>>[];
|
|
9
|
+
entity?: Entity<Record<string, unknown>> | null;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CollectionUpdateMessage extends WebSocketMessage {
|
|
14
|
+
type: "collection_update";
|
|
15
|
+
subscriptionId: string;
|
|
16
|
+
entities: Entity<Record<string, unknown>>[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface EntityUpdateMessage extends WebSocketMessage {
|
|
20
|
+
type: "entity_update";
|
|
21
|
+
subscriptionId: string;
|
|
22
|
+
entity: Entity<Record<string, unknown>> | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Column metadata returned by table introspection.
|
|
27
|
+
*/
|
|
28
|
+
export interface TableColumnInfo {
|
|
29
|
+
column_name: string;
|
|
30
|
+
data_type: string;
|
|
31
|
+
udt_name: string;
|
|
32
|
+
is_nullable: string;
|
|
33
|
+
column_default: string | null;
|
|
34
|
+
character_maximum_length: number | null;
|
|
35
|
+
/** Enum values, populated for USER-DEFINED (enum) columns */
|
|
36
|
+
enum_values?: string[];
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export type Role = {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ID of the role
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Name of the role
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* If this flag is true, the user can perform any action
|
|
17
|
+
*/
|
|
18
|
+
isAdmin?: boolean;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Permissions related to editing the collections
|
|
24
|
+
*/
|
|
25
|
+
config?: {
|
|
26
|
+
|
|
27
|
+
createCollections?: boolean;
|
|
28
|
+
|
|
29
|
+
editCollections?: boolean | "own";
|
|
30
|
+
|
|
31
|
+
deleteCollections?: boolean | "own";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This interface represents a user.
|
|
4
|
+
* It has some of the same fields as a Firebase User.
|
|
5
|
+
* Note that in the default implementation, we simply take the Firebase user
|
|
6
|
+
* and use it as a Rebase user, so that means that even if they are not mapped
|
|
7
|
+
* in this interface, it contains all the methods of the former, such as `delete`,
|
|
8
|
+
* `getIdToken`, etc.
|
|
9
|
+
*
|
|
10
|
+
* @group Models
|
|
11
|
+
*/
|
|
12
|
+
export type User = {
|
|
13
|
+
/**
|
|
14
|
+
* The user's unique ID, scoped to the project.
|
|
15
|
+
*/
|
|
16
|
+
readonly uid: string;
|
|
17
|
+
/**
|
|
18
|
+
* The display name of the user.
|
|
19
|
+
*/
|
|
20
|
+
readonly displayName: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* The email of the user.
|
|
23
|
+
*/
|
|
24
|
+
readonly email: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* The profile photo URL of the user.
|
|
27
|
+
*/
|
|
28
|
+
readonly photoURL: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* The provider used to authenticate the user.
|
|
31
|
+
*/
|
|
32
|
+
readonly providerId: string;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
readonly isAnonymous: boolean;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Role IDs assigned to this user (e.g. ["admin", "editor"]).
|
|
40
|
+
* These are plain string IDs — use the UserManagementDelegate to look up full Role objects.
|
|
41
|
+
*/
|
|
42
|
+
roles?: string[];
|
|
43
|
+
|
|
44
|
+
getIdToken?: (forceRefresh?: boolean) => Promise<string>;
|
|
45
|
+
|
|
46
|
+
};
|