@firecms/core 3.0.0-beta.4.pre.1 → 3.0.0-beta.5

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.
Files changed (70) hide show
  1. package/README.md +1 -1
  2. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +1 -1
  3. package/dist/components/EntityPreview.d.ts +2 -2
  4. package/dist/components/FieldCaption.d.ts +1 -0
  5. package/dist/contexts/AuthControllerContext.d.ts +1 -1
  6. package/dist/hooks/data/delete.d.ts +2 -2
  7. package/dist/hooks/data/save.d.ts +1 -1
  8. package/dist/hooks/data/useDataSource.d.ts +1 -1
  9. package/dist/hooks/data/useEntityFetch.d.ts +3 -3
  10. package/dist/hooks/index.d.ts +1 -0
  11. package/dist/hooks/useBuildNavigationController.d.ts +1 -2
  12. package/dist/hooks/useProjectLog.d.ts +2 -2
  13. package/dist/hooks/useValidateAuthenticator.d.ts +25 -0
  14. package/dist/index.es.js +2333 -2257
  15. package/dist/index.es.js.map +1 -1
  16. package/dist/index.umd.js +5 -5
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/internal/useRestoreScroll.d.ts +1 -1
  19. package/dist/preview/PropertyPreviewProps.d.ts +1 -4
  20. package/dist/types/auth.d.ts +30 -1
  21. package/dist/types/collections.d.ts +3 -3
  22. package/dist/types/datasource.d.ts +1 -1
  23. package/dist/types/entity_callbacks.d.ts +2 -2
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/navigation.d.ts +4 -4
  26. package/dist/types/plugins.d.ts +2 -2
  27. package/dist/types/roles.d.ts +31 -0
  28. package/dist/types/storage.d.ts +11 -3
  29. package/dist/types/user.d.ts +5 -0
  30. package/dist/util/collections.d.ts +1 -1
  31. package/dist/util/useTraceUpdate.d.ts +1 -0
  32. package/package.json +10 -10
  33. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
  34. package/src/components/EntityPreview.tsx +5 -2
  35. package/src/components/FieldCaption.tsx +1 -0
  36. package/src/components/HomePage/DefaultHomePage.tsx +1 -1
  37. package/src/components/HomePage/NavigationCard.tsx +1 -1
  38. package/src/components/ReferenceWidget.tsx +1 -1
  39. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
  40. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  41. package/src/contexts/AuthControllerContext.tsx +1 -1
  42. package/src/core/FireCMS.tsx +1 -1
  43. package/src/form/EntityForm.tsx +1 -1
  44. package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
  45. package/src/hooks/data/delete.ts +3 -3
  46. package/src/hooks/data/save.ts +1 -1
  47. package/src/hooks/data/useDataSource.tsx +1 -1
  48. package/src/hooks/data/useEntityFetch.tsx +3 -3
  49. package/src/hooks/index.tsx +2 -0
  50. package/src/hooks/useBuildNavigationController.tsx +63 -43
  51. package/src/hooks/useProjectLog.tsx +7 -5
  52. package/src/hooks/useValidateAuthenticator.tsx +135 -0
  53. package/src/internal/useBuildSideEntityController.tsx +3 -0
  54. package/src/preview/PropertyPreviewProps.tsx +1 -11
  55. package/src/preview/components/BooleanPreview.tsx +4 -2
  56. package/src/preview/components/ReferencePreview.tsx +1 -1
  57. package/src/types/auth.tsx +40 -1
  58. package/src/types/collections.ts +3 -3
  59. package/src/types/datasource.ts +1 -1
  60. package/src/types/entity_callbacks.ts +2 -2
  61. package/src/types/index.ts +1 -0
  62. package/src/types/navigation.ts +6 -6
  63. package/src/types/plugins.tsx +2 -2
  64. package/src/types/properties.ts +2 -1
  65. package/src/types/roles.ts +41 -0
  66. package/src/types/storage.ts +12 -3
  67. package/src/types/user.ts +7 -0
  68. package/src/util/collections.ts +1 -1
  69. package/src/util/strings.ts +2 -2
  70. package/src/util/useTraceUpdate.tsx +2 -1
@@ -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
+ }
@@ -6,6 +6,7 @@ export interface UploadFileProps {
6
6
  fileName?: string,
7
7
  path?: string,
8
8
  metadata?: any,
9
+ bucket?: string
9
10
  }
10
11
 
11
12
  /**
@@ -16,6 +17,10 @@ export interface UploadFileResult {
16
17
  * Storage path including the file name where the file was uploaded.
17
18
  */
18
19
  path: string;
20
+ /**
21
+ * Bucket where the file was uploaded
22
+ */
23
+ bucket: string;
19
24
  }
20
25
 
21
26
  /**
@@ -73,24 +78,28 @@ export interface StorageSource {
73
78
  * @param fileName
74
79
  * @param path
75
80
  * @param metadata
81
+ * @param bucket
76
82
  */
77
83
  uploadFile: ({
78
84
  file,
79
85
  fileName,
80
86
  path,
81
- metadata
87
+ metadata,
88
+ bucket
82
89
  }: UploadFileProps) => Promise<UploadFileResult>;
83
90
 
84
91
  /**
85
92
  * Convert a storage path or URL into a download configuration
86
93
  * @param path
94
+ * @param bucket
87
95
  */
88
- getDownloadURL: (pathOrUrl: string) => Promise<DownloadConfig>;
96
+ getDownloadURL: (pathOrUrl: string, bucket?: string) => Promise<DownloadConfig>;
89
97
 
90
98
  /**
91
99
  * Get a file from a storage path.
92
100
  * It returns null if the file does not exist.
93
101
  * @param props
102
+ * @param bucket
94
103
  */
95
- getFile: (path:string) => Promise<File | null>;
104
+ getFile: (path:string, bucket?: string) => Promise<File | null>;
96
105
  }
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
  };
@@ -58,7 +58,7 @@ export function resolveDefaultSelectedView(
58
58
  * @param collections
59
59
  * @param permissionsBuilder
60
60
  */
61
- export const applyPermissionsFunctionIfEmpty = (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder): EntityCollection[] => {
61
+ export const applyPermissionsFunctionIfEmpty = (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder<any, any>): EntityCollection[] => {
62
62
 
63
63
  return collections.map(collection => {
64
64
  if (collection.permissions) {
@@ -56,8 +56,8 @@ export function unslugify(slug?: string): string {
56
56
  const result = slug.replace(/[-_]/g, " ");
57
57
  return result.replace(/\w\S*/g, function (txt) {
58
58
  return txt.charAt(0).toUpperCase() + txt.substr(1);
59
- });
59
+ }).trim();
60
60
  } else {
61
- return slug;
61
+ return slug.trim();
62
62
  }
63
63
  }
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef } from "react";
2
2
 
3
- function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: number) {
3
+ export function printChanged(props: any, prev: any, path: string | undefined = "", depth: number | undefined = 0, maxDepth: number | undefined = 10) {
4
4
  if (depth > maxDepth) {
5
5
  return;
6
6
  }
@@ -17,6 +17,7 @@ function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: num
17
17
  export function useTraceUpdate(props: any, maxDepth = 3) {
18
18
  const prev = useRef(props);
19
19
  useEffect(() => {
20
+ console.log("Changed props:");
20
21
  printChanged(props, prev.current, "", 0, maxDepth);
21
22
  prev.current = props;
22
23
  });