@firecms/core 3.0.0-canary.8 → 3.0.0-canary.9

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.
@@ -1,4 +1,5 @@
1
1
  import { User } from "./user";
2
+ import { Role } from "./roles";
2
3
  /**
3
4
  * Controller for retrieving the logged user or performing auth related operations.
4
5
  * Note that if you are implementing your AuthController, you probably will want
@@ -11,6 +12,10 @@ export type AuthController<UserType extends User = User, ExtraData extends any =
11
12
  * The values can be: the user object, null if they skipped login
12
13
  */
13
14
  user: UserType | null;
15
+ /**
16
+ * Roles related to the logged user
17
+ */
18
+ roles?: Role[];
14
19
  /**
15
20
  * Initial loading flag. It is used not to display the login screen
16
21
  * when the app first loads, and it has not been checked whether the user
@@ -22,6 +22,7 @@ export * from "./local_config_persistence";
22
22
  export * from "./plugins";
23
23
  export * from "./analytics";
24
24
  export * from "./firecms";
25
+ export * from "./roles";
25
26
  export * from "./appcheck";
26
27
  export * from "./export_import";
27
28
  export * from "./modify_collections";
@@ -0,0 +1,31 @@
1
+ import { Permissions } from "../index";
2
+ export type Role = {
3
+ /**
4
+ * ID of the role
5
+ */
6
+ id: string;
7
+ /**
8
+ * Name of the role
9
+ */
10
+ name: string;
11
+ /**
12
+ * If this flag is true, the user can perform any action
13
+ */
14
+ isAdmin?: boolean;
15
+ /**
16
+ * Default permissions for all collections for this role.
17
+ * You can override this values at the collection level using
18
+ * {@link collectionPermissions}
19
+ */
20
+ defaultPermissions?: Permissions;
21
+ /**
22
+ * Record of stripped collection ids to their permissions.
23
+ * @see stripCollectionPath
24
+ */
25
+ collectionPermissions?: Record<string, Permissions>;
26
+ config?: {
27
+ createCollections?: boolean;
28
+ editCollections?: boolean | "own";
29
+ deleteCollections?: boolean | "own";
30
+ };
31
+ };
@@ -1,3 +1,4 @@
1
+ import { Role } from "./roles";
1
2
  /**
2
3
  * This interface represents a user.
3
4
  * It has some of the same fields as a Firebase User.
@@ -33,4 +34,8 @@ export type User = {
33
34
  *
34
35
  */
35
36
  readonly isAnonymous: boolean;
37
+ /**
38
+ *
39
+ */
40
+ roles?: Role[];
36
41
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.8",
4
+ "version": "3.0.0-canary.9",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -46,8 +46,8 @@
46
46
  "./package.json": "./package.json"
47
47
  },
48
48
  "dependencies": {
49
- "@firecms/formex": "^3.0.0-canary.8",
50
- "@firecms/ui": "^3.0.0-canary.8",
49
+ "@firecms/formex": "^3.0.0-canary.9",
50
+ "@firecms/ui": "^3.0.0-canary.9",
51
51
  "@fontsource/ibm-plex-mono": "^5.0.12",
52
52
  "@fontsource/roboto": "^5.0.12",
53
53
  "@hello-pangea/dnd": "^16.5.0",
@@ -115,7 +115,7 @@
115
115
  "dist",
116
116
  "src"
117
117
  ],
118
- "gitHead": "6d3cbe74b9d5ac0fbd7ee9110a92d0188a252f02",
118
+ "gitHead": "5bd7f971be5956d225835af3b6cbe9f71d3e7e50",
119
119
  "publishConfig": {
120
120
  "access": "public"
121
121
  }
@@ -1,4 +1,5 @@
1
1
  import { User } from "./user";
2
+ import { Role } from "./roles";
2
3
 
3
4
  /**
4
5
  * Controller for retrieving the logged user or performing auth related operations.
@@ -14,6 +15,11 @@ export type AuthController<UserType extends User = User, ExtraData extends any =
14
15
  */
15
16
  user: UserType | null;
16
17
 
18
+ /**
19
+ * Roles related to the logged user
20
+ */
21
+ roles?: Role[];
22
+
17
23
  /**
18
24
  * Initial loading flag. It is used not to display the login screen
19
25
  * when the app first loads, and it has not been checked whether the user
@@ -22,6 +22,7 @@ export * from "./local_config_persistence";
22
22
  export * from "./plugins";
23
23
  export * from "./analytics";
24
24
  export * from "./firecms";
25
+ export * from "./roles";
25
26
  export * from "./appcheck";
26
27
  export * from "./export_import";
27
28
  export * from "./modify_collections";
@@ -0,0 +1,41 @@
1
+ import { Permissions } from "../index";
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
+ * Default permissions for all collections for this role.
22
+ * You can override this values at the collection level using
23
+ * {@link collectionPermissions}
24
+ */
25
+ defaultPermissions?: Permissions;
26
+
27
+ /**
28
+ * Record of stripped collection ids to their permissions.
29
+ * @see stripCollectionPath
30
+ */
31
+ collectionPermissions?: Record<string, Permissions>;
32
+
33
+ config?: {
34
+
35
+ createCollections?: boolean;
36
+
37
+ editCollections?: boolean | "own";
38
+
39
+ deleteCollections?: boolean | "own";
40
+ }
41
+ }
package/src/types/user.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Role } from "./roles";
2
+
1
3
  /**
2
4
  * This interface represents a user.
3
5
  * It has some of the same fields as a Firebase User.
@@ -34,4 +36,9 @@ export type User = {
34
36
  */
35
37
  readonly isAnonymous: boolean;
36
38
 
39
+ /**
40
+ *
41
+ */
42
+ roles?: Role[];
43
+
37
44
  };