@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,22 @@
|
|
|
1
|
+
export type Role = {
|
|
2
|
+
/**
|
|
3
|
+
* ID of the role
|
|
4
|
+
*/
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* Name of the role
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* If this flag is true, the user can perform any action
|
|
12
|
+
*/
|
|
13
|
+
isAdmin?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Permissions related to editing the collections
|
|
16
|
+
*/
|
|
17
|
+
config?: {
|
|
18
|
+
createCollections?: boolean;
|
|
19
|
+
editCollections?: boolean | "own";
|
|
20
|
+
deleteCollections?: boolean | "own";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This interface represents a user.
|
|
3
|
+
* It has some of the same fields as a Firebase User.
|
|
4
|
+
* Note that in the default implementation, we simply take the Firebase user
|
|
5
|
+
* and use it as a Rebase user, so that means that even if they are not mapped
|
|
6
|
+
* in this interface, it contains all the methods of the former, such as `delete`,
|
|
7
|
+
* `getIdToken`, etc.
|
|
8
|
+
*
|
|
9
|
+
* @group Models
|
|
10
|
+
*/
|
|
11
|
+
export type User = {
|
|
12
|
+
/**
|
|
13
|
+
* The user's unique ID, scoped to the project.
|
|
14
|
+
*/
|
|
15
|
+
readonly uid: string;
|
|
16
|
+
/**
|
|
17
|
+
* The display name of the user.
|
|
18
|
+
*/
|
|
19
|
+
readonly displayName: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* The email of the user.
|
|
22
|
+
*/
|
|
23
|
+
readonly email: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* The profile photo URL of the user.
|
|
26
|
+
*/
|
|
27
|
+
readonly photoURL: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* The provider used to authenticate the user.
|
|
30
|
+
*/
|
|
31
|
+
readonly providerId: string;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
readonly isAnonymous: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Role IDs assigned to this user (e.g. ["admin", "editor"]).
|
|
38
|
+
* These are plain string IDs — use the UserManagementDelegate to look up full Role objects.
|
|
39
|
+
*/
|
|
40
|
+
roles?: string[];
|
|
41
|
+
getIdToken?: (forceRefresh?: boolean) => Promise<string>;
|
|
42
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rebasepro/types",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1-canary.0",
|
|
5
|
+
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
|
+
"funding": {
|
|
7
|
+
"url": "https://github.com/sponsors/rebaseco"
|
|
8
|
+
},
|
|
9
|
+
"author": "Rebase",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/rebaseco/rebase.git",
|
|
14
|
+
"directory": "packages/types"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.umd.js",
|
|
17
|
+
"module": "./dist/index.es.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"source": "src/index.ts",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=14"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"firebase",
|
|
25
|
+
"cms",
|
|
26
|
+
"admin",
|
|
27
|
+
"admin panel",
|
|
28
|
+
"firebase panel",
|
|
29
|
+
"firestore",
|
|
30
|
+
"headless",
|
|
31
|
+
"headless cms",
|
|
32
|
+
"content manager"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"watch": "vite build --watch",
|
|
36
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
37
|
+
"prepublishOnly": "run-s build",
|
|
38
|
+
"test:lint": "eslint \"src/**\" --quiet",
|
|
39
|
+
"test": "jest --passWithNoTests",
|
|
40
|
+
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
|
|
41
|
+
},
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"development": "./src/index.ts",
|
|
45
|
+
"import": "./dist/index.es.js",
|
|
46
|
+
"require": "./dist/index.umd.js",
|
|
47
|
+
"types": "./dist/index.d.ts"
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@dnd-kit/core": "^6.3.1",
|
|
53
|
+
"@dnd-kit/modifiers": "^9.0.0",
|
|
54
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
55
|
+
"@radix-ui/react-portal": "^1.1.5",
|
|
56
|
+
"@rebasepro/editor": "0.0.1-canary.0",
|
|
57
|
+
"@rebasepro/formex": "0.0.1-canary.0",
|
|
58
|
+
"@rebasepro/ui": "0.0.1-canary.0",
|
|
59
|
+
"clsx": "^2.1.1",
|
|
60
|
+
"date-fns": "^3.6.0",
|
|
61
|
+
"fast-equals": "5.3.0",
|
|
62
|
+
"fuse.js": "^7.1.0",
|
|
63
|
+
"history": "^5.3.0",
|
|
64
|
+
"markdown-it": "^14.1.0",
|
|
65
|
+
"notistack": "^3.0.2",
|
|
66
|
+
"object-hash": "^3.0.0",
|
|
67
|
+
"prism-react-renderer": "^2.4.1",
|
|
68
|
+
"react-dropzone": "^14.3.8",
|
|
69
|
+
"react-image-file-resizer": "^0.4.8",
|
|
70
|
+
"react-transition-group": "^4.4.5",
|
|
71
|
+
"react-use-measure": "^2.1.7",
|
|
72
|
+
"react-window": "^1.8.11",
|
|
73
|
+
"yup": "^0.32.11"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"react": ">=19.0.0",
|
|
77
|
+
"react-dom": ">=19.0.0",
|
|
78
|
+
"react-router": "^6.28.0",
|
|
79
|
+
"react-router-dom": "^6.28.0"
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@jest/globals": "^29.7.0",
|
|
83
|
+
"@testing-library/react": "^16.3.0",
|
|
84
|
+
"@testing-library/user-event": "^14.6.1",
|
|
85
|
+
"@types/jest": "^29.5.14",
|
|
86
|
+
"@types/node": "^20.17.14",
|
|
87
|
+
"@types/object-hash": "^3.0.6",
|
|
88
|
+
"@types/react": "^19.0.8",
|
|
89
|
+
"@types/react-dom": "^19.0.3",
|
|
90
|
+
"@types/react-measure": "^2.0.12",
|
|
91
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
92
|
+
"babel-plugin-react-compiler": "beta",
|
|
93
|
+
"cross-env": "^7.0.3",
|
|
94
|
+
"eslint-plugin-react-compiler": "beta",
|
|
95
|
+
"jest": "^29.7.0",
|
|
96
|
+
"npm-run-all": "^4.1.5",
|
|
97
|
+
"react-router": "^7.13.1",
|
|
98
|
+
"react-router-dom": "^7.13.1",
|
|
99
|
+
"ts-jest": "^29.3.1",
|
|
100
|
+
"ts-node": "^10.9.2",
|
|
101
|
+
"tsd": "^0.31.2",
|
|
102
|
+
"typescript": "^5.8.3",
|
|
103
|
+
"vite": "^5.4.17"
|
|
104
|
+
},
|
|
105
|
+
"files": [
|
|
106
|
+
"dist",
|
|
107
|
+
"src"
|
|
108
|
+
],
|
|
109
|
+
"gitHead": "646afae9c387c3ce02c699d98cd8c7272bdd1929",
|
|
110
|
+
"publishConfig": {
|
|
111
|
+
"access": "public"
|
|
112
|
+
},
|
|
113
|
+
"eslintConfig": {
|
|
114
|
+
"extends": [
|
|
115
|
+
"react-app",
|
|
116
|
+
"react-app/jest"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"jest": {
|
|
120
|
+
"transform": {
|
|
121
|
+
"^.+\\.tsx?$": "ts-jest"
|
|
122
|
+
},
|
|
123
|
+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
|
|
124
|
+
"moduleFileExtensions": [
|
|
125
|
+
"ts",
|
|
126
|
+
"tsx",
|
|
127
|
+
"js",
|
|
128
|
+
"jsx",
|
|
129
|
+
"json",
|
|
130
|
+
"node"
|
|
131
|
+
],
|
|
132
|
+
"testEnvironment": "node",
|
|
133
|
+
"moduleNameMapper": {
|
|
134
|
+
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Entity, EntityCollection, FormContext } from "../types";
|
|
2
|
+
import { FormexController } from "./formex";
|
|
3
|
+
|
|
4
|
+
export interface EntityFormActionsProps {
|
|
5
|
+
path: string;
|
|
6
|
+
collection: EntityCollection;
|
|
7
|
+
entity?: Entity;
|
|
8
|
+
layout: "bottom" | "side";
|
|
9
|
+
savingError?: Error;
|
|
10
|
+
formex: FormexController<any>;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
status: "new" | "existing" | "copy";
|
|
13
|
+
pluginActions: React.ReactNode[];
|
|
14
|
+
openEntityMode: "side_panel" | "full_screen";
|
|
15
|
+
showDefaultActions?: boolean;
|
|
16
|
+
navigateBack: () => void;
|
|
17
|
+
formContext: FormContext
|
|
18
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Entity, EntityCollection, EntityCustomViewParams, EntityStatus, FormContext } from "../types";
|
|
2
|
+
import { FormexController } from "./formex";
|
|
3
|
+
import { EntityFormActionsProps } from "./EntityFormActionsProps";
|
|
4
|
+
|
|
5
|
+
export type EntityFormProps<M extends Record<string, any>> = {
|
|
6
|
+
path: string;
|
|
7
|
+
fullIdPath?: string;
|
|
8
|
+
collection: EntityCollection<M>;
|
|
9
|
+
entityId?: string | number;
|
|
10
|
+
entity?: Entity<M>;
|
|
11
|
+
databaseId?: string;
|
|
12
|
+
onIdChange?: (id: string | number) => void;
|
|
13
|
+
onValuesModified?: (modified: boolean, values: M) => void;
|
|
14
|
+
onSaved?: (params: OnUpdateParams) => void;
|
|
15
|
+
initialDirtyValues?: Partial<M>; // dirty cached entity in memory
|
|
16
|
+
onFormContextReady?: (formContext: FormContext) => void;
|
|
17
|
+
forceActionsAtTheBottom?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
initialStatus: EntityStatus;
|
|
20
|
+
onStatusChange?: (status: EntityStatus) => void;
|
|
21
|
+
onEntityChange?: (entity: Entity<M>) => void;
|
|
22
|
+
formex?: FormexController<M>;
|
|
23
|
+
openEntityMode?: "side_panel" | "full_screen";
|
|
24
|
+
/**
|
|
25
|
+
* If true, the form will be disabled and no actions will be available
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Include the copy and delete actions in the form
|
|
30
|
+
*/
|
|
31
|
+
showDefaultActions?: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Display the entity path in the form
|
|
35
|
+
*/
|
|
36
|
+
showEntityPath?: boolean;
|
|
37
|
+
|
|
38
|
+
EntityFormActionsComponent?: React.FC<EntityFormActionsProps>;
|
|
39
|
+
|
|
40
|
+
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
|
|
41
|
+
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type OnUpdateParams = {
|
|
46
|
+
entity: Entity<any>,
|
|
47
|
+
status: EntityStatus,
|
|
48
|
+
path: string,
|
|
49
|
+
entityId?: string | number;
|
|
50
|
+
selectedTab?: string;
|
|
51
|
+
collection: EntityCollection<any>
|
|
52
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { InferPropertyType, Property } from "../types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @group Preview components
|
|
5
|
+
*/
|
|
6
|
+
export type PreviewSize = "small" | "medium" | "large";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @group Preview components
|
|
10
|
+
*/
|
|
11
|
+
export interface PropertyPreviewProps<P extends Property, CustomProps = unknown> {
|
|
12
|
+
/**
|
|
13
|
+
* Name of the property
|
|
14
|
+
*/
|
|
15
|
+
propertyKey?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Current value of the property, inferred from the property schema P
|
|
19
|
+
*/
|
|
20
|
+
value: InferPropertyType<P>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Property this display is related to, now strongly typed to P
|
|
24
|
+
*/
|
|
25
|
+
property: P;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Desired size of the preview, depending on the context.
|
|
29
|
+
*/
|
|
30
|
+
size: PreviewSize;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Max height assigned to the preview, depending on the context.
|
|
34
|
+
* It may be undefined if unlimited.
|
|
35
|
+
*/
|
|
36
|
+
height?: number;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Max height width to the preview, depending on the context.
|
|
40
|
+
* It may be undefined if unlimited.
|
|
41
|
+
*/
|
|
42
|
+
width?: number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Additional properties set by the developer
|
|
46
|
+
*/
|
|
47
|
+
customProps?: CustomProps;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* If the preview should be interactive or not.
|
|
51
|
+
* This applies only to videos.
|
|
52
|
+
*/
|
|
53
|
+
interactive?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* If true, image previews will fill their container completely.
|
|
57
|
+
* Only applies to image type properties.
|
|
58
|
+
*/
|
|
59
|
+
fill?: boolean;
|
|
60
|
+
|
|
61
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { FormEvent } from "react";
|
|
2
|
+
|
|
3
|
+
// this is duplicated from the formex package
|
|
4
|
+
export type FormexController<T extends object> = {
|
|
5
|
+
values: T;
|
|
6
|
+
initialValues: T;
|
|
7
|
+
setValues: (values: T) => void;
|
|
8
|
+
setFieldValue: (key: string, value: unknown, shouldValidate?: boolean) => void;
|
|
9
|
+
touched: Record<string, boolean>;
|
|
10
|
+
setFieldTouched: (key: string, touched: boolean, shouldValidate?: boolean) => void;
|
|
11
|
+
setTouched: (touched: Record<string, boolean>) => void;
|
|
12
|
+
dirty: boolean;
|
|
13
|
+
setDirty: (dirty: boolean) => void;
|
|
14
|
+
setSubmitCount: (submitCount: number) => void;
|
|
15
|
+
errors: Record<string, string>;
|
|
16
|
+
setFieldError: (key: string, error?: string) => void;
|
|
17
|
+
handleChange: (event: React.SyntheticEvent) => void,
|
|
18
|
+
handleBlur: (event: React.FocusEvent) => void,
|
|
19
|
+
handleSubmit: (event?: FormEvent<HTMLFormElement>) => void;
|
|
20
|
+
validate: () => void;
|
|
21
|
+
resetForm: (props?: FormexResetProps<T>) => void;
|
|
22
|
+
submitCount: number;
|
|
23
|
+
isSubmitting: boolean;
|
|
24
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
25
|
+
isValidating: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The version of the form. This is incremented every time the form is reset
|
|
28
|
+
* or the form is submitted.
|
|
29
|
+
*/
|
|
30
|
+
version: number;
|
|
31
|
+
|
|
32
|
+
debugId?: string;
|
|
33
|
+
|
|
34
|
+
undo: () => void;
|
|
35
|
+
redo: () => void;
|
|
36
|
+
|
|
37
|
+
canUndo: boolean;
|
|
38
|
+
canRedo: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type FormexResetProps<T extends object> = {
|
|
42
|
+
values?: T;
|
|
43
|
+
submitCount?: number;
|
|
44
|
+
errors?: Record<string, string>;
|
|
45
|
+
touched?: Record<string, boolean>;
|
|
46
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type AnalyticsController = {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Callback used to get analytics events from the CMS
|
|
5
|
+
*/
|
|
6
|
+
onAnalyticsEvent?: (event: CMSAnalyticsEvent, data?: object) => void;
|
|
7
|
+
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type CMSAnalyticsEvent =
|
|
11
|
+
| "entity_click"
|
|
12
|
+
| "entity_click_from_reference"
|
|
13
|
+
|
|
14
|
+
| "reference_selection_clear"
|
|
15
|
+
| "reference_selection_toggle"
|
|
16
|
+
| "reference_selected_single"
|
|
17
|
+
| "reference_selection_new_entity"
|
|
18
|
+
|
|
19
|
+
| "edit_entity_clicked"
|
|
20
|
+
| "entity_edited"
|
|
21
|
+
| "new_entity_click"
|
|
22
|
+
| "new_entity_saved"
|
|
23
|
+
| "copy_entity_click"
|
|
24
|
+
| "entity_copied"
|
|
25
|
+
|
|
26
|
+
| "single_delete_dialog_open"
|
|
27
|
+
| "multiple_delete_dialog_open"
|
|
28
|
+
| "single_entity_deleted"
|
|
29
|
+
| "multiple_entities_deleted"
|
|
30
|
+
|
|
31
|
+
| "drawer_navigate_to_home"
|
|
32
|
+
| "drawer_navigate_to_collection"
|
|
33
|
+
| "drawer_navigate_to_view"
|
|
34
|
+
|
|
35
|
+
| "home_navigate_to_collection"
|
|
36
|
+
| "home_favorite_navigate_to_collection"
|
|
37
|
+
| "home_navigate_to_view"
|
|
38
|
+
| "home_navigate_to_admin_view"
|
|
39
|
+
| "home_favorite_navigate_to_view"
|
|
40
|
+
| "home_move_card"
|
|
41
|
+
| "home_move_group"
|
|
42
|
+
| "home_drop_new_group"
|
|
43
|
+
|
|
44
|
+
| "collection_inline_editing"
|
|
45
|
+
|
|
46
|
+
| "view_mode_changed"
|
|
47
|
+
|
|
48
|
+
| "kanban_card_moved"
|
|
49
|
+
| "kanban_column_reorder"
|
|
50
|
+
| "kanban_property_changed"
|
|
51
|
+
| "kanban_new_entity_in_column"
|
|
52
|
+
| "kanban_backfill_order"
|
|
53
|
+
|
|
54
|
+
| "card_view_entity_click"
|
|
55
|
+
|
|
56
|
+
| "unmapped_event"
|
|
57
|
+
;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { DataSource } from "./datasource";
|
|
2
|
+
import { StorageSource } from "./storage";
|
|
3
|
+
import { Role, User } from "../users";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Controller for retrieving the logged user or performing auth related operations.
|
|
7
|
+
* Note that if you are implementing your AuthController, you probably will want
|
|
8
|
+
* to do it as the result of a hook.
|
|
9
|
+
* @group Hooks and utilities
|
|
10
|
+
*/
|
|
11
|
+
export type AuthController<USER extends User = any, ExtraData = unknown> = {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The user currently logged in
|
|
15
|
+
* The values can be: the user object, null if they skipped login
|
|
16
|
+
*/
|
|
17
|
+
user: USER | null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initial loading flag. It is used not to display the login screen
|
|
21
|
+
* when the app first loads, and it has not been checked whether the user
|
|
22
|
+
* is logged in or not.
|
|
23
|
+
*/
|
|
24
|
+
initialLoading?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Loading flag. It is used to display a loading screen when the user is
|
|
28
|
+
* logging in or out.
|
|
29
|
+
*/
|
|
30
|
+
authLoading: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Sign out
|
|
34
|
+
*/
|
|
35
|
+
signOut: () => Promise<void>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Error initializing the authentication
|
|
39
|
+
*/
|
|
40
|
+
authError?: unknown;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Error dispatched by the auth provider
|
|
44
|
+
*/
|
|
45
|
+
authProviderError?: unknown;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* You can use this method to retrieve the auth token for the current user.
|
|
49
|
+
*/
|
|
50
|
+
getAuthToken: () => Promise<string>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Has the user skipped the login process
|
|
54
|
+
*/
|
|
55
|
+
loginSkipped: boolean;
|
|
56
|
+
|
|
57
|
+
extra: ExtraData;
|
|
58
|
+
|
|
59
|
+
setExtra: (extra: ExtraData) => void;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
setUser?: (user: USER | null) => void;
|
|
63
|
+
|
|
64
|
+
setUserRoles?: (roles: Role[]) => void;
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Implement this function to allow access to specific users.
|
|
70
|
+
* @group Hooks and utilities
|
|
71
|
+
*/
|
|
72
|
+
export type Authenticator<USER extends User = User> = (props: {
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Logged-in user or null
|
|
76
|
+
*/
|
|
77
|
+
user: USER | null;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* AuthController
|
|
81
|
+
*/
|
|
82
|
+
authController: AuthController<USER>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Connector to your database, e.g. your Firestore database
|
|
86
|
+
*/
|
|
87
|
+
dataSource: DataSource;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Used storage implementation
|
|
91
|
+
*/
|
|
92
|
+
storageSource: StorageSource;
|
|
93
|
+
|
|
94
|
+
}) => boolean | Promise<boolean>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EntityAction, EntityCustomView, EntityLinkBuilder, RebasePlugin, Locale, PropertyConfig } from "../types";
|
|
3
|
+
|
|
4
|
+
export type CustomizationController = {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Builder for generating utility links for entities
|
|
8
|
+
*/
|
|
9
|
+
entityLinkBuilder?: EntityLinkBuilder;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Use plugins to modify the behaviour of the CMS.
|
|
13
|
+
*/
|
|
14
|
+
plugins?: RebasePlugin[];
|
|
15
|
+
|
|
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
|
+
/**
|
|
26
|
+
* List of actions that can be performed on entities.
|
|
27
|
+
* These actions are displayed in the entity view and in the collection view.
|
|
28
|
+
* You can later reuse these actions in the `entityActions` prop of a collection,
|
|
29
|
+
* by specifying the `key` of the action.
|
|
30
|
+
*/
|
|
31
|
+
entityActions?: EntityAction[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Format of the dates in the CMS.
|
|
35
|
+
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
36
|
+
*/
|
|
37
|
+
dateTimeFormat?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Locale of the CMS, currently only affecting dates
|
|
41
|
+
*/
|
|
42
|
+
locale?: Locale;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Record of custom form fields to be used in the CMS.
|
|
46
|
+
* You can use the key to reference the custom field in
|
|
47
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
48
|
+
*/
|
|
49
|
+
propertyConfigs: Record<string, PropertyConfig>;
|
|
50
|
+
|
|
51
|
+
components?: {
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Component to render when a reference is missing
|
|
55
|
+
*/
|
|
56
|
+
missingReference?: React.ComponentType<{
|
|
57
|
+
path: string,
|
|
58
|
+
}>;
|
|
59
|
+
|
|
60
|
+
};
|
|
61
|
+
}
|